Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames
@ 2026-12-01 11:59 Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 1/7] net: dsa: add dsa_link_local_offload_fwd_mark() Oleksij Rempel
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

On networks of KSZ9893-based devices, we saw frames take unexpected
paths and suspected a loop. With STP off, the KSZ bridges could not
help to find it: unlike a software bridge, they did not relay BPDUs,
so other bridges could not detect a loop through them. With STP on, we
hit other problems, fixed in net-next by the series merged in
6e0542a18a75 ("Merge branch
'net-dsa-make-a-shorter-bridge-ageing-time-take-effect'").

A Linux bridge with STP off relays BPDUs between its ports (commit
a598f6aebea2 ("bridge: relay bridge multicast pkgs if !STP")), and so do
bridges on mv88e6xxx and b53 switches. On the KSZ9477 family and
LAN937x, the switch traps BPDUs to the CPU, and the tagger marks them as
forwarded in hardware, so the bridge never sends them to the other ports
of the switch.

This series leaves trapped link-local frames unmarked, with a new DSA
helper. As a side effect, group_fwd_mask now also works for most other
trapped groups. The other patches handle what follows from that. FDB and
MDB entries for these groups would bypass the trap, so the driver
refuses them. The bridge now sends such frames back through the CPU
port, so the CPU port no longer learns addresses. That makes an old FDB
bug easy to hit; without the series it is hard to hit, so its fix comes
with the series to net-next.

The ksz8.c switches keep their behaviour. On the KSZ88x3 and KSZ8463
the static MAC table has only 8 entries, and of the ksz8.c switches I
can test only a KSZ8873.

To reproduce on a KSZ9893, with link partners on lan1 and lan2:

  ip link add br0 type bridge    # STP off by default
  ip link set lan1 master br0 up; ip link set lan2 master br0 up
  ip link set br0 up
  # Send BPDUs (01:80:C2:00:00:00) into lan1. Without the series none
  # reach lan2; with it, all do.

Tested on a KSZ9893.

Changes in v2:
- Link to v1: https://lore.kernel.org/r/20261126-ksz-stp-link-local-v1-0-39aed15f6271@pengutronix.de

---
Oleksij Rempel (7):
      net: dsa: add dsa_link_local_offload_fwd_mark()
      net: dsa: tag_mxl862xx: use dsa_link_local_offload_fwd_mark()
      net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded
      net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
      net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
      net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups
      net: dsa: microchip: ksz9477: report the trapped link-local groups

 drivers/net/dsa/microchip/ksz9477.c      | 103 ++++++++++++++++++++++++++++---
 drivers/net/dsa/microchip/ksz_common.c   |   9 +++
 drivers/net/dsa/microchip/ksz_common.h   |  10 +++
 drivers/net/dsa/microchip/lan937x_main.c |  10 +--
 include/linux/dsa/ksz_common.h           |   5 ++
 net/dsa/tag.h                            |  25 ++++++++
 net/dsa/tag_ksz.c                        |  25 +++++++-
 net/dsa/tag_mxl862xx.c                   |   3 +-
 8 files changed, 169 insertions(+), 21 deletions(-)
---
base-commit: d7f7fac1c3220a430559c6d43904e27917ae1eb0
change-id: 20261125-ksz-stp-link-local-5c53396cc960

Best regards,
-- 
Oleksij Rempel <o.rempel@pengutronix.de>


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

* [PATCH net-next v2 1/7] net: dsa: add dsa_link_local_offload_fwd_mark()
  2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
@ 2026-12-01 11:59 ` Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 2/7] net: dsa: tag_mxl862xx: use dsa_link_local_offload_fwd_mark() Oleksij Rempel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

Add a helper that marks a received frame like
dsa_default_offload_fwd_mark(), except for link-local frames that the
switch traps to the CPU.

Some switches trap all link-local groups (01:80:C2:00:00:00 to :0F),
others only some of them. The tagger must not mark a trapped frame, so
that the bridge decides whether to forward it. tag_mxl862xx.c
open-codes this check for all groups; tag_ksz.c needs it for a set of
groups that depends on the switch.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- New in v2 (Andrew).
---
 net/dsa/tag.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/net/dsa/tag.h b/net/dsa/tag.h
index cf52283fe9df47685a2c8b605f42727691439830..d3a55438fc7a78b689f1a68c6dd9a7c22a3cbea4 100644
--- a/net/dsa/tag.h
+++ b/net/dsa/tag.h
@@ -241,6 +241,31 @@ static inline void dsa_default_offload_fwd_mark(struct sk_buff *skb)
 	skb->offload_fwd_mark = !!(dp->bridge);
 }
 
+/* All link-local groups, 01:80:C2:00:00:00 to :0F */
+#define DSA_LINK_LOCAL_ALL	GENMASK(15, 0)
+
+/**
+ * dsa_link_local_offload_fwd_mark - mark a frame unless the switch trapped it
+ * @skb: received frame
+ * @trapped: link-local groups that the switch traps to the CPU, bit N for
+ *	     01:80:C2:00:00:0N
+ *
+ * Like dsa_default_offload_fwd_mark(), but leave frames to the groups in
+ * @trapped unmarked. The switch did not forward them, so the bridge decides.
+ */
+static inline void dsa_link_local_offload_fwd_mark(struct sk_buff *skb,
+						   u16 trapped)
+{
+	const u8 *addr = eth_hdr(skb)->h_dest;
+
+	/* is_link_local_ether_addr() limits addr[5] to 0x00..0x0f */
+	if (unlikely(is_link_local_ether_addr(addr)) &&
+	    (trapped & BIT(addr[5])))
+		return;
+
+	dsa_default_offload_fwd_mark(skb);
+}
+
 /* Helper for removing DSA header tags from packets in the RX path.
  * Must not be called before skb_pull(len).
  *                                                                 skb->data

-- 
2.47.3


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

* [PATCH net-next v2 2/7] net: dsa: tag_mxl862xx: use dsa_link_local_offload_fwd_mark()
  2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 1/7] net: dsa: add dsa_link_local_offload_fwd_mark() Oleksij Rempel
@ 2026-12-01 11:59 ` Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 3/7] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

