diff mbox

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

Message ID 1377678791-7616-2-git-send-email-tomasz.bursztyka@linux.intel.com
State Accepted
Headers show

Commit Message

Tomasz Bursztyka Aug. 28, 2013, 8:33 a.m. UTC
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>
---
 src/netlink.c | 4 +++-
 src/rule.c    | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Pablo Neira Ayuso Aug. 30, 2013, 9:58 p.m. UTC | #1
On Wed, Aug 28, 2013 at 11:33:07AM +0300, Tomasz Bursztyka wrote:
> 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.

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

Patch

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);
 	}