Message ID | 20250306153446.46712-2-pablo@netfilter.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 5cfe5612ca9590db69b9be29dc83041dbf001108 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,1/3] netfilter: nft_ct: Use __refcount_inc() for per-CPU nft_ct_pcpu_template. | expand |
Hello: This series was applied to netdev/net.git (main) by Pablo Neira Ayuso <pablo@netfilter.org>: On Thu, 6 Mar 2025 16:34:44 +0100 you wrote: > From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> > > nft_ct_pcpu_template is a per-CPU variable and relies on disabled BH for its > locking. The refcounter is read and if its value is set to one then the > refcounter is incremented and variable is used - otherwise it is already > in use and left untouched. > > [...] Here is the summary with links: - [net,1/3] netfilter: nft_ct: Use __refcount_inc() for per-CPU nft_ct_pcpu_template. https://git.kernel.org/netdev/net/c/5cfe5612ca95 - [net,2/3] netfilter: nf_conncount: garbage collection is not skipped when jiffies wrap around https://git.kernel.org/netdev/net/c/df08c94baafb - [net,3/3] netfilter: nf_tables: make destruction work queue pernet https://git.kernel.org/netdev/net/c/fb8286562ecf You are awesome, thank you!
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index 2e59aba681a1..d526e69a2a2b 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -230,6 +230,7 @@ static void nft_ct_set_zone_eval(const struct nft_expr *expr, enum ip_conntrack_info ctinfo; u16 value = nft_reg_load16(®s->data[priv->sreg]); struct nf_conn *ct; + int oldcnt; ct = nf_ct_get(skb, &ctinfo); if (ct) /* already tracked */ @@ -250,10 +251,11 @@ static void nft_ct_set_zone_eval(const struct nft_expr *expr, ct = this_cpu_read(nft_ct_pcpu_template); - if (likely(refcount_read(&ct->ct_general.use) == 1)) { - refcount_inc(&ct->ct_general.use); + __refcount_inc(&ct->ct_general.use, &oldcnt); + if (likely(oldcnt == 1)) { nf_ct_zone_add(ct, &zone); } else { + refcount_dec(&ct->ct_general.use); /* previous skb got queued to userspace, allocate temporary * one until percpu template can be reused. */