From b6a06c1a215f867f7eee4a3f2f40ec14028fe186 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 31 Aug 2018 12:29:57 +0200 Subject: 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 Signed-off-by: Florian Westphal --- iptables/nft.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'iptables/nft.c') 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) { -- cgit v1.2.3