aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2015-03-26 08:39:38 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2015-04-01 05:17:29 -0400
commitcfed7e1b1f8ed9b3d81ab12203cfb69c3ef24ac6 (patch)
treea16ae3f27a6b9a9b5e547a79dd2b86adbed02454 /net
parentc3e1b005ed1cc068fc9d454a6e745830d55d251d (diff)
netfilter: nf_tables: add set garbage collection helpers
Add helpers for GC batch destruction: since element destruction needs a RCU grace period for all set implementations, add some helper functions for asynchronous batch destruction. Elements are collected in a batch structure, which is asynchronously released using RCU once its full. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_tables_api.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 9e032dbc149c..138e47fddab7 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3482,6 +3482,31 @@ static int nf_tables_delsetelem(struct sock *nlsk, struct sk_buff *skb,
3482 return err; 3482 return err;
3483} 3483}
3484 3484
3485void nft_set_gc_batch_release(struct rcu_head *rcu)
3486{
3487 struct nft_set_gc_batch *gcb;
3488 unsigned int i;
3489
3490 gcb = container_of(rcu, struct nft_set_gc_batch, head.rcu);
3491 for (i = 0; i < gcb->head.cnt; i++)
3492 nft_set_elem_destroy(gcb->head.set, gcb->elems[i]);
3493 kfree(gcb);
3494}
3495EXPORT_SYMBOL_GPL(nft_set_gc_batch_release);
3496
3497struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set,
3498 gfp_t gfp)
3499{
3500 struct nft_set_gc_batch *gcb;
3501
3502 gcb = kzalloc(sizeof(*gcb), gfp);
3503 if (gcb == NULL)
3504 return gcb;
3505 gcb->head.set = set;
3506 return gcb;
3507}
3508EXPORT_SYMBOL_GPL(nft_set_gc_batch_alloc);
3509
3485static int nf_tables_fill_gen_info(struct sk_buff *skb, struct net *net, 3510static int nf_tables_fill_gen_info(struct sk_buff *skb, struct net *net,
3486 u32 portid, u32 seq) 3511 u32 portid, u32 seq)
3487{ 3512{