]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Simplify static build extension loading
authorPhil Sutter <phil@nwl.cc>
Tue, 15 Mar 2022 11:25:21 +0000 (12:25 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 15 Mar 2022 13:53:52 +0000 (14:53 +0100)
Instead of guarding all calls to init_extensions*(), define stubs if not
used.

While at it, also add the missing prototypes for arp- and ebtables
extension initializers.

Signed-off-by: Phil Sutter <phil@nwl.cc>
12 files changed:
include/xtables.h
iptables/ip6tables-standalone.c
iptables/iptables-restore.c
iptables/iptables-save.c
iptables/iptables-standalone.c
iptables/xtables-arp.c
iptables/xtables-eb.c
iptables/xtables-monitor.c
iptables/xtables-restore.c
iptables/xtables-save.c
iptables/xtables-standalone.c
iptables/xtables-translate.c

index ca674c2663eb4633130c6b1b628d37a172a41551..044f191f313cc7643ca3408cf8d59ae7085e9179 100644 (file)
@@ -595,8 +595,17 @@ static inline void xtables_print_mark_mask(unsigned int mark,
        extern void init_extensions(void);
        extern void init_extensions4(void);
        extern void init_extensions6(void);
+       extern void init_extensionsa(void);
+       extern void init_extensionsb(void);
 #else
 #      define _init __attribute__((constructor)) _INIT
+#      define EMPTY_FUNC_DEF(x) static inline void x(void) {}
+       EMPTY_FUNC_DEF(init_extensions)
+       EMPTY_FUNC_DEF(init_extensions4)
+       EMPTY_FUNC_DEF(init_extensions6)
+       EMPTY_FUNC_DEF(init_extensionsa)
+       EMPTY_FUNC_DEF(init_extensionsb)
+#      undef EMPTY_FUNC_DEF
 #endif
 
 extern const struct xtables_pprot xtables_chain_protos[];
index 105b83ba54010d5b67517bca75763d939418d2ff..7c8bb0c2748a91e4332ae4a8a224fb35d4cd2034 100644 (file)
@@ -52,11 +52,8 @@ ip6tables_main(int argc, char *argv[])
                                ip6tables_globals.program_version);
                exit(1);
        }
-
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions6();
-#endif
 
        ret = do_command6(argc, argv, &table, &handle, false);
        if (ret) {
index 1917fb2315665a4385dee6a5b51ba06c70fbd641..d8f65ce1335eaec4f78644a7be0e0fa29a87c7f8 100644 (file)
@@ -383,10 +383,8 @@ iptables_restore_main(int argc, char *argv[])
                                iptables_globals.program_version);
                exit(1);
        }
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions4();
-#endif
 
        ret = ip46tables_restore_main(&ipt_restore_cb, argc, argv);
 
@@ -417,10 +415,8 @@ ip6tables_restore_main(int argc, char *argv[])
                                ip6tables_globals.program_version);
                exit(1);
        }
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions6();
-#endif
 
        ret = ip46tables_restore_main(&ip6t_restore_cb, argc, argv);
 
index a114e98bb62dc0b489bfb7311e50c00e91499e26..a8dded639cbad1011c64b58e56384cc0b74507da 100644 (file)
@@ -227,10 +227,8 @@ iptables_save_main(int argc, char *argv[])
                                iptables_globals.program_version);
                exit(1);
        }
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions4();
-#endif
 
        ret = do_iptables_save(&ipt_save_cb, argc, argv);
 
@@ -273,10 +271,8 @@ ip6tables_save_main(int argc, char *argv[])
                                ip6tables_globals.program_version);
                exit(1);
        }
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions6();
-#endif
 
        ret = do_iptables_save(&ip6t_save_cb, argc, argv);
 
