[SRU][F:linux-bluefield][PATCH V1 06/10] netfilter: flowtable: avoid possible false sharing
Bodong Wang
bodong at nvidia.com
Mon Oct 31 20:33:26 UTC 2022
From: Pablo Neira Ayuso <pablo at netfilter.org>
BugLink: https://bugs.launchpad.net/bugs/1995004
The flowtable follows the same timeout approach as conntrack, use the
same idiom as in cc16921351d8 ("netfilter: conntrack: avoid same-timeout
update") but also include the fix provided by e37542ba111f ("netfilter:
conntrack: avoid possible false sharing").
Change-Id: Idf434868f57e1f5af08e04d4fe5989d85743266c
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
(Cherry-picked from upstream 32c3973d808301e7a980f80fee8818fdf7c82b09)
Signed-off-by: Bodong Wang <bodong at nvidia.com>
---
net/netfilter/nf_flow_table_core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index d60a206..f0dae0e 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -278,7 +278,11 @@ int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow)
void flow_offload_refresh(struct nf_flowtable *flow_table,
struct flow_offload *flow)
{
- flow->timeout = nf_flowtable_time_stamp + flow_offload_get_timeout(flow);
+ u32 timeout;
+
+ timeout = nf_flowtable_time_stamp + flow_offload_get_timeout(flow);
+ if (READ_ONCE(flow->timeout) != timeout)
+ WRITE_ONCE(flow->timeout, timeout);
if (likely(!nf_flowtable_hw_offload(flow_table)))
return;
--
1.8.3.1
More information about the kernel-team
mailing list