mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: willemb@google.com
To: Julius Bairaktaris <julius@bairaktaris.de>,
	Andrew Lunn <andrew@lunn.ch>,
	 Vladimir Oltean <olteanv@gmail.com>,
	netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Willem de Bruijn" <willemb@google.com>,
	"Simon Horman" <horms@kernel.org>,
	"Alvin Šipraga" <alvin.sipraga@analog.com>,
	"Linus Walleij" <linusw@kernel.org>,
	"Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Pawel Dembicki" <paweldembicki@gmail.com>,
	"Tobias Waldekranz" <tobias@waldekranz.com>,
	"Daniel Golle" <daniel@makrotopia.org>,
	"Russell King" <linux@armlinux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/6] net: dsa: tag_dsa: send a marked frame of an unbridged port from the CPU
Date: Sat, 05 Dec 2026 22:55:18 -0500	[thread overview]
Message-ID: <willemb.460768b100c@google.com> (raw)
In-Reply-To: <20261128165206.3248835-4-julius@bairaktaris.de>

Julius Bairaktaris wrote:
> dsa_xmit_ll() sends a frame with offload_fwd_mark as a FORWARD frame on
> behalf of the port's bridge, with the bridge number taken from
> dsa_port_bridge_num_get(). The port need not be in a bridge: a frame
> received on a bridged port keeps the mark through a tc mirred redirect
> or an nft netdev fwd to a standalone port of the same switch, and a
> frame that the bridge marked can still be queued for a port that has
> left the bridge. The bridge number is 0 then, and the frame goes out as
> FORWARD from device dst->last_switch, port 0, instead of FROM_CPU to the
> port. The function also reads dp->bridge twice, once for the number and
> once for the device.

> Read dp->bridge once, and send FORWARD only while the port is in a
> bridge; otherwise the frame goes FROM_CPU to the port, as a frame
> without the mark does.

> Found by an LLM review (Claude), and reproduced in QEMU with dsa_loop.

> Fixes: d82f8ab0d874 ("net: dsa: tag_dsa: offload the bridge forwarding  
> process")
> Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>

   net/dsa/tag_dsa.c:143 (dsa_xmit_ll):
   The new guard `if (skb->offload_fwd_mark && bridge)` only verifies that  
the
   egress port belongs to a bridge; it fails to check bridge->tx_fwd_offload  
(or
   bridge->num != 0). In drivers/net/dsa/mv88e6xxx/chip.c:4008-4010 and
   3071-3077, mv88e6xxx_setup() only sets ds->max_num_bridges and
   mv88e6xxx_port_bridge_join() only sets *tx_fwd_offload = true when
   mv88e6xxx_has_pvt(chip) is true. On all 7 non-PVT mv88e6xxx chips  
(MV88E6020,
   MV88E6071, MV88E6095, MV88E6131, MV88E6185, MV88E6220, MV88E6250), a  
bridged
   port has dp->bridge != NULL with bridge->num == 0 and  
bridge->tx_fwd_offload
   == false. Under the exact same tc mirred / nft netdev fwd redirect from  
any
   bridged ingress port (where dsa_default_offload_fwd_mark() sets
   skb->offload_fwd_mark = 1), dsa_xmit_ll() STILL takes the DSA_CMD_FORWARD
   branch and sets tag_dev = dst->last_switch + 0 (dst->last_switch),  
tag_port =
   0, impersonating physical switch dst->last_switch port 0. Additionally,  
during
   dsa_port_bridge_join() on PVT chips, dp->bridge is published before
   mv88e6xxx_map_virtual_bridge_to_pvt() sets dp->bridge->tx_fwd_offload =  
true.
   dsa_xmit_ll() must check bridge && READ_ONCE(bridge->tx_fwd_offload) (and
   bridge->num != 0, with WRITE_ONCE() in dsa_port_bridge_join()).

   net/dsa/tag_dsa.c:139-143 (dsa_xmit_ll):
   skb->offload_fwd_mark carries no bridge/hwdom identity and is overloaded
   between RX ("already hardware-forwarded in ingress hwdom") and TX ("bridge
   requests TX forwarding offload"). Neither tcf_mirred_to_dev()
   (net/sched/act_mirred.c:254-335) nor nf_do_netdev_egress()
   (net/netfilter/nf_dup_netdev.c:17-41) clears skb->offload_fwd_mark when
   redirecting/mirroring to egress. Consequently, redirecting an RX frame  
from a
   bridged port on br0 (or any other switchdev NIC) to a bridged port on br1
   causes dsa_xmit_ll() to transmit DSA_CMD_FORWARD on behalf of br1  
(flooding
   and learning SA on br1) instead of DSA_CMD_FROM_CPU to the target port.
   Clearing skb->offload_fwd_mark on egress redirect (while keeping tagger  
RCU
   and tx_fwd_offload checks for concurrent bridge leave) fixes the root  
cause
   rather than only standalone targets.

  reply	other threads:[~2026-12-06  3:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 16:51 [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 1/6] net: dsa: free struct dsa_bridge after an RCU grace period Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 2/6] net: dsa: tag_sja1105, tag_vsc73xx_8021q: read the bridge once in xmit Julius Bairaktaris
2026-12-06  3:54   ` willemb
2026-11-28 16:52 ` [PATCH net 3/6] net: dsa: tag_dsa: send a marked frame of an unbridged port from the CPU Julius Bairaktaris
2026-12-06  3:55   ` willemb [this message]
2026-11-28 16:52 ` [PATCH net 4/6] net: dsa: do not hand a switch a bridge number above its limit Julius Bairaktaris
2026-12-06  3:55   ` willemb
2026-11-28 16:52 ` [PATCH net 5/6] net: dsa: do not take a bridge number past the end of the bitmap Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 6/6] net: dsa: keep a bridge number while another tree uses it Julius Bairaktaris
2026-12-06  3:57   ` willemb
2026-12-06  3:54 ` [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches willemb
2026-12-06 10:06   ` 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=willemb.460768b100c@google.com \
    --to=willemb@google.com \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=horms@kernel.org \
    --cc=julius@bairaktaris.de \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=paweldembicki@gmail.com \
    --cc=tobias@waldekranz.com \
    /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

all inboxes | Powered by JetHome®