Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: namiltd@yahoo.com
Cc: linusw@kernel.org, andrew@lunn.ch, olteanv@gmail.com,
	kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, linux@armlinux.org.uk, luizluca@gmail.com,
	maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, alvin.sipraga@analog.com,
	gusfmora@gmail.com, kuncy7@gmail.com, fabianotassotti@gmail.com,
	gabonpivovich@gmail.com, contact@c127.dev
Subject: Re: [PATCH net-next v11 12/13] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
Date: Thu, 19 Nov 2026 22:36:34 +0000	[thread overview]
Message-ID: <179512779480.3136.6628132114649129693@kernel.org> (raw)
In-Reply-To: <f98ff821-bb91-4bb7-8d8a-0f018312291e@yahoo.com>

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

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

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).

- [High] On family D, standalone ports, ports of bridges left to
  software, and the offloaded VLAN-unaware bridge all share one LUT…
- [Medium] On family D, static MDB entries (and static FDB entries)
  installed for a VLAN-unaware bridge with VID 0 are deliberately…
- [Medium] rtl8365mb_setup() sets `ds->max_num_bridges = 1` on family D.

--

net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D

This commit teaches the rtl8365mb table and L2 code about the family D
(RTL8367S-VB) LUT. It adds 5-word unicast and multicast entry
(de)serializers that use the SVL key for VID 0, a lookup-before-delete in
l2_del_uc, and a LUT init step. On family D, port_set_efid() becomes a
no-op, fdb_isolation is not advertised and max_num_bridges is set to 1.

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_l2.c b/drivers/net/dsa/realtek/rtl8365mb_l2.c
> index cd5b333932bee..e98ba5c5f9193 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_l2.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_l2.c

[ ... ]

> @@ -240,6 +255,78 @@ void rtl8365mb_c_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc,

[ ... ]

