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-kernel PATCH 3/7] netfilter: nf_tables: Expose the table's chain usage to the netlink API
Date: Mon, 14 Oct 2013 15:46:52 +0300	[thread overview]
Message-ID: <1381754816-28472-4-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1381754816-28472-1-git-send-email-tomasz.bursztyka@linux.intel.com>

User space can therefore know whether a table is in use or not, and by
how many chains.

Suggested by Pablo Neira Ayuso.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
 include/uapi/linux/netfilter/nf_tables.h | 2 ++
 net/netfilter/nf_tables_api.c            | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index b108548..28f0ffb 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -110,11 +110,13 @@ enum nft_table_flags {
  *
  * @NFTA_TABLE_NAME: name of the table (NLA_STRING)
  * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32)
+ * @NFTA_TABLE_CHAINS: number of chains in this table (NLA_U32)
  */
 enum nft_table_attributes {
 	NFTA_TABLE_UNSPEC,
 	NFTA_TABLE_NAME,
 	NFTA_TABLE_FLAGS,
+	NFTA_TABLE_CHAINS,
 	__NFTA_TABLE_MAX
 };
 #define NFTA_TABLE_MAX		(__NFTA_TABLE_MAX - 1)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index dcddc49..482b689 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -180,7 +180,8 @@ static int nf_tables_fill_table_info(struct sk_buff *skb, u32 portid, u32 seq,
 	nfmsg->res_id		= 0;
 
 	if (nla_put_string(skb, NFTA_TABLE_NAME, table->name) ||
-	    nla_put_be32(skb, NFTA_TABLE_FLAGS, htonl(table->flags)))
+	    nla_put_be32(skb, NFTA_TABLE_FLAGS, htonl(table->flags)) ||
+	    nla_put_be32(skb, NFTA_TABLE_CHAINS, htonl(table->use)))
 		goto nla_put_failure;
 
 	return nlmsg_end(skb, nlh);
-- 
1.8.3.2


  parent reply	other threads:[~2013-10-14 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14 12:46 [nftables-kernel PATCH 0/7] API minor fixes and improvement proposals Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 1/7] netfilter: nf_tables: Fix API documentation on a missing part Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 2/7] netfilter: nf_tables: Use byteorder operands length relevantly Tomasz Bursztyka
2013-10-14 12:46 ` Tomasz Bursztyka [this message]
2013-10-14 12:46 ` [nftables-kernel PATCH 4/7] netfilter: nf_tables: Use a semantically relevant name on chain's refs Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 5/7] netfilter: nf_tables: Add a meta key to get the device address length Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 6/7] netfilter: nf_tables: Add left and right shifts to bitwise expression Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 7/7] netfilter: nf_tables: Improve payload expression for an extra offset Tomasz Bursztyka
2013-10-14 12:58 ` [nftables-kernel PATCH 0/7] API minor fixes and improvement proposals Pablo Neira Ayuso
2013-10-14 13:50   ` 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=1381754816-28472-4-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).