🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Pablo Neira Ayuso Sat, 21 Nov 2026 21:10
Re: [PATCH nf-next v11 2/3] netfilter: flowtable: tear down direct xmit flows when the fdb entry moves
#20224
Author: Pablo Neira Ayuso
Date: Sat, 21 Nov 2026 21:10
101 lines
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?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads