[iptables PATCH 4/5] nft: Review static extension loading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 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




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux