Re: [PATCH net-next 3/4] eth: mpnic: sync unicast and multicast address lists

From: Daniel Zahka

Date: Wed Nov 18 2026 - 05:21:56 EST


On Wed Nov 18, 2026 at 4:12 AM EST, netdev-bot+sashiko wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · 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).
>
> - [Medium] The unicast and multicast lists are synced in the wrong order
> in __mpnic_set_rx_mode()…
>
> --
>
> eth: mpnic: sync unicast and multicast address lists
>
> This commit adds the secondary unicast and multicast addresses to the
> MACDA TCAM and advertises IFF_UNICAST_FLT. When either list outgrows the
> table, the driver falls back to promiscuous or all-multicast mode. A
> per-slot users count is kept so the same address can sit in both dev->uc
> and dev->mc.
>
>> diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>> index 43547a7d6e5c7..c01e276c4a74d 100644
>> --- a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>> +++ b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>
> [ ... ]
>
>> @@ -35,7 +53,14 @@ static void __mpnic_set_rx_mode(struct mpnic_dev *mpd,
>> mac_addr->state = MPNIC_TCAM_S_ADD;
>> }
>>
>> - if (!netdev_hw_addr_list_empty(mc))
>> + err = __hw_addr_sync_dev(uc, netdev, mpnic_addr_sync,
>> + mpnic_addr_unsync);
>> + if (err == -ENOSPC)
>> + uc_promisc = true;
>> +
>> + err = __hw_addr_sync_dev(mc, netdev, mpnic_addr_sync,
>> + mpnic_addr_unsync);
>> + if (err == -ENOSPC)
>> mc_promisc = true;
>
> [Severity: Medium]
> Can the device get stuck in unicast promiscuous mode here, even though a
> TCAM slot is free?
>
> The uc and mc lists share the same MACDA slots (between
> MPNIC_TCAM_MACDA_BROADCAST_IDX and MPNIC_TCAM_MACDA_HOST_ADDR_IDX). The
> whole uc pass, both its flush and its add phase, runs before the mc pass
> flushes stale multicast entries.
>
> Consider this sequence:
>
> 1. The table is full of multicast entries and a secondary unicast
> address U is added. mpnic_macda_sync() returns -ENOSPC, U stays at
> sync_cnt == 0, and mpnic_promisc_sync() enables unicast promisc.
>
> 2. A multicast address M is then removed. The core runs
> netif_rx_mode_run()->mpnic_set_rx_mode()->__mpnic_set_rx_mode().
>
> 3. The uc pass retries U. M's slot is still MPNIC_TCAM_S_VALID, so
> mpnic_macda_free() rejects it, mpnic_macda_sync() returns -ENOSPC
> again, and uc_promisc is set.
>
> 4. The mc flush runs only after that. It calls mpnic_macda_unsync() on M:
>
> if (!--mac_addr->users)
> mac_addr->state = MPNIC_TCAM_S_DELETE;
>
> mpnic_write_macda() then frees the slot.
>
> The reverse case works. A unicast removal can make room for a pending
> multicast address, because the uc flush runs before the mc add.
>
> Would it make sense to flush stale entries from both lists before either
> add phase runs?
>

I see this more as a low severity issue, because having the device be in
promiscuous mode when a slot is free is not incorrect, just not optimal.

If anything I would probably just rerun __hw_addr_sync_dev() on the uc
list again after the mc one, if the first call returned -ENOSPC. I
didn't think that was really worth it when this same comment came up in
local review though.

> [ ... ]
>
>> @@ -53,7 +78,7 @@ static int mpnic_set_rx_mode(struct net_device *netdev,
>> struct mpnic_net *mpn = netdev_priv(netdev);
>>
>> if (netif_running(netdev))
>> - __mpnic_set_rx_mode(mpn->mpd, mc);
>> + __mpnic_set_rx_mode(mpn->mpd, uc, mc);
>>
>> return 0;
>> }
>
> Because mpnic_set_rx_mode() always returns 0, netif_rx_mode_run() never
> calls netif_rx_mode_schedule_retry() for the case above.
>
> mpnic_service_task() doesn't re-run the rx mode sync either. So U stays
> unsynced and the promisc entry (zero mask) stays installed until some
> unrelated rx-mode event happens. The commit message says:
>
> Advertise IFF_UNICAST_FLT so we don't need to use promiscuous mode to
> handle extra unicast addresses.
>
> The later patch in the series, "eth: mpnic: support changing the MAC
> address", keeps the same uc-then-mc ordering.