[PATCH net] bnge: skip dev_addr when building the VNIC unicast list
flat view
COOLING4d
REVIEWED: 1 (0M)
From: Vikas Gupta <vikas.gupta@broadcom.com>
Date: 2026-10-06 14:19:43
Also in:
lkml
Subsystem:
broadcom bng_en 800 gigabit ethernet driver, networking drivers, the rest · Maintainers:
Vikas Gupta, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
1 review trailer.
The default VNIC programs the device's MAC as L2 filter 0 in
bnge_init_chip() via bnge_hwrm_set_vnic_filter(bn, 0, 0, dev_addr).
bnge_cfg_rx_mode() then walks dev->uc and programs each unicast
address as a further L2 filter, without excluding dev_addr.
Skip dev_addr when building uc_list, since it is already installed as
filter 0. As dev_addr now takes neither a uc_list slot nor an
l2_filters[] slot, count only the non-dev_addr entries for the
uc_list overflow check too, otherwise an input such as
{dev_addr, A, B, C} would needlessly fall back to promiscuous mode
even though A, B and C fit in exact-match filters.
bnge_uc_list_updated() applies the same skip and count so the
change detection stays consistent and does not loop.
This issue was caught by Sashiko (nipa).
Tested on Thor Ultra device.
Fixes: 9afad4a17174 ("bng_en: Configure default VNIC")
Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Dharmender Garg <redacted>
---
.../net/ethernet/broadcom/bnge/bnge_netdev.c | 28 +++++++++++++------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
index a4288f0258f8..92aea6f6f09f 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c@@ -2182,19 +2182,21 @@ static bool bnge_uc_list_updated(struct bnge_net *bn, const struct netdev_hw_addr_list *uc) { struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT]; + struct net_device *dev = bn->netdev; struct netdev_hw_addr *ha; - int off = 0; - - if (netdev_hw_addr_list_count(uc) != (vnic->uc_filter_count - 1)) - return true; + int off = 0, count = 0; netdev_hw_addr_list_for_each(ha, uc) { + if (ether_addr_equal(ha->addr, dev->dev_addr)) + continue; + if (count >= vnic->uc_filter_count - 1) + return true; if (!ether_addr_equal(ha->addr, vnic->uc_list + off)) return true; - off += ETH_ALEN; + count++; } - return false; + return count != vnic->uc_filter_count - 1; } static bool bnge_promisc_ok(struct bnge_net *bn)
@@ -2207,9 +2209,9 @@ static int bnge_cfg_rx_mode(struct bnge_net *bn, struct netdev_hw_addr_list *uc, { struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT]; struct net_device *dev = bn->netdev; + int i, off = 0, rc, uc_count = 0; struct bnge_dev *bd = bn->bd; struct netdev_hw_addr *ha; - int i, off = 0, rc; if (!uc_update) goto skip_uc;
@@ -2225,10 +2227,20 @@ static int bnge_cfg_rx_mode(struct bnge_net *bn, struct netdev_hw_addr_list *uc, if (!snapshot) netif_addr_lock_bh(dev); - if (netdev_hw_addr_list_count(uc) > (BNGE_MAX_UC_ADDRS - 1)) { + /* dev_addr is already programmed as L2 filter 0, so it takes neither a + * uc_list slot nor an l2_filters[] slot. Count only the entries that + * will actually be programmed so the overflow check matches the fill + * loop below (and bnge_uc_list_updated()). + */ + netdev_hw_addr_list_for_each(ha, uc) + if (!ether_addr_equal(ha->addr, dev->dev_addr)) + uc_count++; + if (uc_count > BNGE_MAX_UC_ADDRS - 1) { vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; } else { netdev_hw_addr_list_for_each(ha, uc) { + if (ether_addr_equal(ha->addr, dev->dev_addr)) + continue; memcpy(vnic->uc_list + off, ha->addr, ETH_ALEN); off += ETH_ALEN; vnic->uc_filter_count++;
--
2.52.0