Use the common helper instead of the open-coded check. No change in
behaviour.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- New in v2 (Andrew).
---
 net/dsa/tag_mxl862xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/dsa/tag_mxl862xx.c b/net/dsa/tag_mxl862xx.c
index 87b80ddf094632fd2842be9ef63daa277fd5596c..163b160ef19d7448eaefa601b267b5f0dddf1fe9 100644
--- a/net/dsa/tag_mxl862xx.c
+++ b/net/dsa/tag_mxl862xx.c
@@ -89,8 +89,7 @@ static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb,
 		return NULL;
 	}
 
-	if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest)))
-		dsa_default_offload_fwd_mark(skb);
+	dsa_link_local_offload_fwd_mark(skb, DSA_LINK_LOCAL_ALL);
 
 	/* remove the MxL862xx special tag between the MAC addresses and the
 	 * current ethertype field.

-- 
2.47.3


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

* [PATCH net-next v2 3/7] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded
  2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 1/7] net: dsa: add dsa_link_local_offload_fwd_mark() Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 2/7] net: dsa: tag_mxl862xx: use dsa_link_local_offload_fwd_mark() Oleksij Rempel
@ 2026-12-01 11:59 ` Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 4/7] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

Do not mark a link-local frame as forwarded in hardware if the switch
trapped it to the CPU. The switch did not forward such a frame, so the
bridge has to decide whether to forward it.

Not all Microchip KSZ switch families trap the full set of link-local
groups. The KSZ9477 family traps all groups from 01:80:C2:00:00:00 to
:0F except :01. The KSZ8873 uses the same tag as the KSZ9893, but traps
only :00 and floods most other groups like normal multicast. These
flooded frames must stay marked, or the bridge would forward them a
second time.

The switch driver therefore gives the tagger a bitmap of the groups
that the switch traps. No driver fills the bitmap yet, so frame
handling does not change with this patch alone.

The tagger now reads its data for every KSZ tag, so the KSZ8795 tag
gets a connect callback that allocates it.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- Use dsa_link_local_offload_fwd_mark() (Andrew).
- Commit message: shorten it.
---
 include/linux/dsa/ksz_common.h |  5 +++++
 net/dsa/tag_ksz.c              | 25 +++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/include/linux/dsa/ksz_common.h b/include/linux/dsa/ksz_common.h
index 576a99ca698d13cc3debd41a310502b29fc85c63..cef71188a6c651dae37d4238b527c89a303f6b79 100644
--- a/include/linux/dsa/ksz_common.h
+++ b/include/linux/dsa/ksz_common.h
@@ -32,6 +32,11 @@ struct ksz_deferred_xmit_work {
 struct ksz_tagger_data {
 	void (*xmit_work_fn)(struct kthread_work *work);
 	void (*hwtstamp_set_state)(struct dsa_switch *ds, bool on);
+	/* Bit N: the switch traps frames to 01:80:C2:00:00:0N to the CPU.
+	 * A switch driver that traps link-local groups sets it in
+	 * .connect_tag_protocol, before the tagger receives any frame.
+	 */
+	u16 link_local_to_cpu;
 };
 
 struct ksz_skb_cb {
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index b0340a7be8c9a6dcd52a64117e10fe3e134026e6..413794e97e1594931ad0505b88299b47030d2172 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -48,11 +48,27 @@ static void ksz_disconnect(struct dsa_switch *ds)
 {
 	struct ksz_tagger_private *priv = ds->tagger_data;
 
-	kthread_destroy_worker(priv->xmit_worker);
+	/* Tags without deferred xmit have no worker */
+	if (priv->xmit_worker)
+		kthread_destroy_worker(priv->xmit_worker);
+
 	kfree(priv);
 	ds->tagger_data = NULL;
 }
 
+static int ksz8795_connect(struct dsa_switch *ds)
+{
+	struct ksz_tagger_private *priv;
+
+	priv = kzalloc_obj(*priv);
+	if (!priv)
+		return -ENOMEM;
+
+	ds->tagger_data = priv;
+
+	return 0;
+}
+
 static int ksz_connect(struct dsa_switch *ds)
 {
 	struct ksz_tagger_data *tagger_data;
@@ -85,6 +101,8 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
 				      struct net_device *dev,
 				      unsigned int port, unsigned int len)
 {
+	struct ksz_tagger_data *tagger_data;
+
 	skb->dev = dsa_conduit_find_user(dev, 0, port);
 	if (!skb->dev) {
 		kfree_skb(skb);
@@ -96,7 +114,8 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
 		return NULL;
 	}
 
-	dsa_default_offload_fwd_mark(skb);
+	tagger_data = ksz_tagger_data(dsa_user_to_port(skb->dev)->ds);
+	dsa_link_local_offload_fwd_mark(skb, tagger_data->link_local_to_cpu);
 
 	return skb;
 }
@@ -360,6 +379,8 @@ static const struct dsa_device_ops ksz8795_netdev_ops = {
 	.proto	= DSA_TAG_PROTO_KSZ8795,
 	.xmit	= ksz8795_xmit,
 	.rcv	= ksz8795_rcv,
+	.connect = ksz8795_connect,
+	.disconnect = ksz_disconnect,
 	.needed_tailroom = KSZ_INGRESS_TAG_LEN,
 };
 

-- 
2.47.3


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

* [PATCH net-next v2 4/7] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
  2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
                   ` (2 preceding siblings ...)
  2026-12-01 11:59 ` [PATCH net-next v2 3/7] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
@ 2026-12-01 11:59 ` Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 5/7] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

Do not keep the learned port when adding a static FDB entry.

The switch keeps one ALU entry per address and FID, for learned and for
static entries. If the switch has learned host H on lan1 and a static
FDB entry for H is added on lan2, the driver makes the learned entry
static and adds lan2 to it. After the FDB entry is deleted, the static
entry still points to lan1 and never ages out.

The next patch, "do not learn addresses on the CPU port", makes this
issue more likely to trigger: DSA then adds a static CPU-port entry for
each address that the bridge learns on a port outside the switch.

This part of the code has one more issue that this patch does not
address: bridge fdb replace of a static entry. When it moves the static
entry for H from lan1 to lan2, the bridge sends no delete for lan1, so
the switch entry keeps lan1. The driver cannot drop the old port on its
own: without FDB isolation, the same ALU entry can also hold the CPU
port for a host entry of H, and that port must stay.

An AI code review agent found the bug fixed here while reviewing the
next patch. Reproduced and tested on a KSZ9893 with H learned on lan1:

  bridge fdb replace <H> dev lan2 master static
  bridge fdb del <H> dev lan2 master static
  bridge fdb show    # without this patch: "<H> dev lan1 self static"

Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- No code changes. Commit message: say that bridge fdb replace is not
  covered, and why (sashiko).
---
 drivers/net/dsa/microchip/ksz9477.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 972703fe7454f2892b98dc507a1cba0a5c91dabd..98211d9835734c52f25dcbf7494df45166bcc8da 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -800,6 +800,13 @@ int ksz9477_fdb_add(struct dsa_switch *ds, int port,
 	/* read ALU entry */
 	ksz9477_read_table(dev, alu_table);
 
+	/* The ALU table holds learned and static entries. If the entry is
+	 * not static (learned, or none found), clear its port map, so that
+	 * the static entry lists only this port.
+	 */
+	if (!(alu_table[0] & ALU_V_STATIC_VALID))
+		alu_table[1] &= ~ALU_V_PORT_MAP;
+
 	/* update ALU entry */
 	alu_table[0] = ALU_V_STATIC_VALID;
 	alu_table[1] |= BIT(port);

-- 
2.47.3


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

* [PATCH net-next v2 5/7] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
  2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
                   ` (3 preceding siblings ...)
  2026-12-01 11:59 ` [PATCH net-next v2 4/7] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
@ 2026-12-01 11:59 ` Oleksij Rempel
  2026-12-04 12:00   ` netdev-bot+sashiko
  2026-12-01 11:59 ` [PATCH net-next v2 6/7] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 7/7] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
  6 siblings, 1 reply; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

