From: sashiko-bot@kernel.org
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v5 8/9] net: dsa: lan9645x: add mdb management
Date: Tue, 19 May 2026 12:27:26 +0000 [thread overview]
Message-ID: <20260519122726.D0831C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260518-dsa_lan9645x_switch_driver_base-v5-8-968fbf34ffa3@microchip.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Deleting a port from an L2 MDB entry can fail with -ENOSPC, leaving the port permanently active in the hardware multicast group.
- [High] IP multicast frames may be duplicated to the CPU port because the CPU port is specified in both the MAC inline portmask and the `MAC_CPU_COPY` flag.
--
commit 12dd40a6c7c29e212ec6866149d379306e63d403
Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
net: dsa: lan9645x: add mdb management
Add support for dsa mdb callbacks to handle L2 multicast and IP multicast,
using PGID indices for L2 and inline port masks for IP multicast.
> 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..0ba3e0974dc08
> --- /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)
> +{
> + struct lan9645x_pgid_entry *old_pgid;
> + unsigned char mac[ETH_ALEN];
> + 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(CPU_PORT));
Can IP multicast frames be duplicated to the CPU port when both the
destination mask and the explicit CPU extraction queue are configured?
When new_ports includes the CPU port, it appears to be both encoded into
the MAC address bytes via lan9645x_mdb_encode_mac() and explicitly passed
as the cpu_copy flag to lan9645x_mact_learn_cpu_copy().
Should the CPU_PORT bit be explicitly stripped from the portmask before
encoding it into the MAC address, similar to how it is stripped for L2
multicast PGIDs?
[ ... ]
> +static int __lan9645x_mdb_del(struct lan9645x *lan9645x, int chip_port,
> + const unsigned char addr[ETH_ALEN], u16 vid,
> + enum macaccess_entry_type type)
> +{
> + struct lan9645x_pgid_entry *new_pgid;
> + struct lan9645x_mdb_entry *mdb_entry;
> + u16 new_ports;
> + int err;
> +
> + mdb_entry = lan9645x_mdb_entry_lookup(lan9645x, addr, vid);
> + if (!mdb_entry)
> + return -ENOENT;
> +
> + if (!(mdb_entry->ports & BIT(chip_port)))
> + return 0;
> +
> + new_ports = mdb_entry->ports & ~BIT(chip_port);
> +
> + if (!new_ports) {
[ ... ]
> + lan9645x_mdb_entry_dealloc(lan9645x, mdb_entry);
> + return 0;
> + }
> +
> + /* Update PGID ptr for non-IP entries (L2 multicast) */
> + new_pgid = lan9645x_mdb_pgid_entry_get(lan9645x, new_ports, type);
> + if (IS_ERR(new_pgid))
> + /* Continue forwarding to old port group. */
> + return PTR_ERR(new_pgid);
Will an out-of-resources condition here cause the port to remain permanently
active in the hardware multicast group?
If lan9645x_mdb_pgid_entry_get() returns -ENOSPC because all hardware PGIDs
are in use, the deletion aborts and the hardware is not updated. Because the
bridge network stack ignores errors from port_mdb_del, the software state
would diverge from the hardware state.
Would it be possible to reuse and update the existing PGID in-place if its
reference count is exactly 1?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518-dsa_lan9645x_switch_driver_base-v5-0-968fbf34ffa3@microchip.com?part=8
next prev parent reply other threads:[~2026-05-19 12:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 12:24 [PATCH net-next v5 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-05-18 12:24 ` [PATCH net-next v5 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-19 12:27 ` sashiko-bot
2026-05-18 12:24 ` [PATCH net-next v5 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-05-19 12:27 ` sashiko-bot
2026-05-19 16:33 ` Conor Dooley
2026-05-18 12:24 ` [PATCH net-next v5 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-05-18 12:24 ` [PATCH net-next v5 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-19 12:27 ` sashiko-bot
2026-05-18 12:25 ` [PATCH net-next v5 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-05-19 12:27 ` sashiko-bot
2026-05-18 12:25 ` [PATCH net-next v5 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-05-18 12:25 ` [PATCH net-next v5 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-05-18 12:25 ` [PATCH net-next v5 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-05-19 12:27 ` sashiko-bot [this message]
2026-05-18 12:25 ` [PATCH net-next v5 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-05-19 12:27 ` sashiko-bot
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=20260519122726.D0831C2BCB3@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