Trying to delete a rule by index from a non-existent chain leads to a
somewhat confusing error message:

| # iptables-nft -D foobar 1
| iptables: Index of deletion too big.

Fix this by performing chain existence checks for CMD_DELETE_NUM, too.

Signed-off-by: Phil Sutter <p...@nwl.cc>
---
 iptables/xtables.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/iptables/xtables.c b/iptables/xtables.c
index 429bd652cc439..24a6e234bcf4b 100644
--- a/iptables/xtables.c
+++ b/iptables/xtables.c
@@ -1040,6 +1040,7 @@ void do_parse(struct nft_handle *h, int argc, char 
*argv[],
 
        if (p->command == CMD_APPEND ||
            p->command == CMD_DELETE ||
+           p->command == CMD_DELETE_NUM ||
            p->command == CMD_CHECK ||
            p->command == CMD_INSERT ||
            p->command == CMD_REPLACE) {
-- 
2.19.0

Reply via email to