Do not learn addresses on the CPU port of the KSZ9477 family and
LAN937x. Set ds->assisted_learning_on_cpu_port instead, so that DSA
adds the addresses that the bridge learns on ports outside the switch
as static entries on the CPU port.

The patch "report the trapped link-local groups" lets the bridge
forward some trapped frames in software, for example BPDUs while STP is
off. It sends them back through the CPU port with the original source
address, and a learning CPU port would record the sender there. Frames
from the other switch ports to that sender would then end at the CPU.
I saw this on a KSZ9893.

While a KSZ9477 offloads HSR, the CPU port learns as before, because
DSA adds no entries for HSR ports. HSR and a bridge use the same CPU
port, so it cannot learn for one and not for the other; they are no
longer offloaded at the same time. This combination was already
problematic before this patch: with a bridge on top of hsr0, the CPU
port could learn the ring nodes.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Q: Does a refused HSR join really fall back to software HSR?
A: Not after an earlier HSR offload on that port: ksz9477_hsr_leave()
   does not clear the HSR feature flags that ksz9477_hsr_join() sets, so
   the HSR core still treats forwarding as offloaded. This is older than
   this series, and I did not fix it here.

Q: Why not a static CPU-port entry for the HSR MAC address instead?
A: I cannot test HSR offload, and HSR is not related to this problem.
   That would be a separate change to the HSR offload code.

Changes in v2:
- Turn learning on the CPU port back on while HSR is offloaded
  (sashiko).
- Do not offload HSR and a bridge at the same time.
- Flush what the CPU port learned when HSR offload ends.
---
 drivers/net/dsa/microchip/ksz9477.c      | 49 ++++++++++++++++++++++++++------
 drivers/net/dsa/microchip/ksz_common.c   |  9 ++++++
 drivers/net/dsa/microchip/lan937x_main.c |  9 +-----
 3 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 98211d9835734c52f25dcbf7494df45166bcc8da..2b563e44945413b95941776146b05399cda11ab8 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1710,7 +1710,6 @@ static int ksz9477_setup(struct dsa_switch *ds)
 	struct ksz_device *dev = ds->priv;
 	u16 storm_mask, storm_rate;
 	struct dsa_port *dp;
-	struct ksz_port *p;
 	const u16 *regs;
 	int ret;
 
@@ -1792,13 +1791,7 @@ static int ksz9477_setup(struct dsa_switch *ds)
 	if (ret < 0)
 		return ret;
 
-	/* Start with learning disabled on standalone user ports, and enabled
-	 * on the CPU port. In lack of other finer mechanisms, learning on the
-	 * CPU port will avoid flooding bridge local addresses on the network
-	 * in some cases.
-	 */
-	p = &dev->ports[dev->cpu_port];
-	p->learning = true;
+	ds->assisted_learning_on_cpu_port = true;
 
 	if (dev->irq > 0) {
 		ret = ksz_girq_setup(dev);
@@ -1897,6 +1890,29 @@ static int ksz9477_tc_cbs_set_cinc(struct ksz_device *dev, int port, u32 val)
  */
 #define KSZ9477_SUPPORTED_HSR_FEATURES (NETIF_F_HW_HSR_DUP | NETIF_F_HW_HSR_FWD)
 
+/* The HSR ports are in no bridge, so DSA adds no static entry for the HSR
+ * MAC address on the CPU port. Let the CPU port learn it while HSR is
+ * offloaded, so that frames to that address are not flooded to the other
+ * ring port.
+ */
+static void ksz9477_hsr_cpu_learning(struct dsa_switch *ds, int port,
+				     bool learning)
+{
+	struct ksz_device *dev = ds->priv;
+	struct ksz_port *p;
+	int cpu_port;
+
+	cpu_port = dsa_upstream_port(ds, port);
+	p = &dev->ports[cpu_port];
+
+	p->learning = learning;
+	ksz_port_stp_state_set(ds, cpu_port, p->stp_state);
+
+	/* Drop what the CPU port learned while HSR was offloaded */
+	if (!learning)
+		ksz9477_flush_dyn_mac_table(ds, cpu_port);
+}
+
 static int ksz9477_hsr_join(struct dsa_switch *ds, int port,
 			    struct net_device *hsr,
 			    struct netlink_ext_ack *extack)
@@ -1937,6 +1953,17 @@ static int ksz9477_hsr_join(struct dsa_switch *ds, int port,
 		return -EOPNOTSUPP;
 	}
 
+	/* The CPU port learns while HSR is offloaded, so it would also learn
+	 * the senders of frames that an offloaded bridge forwards in software.
+	 */
+	dsa_switch_for_each_user_port(hsr_dp, ds) {
+		if (dsa_port_bridge_dev_get(hsr_dp)) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "HSR offload not supported while a bridge is offloaded - using software HSR");
+			return -EOPNOTSUPP;
+		}
+	}
+
 	/* Self MAC address filtering, to avoid frames traversing
 	 * the HSR ring more than once.
 	 */
@@ -1963,6 +1990,8 @@ static int ksz9477_hsr_join(struct dsa_switch *ds, int port,
 		data |= HSR_DUPLICATE_DISCARD;
 		data &= ~HSR_NODE_UNICAST;
 		ksz_write8(dev, REG_HSR_ALU_CTRL_0__1, data);
+
+		ksz9477_hsr_cpu_learning(ds, port, true);
 	}
 
 	/* Enable per port self-address filtering.
@@ -1998,8 +2027,10 @@ static int ksz9477_hsr_leave(struct dsa_switch *ds, int port,
 	ksz_port_cfg(dev, port, REG_PORT_LUE_CTRL, PORT_SRC_ADDR_FILTER, false);
 
 	dev->hsr_ports &= ~BIT(port);
-	if (!dev->hsr_ports)
+	if (!dev->hsr_ports) {
 		dev->hsr_dev = NULL;
+		ksz9477_hsr_cpu_learning(ds, port, false);
+	}
 
 	ksz_switch_macaddr_put(ds);
 
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 78af51c182b91d4903c002b1b3f65be9599d19e2..86959d5ac16eb21fb7e1d984f6e65afc2a8593f6 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -2798,6 +2798,15 @@ int ksz_port_bridge_join(struct dsa_switch *ds, int port,
 			 bool *tx_fwd_offload,
 			 struct netlink_ext_ack *extack)
 {
+	struct ksz_device *dev = ds->priv;
+
+	/* See ksz9477_hsr_join() */
+	if (dev->hsr_ports) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Bridge offload not supported while HSR is offloaded");
+		return -EOPNOTSUPP;
+	}
+
 	/* port_stp_state_set() will be called after to put the port in
 	 * appropriate state so there is no need to do anything.
 	 */
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index f0fb9498026120b3069b31d01bd0252be6f15403..6e95630f99008ea2c02fc4998a004a34d732b2dd 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -770,7 +770,6 @@ static int lan937x_setup(struct dsa_switch *ds)
 	struct ksz_device *dev = ds->priv;
 	u16 storm_mask, storm_rate;
 	struct dsa_port *dp;
