diff mbox series

[SRU,F:linux-bluefield,06/10] netfilter: flowtable: avoid possible false sharing

Message ID 1666906019-80328-7-git-send-email-bodong@nvidia.com
State New
Headers show
Series Increase stability with connection tracking offload | expand

Commit Message

Bodong Wang Oct. 27, 2022, 9:26 p.m. UTC
From: Pablo Neira Ayuso <pablo@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@netfilter.org>
(Cherry-picked from upstream 32c3973d808301e7a980f80fee8818fdf7c82b09)
Signed-off-by: Bodong Wang <bodong@nvidia.com>
---
 net/netfilter/nf_flow_table_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

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;