]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
ebtables: Fix for listing of non-existent chains
authorPhil Sutter <phil@nwl.cc>
Wed, 15 Aug 2018 10:34:24 +0000 (12:34 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Aug 2018 17:43:47 +0000 (19:43 +0200)
When trying to list a non-existent chain, ebtables-nft would just print
the table header and then exit with a code of zero. In order to be more
consistent with legacy ebtables, change the code to:

* Print table header only if chosen chain is found and
* propagate the error condition if chain was not found to print an error
  message.

Note that this does not establish full parity with legacy ebtables due
to the error code being 1 instead of 255 and the error message differing
from the legacy one.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft.c
iptables/xtables-eb.c

index 8a84998b961a74378b354d8a28621aca6baef34d..ad4f61bbd49ac6e200e81bf16e6f627fe2f94cde 100644 (file)
@@ -2323,7 +2323,7 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
        if (iter == NULL)
                goto err;
 
-       if (ops->print_table_header)
+       if (!chain && ops->print_table_header)
                ops->print_table_header(table);
 
        c = nftnl_chain_list_iter_next(iter);
@@ -2347,8 +2347,12 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
 
                if (strcmp(table, chain_table) != 0)
                        goto next;
-               if (chain && strcmp(chain, chain_name) != 0)
-                       goto next;
+               if (chain) {
+                       if (strcmp(chain, chain_name) != 0)
+                               goto next;
+                       else if (ops->print_table_header)
+                               ops->print_table_header(table);
+               }
 
                refs -= nft_rule_count(h, chain_name, table);
 
index a46b9e5a9113b5196e6cfe14355466e95e9c478b..534714de7999af1d15faa165df09d15c3ad908fd 100644 (file)
@@ -1294,8 +1294,6 @@ check_extension:
                                 /*flags&OPT_EXPANDED*/0,
                                 flags&LIST_N,
                                 flags&LIST_C);
-               if (!(flags & OPT_ZERO))
-                       exit(0);
        }
        if (flags & OPT_ZERO) {
                selected_chain = zerochain;