-	struct ksz_port *p;
 	const u16 *regs;
 	int ret;
 
@@ -843,13 +842,7 @@ static int lan937x_setup(struct dsa_switch *ds)
 	if (ret < 0)
 		return ret;
 
-	/* Start with learning disabled on standalone user ports, and enabled
-	 * on the CPU port. In lack of other finer mechanisms, learning on the
-	 * CPU port will avoid flooding bridge local addresses on the network
-	 * in some cases.
-	 */
-	p = &dev->ports[dev->cpu_port];
-	p->learning = true;
+	ds->assisted_learning_on_cpu_port = true;
 
 	if (dev->irq > 0) {
 		ret = ksz_girq_setup(dev);

-- 
2.47.3


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

* [PATCH net-next v2 6/7] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups
  2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
                   ` (4 preceding siblings ...)
  2026-12-01 11:59 ` [PATCH net-next v2 5/7] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
@ 2026-12-01 11:59 ` Oleksij Rempel
  2026-12-01 11:59 ` [PATCH net-next v2 7/7] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

Refuse FDB and MDB entries for trapped link-local groups on user ports,
so that they cannot bypass the trap.

On a KSZ9893, an FDB or MDB entry for a trapped group takes precedence
over the reserved multicast table. With an MDB entry for
01:80:C2:00:00:0E on lan2, the switch forwarded these frames from lan1
to lan2, although group_fwd_mask did not allow it. With a host FDB
entry for 01:80:C2:00:00:00, a Blocking port no longer passed BPDUs to
the CPU.

On the CPU and DSA ports, accept such entries without writing them, as
the trap already sends these frames to the CPU. LAN937x uses the same
code.

Until the next patch, "report the trapped link-local groups", frames to
a group with a refused entry are not forwarded between switch ports.
So this patch has no Fixes tag and must not be backported without it.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- Update the bitmap group by group, so that it matches the table if a
  later group fails (sashiko).
- Commit message: name LAN937x (sashiko).
- Commit message: say why there is no Fixes tag (sashiko).
- Rename ksz9477_link_local_entry_err() to ..._entry_ret(). Its comment
  gives the trap as the reason to accept entries on the CPU and DSA
  ports.
---
 drivers/net/dsa/microchip/ksz9477.c    | 46 ++++++++++++++++++++++++++++++++++
 drivers/net/dsa/microchip/ksz_common.h |  2 ++
 2 files changed, 48 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 2b563e44945413b95941776146b05399cda11ab8..095830fb5273ed4164af7955a5485290bf1e9c6e 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -768,6 +768,19 @@ int ksz9477_port_vlan_del(struct dsa_switch *ds, int port,
 	return 0;
 }
 
+static bool ksz9477_link_local_is_trapped(struct ksz_device *dev,
+					  const unsigned char *addr)
+{
+	return is_link_local_ether_addr(addr) &&
+	       (dev->link_local_to_cpu & BIT(addr[5]));
+}
+
+/* The trap already sends these frames to the CPU */
+static int ksz9477_link_local_entry_ret(struct dsa_switch *ds, int port)
+{
+	return dsa_is_user_port(ds, port) ? -EOPNOTSUPP : 0;
+}
+
 int ksz9477_fdb_add(struct dsa_switch *ds, int port,
 		    const unsigned char *addr, u16 vid, struct dsa_db db)
 {
@@ -776,6 +789,9 @@ int ksz9477_fdb_add(struct dsa_switch *ds, int port,
 	u32 data;
 	int ret = 0;
 
+	if (ksz9477_link_local_is_trapped(dev, addr))
+		return ksz9477_link_local_entry_ret(ds, port);
+
 	mutex_lock(&dev->alu_mutex);
 
 	/* find any entry with mac & vid */
@@ -840,6 +856,10 @@ int ksz9477_fdb_del(struct dsa_switch *ds, int port,
 	u32 data;
 	int ret = 0;
 
+	/* never written, see ksz9477_link_local_entry_ret() */
+	if (ksz9477_link_local_is_trapped(dev, addr))
+		return 0;
+
 	mutex_lock(&dev->alu_mutex);
 
 	/* read any entry with mac & vid */
@@ -989,6 +1009,9 @@ int ksz9477_mdb_add(struct dsa_switch *ds, int port,
 	u32 mac_hi, mac_lo;
 	int err = 0;
 
+	if (ksz9477_link_local_is_trapped(dev, mdb->addr))
+		return ksz9477_link_local_entry_ret(ds, port);
+
 	shifts = dev->info->shifts;
 	masks = dev->info->masks;
 
@@ -1069,6 +1092,10 @@ int ksz9477_mdb_del(struct dsa_switch *ds, int port,
 	int index;
 	u32 data;
 
+	/* never written, see ksz9477_link_local_entry_ret() */
+	if (ksz9477_link_local_is_trapped(dev, mdb->addr))
+		return 0;
+
 	shifts = dev->info->shifts;
 	masks = dev->info->masks;
 
@@ -1554,6 +1581,16 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds)
 
 static u8 reserved_mcast_map[RESV_MCAST_CNT] = { 0, 1, 3, 16, 32, 33, 2, 17 };
 
+/* Link-local addresses (bit X: 01:80:C2:00:00:0X) of each entry of the
+ * reserved multicast table, indexed like reserved_mcast_map.
+ */
+static const u16 ksz9477_resv_mcast_link_local[RESV_MCAST_CNT] = {
+	[0] = BIT(0),			/* STP BPDUs */
+	[1] = BIT(1),			/* MAC control (e.g. PAUSE), dropped */
+	[2] = BIT(3),			/* 802.1X (EAPOL) */
+	[6] = BIT(2) | GENMASK(15, 4),	/* LACP, LLDP and others */
+};
+
 int ksz9477_enable_stp_addr(struct ksz_device *dev)
 {
 	u8 i, ports, update;
@@ -1563,6 +1600,7 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev)
 	int ret;
 
 	masks = dev->info->masks;
+	dev->link_local_to_cpu = 0;
 
 	/* Enable Reserved multicast table */
 	ksz_cfg(dev, REG_SW_LUE_CTRL_0, SW_RESV_MCAST_ENABLE, true);
@@ -1648,6 +1686,14 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev)
 			if (ret < 0)
 				return ret;
 		}
+
+		/* Record entry i only after it is written, so that the bitmap
+		 * matches the switch if a later write fails.
+		 */
+		if (update == BIT(dev->cpu_port)) {
+			dev->link_local_to_cpu |=
+				ksz9477_resv_mcast_link_local[i];
+		}
 	}
 
 	return 0;
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 8819670cbb053eeb73ea4a7685303d9849bd6efb..7b96d110b1f64f4226ee7a371da38cd7e5b3767a 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -243,6 +243,8 @@ struct ksz_device {
 	u16 mirror_rx;
 	u16 mirror_tx;
 	u16 port_mask;
+	/* link-local groups sent to the CPU only, bit X: 01:80:C2:00:00:0X */
+	u16 link_local_to_cpu;
 	struct mutex lock_irq;		/* IRQ Access */
 	struct ksz_irq girq;
 	struct ksz_ptp_data ptp_data;

-- 
2.47.3


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

* [PATCH net-next v2 7/7] net: dsa: microchip: ksz9477: report the trapped link-local groups
  2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
                   ` (5 preceding siblings ...)
  2026-12-01 11:59 ` [PATCH net-next v2 6/7] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
@ 2026-12-01 11:59 ` Oleksij Rempel
  2026-12-04 12:00   ` netdev-bot+sashiko
  6 siblings, 1 reply; 10+ messages in thread
From: Oleksij Rempel @ 2026-12-01 11:59 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Daniel Golle
  Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
	netdev, bridge, kernel, Oleksij Rempel

Tell the tagger which link-local groups the KSZ9477 family and LAN937x
trap to the CPU. The tagger then no longer marks these frames as
forwarded, and the bridge can forward them to the other ports of the
switch, as group_fwd_mask and the STP state allow. With STP off, the
bridge now also relays STP BPDUs (01:80:C2:00:00:00) between the switch
ports, as a software bridge does.

Tested on a KSZ9893: with the group_fwd_mask bit for 01:80:C2:00:00:0E
set, the bridge relayed 20 of 20 frames to that group from lan1 to lan2
with this change, and 0 of 20 without it.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- Commit message: say that the bridge relays BPDUs with STP off
  (sashiko).
- Drop the helper comment; the field comment covers it.
---
 drivers/net/dsa/microchip/ksz9477.c      | 1 +
 drivers/net/dsa/microchip/ksz_common.h   | 8 ++++++++
 drivers/net/dsa/microchip/lan937x_main.c | 1 +
 3 files changed, 10 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 095830fb5273ed4164af7955a5485290bf1e9c6e..17c55e4311eadcfb7974219c351aa7d88ea2819a 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -2127,6 +2127,7 @@ static int ksz9477_connect_tag_protocol(struct dsa_switch *ds,
 
 	tagger_data = ksz_tagger_data(ds);
 	tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+	ksz_tagger_set_link_local_to_cpu(ds);
 
 	return 0;
 }
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 7b96d110b1f64f4226ee7a371da38cd7e5b3767a..76f08e4dd9235912b9515b6431284745f68c4341 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -7,6 +7,7 @@
 #ifndef __KSZ_COMMON_H
 #define __KSZ_COMMON_H
 
+#include <linux/dsa/ksz_common.h>
 #include <linux/etherdevice.h>
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
@@ -836,6 +837,13 @@ static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port)
 		dev->chip_id == LAN9372_CHIP_ID) && port == KSZ_PORT_4;
 }
 
