summaryrefslogtreecommitdiffstats
path: root/iptables/nft.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2018-08-31 12:29:57 +0200
committerFlorian Westphal <fw@strlen.de>2018-09-01 10:12:40 +0200
commitb6a06c1a215f867f7eee4a3f2f40ec14028fe186 (patch)
treea941776217826cb296c2477e403747f8397437a1 /iptables/nft.c
parent3bb497c61d743ba811e7f501e54cc5071216e1f5 (diff)
xtables: Align return codes with legacy iptables
Make sure return codes match legacy ones at least for a few selected commands typically used to check ruleset state. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/nft.c')
-rw-r--r--iptables/nft.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/iptables/nft.c b/iptables/nft.c
index b2165069..7123060b 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -1725,6 +1725,21 @@ nft_chain_find(struct nft_handle *h, const char *table, const char *chain)
return nft_chain_list_find(list, table, chain);
}
+bool nft_chain_exists(struct nft_handle *h,
+ const char *table, const char *chain)
+{
+ struct builtin_table *t = nft_table_builtin_find(h, table);
+
+ /* xtables does not support custom tables */
+ if (!t)
+ return false;
+
+ if (nft_chain_builtin_find(t, chain))
+ return true;
+
+ return !!nft_chain_find(h, table, chain);
+}
+
int nft_chain_user_rename(struct nft_handle *h,const char *chain,
const char *table, const char *newname)
{