index 8c67ea4d9a2fb5f1de35c7de4fc05ca09610251a..0f263f6fd45e4f6aaffb5e18d6e0b18262ed1fb6 100644 (file)
@@ -53,10 +53,8 @@ iptables_main(int argc, char *argv[])
                                iptables_globals.program_version);
                                exit(1);
        }
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions4();
-#endif
 
        ret = do_command4(argc, argv, &table, &handle, false);
        if (ret) {
index 805fb19a5f93767f247379390b3976a50acf69a1..9c44cfc2e46f7a8fa513b3b700252e189c811ae1 100644 (file)
@@ -205,10 +205,7 @@ int nft_init_arp(struct nft_handle *h, const char *pname)
                        arptables_globals.program_version);
                exit(1);
        }
-
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensionsa();
-#endif
 
        if (nft_init(h, NFPROTO_ARP) < 0)
                xtables_error(OTHER_PROBLEM,
index 1e5b50ba5b0aba6f055239651c9d4ae6604a40be..dcb707f6a66e21e411c4609c310eb504ec2fd9f2 100644 (file)
@@ -668,10 +668,7 @@ int nft_init_eb(struct nft_handle *h, const char *pname)
                        ebtables_globals.program_version);
                exit(1);
        }
-
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensionsb();
-#endif
 
        if (nft_init(h, NFPROTO_BRIDGE) < 0)
                xtables_error(OTHER_PROBLEM,
index 73dc80c24d7220f5e97f4d482aa3ed7c24474051..72d5e04bf40bff8e621546368718b97ea5e70f1d 100644 (file)
@@ -625,11 +625,9 @@ int xtables_monitor_main(int argc, char *argv[])
                                xtables_globals.program_version);
                exit(1);
        }
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions4();
        init_extensions6();
-#endif
 
        if (nft_init(&h, AF_INET)) {
                fprintf(stderr, "%s/%s Failed to initialize nft: %s\n",
index 81b25a43c9a04946fd177c74a3d2ba53398b3360..c6a5ffedc5cb0a98cb962f44a9d579623d97e579 100644 (file)
@@ -363,11 +363,9 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
        switch (family) {
        case NFPROTO_IPV4:
        case NFPROTO_IPV6: /* fallthough, same table */
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
                init_extensions();
                init_extensions4();
                init_extensions6();
-#endif
                break;
        case NFPROTO_ARP:
        case NFPROTO_BRIDGE:
index 03d2b980d5371c46c96cc33f058b0046e920749a..9bbe8511e71149439eab993e6deaf81aeeb5c85e 100644 (file)
@@ -202,11 +202,9 @@ xtables_save_main(int family, int argc, char *argv[],
        switch (family) {
        case NFPROTO_IPV4:
        case NFPROTO_IPV6: /* fallthough, same table */
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
                init_extensions();
                init_extensions4();
                init_extensions6();
-#endif
                d.commit = true;
                break;
        case NFPROTO_ARP:
index 5482a85689d791e310358c17bd454733c1864a67..06fedf261d68b98be1d5a332f4de07adb9d9974a 100644 (file)
@@ -67,7 +67,6 @@ xtables_main(int family, const char *progname, int argc, char *argv[])
                exit(1);
        }
        xt_params->program_name = progname;
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        switch (family) {
        case NFPROTO_IPV4:
        case NFPROTO_IPV6:
@@ -79,7 +78,6 @@ xtables_main(int family, const char *progname, int argc, char *argv[])
                init_extensionsa();
                break;
        }
-#endif
 
        if (nft_init(&h, family) < 0) {
                fprintf(stderr, "%s: Failed to initialize nft: %s\n",
index 6a1cdac14a7da11f9044262bf4c6d99583c7be97..c518433463deae416119f833b1663a087660241d 100644 (file)
@@ -488,11 +488,9 @@ static int xtables_xlate_main_common(struct nft_handle *h,
        switch (family) {
        case NFPROTO_IPV4:
        case NFPROTO_IPV6: /* fallthrough: same table */
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
        init_extensions4();
        init_extensions6();
-#endif
                break;
        case NFPROTO_ARP:
        case NFPROTO_BRIDGE: