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: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 04/13] netfilter: nf_tables: Expose the table usage counter via netlink
Date: Mon,  6 Jan 2014 14:46:33 +0100	[thread overview]
Message-ID: <1389016002-9116-5-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1389016002-9116-1-git-send-email-pablo@netfilter.org>

From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>

Userspace 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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 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 256d36b..b25481e 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_USE: number of chains in this table (NLA_U32)
  */
 enum nft_table_attributes {
 	NFTA_TABLE_UNSPEC,
 	NFTA_TABLE_NAME,
 	NFTA_TABLE_FLAGS,
+	NFTA_TABLE_USE,
 	__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..604512d 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_USE, htonl(table->use)))
 		goto nla_put_failure;
 
 	return nlmsg_end(skb, nlh);
-- 
1.7.10.4


  parent reply	other threads:[~2014-01-06 13:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-06 13:46 [PATCH 00/13] nftables updates for net-next Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 01/13] netfilter: nf_tables: fix issue with verdict support Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 02/13] netfilter: xt_NFQUEUE: separate reusable code Pablo Neira Ayuso
2014-01-06 14:02   ` Florian Westphal
2014-01-06 13:46 ` [PATCH 03/13] netfilter: nft: add queue module Pablo Neira Ayuso
2014-01-06 13:46 ` Pablo Neira Ayuso [this message]
2014-01-06 13:46 ` [PATCH 05/13] netfilter: nf_tables: nft_meta module get/set ops Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 06/13] netfilter: nf_tables: remove nft_meta_target Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 07/13] netfilter: select NFNETLINK when enabling NF_TABLES Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 08/13] netfilter: REJECT: separate reusable code Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 09/13] netfilter: nft_reject: support for IPv6 and TCP reset Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 10/13] netfilter: add help information to new nf_tables Kconfig options Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 11/13] netfilter: nf_tables: fix type in parsing in nf_tables_set_alloc_name() Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 12/13] netfilter: nf_tables: remove unused variable in nf_tables_dump_set() Pablo Neira Ayuso
2014-01-06 13:46 ` [PATCH 13/13] netfilter: nf_tables: dump sets in all existing families Pablo Neira Ayuso
2014-01-06 18:30 ` [PATCH 00/13] nftables updates for net-next David Miller

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=1389016002-9116-5-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --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).