Skip to content

Commit 4a9e12e

Browse files
committed
netfilter: nft_set_pipapo: call nft_trans_gc_queue_sync() in catchall GC
pipapo needs to enqueue GC transactions for catchall elements through nft_trans_gc_queue_sync(). Add nft_trans_gc_catchall_sync() and nft_trans_gc_catchall_async() to handle GC transaction queueing accordingly. Fixes: 5f68718 ("netfilter: nf_tables: GC transaction API to avoid race with control plane") Fixes: f6c383b ("netfilter: nf_tables: adapt set backend to use GC transaction API") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 96b3330 commit 4a9e12e

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,9 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans);
17001700

17011701
void nft_trans_gc_elem_add(struct nft_trans_gc *gc, void *priv);
17021702

1703-
struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
1704-
unsigned int gc_seq);
1703+
struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc,
1704+
unsigned int gc_seq);
1705+
struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc);
17051706

17061707
void nft_setelem_data_deactivate(const struct net *net,
17071708
const struct nft_set *set,

net/netfilter/nf_tables_api.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9613,8 +9613,9 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans)
96139613
call_rcu(&trans->rcu, nft_trans_gc_trans_free);
96149614
}
96159615

9616-
struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
9617-
unsigned int gc_seq)
9616+
static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
9617+
unsigned int gc_seq,
9618+
bool sync)
96189619
{
96199620
struct nft_set_elem_catchall *catchall;
96209621
const struct nft_set *set = gc->set;
@@ -9630,7 +9631,11 @@ struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
96309631

96319632
nft_set_elem_dead(ext);
96329633
dead_elem:
9633-
gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC);
9634+
if (sync)
9635+
gc = nft_trans_gc_queue_sync(gc, GFP_ATOMIC);
9636+
else
9637+
gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC);
9638+
96349639
if (!gc)
96359640
return NULL;
96369641

@@ -9640,6 +9645,17 @@ struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
96409645
return gc;
96419646
}
96429647

9648+
struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc,
9649+
unsigned int gc_seq)
9650+
{
9651+
return nft_trans_gc_catchall(gc, gc_seq, false);
9652+
}
9653+
9654+
struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc)
9655+
{
9656+
return nft_trans_gc_catchall(gc, 0, true);
9657+
}
9658+
96439659
static void nf_tables_module_autoload_cleanup(struct net *net)
96449660
{
96459661
struct nftables_pernet *nft_net = nft_pernet(net);

net/netfilter/nft_set_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static void nft_rhash_gc(struct work_struct *work)
372372
nft_trans_gc_elem_add(gc, he);
373373
}
374374

375-
gc = nft_trans_gc_catchall(gc, gc_seq);
375+
gc = nft_trans_gc_catchall_async(gc, gc_seq);
376376

377377
try_later:
378378
/* catchall list iteration requires rcu read side lock. */

net/netfilter/nft_set_pipapo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ static void pipapo_gc(const struct nft_set *_set, struct nft_pipapo_match *m)
16101610
}
16111611
}
16121612

1613-
gc = nft_trans_gc_catchall(gc, 0);
1613+
gc = nft_trans_gc_catchall_sync(gc);
16141614
if (gc) {
16151615
nft_trans_gc_queue_sync_done(gc);
16161616
priv->last_gc = jiffies;

net/netfilter/nft_set_rbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static void nft_rbtree_gc(struct work_struct *work)
669669
nft_trans_gc_elem_add(gc, rbe);
670670
}
671671

672-
gc = nft_trans_gc_catchall(gc, gc_seq);
672+
gc = nft_trans_gc_catchall_async(gc, gc_seq);
673673

674674
try_later:
675675
read_unlock_bh(&priv->lock);

0 commit comments

Comments
 (0)