[iptables PATCH 1/5] xtables: Fix error message when zeroing a non-existent chain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Previously, error message was a bit misleading:

| # iptables-nft -Z noexist
| iptables: Incompatible with this kernel.

Set errno value so that the typical "No chain/target/match by that
name." is printed instead.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 iptables/nft.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/iptables/nft.c b/iptables/nft.c
index d708fb6176b88..60b0531f4c8c8 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -3235,8 +3235,10 @@ int nft_chain_zero_counters(struct nft_handle *h, const char *chain,
 
 	if (chain) {
 		c = nftnl_chain_list_lookup_byname(list, chain);
-		if (!c)
+		if (!c) {
+			errno = ENOENT;
 			return 0;
+		}
 
 		ret = __nft_chain_zero_counters(c, &d);
 		goto err;
-- 
2.20.1




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux