diff options
author | Phil Sutter <phil@nwl.cc> | 2019-02-13 11:11:26 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-02-13 20:08:31 +0100 |
commit | 4e13970a6c2ff03f60681b260db6f18290fd0a80 (patch) | |
tree | 9b4e3a7613eff314406726a990f5741b3507713a /iptables | |
parent | 0dbe82362b5cd257162109a29e1f5142fb6f8a09 (diff) |
xtables: Fix error message for chain renaming
If the new name already exists, legacy iptables prints "File exists.".
This is a bit exotic, but more appropriate than "No chain/target/match
by that name." printed by iptables-nft without this patch.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables')
-rw-r--r-- | iptables/nft.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/iptables/nft.c b/iptables/nft.c index f42a1be7..a297d985 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -1855,7 +1855,12 @@ int nft_chain_user_rename(struct nft_handle *h,const char *chain, uint64_t handle; int ret; - nft_fn = nft_chain_user_add; + nft_fn = nft_chain_user_rename; + + if (nft_chain_exists(h, table, newname)) { + errno = EEXIST; + return 0; + } /* If built-in chains don't exist for this table, create them */ if (nft_xtables_config_load(h, XTABLES_CONFIG_DEFAULT, 0) < 0) @@ -2985,6 +2990,7 @@ const char *nft_strerror(int err) { nft_chain_user_del, EMLINK, "Can't delete chain with references left" }, { nft_chain_user_add, EEXIST, "Chain already exists" }, + { nft_chain_user_rename, EEXIST, "File exists" }, { nft_rule_insert, E2BIG, "Index of insertion too big" }, { nft_rule_check, ENOENT, "Bad rule (does a matching rule exist in that chain?)" }, { nft_rule_replace, E2BIG, "Index of replacement too big" }, |