Re: [PATCH net v5 4/8] net: dsa: b53: reject conflicting mirror destinations
From: Florian Fainelli
Date: Mon Nov 16 2026 - 15:38:49 EST
On 11/16/26 11:02, netdev-bot+sashiko@xxxxxxxxxx wrote:
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] The commit message describes the b53_mirror_del() capture-port
change as a separate bug fix ("This also fixes b53_mirror_del() ... a…
--
net: dsa: b53: reject conflicting mirror destinations
This patch makes b53_mirror_add() read B53_MIR_CAP_CTL before it changes
any source mask. While mirroring is enabled, it rejects a rule for a
different capture port and returns an extack message. It also changes
b53_mirror_del() so that the whole CAP_PORT_MASK field is cleared along
with MIRROR_EN when the last source is removed.
Clear the capture-port field when the final source is removed so a later
rule can select a new destination. This also fixes b53_mirror_del(),
which tried to clear the destination with ~mirror->to_local_port. That
only cleared the bits set in the port number, so a stale capture port
could remain after the last source was removed.
[Severity: Low]
Is this paragraph accurate? A later rule doesn't seem to need
b53_mirror_del() to clear CAP_PORT_MASK in order to select a new
destination.
In drivers/net/dsa/b53/b53_common.c, the new conflict check in
b53_mirror_add() only applies while MIRROR_EN is set:
if ((cap_ctl & MIRROR_EN) &&
(cap_ctl & CAP_PORT_MASK) != mirror->to_local_port) {
The add path also always rewrites the field:
cap_ctl &= ~CAP_PORT_MASK;
cap_ctl |= mirror->to_local_port;
cap_ctl |= MIRROR_EN;
b53_mirror_del() clears MIRROR_EN in the same statement. Once that bit
is clear, leftover bits in CAP_PORT_MASK affect neither the hardware nor
the check.
Before this patch, the old reg &= ~mirror->to_local_port could leave a
stale value in only one case: after one rule had overwritten another
rule's destination. This patch now rejects that case. Even then,
MIRROR_EN was cleared at the same time, and the next add overwrote the
field.
A later patch in this series, "net: dsa: b53: harden mirror register
programming", describes the same change this way: "Clearing the inactive
capture-port field is cleanup."
Could the commit message call the b53_mirror_del() change a cleanup
instead of a separate fix?
Sashiko's point is correct. b53_mirror_del() clears MIRROR_EN in the same write, and the add path always rewrites CAP_PORT_MASK. A stale capture port therefore has no effect on the hardware or on the conflict check. I have reworded the paragraph accordingly.
pw-bot: cr
--
Florian