netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, Etienne <champetier.etienne@gmail.com>
Subject: [iptables PATCH 4/5] nft: Review static extension loading
Date: Tue, 15 Mar 2022 14:26:18 +0100	[thread overview]
Message-ID: <20220315132619.20256-5-phil@nwl.cc> (raw)
In-Reply-To: <20220315132619.20256-1-phil@nwl.cc>

Combine the init_extensions() call common to all families, do not load
IPv6 extensions for iptables and vice versa, drop the outdated comment
about "same table".

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/xtables-restore.c    | 7 +++----
 iptables/xtables-save.c       | 8 ++++----
 iptables/xtables-standalone.c | 7 +++----
 iptables/xtables-translate.c  | 7 +++----
 4 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index 0250ed7dd8d66..b3cf401794198 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -360,19 +360,18 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
 		p.in = stdin;
 	}
 
+	init_extensions();
 	switch (family) {
 	case NFPROTO_IPV4:
-	case NFPROTO_IPV6: /* fallthough, same table */
-		init_extensions();
 		init_extensions4();
+		break;
+	case NFPROTO_IPV6:
 		init_extensions6();
 		break;
 	case NFPROTO_ARP:
-		init_extensions();
 		init_extensionsa();
 		break;
 	case NFPROTO_BRIDGE:
-		init_extensions();
 		init_extensionsb();
 		break;
 	default:
diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c
index 3b6b7e25063fe..5a82cac5dd7c0 100644
--- a/iptables/xtables-save.c
+++ b/iptables/xtables-save.c
@@ -199,16 +199,17 @@ xtables_save_main(int family, int argc, char *argv[],
 		exit(1);
 	}
 
+	init_extensions();
 	switch (family) {
 	case NFPROTO_IPV4:
-	case NFPROTO_IPV6: /* fallthough, same table */
-		init_extensions();
 		init_extensions4();
+		d.commit = true;
+		break;
+	case NFPROTO_IPV6:
 		init_extensions6();
 		d.commit = true;
 		break;
 	case NFPROTO_ARP:
-		init_extensions();
 		init_extensionsa();
 		break;
 	case NFPROTO_BRIDGE: {
@@ -220,7 +221,6 @@ xtables_save_main(int family, int argc, char *argv[],
 			d.format &= ~FMT_NOCOUNTS;
 			d.format |= FMT_C_COUNTS | FMT_EBT_SAVE;
 		}
-		init_extensions();
 		init_extensionsb();
 		break;
 	}
diff --git a/iptables/xtables-standalone.c b/iptables/xtables-standalone.c
index 3faae02d408cc..117b0c69dd14f 100644
--- a/iptables/xtables-standalone.c
+++ b/iptables/xtables-standalone.c
@@ -67,19 +67,18 @@ xtables_main(int family, const char *progname, int argc, char *argv[])
 		exit(1);
 	}
 	xt_params->program_name = progname;
+	init_extensions();
 	switch (family) {
 	case NFPROTO_IPV4:
-	case NFPROTO_IPV6:
-		init_extensions();
 		init_extensions4();
+		break;
+	case NFPROTO_IPV6:
 		init_extensions6();
 		break;
 	case NFPROTO_ARP:
-		init_extensions();
 		init_extensionsa();
 		break;
 	case NFPROTO_BRIDGE:
-		init_extensions();
 		init_extensionsb();
 		break;
 	}
diff --git a/iptables/xtables-translate.c b/iptables/xtables-translate.c
index 07a9c1bec0bc5..d1e87f167df74 100644
--- a/iptables/xtables-translate.c
+++ b/iptables/xtables-translate.c
@@ -485,19 +485,18 @@ static int xtables_xlate_main_common(struct nft_handle *h,
 			xtables_globals.program_version);
 		return 1;
 	}
+	init_extensions();
 	switch (family) {
 	case NFPROTO_IPV4:
-	case NFPROTO_IPV6: /* fallthrough: same table */
-		init_extensions();
 		init_extensions4();
+		break;
+	case NFPROTO_IPV6:
 		init_extensions6();
 		break;
 	case NFPROTO_ARP:
-		init_extensions();
 		init_extensionsa();
 		break;
 	case NFPROTO_BRIDGE:
-		init_extensions();
 		init_extensionsb();
 		break;
 	default:
-- 
2.34.1


  parent reply	other threads:[~2022-03-15 13:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 13:26 [iptables PATCH 0/5] Fixes for static builds Phil Sutter
2022-03-15 13:26 ` [iptables PATCH 1/5] libxtables: Fix for warning in xtables_ipmask_to_numeric Phil Sutter
2022-03-15 13:26 ` [iptables PATCH 2/5] Simplify static build extension loading Phil Sutter
2022-03-15 13:26 ` [iptables PATCH 3/5] xtables: Call init_extensions{,a,b}() for static builds Phil Sutter
2022-03-15 13:50   ` Etienne Champetier
2022-03-15 13:54     ` Phil Sutter
2022-03-15 13:26 ` Phil Sutter [this message]
2022-03-15 13:26 ` [iptables PATCH 5/5] tests: shell: Fix 0004-return-codes_0 " Phil Sutter

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=20220315132619.20256-5-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=champetier.etienne@gmail.com \
    --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).