Instead of checking chain existence in xtables.c, do it in
nft_chain_user_add() and reuse predefined error message.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
if (nft_xtables_config_load(h, XTABLES_CONFIG_DEFAULT, 0) < 0)
nft_xt_builtin_init(h, table);
+ if (nft_chain_exists(h, table, chain)) {
+ errno = EEXIST;
+ return 0;
+ }
+
c = nftnl_chain_alloc();
if (c == NULL)
return 0;
xtables_error(PARAMETER_PROBLEM,
"Chain '%s' does not exist", cs->jumpto);
}
- if (!p->xlate && p->command == CMD_NEW_CHAIN &&
- nft_chain_exists(h, p->table, p->chain))
- xtables_error(OTHER_PROBLEM, "Chain already exists");
}
int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table,