]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: Fix base chain printing
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Wed, 28 Aug 2013 08:33:07 +0000 (11:33 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 30 Aug 2013 21:14:18 +0000 (23:14 +0200)
Relying on chain's hooknum to know whether the chain is a base one or
not is bogus: having 0 as hooknum is a valid number. Thus setting the
right flag and handling it is the way to go, as parser does already.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink.c
src/rule.c

index 962561f313198c4857643c473b1f1d67f1cf7e1d..9a766cb19e748d5c422c26da744b3fbca3fd7ed1 100644 (file)
@@ -536,6 +536,7 @@ static int list_chain_cb(struct nft_chain *nlc, void *arg)
                        nft_chain_attr_get_u32(nlc, NFT_CHAIN_ATTR_PRIO);
                chain->type          =
                        xstrdup(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_TYPE));
+               chain->flags        |= CHAIN_F_BASECHAIN;
        }
        list_add_tail(&chain->list, &ctx->list);
 
index fb0387c3d461cac7d3ec6c3a9de039402889f0ec..73054bada4ccf297762ae970ee27ea89de3e315a 100644 (file)
@@ -249,7 +249,7 @@ static void chain_print(const struct chain *chain)
        struct rule *rule;
 
        printf("\tchain %s {\n", chain->handle.chain);
-       if (chain->hooknum) {
+       if (chain->flags & CHAIN_F_BASECHAIN) {
                printf("\t\t type %s hook %s %u;\n", chain->type,
                       hooknum2str(chain->hooknum), chain->priority);
        }