+static inline void ksz_tagger_set_link_local_to_cpu(struct dsa_switch *ds)
+{
+	struct ksz_device *dev = ds->priv;
+
+	ksz_tagger_data(ds)->link_local_to_cpu = dev->link_local_to_cpu;
+}
+
 static inline int ksz_get_sgmii_port(struct ksz_device *dev)
 {
 	return dev->info->sgmii_port - 1;
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index 6e95630f99008ea2c02fc4998a004a34d732b2dd..ddb495a0082a237199fc3c6aa35faea85bd4cb4a 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -916,6 +916,7 @@ static int lan937x_connect_tag_protocol(struct dsa_switch *ds,
 
 	tagger_data = ksz_tagger_data(ds);
 	tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+	ksz_tagger_set_link_local_to_cpu(ds);
 
 	return 0;
 }

-- 
2.47.3


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

* Re: [PATCH net-next v2 5/7] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
  2026-12-01 11:59 ` [PATCH net-next v2 5/7] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
@ 2026-12-04 12:00   ` netdev-bot+sashiko
  0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 12:00 UTC (permalink / raw)
  To: o.rempel
  Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
	kuba, pabeni, willemb, daniel, horms, f.fainelli, razor, idosch,
	netdev, bridge, kernel

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 3

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] This patch adds a new refusal path to ksz9477_hsr_join()
  (drivers/net/dsa/microchip/ksz9477.c:1959-1965).
- [Low] Concern: the KSZ8 family still turns on learning on the CPU port
  (drivers/net/dsa/microchip/ksz8.c:2581 and :2881).
- [Low] Concern: on KSZ9477 the patch makes HSR offload and bridge
  offload mutually exclusive.
- [Low] Concern: the new guards in ksz_port_bridge_join() and
  ksz9477_hsr_join() miss two cases.

--

net: dsa: microchip: ksz9477: do not learn addresses on the CPU port

This patch turns off learning on the CPU port of the KSZ9477 family and
LAN937x, and sets ds->assisted_learning_on_cpu_port instead. While HSR is
offloaded on a KSZ9477, the CPU port learns again. HSR offload and bridge
offload are now mutually exclusive in ksz9477_hsr_join() and
ksz_port_bridge_join().

> diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
> index 98211d9835734..2b563e4494541 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c

[ ... ]

> @@ -1937,6 +1953,17 @@ static int ksz9477_hsr_join(struct dsa_switch *ds, int port,
>  		return -EOPNOTSUPP;
>  	}
>  
> +	/* The CPU port learns while HSR is offloaded, so it would also learn
> +	 * the senders of frames that an offloaded bridge forwards in software.
> +	 */
> +	dsa_switch_for_each_user_port(hsr_dp, ds) {
> +		if (dsa_port_bridge_dev_get(hsr_dp)) {
> +			NL_SET_ERR_MSG_MOD(extack,
> +					   "HSR offload not supported while a bridge is offloaded - using software HSR");
> +			return -EOPNOTSUPP;
> +		}
> +	}

[Severity: Medium]
Does the "using software HSR" fallback work if these ports offloaded HSR
before?

When ksz9477_hsr_join() succeeds, it sets the offload feature bits on the
user netdev:

    user->features |= KSZ9477_SUPPORTED_HSR_FEATURES;

ksz9477_hsr_leave() never clears NETIF_F_HW_HSR_DUP or NETIF_F_HW_HSR_FWD.
Consider this sequence:

1. hsr0 is created on lan1/lan2 and offloaded.
2. hsr0 is deleted. The port map, the membership and PORT_SRC_ADDR_FILTER
   are cleared, but the feature bits stay set.
3. lan3/lan4 join an offloaded bridge. ksz_port_bridge_join() accepts
   this because dev->hsr_ports is 0.
4. hsr0 is created on lan1/lan2 again.

In step 4, hsr_dev_finalize() checks the slave features before the driver
join is called:

net/hsr/hsr_device.c:hsr_dev_finalize() {
    ...
	if ((slave[0]->features & NETIF_F_HW_HSR_FWD) &&
	    (slave[1]->features & NETIF_F_HW_HSR_FWD))
		hsr->fwd_offloaded = true;
    ...
}

Then ksz9477_hsr_join() returns -EOPNOTSUPP from the new check above, and
dsa_port_hsr_join() resets dp->hsr_dev to NULL.

Would ring forwarding then stop at this node? The hardware no longer
forwards between lan1 and lan2. hsr_drop_frame() still skips software
forwarding between the slaves, because NETIF_F_HW_HSR_FWD is set.

hsr_forward_do() also sends on only one slave, because NETIF_F_HW_HSR_DUP
is set. For that slave, dsa_xmit_port_mask() runs with dp->hsr_dev ==
NULL:

net/dsa/tag.h:dsa_xmit_port_mask() {
    ...
		struct net_device *hsr_dev = dp->hsr_dev;
		struct dsa_port *other_dp;

		dsa_hsr_foreach_port(other_dp, dp->ds, hsr_dev)
			mask |= BIT(other_dp->index);
    ...
}

Can this loop match every port whose hsr_dev is NULL, including the
bridged lan3/lan4? If so, HSR frames from this node would leak into the
bridge's L2 domain.

