netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: netfilter-devel@vger.kernel.org
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Florian Westphal <fw@strlen.de>, Jan Engelhardt <jengelh@inai.de>
Subject: [iptables PATCH 12/12] extensions: NFQUEUE: Do not print default queue number 0
Date: Thu,  6 Oct 2022 02:28:02 +0200	[thread overview]
Message-ID: <20221006002802.4917-13-phil@nwl.cc> (raw)
In-Reply-To: <20221006002802.4917-1-phil@nwl.cc>

Instead make sure it is mentioned in help output.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 extensions/libxt_NFQUEUE.c | 27 +++++++++++++++------------
 extensions/libxt_NFQUEUE.t |  4 ++--
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/extensions/libxt_NFQUEUE.c b/extensions/libxt_NFQUEUE.c
index fe5190789e306..9de417ae633ca 100644
--- a/extensions/libxt_NFQUEUE.c
+++ b/extensions/libxt_NFQUEUE.c
@@ -24,7 +24,7 @@ static void NFQUEUE_help(void)
 	printf(
 "NFQUEUE target options\n"
 "  --queue-num value		Send packet to QUEUE number <value>.\n"
-"  		                Valid queue numbers are 0-65535\n"
+"  		                Valid queue numbers are 0-65535 (default 0)\n"
 );
 }
 
@@ -33,7 +33,7 @@ static void NFQUEUE_help_v1(void)
 	printf(
 "NFQUEUE target options\n"
 "  --queue-num value            Send packet to QUEUE number <value>.\n"
-"                               Valid queue numbers are 0-65535\n"
+"                               Valid queue numbers are 0-65535 (default 0)\n"
 "  --queue-balance first:last	Balance flows between queues <value> to <value>.\n");
 }
 
@@ -42,7 +42,7 @@ static void NFQUEUE_help_v2(void)
 	printf(
 "NFQUEUE target options\n"
 "  --queue-num value            Send packet to QUEUE number <value>.\n"
-"                               Valid queue numbers are 0-65535\n"
+"                               Valid queue numbers are 0-65535 (default 0)\n"
 "  --queue-balance first:last   Balance flows between queues <value> to <value>.\n"
 "  --queue-bypass		Bypass Queueing if no queue instance exists.\n"
 "  --queue-cpu-fanout	Use current CPU (no hashing)\n");
@@ -53,7 +53,7 @@ static void NFQUEUE_help_v3(void)
 	printf(
 "NFQUEUE target options\n"
 "  --queue-num value            Send packet to QUEUE number <value>.\n"
-"                               Valid queue numbers are 0-65535\n"
+"                               Valid queue numbers are 0-65535 (default 0)\n"
 "  --queue-balance first:last   Balance flows between queues <value> to <value>.\n"
 "  --queue-bypass               Bypass Queueing if no queue instance exists.\n"
 "  --queue-cpu-fanout	Use current CPU (no hashing)\n");
@@ -157,7 +157,9 @@ static void NFQUEUE_print(const void *ip,
 {
 	const struct xt_NFQ_info *tinfo =
 		(const struct xt_NFQ_info *)target->data;
-	printf(" NFQUEUE num %u", tinfo->queuenum);
+
+	if (tinfo->queuenum)
+		printf(" NFQUEUE num %u", tinfo->queuenum);
 }
 
 static void NFQUEUE_print_v1(const void *ip,
@@ -169,7 +171,7 @@ static void NFQUEUE_print_v1(const void *ip,
 	if (last > 1) {
 		last += tinfo->queuenum - 1;
 		printf(" NFQUEUE balance %u:%u", tinfo->queuenum, last);
-	} else {
+	} else if (tinfo->queuenum) {
 		printf(" NFQUEUE num %u", tinfo->queuenum);
 	}
 }
@@ -183,7 +185,7 @@ static void NFQUEUE_print_v2(const void *ip,
 	if (last > 1) {
 		last += info->queuenum - 1;
 		printf(" NFQUEUE balance %u:%u", info->queuenum, last);
-	} else
+	} else if (info->queuenum)
 		printf(" NFQUEUE num %u", info->queuenum);
 
 	if (info->bypass & NFQ_FLAG_BYPASS)
@@ -199,7 +201,7 @@ static void NFQUEUE_print_v3(const void *ip,
 	if (last > 1) {
 		last += info->queuenum - 1;
 		printf(" NFQUEUE balance %u:%u", info->queuenum, last);
-	} else
+	} else if (info->queuenum)
 		printf(" NFQUEUE num %u", info->queuenum);
 
 	if (info->flags & NFQ_FLAG_BYPASS)
@@ -214,7 +216,8 @@ static void NFQUEUE_save(const void *ip, const struct xt_entry_target *target)
 	const struct xt_NFQ_info *tinfo =
 		(const struct xt_NFQ_info *)target->data;
 
-	printf(" --queue-num %u", tinfo->queuenum);
+	if (tinfo->queuenum)
+		printf(" --queue-num %u", tinfo->queuenum);
 }
 
 static void NFQUEUE_save_v1(const void *ip, const struct xt_entry_target *target)
@@ -225,7 +228,7 @@ static void NFQUEUE_save_v1(const void *ip, const struct xt_entry_target *target
 	if (last > 1) {
 		last += tinfo->queuenum - 1;
 		printf(" --queue-balance %u:%u", tinfo->queuenum, last);
-	} else {
+	} else if (tinfo->queuenum) {
 		printf(" --queue-num %u", tinfo->queuenum);
 	}
 }
@@ -238,7 +241,7 @@ static void NFQUEUE_save_v2(const void *ip, const struct xt_entry_target *target
 	if (last > 1) {
 		last += info->queuenum - 1;
 		printf(" --queue-balance %u:%u", info->queuenum, last);
-	} else
+	} else if (info->queuenum)
 		printf(" --queue-num %u", info->queuenum);
 
 	if (info->bypass & NFQ_FLAG_BYPASS)
@@ -254,7 +257,7 @@ static void NFQUEUE_save_v3(const void *ip,
 	if (last > 1) {
 		last += info->queuenum - 1;
 		printf(" --queue-balance %u:%u", info->queuenum, last);
-	} else
+	} else if (info->queuenum)
 		printf(" --queue-num %u", info->queuenum);
 
 	if (info->flags & NFQ_FLAG_BYPASS)
diff --git a/extensions/libxt_NFQUEUE.t b/extensions/libxt_NFQUEUE.t
index b51b19fd435f7..de816247ef024 100644
--- a/extensions/libxt_NFQUEUE.t
+++ b/extensions/libxt_NFQUEUE.t
@@ -1,6 +1,6 @@
 :INPUT,FORWARD,OUTPUT
 -j NFQUEUE;=;OK
--j NFQUEUE --queue-num 0;=;OK
+-j NFQUEUE --queue-num 0;-j NFQUEUE;OK
 -j NFQUEUE --queue-num 65535;=;OK
 -j NFQUEUE --queue-num 65536;;FAIL
 -j NFQUEUE --queue-num -1;;FAIL
@@ -13,4 +13,4 @@
 -j NFQUEUE --queue-balance 0:6 --queue-cpu-fanout --queue-bypass;-j NFQUEUE --queue-balance 0:6 --queue-bypass --queue-cpu-fanout;OK
 -j NFQUEUE --queue-bypass --queue-balance 0:6 --queue-cpu-fanout;-j NFQUEUE --queue-balance 0:6 --queue-bypass --queue-cpu-fanout;OK
 -j NFQUEUE --queue-balance 0:6 --queue-bypass;=;OK
--j NFQUEUE --queue-bypass;-j NFQUEUE --queue-num 0 --queue-bypass;OK
+-j NFQUEUE --queue-bypass;=;OK
-- 
2.34.1


      parent reply	other threads:[~2022-10-06  0:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-06  0:27 [iptables PATCH 00/12] Speed up iptables-tests.py Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 01/12] tests: iptables-test: Implement fast test mode Phil Sutter
2022-10-06  6:13   ` Jan Engelhardt
2022-10-06 11:21     ` Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 02/12] tests: iptables-test: Cover for obligatory -j CONTINUE in ebtables Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 03/12] tests: *.t: Fix expected output for simple calls Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 04/12] tests: *.t: Fix for hexadecimal output Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 05/12] tests: libebt_redirect.t: Plain redirect prints with trailing whitespace Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 06/12] tests: libxt_length.t: Fix odd use-case output Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 07/12] tests: libxt_recent.t: Add missing default values Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 08/12] tests: libxt_tos.t, libxt_TOS.t: Add missing masks in output Phil Sutter
2022-10-06  0:27 ` [iptables PATCH 09/12] tests: libebt_vlan.t: Drop trailing whitespace from rules Phil Sutter
2022-10-06  0:28 ` [iptables PATCH 10/12] tests: libxt_connlimit.t: Add missing --connlimit-saddr Phil Sutter
2022-10-06  0:28 ` [iptables PATCH 11/12] extensions: Do not print all-one's netmasks Phil Sutter
2022-10-06  6:27   ` Jan Engelhardt
2022-10-06 11:54     ` Phil Sutter
2022-10-06 19:01       ` Jan Engelhardt
2022-10-06  0:28 ` Phil Sutter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221006002802.4917-13-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=fw@strlen.de \
    --cc=jengelh@inai.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).