From: sashiko-bot@kernel.org
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v11 8/9] net: dsa: lan9645x: add mdb management
Date: Thu, 06 Aug 2026 14:38:41 +0000 [thread overview]
Message-ID: <20260806143842.3AC321F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260805-dsa_lan9645x_switch_driver_base-v11-8-007ebc983a0a@microchip.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Duplicate CPU packet delivery on IP multicast MDB matches
- [Low] Inverted teardown sequence between MAC and MDB initialization
--
--- Patch [8]: [PATCH net-next v11 8/9] net: dsa: lan9645x: add mdb management ---
commit c8677da78fd630673d16e31ac732c8854e853dbe
Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
net: dsa: lan9645x: add mdb management
Add support for dsa mdb callbacks. L2 multicast and IP multicast is
handled differently. IP multicast stores the port group mask inline in
the mac table. L2 multicast points to a PGID index, which encodes the
port group mask.
> diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> index af158d4461aee..fc604edb309b9 100644
> --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> @@ -70,6 +70,7 @@ static void lan9645x_teardown(struct dsa_switch *ds)
> destroy_workqueue(lan9645x->owq);
> lan9645x_npi_port_deinit(lan9645x, lan9645x->npi);
> lan9645x_mac_deinit(lan9645x);
> + lan9645x_mdb_deinit(lan9645x);
[Severity: Low]
In lan9645x_setup(), lan9645x_mac_init() is called before lan9645x_mdb_init().
However, lan9645x_teardown() and the err_mac path destroy these in the forward
order (lan9645x_mac_deinit() followed by lan9645x_mdb_deinit()).
Since lan9645x_mac_deinit() destroys mact_lock, could calling it before
lan9645x_mdb_deinit() cause a use-after-destroy if MDB cleanup ever needs to
take mact_lock?
[ ... ]
> diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_mdb.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_mdb.c
> new file mode 100644
> index 0000000000000..ea37bb660273c
> --- /dev/null
> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_mdb.c
[ ... ]
> +static int lan9645x_mdb_update_dest(struct lan9645x *lan9645x,
> + struct lan9645x_mdb_entry *mdb_entry,
> + enum macaccess_entry_type type,
> + struct lan9645x_pgid_entry *new_pgid,
> + u16 new_ports)
> +{
> + unsigned char mac[ETH_ALEN] __aligned(2);
> + struct lan9645x_pgid_entry *old_pgid;
> + int err, pgid_index;
> + bool cpu_copy;
> +
> + old_pgid = mdb_entry->pgid;
> + lan9645x_mdb_encode_mac(mac, mdb_entry->mac, new_ports, type);
> + cpu_copy = !!(new_ports & BIT(lan9645x->num_phys_ports));
[Severity: Medium]
For IP multicast entries, the port mask is stored inline in the high bytes of
the MAC address via lan9645x_mdb_encode_mac().
Because new_ports includes the CPU port bit, the hardware will forward the
packet to the CPU port according to the inline mask. The code also sets the
MAC_CPU_COPY bit via cpu_copy.
If the hardware acts on both the inline port mask and the MAC_CPU_COPY bit,
will this result in duplicate packets being delivered to the CPU?
Should the CPU port bit be stripped from the new_ports mask before encoding it
into the MAC address, similarly to how it is stripped from L2 multicast PGID
entries in lan9645x_mdb_pgid_entry_get()?
> + pgid_index = PGID_INDEX(new_pgid);
> +
> + /* For IP multicast, the hardware lookup uses the DMAC
> + * (01:00:5E:.. / 33:33:..) as the (mac, vid) key, not the encoded mac.
> + * Therefore, this CMD_LEARN will atomically rewrite the existing
> + * hardware entry. We intentionally do not do a forget before learn
> + * sequence, as that would not be atomic, and leave a forwarding gap.
> + */
> + err = lan9645x_mact_learn_cpu_copy(lan9645x, pgid_index, mac,
> + mdb_entry->vid, type, cpu_copy);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-dsa_lan9645x_switch_driver_base-v11-0-007ebc983a0a@microchip.com?part=8
next prev parent reply other threads:[~2026-08-06 14:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 14:34 [PATCH net-next v11 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-08-05 14:34 ` [PATCH net-next v11 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-08-06 14:38 ` sashiko-bot
2026-08-07 14:41 ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-08-06 14:38 ` sashiko-bot
2026-08-07 14:15 ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-08-05 14:34 ` [PATCH net-next v11 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-08-06 14:38 ` sashiko-bot
2026-08-07 14:07 ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-08-06 14:38 ` sashiko-bot
2026-08-07 13:44 ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-08-06 14:38 ` sashiko-bot
2026-08-07 13:40 ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-08-05 14:34 ` [PATCH net-next v11 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-08-06 14:38 ` sashiko-bot [this message]
2026-08-07 13:22 ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
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=20260806143842.3AC321F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jensemil.schulzostergaard@microchip.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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