summaryrefslogtreecommitdiffstats
path: root/iptables/xtables.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-11-26 15:53:14 +0100
committerPhil Sutter <phil@nwl.cc>2022-01-12 14:04:52 +0100
commit98a4462f0abd54d96ed91d07d55608dd10fec414 (patch)
treea7c9ad026fdd0a6fca309d4ee63b310861ff5077 /iptables/xtables.c
parentd83371c7330632a85a443c09ade2f9e0fac615e4 (diff)
xtables: Pull table validity check out of do_parse()
Makes do_parse() more generic, error codes don't change so this should be safe. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xtables.c')
-rw-r--r--iptables/xtables.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/iptables/xtables.c b/iptables/xtables.c
index 5c48bd94..ac864eb2 100644
--- a/iptables/xtables.c
+++ b/iptables/xtables.c
@@ -514,10 +514,6 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
xtables_error(PARAMETER_PROBLEM,
"The -t option cannot be used in %s.\n",
xt_params->program_name);
- if (!nft_table_builtin_find(h, optarg))
- xtables_error(VERSION_PROBLEM,
- "table '%s' does not exist",
- optarg);
p->table = optarg;
table_set = true;
break;
@@ -720,6 +716,10 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table,
do_parse(h, argc, argv, &p, &cs, &args);
+ if (!nft_table_builtin_find(h, p.table))
+ xtables_error(VERSION_PROBLEM,
+ "table '%s' does not exist",
+ p.table);
switch (p.command) {
case CMD_APPEND:
ret = h->ops->add_entry(h, p.chain, p.table, &cs, &args,