The notes below the commit message say the stale feature flags are an
older issue in ksz9477_hsr_leave(). This patch adds a new and common
trigger, though: any offloaded bridge on the switch. The new HSR/bridge
exclusion also relies on the software fallback working.

Could ksz9477_hsr_leave() clear KSZ9477_SUPPORTED_HSR_FEATURES as part of
this change?

> +
>  	/* Self MAC address filtering, to avoid frames traversing
>  	 * the HSR ring more than once.
>  	 */

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-ksz-stp-link-local-v2-0-5dd1201d67c6%40pengutronix.de

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

* Re: [PATCH net-next v2 7/7] net: dsa: microchip: ksz9477: report the trapped link-local groups
  2026-12-01 11:59 ` [PATCH net-next v2 7/7] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
@ 2026-12-04 12:00   ` netdev-bot+sashiko
  0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 12:00 UTC (permalink / raw)
  To: o.rempel
  Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
	kuba, pabeni, willemb, daniel, horms, f.fainelli, razor, idosch,
	netdev, bridge, kernel

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] This patch makes the tagger trust dev->link_local_to_cpu when it
  decides whether a link-local frame was trapped or flooded by the…

--

net: dsa: microchip: ksz9477: report the trapped link-local groups

This patch adds ksz_tagger_set_link_local_to_cpu(). It copies
dev->link_local_to_cpu into the KSZ tagger data from
ksz9477_connect_tag_protocol() and lan937x_connect_tag_protocol(). The
tagger then stops setting offload_fwd_mark on trapped link-local frames,
so the bridge can forward them to other switch ports.

> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> index 7b96d110b1f64..76f08e4dd9235 100644
> --- a/drivers/net/dsa/microchip/ksz_common.h
> +++ b/drivers/net/dsa/microchip/ksz_common.h

[ ... ]

> @@ -836,6 +837,13 @@ static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port)
>  		dev->chip_id == LAN9372_CHIP_ID) && port == KSZ_PORT_4;
>  }
>  
> +static inline void ksz_tagger_set_link_local_to_cpu(struct dsa_switch *ds)
> +{
> +	struct ksz_device *dev = ds->priv;
> +
> +	ksz_tagger_data(ds)->link_local_to_cpu = dev->link_local_to_cpu;
> +}

[Severity: Low]
Can dev->link_local_to_cpu say that groups are trapped to the CPU when
the switch is not trapping them?

ksz9477_enable_stp_addr() turns on the reserved multicast table through
ksz_cfg(). ksz_cfg() is a void wrapper that drops the return value of
regmap_update_bits():

drivers/net/dsa/microchip/ksz9477.c:ksz9477_enable_stp_addr() {
    ...
	dev->link_local_to_cpu = 0;

	/* Enable Reserved multicast table */
	ksz_cfg(dev, REG_SW_LUE_CTRL_0, SW_RESV_MCAST_ENABLE, true);
    ...
}

The loop that follows sets bits each time the per-entry ALU table writes
succeed:

		/* Record entry i only after it is written, so that the bitmap
		 * matches the switch if a later write fails.
		 */
		if (update == BIT(dev->cpu_port)) {
			dev->link_local_to_cpu |=
				ksz9477_resv_mcast_link_local[i];
		}

Suppose the SW_RESV_MCAST_ENABLE read-modify-write fails at setup and
the later table writes succeed. The switch then ignores the reserved
multicast table and floods those frames as ordinary multicast. The
bitmap still reports groups 00 and 02-0F as trapped to the CPU only. The
comment above holds for the per-entry writes, but not for the global
enable.

ksz9477_setup() and lan937x_setup() also ignore the return value of
ksz9477_enable_stp_addr(), so nothing higher up catches the failure.

With this patch, ksz_tagger_set_link_local_to_cpu() copies that bitmap
into the tagger. ksz_common_rcv()->dsa_link_local_offload_fwd_mark()
then leaves those frames without offload_fwd_mark.

Would the bridge then forward a second copy of frames the hardware has
already flooded? That would affect groups set in group_fwd_mask, and STP
BPDUs when STP is off.

Could the result of the SW_RESV_MCAST_ENABLE update be checked, or the
bit read back, with link_local_to_cpu left at 0 on failure?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-ksz-stp-link-local-v2-0-5dd1201d67c6%40pengutronix.de

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

end of thread, other threads:[~2026-12-04 12:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 11:59 [PATCH net-next v2 0/7] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
2026-12-01 11:59 ` [PATCH net-next v2 1/7] net: dsa: add dsa_link_local_offload_fwd_mark() Oleksij Rempel
2026-12-01 11:59 ` [PATCH net-next v2 2/7] net: dsa: tag_mxl862xx: use dsa_link_local_offload_fwd_mark() Oleksij Rempel
2026-12-01 11:59 ` [PATCH net-next v2 3/7] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
2026-12-01 11:59 ` [PATCH net-next v2 4/7] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
2026-12-01 11:59 ` [PATCH net-next v2 5/7] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
2026-12-04 12:00   ` netdev-bot+sashiko
2026-12-01 11:59 ` [PATCH net-next v2 6/7] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
2026-12-01 11:59 ` [PATCH net-next v2 7/7] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
2026-12-04 12:00   ` netdev-bot+sashiko

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