🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10681

[PATCH nf] netfilter: flowtable: remove hw flows before unbinding the flow block

#10681
From: Arnau Valls
Date: Tue, 03 Nov 2026 22:22
62 lines
13269 bytes
Since commit 13210fc63f35 ("netfilter: nf_tables: imbalance in flowtable
binding"), deleting a flowtable unbinds the driver callbacks at commit
time, before nf_flow_table_free() queues FLOW_CLS_DESTROY for the
remaining flows. The destroy requests find an empty cb_list and the
flows stay in hardware.

Conntrack then times the entries out while the hardware keeps forwarding
them. Once one direction ages out of the hardware table, its packets hit
the stack without a conntrack entry and get rejected. This breaks
long-lived UDP flows such as WireGuard whenever the flowtable is
recreated, for example on every firewall reload in OpenWrt.

Remove the device's flows on FLOW_BLOCK_UNBIND while the driver is still
bound, as nf_flow_table_indr_cleanup() does for indirect blocks. The gc
skips flows with pending offload work, so run one more pass and flush.

Tested on MT7981 (mtk_eth_soc PPE) with v7.4-rc1 and 6.12.74. Found and
fixed with help from an AI assistant (Claude).

Fixes: 13210fc63f35 ("netfilter: nf_tables: imbalance in flowtable binding")
Cc: stable@vger.kernel.org
Link: https://github.com/openwrt/openwrt/issues/17915
Signed-off-by: Arnau Valls <vallsfustearnau@gmail.com>
---

Notes:
    Reproducer: hw-offloaded UDP flow through NAT, then delete and recreate
    the flowtable in one transaction (fw4 reload). Without the patch the
    conntrack entry gets a timeout and the PPE entries stay bound. With it
    the PPE entries are removed and the flow is offloaded again within a
    second, no packet loss over six reloads.
    
    Not tested: lockdep, other drivers, the indirect block path.

 net/netfilter/nf_flow_table_offload.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c
index 4365859220e6..68654d243bae 100644
--- a/net/netfilter/nf_flow_table_offload.c
+++ b/net/netfilter/nf_flow_table_offload.c
@@ -1279,6 +1279,15 @@ int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
 	if (!nf_flowtable_hw_offload(flowtable))
 		return nf_flow_offload_xdp_setup(flowtable, dev, cmd);
 
+	/* Flush this device's hw flows while the driver is still bound. The
+	 * second gc pass catches flows skipped due to pending offload work.
+	 */
+	if (cmd == FLOW_BLOCK_UNBIND) {
+		nf_flow_table_gc_cleanup(flowtable, dev);
+		nf_flow_table_gc_run(flowtable);
+		nf_flow_table_offload_flush(flowtable);
+	}
+
 	if (dev->netdev_ops->ndo_setup_tc)
 		err = nf_flow_table_offload_cmd(&bo, flowtable, dev, cmd,
 						&extack);

base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
-- 
2.54.0
Technical Details
Message-ID: <20261103222243.445644-1-vallsfustearnau@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356038-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356038-linux-kernel-netdev=dewy.ru
From: vallsfustearnau@gmail.com (Arnau Valls)
Newsgroups: linux.kernel.netdev
Subject: [PATCH nf] netfilter: flowtable: remove hw flows before unbinding the flow block
Date: Tue,  3 Nov 2026 23:22:43 +0100
Organization: Usenet Network
Message-ID: <20261103222243.445644-1-vallsfustearnau@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3275612"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pjyoetrf6QY19yI3r/y6wTVQEhU= sha256:blS3QAfQ/l5BT6B8hTsUu+DwMFNCeH0fYPQXhbPA5rY=
	sha1:sNk3bqbLtFhDqDyAf4fZjq2xPE8= sha256:48Y2IjLBj13eD5WVXTqaFxdMR+VYpQ/ImBRNZroiMKE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 5D95C112A59; Wed,  4 Nov 2026 01:25:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 05smEwmsTj-m;
	Wed,  4 Nov 2026 01:25:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356038-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id DAF8A112A48; Wed,  4 Nov 2026 01:25:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 907332B872; Tue,  3 Nov 2026 22:23:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793744600;
	b=VD/2lWKuAiRfkQEkF5lNVruEyzwXA3DFADjxhYS90Flrd4EipZx4p816u8rAO4S1V2j7
	 Q1GW6IjaTNFfz/qBMEDsLpUWmGeDss/m1muxCxuLhgxJ9R/GfJ9bWUG9ugt6tIVLmgtg0
	 DHuCzQOFaVS6SB/si2k+8lJwwZBAMgQiZJtx754EM0EJMTulB9bEIpRxhxUFz43MpR0nV
	 iHBdwBfrfP+fsxxfqBrqWnjUGZoWSs+VtVyMX2nUlr9XWSeRDIKq+XgA7skz7bG0yzs+c
	 uOLISjCCYVIWknXWrZhmlk39x3a9kpl6yLOKM/HzpPtL9U5w+/YrN4fw+uyfzU4LqgQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793744600;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=iGr4yuTjefH8ZNfeidLmCflxZz4RxW5d0w05fPgAcqY=;
	b=dgexiuCe8ILDBKKS9rpqoLmFImXOqdoBzsczBKi93EfY3RFd6Ag/OOVrWLO2ogvh3bJr
	 oHd/KhgUR7c0By0W27REnJeKC65fSk32wgPQbWFqe9x18dl9cG41MepVKOo1NX4hgO9OQ
	 JUxZg9k7vOcoujbWaqlS4Z78pALwW+M8pAqFtJrohWFKRVeRSnKKPuJQc4GYMHRP5baUw
	 c+hCYzYYjk97LTxdqCnh/8JaLV/eKjDc7uFzyUZ/OHg+7CI2grV60YghYk9RMJsAOLiV7
	 9Z0fye0JPSVY9PIDSojR5Cpwlg1nbKupYHliHHoxcGmdP1I/WqUCng1QQn1VcFKOxdw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=c1a4sCHR;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 760C4606D831;
	Tue,  3 Nov 2026 22:23:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=c1a4sCHR
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793744599;
	b=lZZPVX+YYd+hdyVRFIB73+ow5PdcyzTcurBfUDof9X3tXgtiI5eEeY+5/CD6zVh1sjok
	 +T7xYEHavuqvfmNnSC4JII2E9f7Iv8SDXST9800y4eneBhgfxy9Dycn6VVNLNNXKAVj0n
	 YuUtuhweyQsUwlfg/kCDv/65XGvTPbagbhaR+IDTvEYmXuzkjiv5Tl0gOGxPcNig0fAl6
	 z8FOB4F0Ye9zLmRwf+4aXsPfLULuTqn6XxZZ3dP6tKejuvtSF0Y1ftzOoU+cJUTX+9vWS
	 QdYySBIlVgZIJZ2PcG3vCA4SyCbx9GQDol8OVVz6Qje3DAtjoiB+FISLPqip/hB84tg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793744599;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=iGr4yuTjefH8ZNfeidLmCflxZz4RxW5d0w05fPgAcqY=;
	b=02OSL4Gv/KONPhNKR7Squ2aBDWFn1LSr7i7uiYw5u8o7B71pYwjwBL4+73rp/T2iEqJX
	 z/g5/+b+j12FKdFfzkADICvEgL52hhiT9MuI0TE+PwLKAEA2IR9JUptAVrI7ESNPLX3iL
	 fIaqukzz4/atQ3AEkGIo66hWSrrAb4NetMOjXVVVjVZnmU2oglAl/G0QSDvhleII0+Ap2
	 PZ2qwUKzXK7X/03R/e85dpwp5SU22ccRyYvmULFVVeHFxykcffbSAmUdlryBvzykRx49M
	 95y+PHSDSpS5yft3Lof1u6flI/EeSwIoNp2glH2rNQ87AnJzwzUiSJ48cQXV/Ez6jcA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=c1a4sCHR;
	arc=none smtp.remote-ip=209.85.221.49
X-Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BEF4606D82E
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 22:23:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3BEF4606D82E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-48df8fe8513so75003f8f.0
        for <netdev@vger.kernel.org>; Tue, 03 Nov 2026 14:23:19 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793744598; x=1794349398; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=iGr4yuTjefH8ZNfeidLmCflxZz4RxW5d0w05fPgAcqY=;
        b=c1a4sCHRs1R+HVGA0+smgfHw8U77MLHfiDhHaSSDZM0rMyYJM6NJ7y/aLc9PMYvMVE
         aEImCURBIakHt1zdqXNFUDlV84a+zq9LpoM/Ew4Ftv/eOqVx8RM3fsncbkztSwk0HToa
         qmHe5uB8FlQrv3tM9B0mYp9yro7N2iJaDYVtBUcGeFYvnatIZpoz4H7ofchRtbc1FeQ6
         HmUTIn4o6jUP2sEpSnVxWb4t8Bynx1S+XGYDDBPYxgJN8MIenxD88qEmzlw2EgKYjbrH
         J8ntbQ+3vS64o+r+cxZC3TgvBHdZ620m577ridfNOYiwXfFxvLYn0iqRsn6swLbP0Q0m
         RuyQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793744598; x=1794349398;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=iGr4yuTjefH8ZNfeidLmCflxZz4RxW5d0w05fPgAcqY=;
        b=MBRkaddDKIIlRxEueIlkNa1iOE8nkY40qArV5IXc7je0XQO+cW0NT52R4dbvQPgjz/
         nlpDmFfI6cIaQiGk400UDqqSFC5BkaeDdR8Mdluaik7uET1XgnQinvt7TDAvf8z6ZnV4
         NVfrPLiysP48tXfN6rMnqXYL8lTwPwS9LXHHoLnuGZoHmQsFeek3PAmjF5wQldYXuLxj
         yTVswvotN0cMdqBp7aaLIMWnOyAuSTQfdvFY1eW0ISz68KFIfPfuQtCjrodj3aDzOl1R
         J1AlPij00KIFRTmPZ1WFuZkGdCEszD2ecGLGmJrZ23RMJBaFehZ9gpUQ1Phq0/XIanlp
         c7Mg==
X-Forwarded-Encrypted: i=1; AKwUvBz1aMhChWLD4TOcRisE/0AuSUR7MmPsYzdkWizeZ+FxPmtUEokNOF8sNfJ6+ciltviYVuIW6LM=@vger.kernel.org
X-Gm-Message-State: APuU4Z8EqyCvZgWkIE5cKWUfg+eFq7h3ANeZLwUfPtYjzEK1uVIX7Mc9
	TJzjRcvekHjSGGVgcr120qTYw/qlDIQrEEUW37qpWjVnT7Q9HkLsVi0=
X-Gm-Gg: AYBFou3m5eHqfI9iEwX7HP3H6rNRhK1Duh1KU4HHV730Rhv2DfTbFEyMCX0r5Ks4ytT
	FYTz+gULcTFs5zPDgo+JFdzZLMPii7mjtZ5/NfbQfPvuQZ/X8YFjZcfVQn4W97ndTknhDM58/vL
	oKAne9LDujITgZLH6ZcGi0YJCJCKo0kw98WpcW+SASWa6aoexwbwXYxYOFww/L1v1zLy3yXrmgh
	ljSFrayvwP2qZRjMZrd2napSJNic2nOTw8bP4vZTgj2ph7SrDc8gR7sIjjOBxFCHLR9gVE6NF/2
	mU3A2STZ3KmDHPCCS12LgezPcBfwgWGncrFA5u+GT8Fwbxb0wy1UemkSBgmWkwRo/b2pCpkupva
	Pz7SzFxWb2zMuDuD8GdTgLVkTJn6svshwVvja7qLrgY6T/85zRLroYsUnc7bb8Fo247uUtDEzXl
	L6CUfgw3OeENHMf0AwktJiFYLH3IEIjbPlnxbYxLljhFMXYSfo055RHEHoc+suvvuSeEurKZuaP
	EOj/khzVoSxKw1Sqz3HLpSOnsCbS256sQP83v+wmcZJAInlR/Cxa3xlVrEkVs4ZfNZ5uRdt+q/b
	LvuWKD2KfLSBqdh8HfTIOBY3qwHOHWyusDDXhcy43YkmOrw+7ifxKEKm0g==
X-Received: by 2002:a05:6000:26c5:b0:48b:e50:714e with SMTP id ffacd0b85a97d-48e6e50d8a5mr30353676f8f.36.1793744597651;
        Tue, 03 Nov 2026 14:23:17 -0800 (PST)
X-Received: from ps42.lan.pis.avalls.dev ([2a0c:5a83:540e:7d02::ed7])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48fed551dc5sm279312f8f.34.2026.11.03.14.23.16
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Tue, 03 Nov 2026 14:23:17 -0800 (PST)
X-Cc: pablo@netfilter.org,
	fw@strlen.de,
	phil@nwl.cc,
	coreteam@netfilter.org,
	netdev@vger.kernel.org,
	Arnau Valls <vallsfustearnau@gmail.com>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.54.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list