summaryrefslogtreecommitdiffstats
path: root/iptables/xtables.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-12-23 18:55:53 +0100
committerPhil Sutter <phil@nwl.cc>2022-01-12 14:08:41 +0100
commit3039a52c3ecf96df4e3b815d242f788c189093e1 (patch)
tree58e536a794f5a28f3db2c934d23cd1ee15c8e3af /iptables/xtables.c
parentece001c258e3fd8779e177ef00394877f2327f56 (diff)
xtables: Do not pass nft_handle to do_parse()
Make it fit for sharing with legacy iptables, drop nft-specific parameter. This requires to mirror proto_parse and post_parse callbacks from family_ops somewhere reachable - use xt_cmd_parse, it holds other "parser setup data" as well. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xtables.c')
-rw-r--r--iptables/xtables.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/iptables/xtables.c b/iptables/xtables.c
index 5e8c027b..59fc63d0 100644
--- a/iptables/xtables.c
+++ b/iptables/xtables.c
@@ -186,7 +186,7 @@ static void check_inverse(struct xtables_args *args, const char option[],
}
}
-void do_parse(struct nft_handle *h, int argc, char *argv[],
+void do_parse(int argc, char *argv[],
struct xt_cmd_parse *p, struct iptables_command_state *cs,
struct xtables_args *args)
{
@@ -382,8 +382,8 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
"rule would never match protocol");
/* This needs to happen here to parse extensions */
- if (h->ops->proto_parse)
- h->ops->proto_parse(cs, args);
+ if (p->ops->proto_parse)
+ p->ops->proto_parse(cs, args);
break;
case 's':
@@ -653,7 +653,8 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
xtables_error(PARAMETER_PROBLEM,
"nothing appropriate following !");
- h->ops->post_parse(p->command, cs, args);
+ if (p->ops->post_parse)
+ p->ops->post_parse(p->command, cs, args);
if (p->command == CMD_REPLACE &&
(args->s.naddrs != 1 || args->d.naddrs != 1))
@@ -702,6 +703,7 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table,
struct xt_cmd_parse p = {
.table = *table,
.restore = restore,
+ .ops = &h->ops->cmd_parse,
};
struct iptables_command_state cs = {
.jumpto = "",
@@ -714,7 +716,7 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table,
if (h->ops->init_cs)
h->ops->init_cs(&cs);
- do_parse(h, argc, argv, &p, &cs, &args);
+ do_parse(argc, argv, &p, &cs, &args);
if (!nft_table_builtin_find(h, p.table))
xtables_error(VERSION_PROBLEM,