[nftables tool PATCH 1/5] src: Fix base chain print out

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

 



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@xxxxxxxxxxxxxxx>
---
 src/netlink.c | 4 +++-
 src/rule.c    | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/netlink.c b/src/netlink.c
index 962561f..7f99416 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -535,7 +535,9 @@ static int list_chain_cb(struct nft_chain *nlc, void *arg)
 		chain->priority      =
 			nft_chain_attr_get_u32(nlc, NFT_CHAIN_ATTR_PRIO);
 		chain->type          =
-			xstrdup(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_TYPE));
+			xstrdup(nft_chain_attr_get_str(nlc,
+				NFT_CHAIN_ATTR_TYPE));
+		chain->flags        |= CHAIN_F_BASECHAIN;
 	}
 	list_add_tail(&chain->list, &ctx->list);
 
diff --git a/src/rule.c b/src/rule.c
index fb0387c..73054ba 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -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);
 	}
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

  Powered by Linux