From 03572549df349455fcade80dfab0b28904975330 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 3 Aug 2018 15:56:19 +0200 Subject: xtables: Print error when listing non-existent chains Just like legacy iptables, iptables-nft should not treat the attempt to list a non-existing chain as OK. Signed-off-by: Phil Sutter Signed-off-by: Florian Westphal --- iptables/nft.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/iptables/nft.c b/iptables/nft.c index f9bd0ed2..154ae19c 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -2298,18 +2298,21 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table, __nft_rule_list(h, chain_name, table, rulenum, format, ops->print_rule); + found = true; + /* we printed the chain we wanted, stop processing. */ if (chain) break; - found = true; - next: c = nftnl_chain_list_iter_next(iter); } nftnl_chain_list_iter_destroy(iter); err: + if (chain && !found) + return 0; + return 1; } -- cgit v1.2.3