Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49 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== 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== 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 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 ; Tue, 3 Nov 2026 22:23:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3BEF4606D82E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-48df8fe8513so75003f8f.0 for ; Tue, 03 Nov 2026 14:23:19 -0800 (PST) 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) 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) From: Arnau Valls To: netfilter-devel@vger.kernel.org Cc: pablo@netfilter.org, fw@strlen.de, phil@nwl.cc, coreteam@netfilter.org, netdev@vger.kernel.org, Arnau Valls , stable@vger.kernel.org Subject: [PATCH nf] netfilter: flowtable: remove hw flows before unbinding the flow block Date: Tue, 3 Nov 2026 23:22:43 +0100 Message-ID: <20261103222243.445644-1-vallsfustearnau@gmail.com> X-Mailer: git-send-email 2.54.0 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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