Netdev List
 help / color / mirror / Atom feed
* [RFC PATCH net] netfilter: flowtable: fix offloaded ct timeout never being extended
@ 2026-05-26  6:01 Adrian Bente
  0 siblings, 0 replies; only message in thread
From: Adrian Bente @ 2026-05-26  6:01 UTC (permalink / raw)
  To: pablo, kadlec, fw, netfilter-devel
  Cc: phil, davem, edumazet, kuba, pabeni, horms, nbd, sean.wang,
	lorenzo, andrew+netdev, matthias.bgg, angelogioacchino.delregno,
	daniel, coreteam, netdev, linux-kernel, linux-arm-kernel,
	linux-mediatek, Adrian Bente

OpenWrt has recently migrated many platforms to kernel 6.18. On the
MediaTek platform, which supports hardware network offloading, WiFi
connections accelerated via the WED path were observed to drop after
roughly 300 seconds.

After several debugging sessions, assisted by the Claude LLM, the
problem was narrowed down as follows:

nf_flow_table_extend_ct_timeout() extends ct->timeout for offloaded
flows using:

	cmpxchg(&ct->timeout, expires, new_timeout);

'expires' comes from nf_ct_expires(ct) and is a relative value, while
ct->timeout holds an absolute timestamp. The two are never equal, so
the cmpxchg always fails and the timeout is never extended.

This goes unnoticed for most flows, but a long-lived hardware (WED)
offloaded flow on MediaTek MT7986 eventually has ct->timeout decay to
zero, the conntrack entry is reaped and the connection breaks.

Compare against the current ct->timeout value instead.

This patch is sent as RFC: the diagnosis is verified on hardware and
the fix resolves the drop, but review of the chosen approach is
welcome.

Fixes: 03428ca5cee9 ("netfilter: conntrack: rework offload nf_conn timeout extension logic")
Signed-off-by: Adrian Bente <adibente@gmail.com>
---
 net/netfilter/nf_flow_table_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -541,8 +541,10 @@
 		 * after this -- is fine, datapath is authoritative.
 		 */
 		if (new_timeout) {
+			u32 old = READ_ONCE(ct->timeout);
+
 			new_timeout += nfct_time_stamp;
-			cmpxchg(&ct->timeout, expires, new_timeout);
+			cmpxchg(&ct->timeout, old, new_timeout);
 		}
 	}
 

-- 
2.46.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-26  6:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26  6:01 [RFC PATCH net] netfilter: flowtable: fix offloaded ct timeout never being extended Adrian Bente

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox