netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH nft 2/3] src: set chain->hookstr from delinearization
Date: Mon,  6 Jul 2015 19:06:45 +0200	[thread overview]
Message-ID: <1436202406-14059-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1436202406-14059-1-git-send-email-pablo@netfilter.org>

Set human readable hookname chain->hookstr field from delinearize.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 include/rule.h |    1 +
 src/netlink.c  |    2 ++
 src/rule.c     |    8 +++-----
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/rule.h b/include/rule.h
index 5d44599..8ec7f91 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -138,6 +138,7 @@ extern struct chain *chain_lookup(const struct table *table,
 				  const struct handle *h);
 
 extern const char *family2str(unsigned int family);
+extern const char *hooknum2str(unsigned int family, unsigned int hooknum);
 extern void chain_print_plain(const struct chain *chain);
 
 /**
diff --git a/src/netlink.c b/src/netlink.c
index 429eed4..d11d82f 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -691,6 +691,8 @@ static struct chain *netlink_delinearize_chain(struct netlink_ctx *ctx,
 	    nft_chain_attr_is_set(nlc, NFT_CHAIN_ATTR_POLICY)) {
 		chain->hooknum       =
 			nft_chain_attr_get_u32(nlc, NFT_CHAIN_ATTR_HOOKNUM);
+		chain->hookstr       =
+			hooknum2str(chain->handle.family, chain->hooknum);
 		chain->priority      =
 			nft_chain_attr_get_s32(nlc, NFT_CHAIN_ATTR_PRIO);
 		chain->type          =
diff --git a/src/rule.c b/src/rule.c
index 39b4d9a..993f970 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -408,7 +408,7 @@ const char *family2str(unsigned int family)
 	return "unknown";
 }
 
-static const char *hooknum2str(unsigned int family, unsigned int hooknum)
+const char *hooknum2str(unsigned int family, unsigned int hooknum)
 {
 	switch (family) {
 	case NFPROTO_IPV4:
@@ -466,8 +466,7 @@ static void chain_print(const struct chain *chain)
 	printf("\tchain %s {\n", chain->handle.chain);
 	if (chain->flags & CHAIN_F_BASECHAIN) {
 		printf("\t\ttype %s hook %s priority %d; policy %s;\n",
-		       chain->type,
-		       hooknum2str(chain->handle.family, chain->hooknum),
+		       chain->type, chain->hookstr,
 		       chain->priority, chain_policy2str(chain->policy));
 	}
 	list_for_each_entry(rule, &chain->rules, list) {
@@ -488,8 +487,7 @@ void chain_print_plain(const struct chain *chain)
 
 	if (chain->flags & CHAIN_F_BASECHAIN) {
 		printf(" { type %s hook %s priority %d; policy %s; }",
-		       chain->type,
-		       hooknum2str(chain->handle.family, chain->hooknum),
+		       chain->type, chain->hookstr,
 		       chain->priority, chain_policy2str(chain->policy));
 	}
 
-- 
1.7.10.4


  reply	other threads:[~2015-07-06 17:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 17:06 [PATCH nft 1/3] rule: missing family when listing of tables Pablo Neira Ayuso
2015-07-06 17:06 ` Pablo Neira Ayuso [this message]
2015-07-06 17:06 ` [PATCH nft 3/3] rule: add do_list_tables() Pablo Neira Ayuso

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=1436202406-14059-2-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=kaber@trash.net \
    --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).