All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Leblond <eric@regit.org>
To: netfilter-devel@vger.kernel.org, pablo@netfilter.org
Cc: eric@regit.org
Subject: [nftables PATCH] listing: only display wanted chain
Date: Mon, 18 Nov 2013 08:40:21 +0100	[thread overview]
Message-ID: <1384760421-4238-1-git-send-email-eric@regit.org> (raw)

When specifying a chain to list, all created chains were displayed
with a void content:

 # nft list chain filter
 table ip filter {
  	chain input {
  	}

  	chain new {
  		 counter packets 17971 bytes 2380637 accept
  		 counter packets 0 bytes 0 accept
  	}
  }

With the attached patch, only the asked chain is displayed:

  # nft list chain filter
  table ip filter {
  	chain new {
  		 counter packets 17971 bytes 2380637 accept # handle 36
  		 counter packets 0 bytes 0 accept # handle 40
  	}
  }

Signed-off-by: Eric Leblond <eric@regit.org>
---
 src/netlink.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/netlink.c b/src/netlink.c
index a62c357..15cba79 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -544,6 +544,10 @@ static int list_chain_cb(struct nft_chain *nlc, void *arg)
 	    strcmp(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_TABLE), h->table) != 0)
 		return 0;
 
+	if (h->chain &&
+	    strcmp(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_NAME), h->chain) != 0)
+		return 0;
+
 	chain = chain_alloc(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_NAME));
 	chain->handle.family =
 		nft_chain_attr_get_u32(nlc, NFT_CHAIN_ATTR_FAMILY);
-- 
1.8.4.3


             reply	other threads:[~2013-11-18  7:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-18  7:40 Eric Leblond [this message]
2013-11-19  9:26 ` [nftables PATCH] listing: only display wanted chain Arturo Borrero Gonzalez
2013-11-19 20:32 ` 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=1384760421-4238-1-git-send-email-eric@regit.org \
    --to=eric@regit.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.