Re: [PATCH net-next v12 08/10] bnge: add NTUPLE filter support in ethtool
From: Vikas Gupta
Date: Sun Dec 06 2026 - 03:41:10 EST
On Sat, Dec 5, 2026 at 8:16 PM <netdev-bot+sashiko@xxxxxxxxxx> wrote:
>
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 1
>
> 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] bnge_srxclsrldel() in
> drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c ignores the return…
> - [Low] The commit message says user filters "stay in software while the
> interface is down" and that "bnge_cfg_usr_fltrs() programs them in…
>
> --
>
> bnge: add NTUPLE filter support in ethtool
>
> This commit adds ethtool get_rxnfc/set_rxnfc support for ntuple and
> ETHER_FLOW rules. User rules are kept in software across down/up and
> programmed in firmware again on open. The unicast address filters now
> share the L2 filter pool with these rules, and NETIF_F_NTUPLE is enabled
> by default.
>
> > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
> > index 99a69f16a0a62..77edcd564b619 100644
> > --- a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
> > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
>
> [ ... ]
>
> > +static int bnge_srxclsrldel(struct bnge_net *bn, struct ethtool_rxnfc *cmd)
> > +{
> > + struct ethtool_rx_flow_spec *fs = &cmd->fs;
> > + struct bnge_filter_base *fltr_base;
> > + struct bnge_ntuple_filter *fltr;
> > + u32 id = fs->location;
> > +
> > + rcu_read_lock();
> > + fltr_base = bnge_get_one_fltr_rcu(bn, bn->l2_fltr_hash_tbl,
> > + BNGE_L2_FLTR_HASH_SIZE, id, 0);
> > + if (fltr_base) {
> > + struct bnge_l2_filter *l2_fltr;
> > +
> > + l2_fltr = container_of(fltr_base, struct bnge_l2_filter, base);
> > + rcu_read_unlock();
> > + /* The firmware filter is gone once the interface is closed. */
> > + if (test_bit(BNGE_FLTR_VALID, &l2_fltr->base.state))
> > + bnge_hwrm_l2_filter_free(bn->bd, l2_fltr);
> > + bnge_del_usr_l2_filter(bn, l2_fltr);
> > + return 0;
> > + }
>
> [ ... ]
>
> > + rcu_read_unlock();
> > + bnge_hwrm_cfa_ntuple_filter_free(bn->bd, fltr);
> > + bnge_del_ntp_filter_rcu(bn, fltr);
> > + return 0;
> > +}
>
> [Severity: Medium]
> What happens here if the firmware fails HWRM_CFA_L2_FILTER_FREE or
> HWRM_CFA_NTUPLE_FILTER_FREE?
>
> bnge_srxclsrldel() drops the return values of bnge_hwrm_l2_filter_free()
> and bnge_hwrm_cfa_ntuple_filter_free(). It then tears down the software
> filter anyway, through bnge_del_usr_l2_filter()->bnge_del_l2_filter_rcu()
> or through bnge_del_ntp_filter_rcu(). Those clear the sw_id bit, unlink
> the list node and kfree_rcu() the object. Then 0 is returned to user
> space.
>
> bnge_hwrm_l2_filter_free() returns the result of bnge_hwrm_req_send(), so
> a firmware busy error (-EAGAIN) or an HWRM timeout can reach this point.
> bnge_cfg_rx_mode() already treats -EAGAIN from the firmware as a
> transient condition.
>
> Once the object is freed, base.filter_id is freed with it, and nothing
> can release the firmware filter later. At close,
> bnge_hwrm_clear_usr_l2_fltrs() walks usr_fltr_list, and the node is no
> longer on it.
>
> For an ETHER_FLOW rule, could the leaked filter keep steering the MAC to
> the NTUPLE VNIC ring after ethtool -n stops listing it?
> bnge_del_usr_l2_filter() would also program a default VNIC unicast filter
> for the same MAC while the stale filter may still be active. A leaked
> ntuple filter would likewise keep steering or dropping the matching
> flows.
>
> bnxt_srxclsrldel() uses the same pattern. Would it be better to return
> the error and keep the software filter when the firmware free fails? The
> last patch of the series still has this pattern.
>
> bnge_hwrm_clear_usr_l2_fltrs() has a weaker version of the same thing.
> It clears BNGE_FLTR_VALID before a free whose result is ignored. That is
> the close path, though, where ignoring release errors is more usual.
We deliberately ignore the free HWRM return values here to keep consistency
with the other free paths in the driver, and plan to address this as
an enhancement
in a future series for other free HWRM calls for other resources as well.
>
> > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
> > index 3ebb3cae4829b..639c36d571f24 100644
> > --- a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
> > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
>
> [ ... ]
>
> > +static void bnge_cfg_one_usr_fltr(struct bnge_net *bn,
> > + struct bnge_filter_base *fltr)
> > +{
> > + struct bnge_ntuple_filter *ntp_fltr;
> > + struct bnge_l2_filter *l2_fltr;
> > +
> > + if (list_empty(&fltr->list_node))
> > + return;
> > +
> > + if (fltr->type == BNGE_FLTR_TYPE_NTUPLE) {
> > + ntp_fltr = container_of(fltr, struct bnge_ntuple_filter, base);
> > + l2_fltr = bn->vnic_info[BNGE_VNIC_DEFAULT].l2_filters[0];
> > + ntp_fltr->l2_filter_id = l2_fltr->base.filter_id;
> > + if (bnge_usr_fltr_ring_lost(bn, fltr) ||
> > + bnge_hwrm_cfa_ntuple_filter_alloc(bn->bd, ntp_fltr)) {
> > + netdev_err(bn->netdev,
> > + "restoring previously configured ntuple filter id %d failed\n",
> > + BNGE_MAX_L2_FLTRS + fltr->sw_id);
> > + bnge_del_ntp_filter_rcu(bn, ntp_fltr);
> > + }
> > + } else if (fltr->type == BNGE_FLTR_TYPE_L2) {
> > + l2_fltr = container_of(fltr, struct bnge_l2_filter, base);
> > + fltr->fw_vnic_id = bn->vnic_info[BNGE_VNIC_NTUPLE].fw_vnic_id;
> > + if (bnge_usr_fltr_ring_lost(bn, fltr) ||
> > + bnge_hwrm_l2_filter_alloc(bn->bd, l2_fltr)) {
> > + netdev_err(bn->netdev,
> > + "restoring previously configured l2 filter id %d failed\n",
> > + fltr->sw_id);
> > + bnge_del_usr_l2_filter(bn, l2_fltr);
> > + }
> > + }
> > +}
>
> [Severity: Low]
> The commit message says:
>
> User filters stay in software while the interface is down.
> bnge_cfg_usr_fltrs() programs them in firmware again on open, and
> bnge_clear_usr_fltrs() deletes them when NTUPLE is turned off.
>
> Should it also say that bnge_cfg_one_usr_fltr() permanently deletes a
> retained rule that it cannot restore on open?
>
> The rule is dropped in two cases. One is when bnge_usr_fltr_ring_lost()
> reports that the target RX ring no longer exists. The other is when the
> firmware refuses bnge_hwrm_cfa_ntuple_filter_alloc() or
> bnge_hwrm_l2_filter_alloc().
>
> The rule then leaves usr_fltr_list, the hash table and the sw_id bitmap,
> so it disappears from ethtool -n. Only a log message is left, and
> bnge_open_core() still returns 0 after bnge_cfg_usr_fltrs().
>
> The ring-lost case looks reachable. The ethtool core stops ethtool -L
> from shrinking below the rings that rules use. However,
> bnge_reserve_rings() in bnge_resc.c can still lower the ring count at
> reservation time:
>
> dev_warn(bd->dev, "RX rings resv reduced to %d than earlier %d requested\n",
> rx_rings, bd->rx_nr_rings);
> ...
> bd->rx_nr_rings = rx_rings;
>
> bnge_check_rss_ctxs_lost() already handles this case for RSS contexts.
>
> The commit message covers the other caveats in detail. Could it also
> note that rules can vanish after a down/up? This behavior is the same in
> the last patch of the series.
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201132011.2705569-1-vikas.gupta%40broadcom.com
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature