Netdev List
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Julius Bairaktaris <julius@bairaktaris.de>
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
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	[thread overview]
Message-ID: <awIItwlvNhrdOdjn@chamomile> (raw)
In-Reply-To: <20261121205535.1888592-3-julius@bairaktaris.de>

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?

  reply	other threads:[~2026-11-21 21:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 20:55 [PATCH nf-next v11 0/3] netfilter: flowtable: tear down bridged flows on layer 2 roaming Julius Bairaktaris
2026-11-21 20:55 ` [PATCH nf-next v11 1/3] net: bridge: fill a forward path only to a port that forwards Julius Bairaktaris
2026-11-21 20:55 ` [PATCH nf-next v11 2/3] netfilter: flowtable: tear down direct xmit flows when the fdb entry moves Julius Bairaktaris
2026-11-21 21:10   ` Pablo Neira Ayuso [this message]
2026-11-21 20:55 ` [PATCH nf-next v11 3/3] selftests: netfilter: nft_flowtable.sh: roam a host between two bridge ports Julius Bairaktaris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awIItwlvNhrdOdjn@chamomile \
    --to=pablo@netfilter.org \
    --cc=bridge@lists.linux.dev \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=ericwouds@gmail.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=julius@bairaktaris.de \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=phil@nwl.cc \
    --cc=razor@blackwall.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox