Skip to content

Commit bee501c

Browse files
committed
netfilter: nft_set_pipapo: call nft_trans_gc_queue_sync() in catchall GC
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit 4a9e12e commit 4a9e12e Author: Pablo Neira Ayuso <[email protected]> Date: Wed Sep 6 15:07:53 2023 +0200 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]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 29530d2 commit bee501c

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
@@ -1629,8 +1629,9 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans);
16291629

16301630
void nft_trans_gc_elem_add(struct nft_trans_gc *gc, void *priv);
16311631

1632-
struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
1633-
unsigned int gc_seq);
1632+
struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc,
1633+
unsigned int gc_seq);
1634+
struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc);
16341635

16351636
void nft_setelem_data_deactivate(const struct net *net,
16361637
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
@@ -9231,8 +9231,9 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans)
92319231
call_rcu(&trans->rcu, nft_trans_gc_trans_free);
92329232
}
92339233

9234-
struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
9235-
unsigned int gc_seq)
9234+
static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
9235+
unsigned int gc_seq,
9236+
bool sync)
92369237
{
92379238
struct nft_set_elem_catchall *catchall;
92389239
const struct nft_set *set = gc->set;
@@ -9248,7 +9249,11 @@ struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
92489249

92499250
nft_set_elem_dead(ext);
92509251
dead_elem:
9251-
gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC);
9252+
if (sync)
9253+
gc = nft_trans_gc_queue_sync(gc, GFP_ATOMIC);
9254+
else
9255+
gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC);
9256+
92529257
if (!gc)
92539258
return NULL;
92549259

@@ -9258,6 +9263,17 @@ struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
92589263
return gc;
92599264
}
92609265

9266+
struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc,
9267+
unsigned int gc_seq)
9268+
{
9269+
return nft_trans_gc_catchall(gc, gc_seq, false);
9270+
}
9271+
9272+
struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc)
9273+
{
9274+
return nft_trans_gc_catchall(gc, 0, true);
9275+
}
9276+
92619277
static void nf_tables_module_autoload_cleanup(struct net *net)
92629278
{
92639279
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
@@ -1611,7 +1611,7 @@ static void pipapo_gc(const struct nft_set *_set, struct nft_pipapo_match *m)
16111611
}
16121612
}
16131613

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

net/netfilter/nft_set_rbtree.c

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

673-
gc = nft_trans_gc_catchall(gc, gc_seq);
673+
gc = nft_trans_gc_catchall_async(gc, gc_seq);
674674

675675
try_later:
676676
write_seqcount_end(&priv->count);

0 commit comments

Comments
 (0)