]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xshared: Turn command_default() into a callback
authorPhil Sutter <phil@nwl.cc>
Wed, 15 Nov 2023 15:58:15 +0000 (16:58 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 5 Dec 2023 15:35:37 +0000 (16:35 +0100)
Ebtables' variant is pretty different since all extensions are loaded up
front and some targets serve as "watcher" extensions, so let variants
specify the function to call for extension parameters.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/ip6tables.c
iptables/iptables.c
iptables/nft-arp.c
iptables/nft-ipv4.c
iptables/nft-ipv6.c
iptables/xshared.c
iptables/xshared.h

index 53eeb6e90bbb74ea93d7d334cac76eaefe4a17c8..96603756324a51cf58aa94e62d5cdee35d4f37f4 100644 (file)
@@ -670,6 +670,7 @@ int do_command6(int argc, char *argv[], char **table,
                .post_parse     = ipv6_post_parse,
                .option_name    = ip46t_option_name,
                .option_invert  = ip46t_option_invert,
+               .command_default = command_default,
        };
        struct xt_cmd_parse p = {
                .table          = *table,
index 69dd2890605288e66d75d116173f9b68766d4220..b57483ef445147bc839b2131719f3f2e872d3853 100644 (file)
@@ -664,6 +664,7 @@ int do_command4(int argc, char *argv[], char **table,
                .post_parse     = ipv4_post_parse,
                .option_name    = ip46t_option_name,
                .option_invert  = ip46t_option_invert,
+               .command_default = command_default,
        };
        struct xt_cmd_parse p = {
                .table          = *table,
index c009dd83e26cf774d07b99c6552f807db05b7164..f3e2920ac6d15aabc453a022661d8280c6434abf 100644 (file)
@@ -858,6 +858,7 @@ struct nft_family_ops nft_family_ops_arp = {
                .post_parse     = nft_arp_post_parse,
                .option_name    = nft_arp_option_name,
                .option_invert  = nft_arp_option_invert,
+               .command_default = command_default,
        },
        .rule_to_cs             = nft_rule_to_iptables_command_state,
        .init_cs                = nft_arp_init_cs,
index c140ffde34b625d6caab9e802386e11b22139992..754c7764731431f748af004b28318637b2aab83d 100644 (file)
@@ -354,6 +354,7 @@ struct nft_family_ops nft_family_ops_ipv4 = {
                .post_parse     = ipv4_post_parse,
                .option_name    = ip46t_option_name,
                .option_invert  = ip46t_option_invert,
+               .command_default = command_default,
        },
        .rule_to_cs             = nft_rule_to_iptables_command_state,
        .clear_cs               = xtables_clear_iptables_command_state,
index 4bf4f54f18a00f8174d2fc3ce00d44515ae12ff8..b1b5891013577fa983e77bba6ca422193b6a203b 100644 (file)
@@ -345,6 +345,7 @@ struct nft_family_ops nft_family_ops_ipv6 = {
                .post_parse     = ipv6_post_parse,
                .option_name    = ip46t_option_name,
                .option_invert  = ip46t_option_invert,
+               .command_default = command_default,
        },
        .rule_to_cs             = nft_rule_to_iptables_command_state,
        .clear_cs               = xtables_clear_iptables_command_state,
index ff809f2be3438bbed664ad502cebc8b7b388f6f8..29b3992904e688892677c7be351ffba1b4ad34e5 100644 (file)
@@ -122,8 +122,8 @@ static struct xtables_match *load_proto(struct iptables_command_state *cs)
                          cs->options & OPT_NUMERIC, &cs->matches);
 }
 
-static int command_default(struct iptables_command_state *cs,
-                          struct xtables_globals *gl, bool invert)
+int command_default(struct iptables_command_state *cs,
+                   struct xtables_globals *gl, bool invert)
 {
        struct xtables_rule_match *matchp;
        struct xtables_match *m;
@@ -1784,7 +1784,7 @@ void do_parse(int argc, char *argv[],
                        exit_tryhelp(2, p->line);
 
                default:
-                       if (command_default(cs, xt_params, invert))
+                       if (p->ops->command_default(cs, xt_params, invert))
                                /* cf. ip6tables.c */
                                continue;
                        break;
index 3df2153fd6a10bb9c7936b5f0ceb3c31ad92af63..bf24fd568a6f52fa68c1db1d609143ecbcf7913f 100644 (file)
@@ -272,6 +272,8 @@ struct xt_cmd_parse_ops {
                              struct xtables_args *args);
        const char *(*option_name)(int option);
        int     (*option_invert)(int option);
+       int     (*command_default)(struct iptables_command_state *cs,
+                                  struct xtables_globals *gl, bool invert);
 };
 
 struct xt_cmd_parse {
@@ -289,6 +291,8 @@ struct xt_cmd_parse {
 
 const char *ip46t_option_name(int option);
 int ip46t_option_invert(int option);
+int command_default(struct iptables_command_state *cs,
+                   struct xtables_globals *gl, bool invert);
 
 void do_parse(int argc, char *argv[],
              struct xt_cmd_parse *p, struct iptables_command_state *cs,