All of lore.kernel.org
 help / color / mirror / Atom feed
* [nf_tables PATCH 1/2 v2] netfilter: nf_tables: store and dump sets policy
@ 2014-09-23 11:30 Arturo Borrero Gonzalez
  2014-09-23 11:30 ` [nft PATCH 2/2 v2] src: add set optimization options Arturo Borrero Gonzalez
  2014-09-29 10:18 ` [nf_tables PATCH 1/2 v2] netfilter: nf_tables: store and dump sets policy Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Arturo Borrero Gonzalez @ 2014-09-23 11:30 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo, kaber, Arturo Borrero Gonzalez

We want to know in which cases the user explicitly set the policy
options. In that case, we also want to dump back the info.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
v2: address comments by Patrick. Only dump policy if not the default.
    Also, set size info if != 0.

 include/net/netfilter/nf_tables.h |    2 ++
 net/netfilter/nf_tables_api.c     |    6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index c4d8619..9cfa155 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -241,6 +241,7 @@ void nft_unregister_set(struct nft_set_ops *ops);
  * 	@dtype: data type (verdict or numeric type defined by userspace)
  * 	@size: maximum set size
  * 	@nelems: number of elements
+ *	@policy: (enum nft_set_policies)
  * 	@ops: set ops
  * 	@flags: set flags
  * 	@klen: key length
@@ -255,6 +256,7 @@ struct nft_set {
 	u32				dtype;
 	u32				size;
 	u32				nelems;
+	u16				policy;
 	/* runtime data below here */
 	const struct nft_set_ops	*ops ____cacheline_aligned;
 	u16				flags;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index a476b99..0534c30 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2344,6 +2344,11 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
 			goto nla_put_failure;
 	}
 
+	if (set->policy != NFT_SET_POL_PERFORMANCE) {
+		if (nla_put_be32(skb, NFTA_SET_POLICY, htonl(set->policy)))
+			goto nla_put_failure;
+	}
+
 	desc = nla_nest_start(skb, NFTA_SET_DESC);
 	if (desc == NULL)
 		goto nla_put_failure;
@@ -2669,6 +2674,7 @@ static int nf_tables_newset(struct sock *nlsk, struct sk_buff *skb,
 	set->dlen  = desc.dlen;
 	set->flags = flags;
 	set->size  = desc.size;
+	set->policy	= policy;
 
 	err = ops->init(set, &desc, nla);
 	if (err < 0)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-29 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-23 11:30 [nf_tables PATCH 1/2 v2] netfilter: nf_tables: store and dump sets policy Arturo Borrero Gonzalez
2014-09-23 11:30 ` [nft PATCH 2/2 v2] src: add set optimization options Arturo Borrero Gonzalez
2014-09-29 10:18 ` [nf_tables PATCH 1/2 v2] netfilter: nf_tables: store and dump sets policy Pablo Neira Ayuso

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.