netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: netfilter-devel@vger.kernel.org
Cc: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [nftables tool PATCH 1/5] src: Fix base chain print out
Date: Wed, 28 Aug 2013 11:33:07 +0300	[thread overview]
Message-ID: <1377678791-7616-2-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1377678791-7616-1-git-send-email-tomasz.bursztyka@linux.intel.com>

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(-)

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


  reply	other threads:[~2013-08-28  8:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-28  8:33 [nftables tool PATCH 0/5] Easier base chain declaration Tomasz Bursztyka
2013-08-28  8:33 ` Tomasz Bursztyka [this message]
2013-08-30 21:58   ` [nftables tool PATCH 1/5] src: Fix base chain print out Pablo Neira Ayuso
2013-08-28  8:33 ` [nftables tool PATCH 2/5] src: Wrap netfilter hooks around human readable strings Tomasz Bursztyka
2013-08-30 22:05   ` Pablo Neira Ayuso
2013-09-02  5:03     ` Tomasz Bursztyka
2013-08-28  8:33 ` [nftables tool PATCH 3/5] syntax: Add priority keyword on base chain description Tomasz Bursztyka
2013-08-28  8:33 ` [nftables tool PATCH 4/5] src: Ensure given base chain type is a valid one Tomasz Bursztyka
2013-08-28  8:33 ` [nftables tool PATCH 5/5] tests: Update bate chain creation according to latest syntax changes Tomasz Bursztyka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377678791-7616-2-git-send-email-tomasz.bursztyka@linux.intel.com \
    --to=tomasz.bursztyka@linux.intel.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).