Netdev List
 help / color / mirror / Atom feed
* [PATCH nf-next v11 0/3] netfilter: flowtable: tear down bridged flows on layer 2 roaming
@ 2026-11-21 20:55 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
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Julius Bairaktaris @ 2026-11-21 20:55 UTC (permalink / raw)
  To: netfilter-devel
  Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter,
	Nikolay Aleksandrov, Ido Schimmel, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan,
	Eric Woudstra, netdev, bridge, coreteam, linux-kselftest

A flowtable flow that transmits straight to a bridge port keeps sending
to the old port when the host moves to another port, for example a Wi-Fi
station roaming between access points.

The series applies on top of Pablo's "netfilter: flowtable: unify direct
and neigh xmit path" series (nf, v6):
https://lore.kernel.org/netfilter-devel/20261120225227.3565643-1-pablo@netfilter.org/
His series is posted for nf; this series is for nf-next and applies once
nf, with his series, has been merged into nf-next.

Patch 1 is a bridge fix the series needs: br_fill_forward_path() fills a
path to a port that does not forward (STP blocking or disabled, an MST
vlan not forwarding), so the flowtable transmits where the bridge would
not. Patch 2 makes the gc tear a flow down when the fdb entry moves or
the port no longer forwards in its vid. It is Pablo's patch with my
changes on top: it keeps his authorship, his Signed-off-by from his
posting and a note of what I changed. Patch 3 adds selftest cases.

The gc finds the bridge port from out.ifidx through the vlan devices of
the path and the bridge from the port, and looks the entry up in the vid
the forward path used, which the tuple now keeps in out.bridge_vid. With
two bridges on the path it also checks the outer one. Neigh xmit flows
need no such check: a forward path through a bridge always makes the
flow direct xmit. struct flow_offload grows from 296 to 312 bytes on
x86_64; its slab cache is SLAB_HWCACHE_ALIGN, so an object takes 320
bytes either way. A gc pass over 2000 flows, 1021 of them offloaded to a
bridge port, took 368 to 393 us with the series and 261 to 276 us
without it (median of each of three runs), and no flow was torn down.

Tested on nf-next 994089a3fa38 with Pablo's series in an x86_64 guest:
nft_flowtable.sh passes three runs out of three with PROVE_LOCKING and
three out of three with KASAN and PROVE_LOCKING, including the twenty
roaming cases in both of its passes, with no lockdep or KASAN report.
Without this series every roaming case but "del" and "age" fails, the
two tunnel cases included. net/netfilter and net/bridge build without
warnings with W=1 (x86_64 allmodconfig), each patch on its own, and with
BRIDGE_VLAN_FILTERING off.

I used Claude (Anthropic) to help write these patches.

Changes in v11:
- rebased onto nf-next and Pablo's xmit series: the gc checks the fdb
  entry after his nf_flow_dst_check_gc()
- selftest: the host roams below an IPIP and an IP6IP6 tunnel on the
  router; Pablo's series offloads such a flow as direct xmit to the
  bridge port

Changes in v10:
- the tuple keeps the vid of the fdb lookup (out.bridge_vid) instead of
  the bridge_vlan bit and the port pvid: a bridge vlan that leaves the
  port untagged is popped from the encap stack (DEV_PATH_BR_VLAN_UNTAG)
  or never pushed (DEV_PATH_BR_VLAN_KEEP), so v9 looked in the pvid of
  the port, which is another vlan when the untagged one is not the pvid,
  and kept the stale flow (Sashiko). This answers Pablo's v7 question on
  bridge_vid: no bit can recover that vid
- the gc also tears the flow down when the port stops forwarding in its
  vid (STP blocking or a disabled port, a vlan removed from the port,
  vlan_filtering toggled); v9 kept sending to a disabled port and in a
  vlan removed from the port. The new patch 1 keeps the forward path
  from recreating such a flow
- with two stacked bridges the gc checks the outer one too; v9 checked
  only the bridge of the transmit port and missed a move on the outer
- selftest: vid 10 untagged on ports of pvid 1 through a vlan device on
  the bridge and through the bridge pvid; a move from behind the inner
  to a port of the outer bridge; the host's port disabled; the vlan
  leaving the port; vlan_filtering turned off before a roam
- selftest: the IPv4 roaming cases turn IPv6 off on the host, whose
  router solicitations crossed the bridge and refreshed the entry the
  "age" case waits to expire (2 of 8 runs failed)
- selftest: lines wrapped to 80 columns, namespace names initialised
  (NIPA checkpatch and shellcheck on v9)
- Cc coreteam and linux-kselftest (NIPA cc_maintainers on v9)

Changes in v9:
- reset port_vlans at each bridge in the forward path, so the gc checks
  the bridge the flow transmits on: with a vlan device of one bridge
  enslaved to another, v8 counted the vlans below both bridges, looked
  up the bridge port from the wrong device and read past encap[]
  (Sashiko)
- selftest: a bridge port that is a vlan device of another bridge
- selftest: the roaming cases give socat five times SOCAT_TIMEOUT, as
  roam_stop() ends it; on a loaded host a case took 109 s and the 60 s
  timeout ended the transfer before the check
- authorship: Pablo's patch is credited as such, with his sign-off from
  his posting and a note of my changes, instead of Co-developed-by; his
  paragraph on the switchdev notifier alternative is back in the commit
  message
- rebased onto current nf-next

Changes in v8:
- drop bridge_ifidx and bridge_vid (Pablo): the bridge port is found
  from out.ifidx through the vlan devices below the port, the vid comes
  from the encap stack (bridge_vlan bit) or is the pvid of an untagged
  port of a vlan_filtering bridge
- the fdb check sits in nf_flow_dst_valid() next to nf_flow_dst_check(),
  the hook is fdb_valid_dst() again, and the comments Pablo pointed out
  are gone

v10: https://lore.kernel.org/netfilter-devel/20261115005555.645727-1-julius@bairaktaris.de/
v9: https://lore.kernel.org/netfilter-devel/20261108155344.35845-1-julius@bairaktaris.de/
v8: https://lore.kernel.org/netfilter-devel/20261017235849.1066624-1-julius@bairaktaris.de/
v7: https://lore.kernel.org/netfilter-devel/20261014235628.197976-1-julius@bairaktaris.de/
v6: https://lore.kernel.org/netfilter-devel/20261004171605.3544792-1-julius@bairaktaris.de/
v5: https://lore.kernel.org/netfilter-devel/20260914072541.897040-1-julius@bairaktaris.de/
Pablo's patch: https://lore.kernel.org/netfilter-devel/20261014210256.1573072-1-pablo@netfilter.org/

Julius Bairaktaris (2):
  net: bridge: fill a forward path only to a port that forwards
  selftests: netfilter: nft_flowtable.sh: roam a host between two bridge
    ports

Pablo Neira Ayuso (1):
  netfilter: flowtable: tear down direct xmit flows when the fdb entry
    moves

 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_device.c                        |   2 +-
 net/bridge/br_forward.c                       |  19 +
 net/bridge/br_nf_utils.c                      |  35 ++
 net/bridge/br_private.h                       |  14 +
 net/netfilter/core.c                          |   3 +
 net/netfilter/nf_flow_table_core.c            |  68 ++-
 net/netfilter/nf_flow_table_path.c            |  29 +-
 .../selftests/net/netfilter/nft_flowtable.sh  | 390 ++++++++++++++++++
 12 files changed, 587 insertions(+), 6 deletions(-)
 create mode 100644 net/bridge/br_nf_utils.c


base-commit: 994089a3fa3882f27f4bed9fc5815ee7df502e88
prerequisite-patch-id: d7af24391d138e7c6afe5585de4a14c8bba23c67
prerequisite-patch-id: dfb16f54f47b0c18b09eeeeccba9725bd15a6c7d
prerequisite-patch-id: 9949846db34c9fa718ff1968445bcb618920f93b
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-21 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox