From: Phil Sutter Date: Fri, 26 Nov 2021 14:53:14 +0000 (+0100) Subject: xtables: Pull table validity check out of do_parse() X-Git-Tag: v1.8.8~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98a4462f0abd54d96ed91d07d55608dd10fec414;p=thirdparty%2Fiptables.git 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 --- 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,