diff options
| author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2013-12-12 08:00:42 -0500 |
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-12-17 08:28:05 -0500 |
| commit | d8bcc768c80e73cf4e948cb327949174b4b5b9e7 (patch) | |
| tree | 18be32c57d81b76d31933c7cd60142ebdb21c0c2 | |
| parent | 0aff078d58e1c69139189e45ba5e929c030e8056 (diff) | |
netfilter: nf_tables: Expose the table usage counter via netlink
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>
| -rw-r--r-- | include/uapi/linux/netfilter/nf_tables.h | 2 | ||||
| -rw-r--r-- | net/netfilter/nf_tables_api.c | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h index 256d36b1b94a..b25481e16f0a 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 { | |||
| 110 | * | 110 | * |
| 111 | * @NFTA_TABLE_NAME: name of the table (NLA_STRING) | 111 | * @NFTA_TABLE_NAME: name of the table (NLA_STRING) |
| 112 | * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32) | 112 | * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32) |
| 113 | * @NFTA_TABLE_USE: number of chains in this table (NLA_U32) | ||
| 113 | */ | 114 | */ |
| 114 | enum nft_table_attributes { | 115 | enum nft_table_attributes { |
| 115 | NFTA_TABLE_UNSPEC, | 116 | NFTA_TABLE_UNSPEC, |
| 116 | NFTA_TABLE_NAME, | 117 | NFTA_TABLE_NAME, |
| 117 | NFTA_TABLE_FLAGS, | 118 | NFTA_TABLE_FLAGS, |
| 119 | NFTA_TABLE_USE, | ||
| 118 | __NFTA_TABLE_MAX | 120 | __NFTA_TABLE_MAX |
| 119 | }; | 121 | }; |
| 120 | #define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1) | 122 | #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 dcddc49c0e08..604512d523f7 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, | |||
| 180 | nfmsg->res_id = 0; | 180 | nfmsg->res_id = 0; |
| 181 | 181 | ||
| 182 | if (nla_put_string(skb, NFTA_TABLE_NAME, table->name) || | 182 | if (nla_put_string(skb, NFTA_TABLE_NAME, table->name) || |
| 183 | nla_put_be32(skb, NFTA_TABLE_FLAGS, htonl(table->flags))) | 183 | nla_put_be32(skb, NFTA_TABLE_FLAGS, htonl(table->flags)) || |
| 184 | nla_put_be32(skb, NFTA_TABLE_USE, htonl(table->use))) | ||
| 184 | goto nla_put_failure; | 185 | goto nla_put_failure; |
| 185 | 186 | ||
| 186 | return nlmsg_end(skb, nlh); | 187 | return nlmsg_end(skb, nlh); |
