diff options
author | Jacek Tomasiak <jacek.tomasiak@gmail.com> | 2024-01-23 11:14:27 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2024-01-24 15:21:58 +0100 |
commit | 0a118c474924f05224b215cf38b7b3a19a9f0265 (patch) | |
tree | 9daa03711b14198f30f678b209701af4654fcfc7 | |
parent | b1ae6a45c9f38a60a13d9ecb88dcbeb12e5d13e0 (diff) |
iptables: Add missing error codes
Without these, commands like `iptables -n -L CHAIN` sometimes print
"Incompatible with this kernel" instead of "No chain/target/match
by that name".
Signed-off-by: Jacek Tomasiak <jacek.tomasiak@gmail.com>
Signed-off-by: Jacek Tomasiak <jtomasiak@arista.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r-- | iptables/nft.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/iptables/nft.c b/iptables/nft.c index f5368578..c2cbc9d7 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -2812,8 +2812,10 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table, if (chain) { c = nft_chain_find(h, table, chain); - if (!c) + if (!c) { + errno = ENOENT; return 0; + } if (rulenum) d.save_fmt = true; /* skip header printing */ @@ -2920,8 +2922,10 @@ int nft_rule_list_save(struct nft_handle *h, const char *chain, if (chain) { c = nft_chain_find(h, table, chain); - if (!c) + if (!c) { + errno = ENOENT; return 0; + } if (!rulenum) nft_rule_list_chain_save(c, &counters); @@ -2953,8 +2957,10 @@ int nft_rule_zero_counters(struct nft_handle *h, const char *chain, nft_fn = nft_rule_delete; c = nft_chain_find(h, table, chain); - if (!c) + if (!c) { + errno = ENOENT; return 0; + } r = nft_rule_find(h, c, NULL, rulenum); if (r == NULL) { |