summaryrefslogtreecommitdiffstats
path: root/iptables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2023-11-15 16:58:15 +0100
committerPhil Sutter <phil@nwl.cc>2023-12-05 16:35:37 +0100
commite224f0b10ef01e3e2081054e7fa4f64601726646 (patch)
tree044422b2440e7f667df3e4d57807ccc670384507 /iptables
parentea7fef2a6f0457c44929bc8d1871257c15ed78ce (diff)
xshared: Turn command_default() into a callback
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>
Diffstat (limited to 'iptables')
-rw-r--r--iptables/ip6tables.c1
-rw-r--r--iptables/iptables.c1
-rw-r--r--iptables/nft-arp.c1
-rw-r--r--iptables/nft-ipv4.c1
-rw-r--r--iptables/nft-ipv6.c1
-rw-r--r--iptables/xshared.c6
-rw-r--r--iptables/xshared.h4
7 files changed, 12 insertions, 3 deletions
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
index 53eeb6e9..96603756 100644
--- a/iptables/ip6tables.c
+++ b/iptables/ip6tables.c
@@ -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,
diff --git a/iptables/iptables.c b/iptables/iptables.c
index 69dd2890..b57483ef 100644
--- a/iptables/iptables.c
+++ b/iptables/iptables.c
@@ -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,
diff --git a/iptables/nft-arp.c b/iptables/nft-arp.c
index c009dd83..f3e2920a 100644
--- a/iptables/nft-arp.c
+++ b/iptables/nft-arp.c
@@ -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,
diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
index c140ffde..754c7764 100644
--- a/iptables/nft-ipv4.c
+++ b/iptables/nft-ipv4.c
@@ -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,
diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
index 4bf4f54f..b1b58910 100644
--- a/iptables/nft-ipv6.c
+++ b/iptables/nft-ipv6.c
@@ -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,
diff --git a/iptables/xshared.c b/iptables/xshared.c
index ff809f2b..29b39929 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -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;
diff --git a/iptables/xshared.h b/iptables/xshared.h
index 3df2153f..bf24fd56 100644
--- a/iptables/xshared.h
+++ b/iptables/xshared.h
@@ -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,