Article View: linux.kernel.netdev
Article #20224Re: [PATCH nf-next v11 2/3] netfilter: flowtable: tear down direct xmit flows when the fdb entry moves
From: Pablo Neira Ayuso
Date: Sat, 21 Nov 2026 21:10
Date: Sat, 21 Nov 2026 21:10
101 lines
13143 bytes
13143 bytes
On Sat, Nov 21, 2026 at 09:55:34PM +0100, Julius Bairaktaris wrote:
> From: Pablo Neira Ayuso <pablo@netfilter.org>
>
> A direct xmit flow that reaches a bridge port keeps sending to that port
> when the host moves to another port of the bridge, and packets from the
> other side keep the flow from timing out.
>
> The gc now checks the fdb entry after nf_flow_dst_check_gc(), through
> nf_br_utils_hook, and tears the flow down when the entry points to
> another port. An entry that aged out does not tear it down, because
> offloaded packets do not refresh it.
>
> One possibility to address this issue is to subscribe to
> SWITCHDEV_FDB_DEL_TO_DEVICE event notifications, however, this requires
> iterating over the whole flowtable whenever a fdb entry is removed.
>
> The bridge port is found from out.ifidx through the vlan devices that
> the forward path has below the port. The flow keeps the vid the forward
> path looked the fdb entry up in: a vlan that leaves the port untagged
> is in neither encap stack. struct flow_offload grows from 296 to 312
> bytes on x86_64; its slab cache is cacheline aligned, so an object takes
> 320 bytes either way.
>
> The flow is also torn down when the port no longer forwards in that
> vid, where the bridge would no longer deliver either: the port left the
> forwarding state, the vlan left the port, or vlan filtering was turned
> on or off. With two bridges on the path, at most two fit in a forward
> path, the gc goes up from the inner bridge through the vlan devices
> between them to the port of the outer one and checks its entry as well.
>
> Neigh xmit flows need no fdb check: a forward path that crosses a bridge
> always makes the flow direct xmit, and a failed walk is not offloaded.
>
> Reported-by: Eric Woudstra <ericwouds@gmail.com>
> Link: https://lore.kernel.org/netfilter-devel/20250925182623.114045-1-ericwouds@gmail.com/
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> [julius@bairaktaris.de: find the bridge port below the vlan devices of the
> path, keep the vid of the fdb lookup, keep a flow whose entry aged out,
> check that the port forwards the vid, check both bridges of a stacked
> path, follow struct net_bridge_dst, build br_nf_utils.o only with the
> flowtable]
> Link: https://lore.kernel.org/netfilter-devel/20261014210256.1573072-1-pablo@netfilter.org/
> Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
> ---
> v11: rebased onto Pablo's xmit series: the gc checks the fdb entry
> after his nf_flow_dst_check_gc(), which replaces nf_flow_dst_check()
> there, and his patch now sets out.h_dest for every xmit type
> v10: https://lore.kernel.org/netfilter-devel/20261115005555.645727-3-julius@bairaktaris.de/
>
> include/linux/netfilter.h | 7 +++
> include/net/netfilter/nf_flow_table.h | 22 ++++++++-
> net/bridge/Makefile | 2 +
> net/bridge/br.c | 2 +
> net/bridge/br_nf_utils.c | 35 ++++++++++++++
> net/bridge/br_private.h | 13 +++++
> net/netfilter/core.c | 3 ++
> net/netfilter/nf_flow_table_core.c | 68 ++++++++++++++++++++++++++-
> net/netfilter/nf_flow_table_path.c | 29 +++++++++++-
> 9 files changed, 176 insertions(+), 5 deletions(-)
> create mode 100644 net/bridge/br_nf_utils.c
>
> diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
> index e99afc1414cd..be85d8f68b45 100644
> --- a/include/linux/netfilter.h
> +++ b/include/linux/netfilter.h
> @@ -67,6 +67,13 @@ static inline void nf_inet_addr_mask(const union nf_inet_addr *a1,
> #endif
> }
>
> +struct nf_br_utils {
> + bool (*fdb_valid_dst)(const struct net_device *dev,
> + const unsigned char *addr, u16 vid);
> +};
> +
> +extern const struct nf_br_utils __rcu *nf_br_utils_hook;
> +
> int netfilter_init(void);
>
> struct sk_buff;
> diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h
> index 143bcfce3678..206296483fe1 100644
> --- a/include/net/netfilter/nf_flow_table.h
> +++ b/include/net/netfilter/nf_flow_table.h
> @@ -121,6 +121,18 @@ struct flow_offload_tunnel {
> u8 encap_proto;
> };
>
> +/* The outer of two bridges on the path: its vid, and how to reach its port
> + * from the inner bridge.
> + */
> +struct flow_offload_br_outer {
> + u16 vid;
> + u8 present:1,
> + link_vlans:2,
> + link_untag:1,
> + link_8021ad:1,
> + inner_tag:1;
> +};
What scenario are you trying to support with this?
Technical Details
Message-ID:
<awIItwlvNhrdOdjn@chamomile>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368452-linux-kernel-netdev=dewy.ruReferences:
<20261121205535.1888592-1-julius@bairaktaris.de> <20261121205535.1888592-3-julius@bairaktaris.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368452-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH nf-next v11 2/3] netfilter: flowtable: tear down direct xmit flows when the fdb entry moves Date: Sat, 21 Nov 2026 22:10:15 +0100 Organization: Usenet Network Message-ID: <awIItwlvNhrdOdjn@chamomile> References: <20261121205535.1888592-1-julius@bairaktaris.de> <20261121205535.1888592-3-julius@bairaktaris.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Injection-Info: usenet.network; logging-data="3494880"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Te3dGV7qHKSm74yjp0Eis0LKmAQ= sha256:UvWiV3S8/JXZxB0Qz6TsaCH6fw6N/0l1C5pY8oANBfg= sha1:mZo83unrXWBwlU3bMeFaYxALq44= sha256:DElu9VTcuvHi+u+sbXeH6TewbHWcceArEEg1CQDgzkw= Content-Disposition: inline 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 1F815115BEB; Sun, 22 Nov 2026 00:10:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.15 X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, 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, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=netfilter.org 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 yFEZvar2Q5Vi; Sun, 22 Nov 2026 00:10:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-368452-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 5D6CF115BDC; Sun, 22 Nov 2026 00:10:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id C3019607F77; Sat, 21 Nov 2026 21:10:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1795295423; b=5naKnZiUwG9yuS91CO384qcR8uPcmgnP/ivZldu5phMDHssfb2AWv/q8cie14Kf9bkTZ 8upibswxJwC7Z3zxpQVHXOTEl72E0+KcDRGDcOh+dSN2BzjrlWze41Xl144pIaLMS1mo3 rTU8aL7UKAx31sQYaOLbE7c2mWfoK4ijEhBtKvPZjwWp3gmyqNocSZDvtTq+I+SDRNUZE EkMpUnWiqF1v1JCtpFdD33syssy4zLC0yGyKiemYTA/Zk3SoKHPges38v+zI5fIWG3mjm tpVp9xLSkEOsAcnGomj8MDk98uWpjhzReU0xbbMLNAd/drSqIYS4i9bfxBO9eHhw+6A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795295423; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date: From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=a2NKQrpvPoSFGsmTW495uzvdLwTr591GoJMHlrOmQEQ=; b=kRbpp+jUhnd33N+UNmCz/DmjOzLtD0VnR9Ls5LxuBOdSXiSngNm/9QZuamWwU1ajMk4b Dv0tzIrOpTYpE0Ja3ZxwcEyu57xmjrokFAAqHAy4jAZZwOjJnvdl8EAd5s4SIy8o6apKS u4ttrhjoO24X56RqbQY2gMJ39jijE4ihocZWhapA77/Hch/0odVXHji0ap9HX+j/5aVdn Byi2PTUmurTx7qy1iOqsS4yfYUHHUqoROoDQSNBz6sOwKIu3k0LJPwM2MuAtd4YNTORoX bxArxJj/cfQFgITPMfGoLO3hyO2NmTrm3AVkkTaAEFsh+/0Meb+MIYdRMwTIkGc5Vqw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=DY2yRP4Y; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=fail 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 D99E6606A33B; Sat, 21 Nov 2026 21:10:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=DY2yRP4Y X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795295423; b=axzKcI5yeUSlg5c3yhDEgUvOct0a5PtEMbQknNGGZKJnAwcZBtUPM1YqrbvYlVStPr39 mJmfeY+OVdDzVnU0YDG6r8gwJagKH5VyuCvyH+j6G9PFhh9qpJMdfPUDS2uJ+TlFQLPDu iopgJWYJeBmGAu/WoykybuzjHiwGr2kOyDwG4JAhhc6THoBvkThNgVGK2GKex3T2xd0xB FYTnGdnsWLb8sKnWtJ4edCL7+4t4U6Jjp0dL5Bd9yzBVBlgX9cs3vWJMn4strMvHK39jH glTGMQeEyV4fNJCs6kJC4TEcmsLQ4UVAEutrh43bWBsRUO+QV8XBgMkAWcy2O455yTQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795295423; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-Spam-Status:X-Spam-Checker-Version; bh=a2NKQrpvPoSFGsmTW495uzvdLwTr591GoJMHlrOmQEQ=; b=DFm1qpFWuLZbbUXyYNuopor1or8Ii9lIy0pZN/J7cFPTYt7tbFr69EL984+eHJ5wKmJT ecKsB0QKU6xVlRHIhYXQbKRVULG8bOhzYTSoPjvGZpa5bzZJsR15jYCZt0eAv478cDVEw R/6ZOzL78fJG0lPtWsvC+QhceypdW8LoxG4zdl2YUGpA8Md5HjY3KuDwzD0GT3O09uDAV AhZgqBuDo/qPZMfBfNkatUypt6Eey1whHpy5jmU2MWyPaJbEPzWsU8BpJFrWT9+gDWMfW IxKLWuPXLOTgToAq8wnbciER/EWbWrdpuf+kgr8zLNMjQR70pgnUg1pv5T2on1WzKRA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=DY2yRP4Y; arc=none smtp.remote-ip=217.70.190.124 X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id BBB0D606A320; Sat, 21 Nov 2026 21:10:21 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BBB0D606A320 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1795295417; bh=a2NKQrpvPoSFGsmTW495uzvdLwTr591GoJMHlrOmQEQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DY2yRP4YffYyDEplaRFW/pR+w5WYQMzSAnb7Fk36iVoR6lArAINIhH4yZGJHAb0dY GyqdqR/PUsnmw/U/RiLkqioEnxytnFN3p4BAJKxfG1o9m6nPczFRm7LWhFIqUg6x3B 1mAksXdhS4orAdS0EL0alcm8J07vtIwGf3OWUnLlbgks4fgPAdnLHquPZdTaTPA+gX 1PQ4FmfxJRMnspWQtYKL0k+XLyUx8zPlGai6pNszjHpeyAv+uhEzTEj7+jKQtmj003 4MebVVYykpa5sqbya9UPizyv/31eNY600yCp/P5vtvSvPuZ2T1u2Amngi0/Wr5c4z8 aITV1Y64PIJ+A== X-Received: from netfilter.org (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with UTF8SMTPSA id 7E49D6005A; Sat, 21 Nov 2026 22:10:17 +0100 (CET) X-Cc: netfilter-devel@vger.kernel.org, Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>, Nikolay Aleksandrov <razor@blackwall.org>, Ido Schimmel <idosch@nvidia.com>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>, Eric Woudstra <ericwouds@gmail.com>, netdev@vger.kernel.org, bridge@lists.linux.dev, coreteam@netfilter.org, linux-kselftest@vger.kernel.org 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 X-In-Reply-To: <20261121205535.1888592-3-julius@bairaktaris.de>