Skip to content

Commit 54e39cc

Browse files
committed
netfilter: nf_tables: remove catchall element in GC sync path
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit 93995bf Conflicts: net/netfilter/nf_tables_api.c Series lacks commit 0e1ea65 ("netfilter: nf_tables: shrink memory consumption of set elements"), so we need to pass set_elem container struct instead of "elem_priv". commit 93995bf Author: Pablo Neira Ayuso <[email protected]> Date: Mon Nov 6 10:53:09 2023 +0100 netfilter: nf_tables: remove catchall element in GC sync path The expired catchall element is not deactivated and removed from GC sync path. This path holds mutex so just call nft_setelem_data_deactivate() and nft_setelem_catchall_remove() before queueing the GC work. Fixes: 4a9e12e ("netfilter: nft_set_pipapo: call nft_trans_gc_queue_sync() in catchall GC") Reported-by: lonial con <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 71f4dce commit 54e39cc

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6198,6 +6198,12 @@ static int nft_setelem_deactivate(const struct net *net,
61986198
return ret;
61996199
}
62006200

6201+
static void nft_setelem_catchall_destroy(struct nft_set_elem_catchall *catchall)
6202+
{
6203+
list_del_rcu(&catchall->list);
6204+
kfree_rcu(catchall, rcu);
6205+
}
6206+
62016207
static void nft_setelem_catchall_remove(const struct net *net,
62026208
const struct nft_set *set,
62036209
const struct nft_set_elem *elem)
@@ -6206,8 +6212,7 @@ static void nft_setelem_catchall_remove(const struct net *net,
62066212

62076213
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
62086214
if (catchall->elem == elem->priv) {
6209-
list_del_rcu(&catchall->list);
6210-
kfree_rcu(catchall, rcu);
6215+
nft_setelem_catchall_destroy(catchall);
62116216
break;
62126217
}
62136218
}
@@ -9270,11 +9275,12 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
92709275
unsigned int gc_seq,
92719276
bool sync)
92729277
{
9273-
struct nft_set_elem_catchall *catchall;
9278+
struct nft_set_elem_catchall *catchall, *next;
92749279
const struct nft_set *set = gc->set;
9280+
struct nft_elem_priv *elem_priv;
92759281
struct nft_set_ext *ext;
92769282

9277-
list_for_each_entry_rcu(catchall, &set->catchall_list, list) {
9283+
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
92789284
ext = nft_set_elem_ext(set, catchall->elem);
92799285

92809286
if (!nft_set_elem_expired(ext))
@@ -9292,7 +9298,17 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
92929298
if (!gc)
92939299
return NULL;
92949300

9295-
nft_trans_gc_elem_add(gc, catchall->elem);
9301+
elem_priv = catchall->elem;
9302+
if (sync) {
9303+
struct nft_set_elem elem = {
9304+
.priv = elem_priv,
9305+
};
9306+
9307+
nft_setelem_data_deactivate(gc->net, gc->set, &elem);
9308+
nft_setelem_catchall_destroy(catchall);
9309+
}
9310+
9311+
nft_trans_gc_elem_add(gc, elem_priv);
92969312
}
92979313

92989314
return gc;

0 commit comments

Comments
 (0)