> +void rtl8365mb_d_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc,
> +			       u16 *data)
> +{
> +	/* Same as for unicast: VID 0 means a VLAN-unaware bridge, use SVL. */
> +	bool ivl = mc->key.ivl && mc->key.vid;

[Severity: Medium]
With a VLAN-unaware bridge, MDB entries arrive here with VID 0. They are
written with the SVL key (IVL=0, FID 0), which standalone and
software-bridged ports also look up.

rtl8365mb_d_lut_init() also clears IPMC_HASH, so IP multicast is looked up
by DMAC too:

	ret = regmap_update_bits(priv->map, RTL8365MB_D_LUT_CFG_REG,
				 RTL8365MB_D_LUT_CFG_IPMC_HASH_MASK |
				 RTL8365MB_D_LUT_CFG_BCAM_DISABLE_MASK, 0);

Take a multicast frame that arrives on a standalone port such as WAN, with
a DMAC that matches a bridge MDB group. It would hit this static MC entry.
The member mask holds only bridge ports, plus the CPU port only if the
host itself joined.

After masking with the standalone port's isolation mask (CPU port only),
is the egress set empty, so the frame is dropped instead of reaching the
CPU?

A LAN host can reach this path with IGMP/MLD reports, since snooping is on
by default:

  rtl83xx_port_mdb_add()
    rtl8365mb_l2_add_mc()
      rtl8365mb_d_l2_mc_to_data()    /* vid 0 -> IVL=0, FID 0 */

Two examples:

- A LAN host joins the solicited-node group of the router's WAN IPv6
  address, so NS frames arriving on WAN are blackholed.
- In an igmpproxy/IPTV setup, the LAN client's join on br-lan blackholes
  the stream arriving on the standalone WAN port.

MC entries have no age field, and the bridge refreshes MDB entries on
every report. So the drop would last as long as the bridge MDB entry
exists.

The commit message describes the shared FID 0 problem only for learned
unicast:

  "... until the entry ages out or is replaced."

  "This needs a host on the local L2 segment and is bounded by the aging
  time."

The existing comment in rtl8365mb_l2_add_mc() says:

  However, traffic isolation is still maintained
  because the hardware applies the port isolation masks
  (pmasks) configured in bridge_join after the L2 lookup.

Do these cover frames from non-member standalone or software-bridged ports
being dropped? The same question applies to VID 0 static FDB entries built
by rtl8365mb_d_l2_uc_to_data(), which do not age either.

I could not confirm from the code alone that multicast lookups from a
standalone port hit the same SVL entry. This is inferred from the unicast
behaviour and the MDB flood test described in the commit message.

> +
> +	memset(data, 0, RTL8365MB_D_L2_ENTRY_SIZE * 2);

[ ... ]

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index 0cec3b601998f..c7f209b41cac9 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c

[ ... ]

> @@ -2673,6 +2685,10 @@ static int rtl8365mb_port_pre_bridge_flags(struct dsa_switch *ds, int port,
>  static int rtl8365mb_port_set_efid(struct realtek_priv *priv, int port,
>  				   u32 efid)
>  {
> +	/* Family D has no EFID; see RTL8365MB_D_LUT_CFG2_REG. */
> +	if (rtl8365mb_is_d(priv))
> +		return 0;
> +

[Severity: High]
With this no-op, and with ds->fdb_isolation not set on family D, three
groups of ports share one LUT keyspace (SVL, FID 0): standalone ports,
software-bridged ports and the offloaded VLAN-unaware bridge. Learning
stays enabled on the offloaded bridge ports.

dsa_switch_supports_uc_filtering() requires fdb_isolation:

net/dsa/user.c:dsa_switch_supports_uc_filtering() {
	return ds->ops->port_fdb_add && ds->ops->port_fdb_del &&
	       ds->fdb_isolation && !ds->vlan_filtering_is_global &&
	       !ds->needs_standalone_vlan_filtering;
}

So DSA never installs static CPU-port entries for the standalone ports'
own MACs.

Can a host on an offloaded bridge port send frames with its SA set to a
standalone port's MAC? A common case is the WAN MAC in the usual
standalone WAN plus VLAN-unaware br-lan layout. The switch would learn
that MAC in FID 0 on the attacker's port.

Unicast arriving on WAN for that MAC would then hit the entry, be masked
by WAN's isolation mask (CPU only), and be dropped. If the host keeps
sending the spoofed SA, the entry stays alive past the aging time. The
tester also saw this happen without an attacker, when the same MAC was
learned on the bridge side.

This seems to conflict with Documentation/networking/dsa/dsa.rst.
Standalone ports are expected to use a port private database. Ports under
a software bridge "must remain configured in the same way as for
standalone operation ... and send all received packets to the CPU port
only".

The commit message says:

  "Avoiding it needs a per-bridge FID, which this chip does not have
  without EFID, so it is a known limitation."

Is that accurate? Family D VLAN 4K entries have a FID field, written by
rtl8365mb_d_vlan_4k_write():

	data[1] |= FIELD_PREP(RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK,
			      vlan4k->fid);

Could the standalone and bridge domains be split by VLAN/FID instead?
Other options might be:

- installing static CPU-port entries for the standalone ports' MACs
- not offloading a VLAN-unaware bridge, or not enabling learning on it,
  while other user ports are standalone

[ ... ]

> @@ -3623,9 +3665,19 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
>  		goto out_teardown_irq;
>  
>  	ds->assisted_learning_on_cpu_port = true;
> -	ds->fdb_isolation = true;
> -	/* The EFID is 3 bits, but EFID 0 is reserved for standalone ports */
> -	ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	if (!rtl8365mb_is_d(priv)) {
> +		ds->fdb_isolation = true;
> +		/* The EFID is 3 bits, but EFID 0 is reserved for standalone */
> +		ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	} else {
> +		/* No EFID, so bridges cannot be told apart in the LUT: allow
> +		 * at most one offloaded bridge. Bridge numbers are allocated
> +		 * system-wide by DSA, so if another switch already holds
> +		 * bridge 1, the bridge here will fall back to software
> +		 * forwarding.
> +		 */
> +		ds->max_num_bridges = 1;

[Severity: Medium]
Does max_num_bridges = 1 limit this switch to one offloaded bridge?

dsa_bridge_num_get() returns a number found in any tree without comparing
it to max:

net/dsa/dsa.c:dsa_bridge_num_get() {
	unsigned int bridge_num = dsa_bridge_num_find(bridge_dev);
	...
	if (!bridge_num) {
		...
		bridge_num = find_next_zero_bit(&dsa_fwd_offloading_bridges,
						DSA_MAX_NUM_OFFLOADING_BRIDGES,
						1);
		if (bridge_num > max)
			return 0;
		...
	}

	return bridge_num;
}

dsa_port_bridge_create() then rejects only a zero number:

	bridge->num = dsa_bridge_num_get(br, ds->max_num_bridges);
	if (ds->max_num_bridges && !bridge->num) {

Consider a system with a second DSA tree, for example a family C switch
with max_num_bridges = 7. Suppose br0 and br1 were first created there and
got numbers 1 and 2. Could ports of the family D switch then join both
bridges, with both offloaded here?

The driver does not count offloaded bridges either.
rtl83xx_port_bridge_join() only passes bridge.num to port_set_efid(),
which is now a no-op on family D.

The two bridges would share the LUT keyspace, separated only by the
isolation masks. On family D, rtl8365mb_l2_del_uc() matches only MAC, VID
and port. Could an fdb_del for one bridge remove the other bridge's entry,
for example a host entry on the shared CPU port?

The comment above says the bridge falls back to software forwarding if
another switch already holds bridge 1. That only holds when a new number
has to be allocated, not when the same bridge already has a number from
another tree.

> +	}

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cf3fd237-2290-4002-8de0-ea4100ef0f85%40yahoo.com

  reply	other threads:[~2026-11-19 22:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cf3fd237-2290-4002-8de0-ea4100ef0f85.ref@yahoo.com>
2026-11-17  7:34 ` [PATCH net-next v11 00/13] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-17  7:35   ` [PATCH net-next v11 01/13] dt-bindings: net: dsa: realtek: add RTL8367S-VB Mieczyslaw Nalewaj
2026-11-17  7:36   ` [PATCH net-next v11 02/13] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-11-17  7:36   ` [PATCH net-next v11 03/13] net: dsa: realtek: rtl8365mb: refactor forcemode handling Mieczyslaw Nalewaj
2026-11-17  7:37   ` [PATCH net-next v11 04/13] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-11-17  7:38   ` [PATCH net-next v11 05/13] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-11-17  7:38   ` [PATCH net-next v11 06/13] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling Mieczyslaw Nalewaj
2026-11-17  7:39   ` [PATCH net-next v11 07/13] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D Mieczyslaw Nalewaj
2026-11-17  8:23     ` Linus Walleij
2026-11-18  1:48       ` Gustavo Foletto Mora
2026-11-18  7:59         ` Mieczyslaw Nalewaj
2026-11-19  1:47           ` Gustavo Foletto Mora
2026-11-19 22:36     ` netdev-bot+sashiko
2026-11-17  7:39   ` [PATCH net-next v11 08/13] net: dsa: realtek: rtl8365mb: refactor PVID handling Mieczyslaw Nalewaj
2026-11-17  8:34     ` Linus Walleij
2026-11-17  8:53       ` Mieczyslaw Nalewaj
2026-11-18  1:55     ` Gustavo Foletto Mora
2026-11-17  7:40   ` [PATCH net-next v11 09/13] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D Mieczyslaw Nalewaj
2026-11-18  2:00     ` Gustavo Foletto Mora
2026-11-19 22:36     ` netdev-bot+sashiko
2026-11-17  7:41   ` [PATCH net-next v11 10/13] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-11-19 22:36     ` netdev-bot+sashiko
2026-11-17  7:41   ` [PATCH net-next v11 11/13] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling Mieczyslaw Nalewaj
2026-11-17  7:42   ` [PATCH net-next v11 12/13] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D Mieczyslaw Nalewaj
2026-11-19 22:36     ` netdev-bot+sashiko [this message]
2026-11-17  7:43   ` [PATCH net-next v11 13/13] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-19 22:36     ` netdev-bot+sashiko

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=179512779480.3136.6628132114649129693@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=contact@c127.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fabianotassotti@gmail.com \
    --cc=gabonpivovich@gmail.com \
    --cc=gusfmora@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuncy7@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luizluca@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=namiltd@yahoo.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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