Patchwork [2/2] netfilter: nf_tables: don't skip inactive rules and dump generation mask

login
register
mail settings
Submitter Pablo Neira
Date Feb. 28, 2013, 11:08 p.m.
Message ID <1362092898-23306-2-git-send-email-pablo@netfilter.org>
Download mbox | patch
Permalink /patch/224197/
State Not Applicable
Headers show

Comments

Pablo Neira - Feb. 28, 2013, 11:08 p.m.
From: Pablo Neira Ayuso <pablo@netfilter.org>

The user-space program gets the full rule-set, including active
and inactive ones plus the generation mask to know what the current
state of the rule is.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 include/uapi/linux/netfilter/nf_tables.h |    1 +
 net/netfilter/nf_tables_api.c            |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 76b215f..66d5bde 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -101,6 +101,7 @@  enum nft_rule_attributes {
 	NFTA_RULE_EXPRESSIONS,
 	NFTA_RULE_FLAGS,
 	NFTA_RULE_COMPAT,
+	NFTA_RULE_GENMASK,
 	__NFTA_RULE_MAX
 };
 #define NFTA_RULE_MAX		(__NFTA_RULE_MAX - 1)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index beace28..fd2c8b6 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1287,6 +1287,8 @@  static int nf_tables_fill_rule_info(struct sk_buff *skb, u32 portid, u32 seq,
 		goto nla_put_failure;
 	if (nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle)))
 		goto nla_put_failure;
+	if (nla_put_be32(skb, NFTA_RULE_GENMASK, htonl(rule->genmask)))
+		return -1;
 
 	list = nla_nest_start(skb, NFTA_RULE_EXPRESSIONS);
 	if (list == NULL)
@@ -1401,8 +1403,6 @@  static int nf_tables_dump_rules(struct sk_buff *skb,
 		list_for_each_entry(table, &afi->tables, list) {
 			list_for_each_entry(chain, &table->chains, list) {
 				list_for_each_entry(rule, &chain->rules, list) {
-					if (!nft_rule_is_active(net, rule))
-						goto cont;
 					if (idx < s_idx)
 						goto cont;
 					if (idx > s_idx)