Re: [PATCH net-next v9 06/10] bnge: remove refcount from L2 filter
From: netdev-bot+sashiko
Date: Tue Nov 24 2026 - 05:20:52 EST
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 does not describe two behaviour changes this
patch makes.
--
bnge: remove refcount from L2 filter
This patch removes the refcount from struct bnge_l2_filter. A filter is
now expected to be removed only by the context that created it. It also
folds the RCU lookup wrapper into bnge_lookup_l2_filter(), and makes
bnge_alloc_l2_filter() return an error when the key is already present.
> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
> index a8bb441ebef9a..6316f75ca36ea 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
[ ... ]
> @@ -13,8 +14,8 @@
>
> void bnge_del_l2_filter(struct bnge_net *bn, struct bnge_l2_filter *fltr)
> {
> - if (!refcount_dec_and_test(&fltr->refcnt))
> - return;
> + netdev_assert_locked_or_invisible(bn->netdev);
> +
> hlist_del_rcu(&fltr->base.hlist);
> kfree_rcu(fltr, base.rcu);
> }
[ ... ]
> -static struct bnge_l2_filter *__bnge_lookup_l2_filter(struct bnge_net *bn,
> - struct bnge_l2_key *key,
> - u32 idx)
> +static struct bnge_l2_filter *bnge_lookup_l2_filter(struct bnge_net *bn,
> + struct bnge_l2_key *key,
> + u32 idx)
> {
> struct bnge_l2_filter *fltr;
> struct hlist_head *head;
>
> + netdev_assert_locked_or_invisible(bn->netdev);
> +
> head = &bn->l2_fltr_hash_tbl[idx];
> - hlist_for_each_entry_rcu(fltr, head, base.hlist) {
> + hlist_for_each_entry(fltr, head, base.hlist) {
[ ... ]
> @@ -75,9 +63,10 @@ static struct bnge_l2_filter *bnge_alloc_l2_filter(struct bnge_net *bn,
>
> idx = jhash2(&key->filter_key, BNGE_L2_KEY_SIZE, bn->hash_seed) &
> BNGE_L2_FLTR_HASH_MASK;
> +
> fltr = bnge_lookup_l2_filter(bn, key, idx);
> if (fltr)
> - return fltr;
> + return ERR_PTR(-EEXIST);
[Severity: Low]
This isn't a bug, but should the commit message describe two behaviour
changes this patch makes? The message only talks about removing the
refcount:
However, going forward, the filter will only be removed by the same
context that created it, making refcount unnecessary.
First, the contract of bnge_alloc_l2_filter() changes. When it found a
duplicate MAC/VLAN key it used to take a reference and return the
existing filter. It now returns ERR_PTR(-EEXIST).
That error would go back through bnge_hwrm_set_vnic_filter() to
bnge_init_chip(), where open fails with "HWRM vnic filter failure", and
to bnge_cfg_rx_mode(). As far as I can tell this branch can't be reached
today, so there is no runtime impact.
Second, lookups of l2_fltr_hash_tbl switch from an RCU walk under
rcu_read_lock() to a plain hlist_for_each_entry(). The new
netdev_assert_locked_or_invisible() calls in bnge_lookup_l2_filter() and
bnge_del_l2_filter() make the netdev instance lock the required
protection.
At this commit nothing documents that rule. The bnge_netdev.h comment
saying l2_fltr_hash_tbl is covered by the netdev instance lock only
appears later in the series.
Could the commit message mention the new -EEXIST return and the move
from RCU to the instance lock for lookup and delete? Other commits in
this series list changes like these explicitly.
>
> fltr = kzalloc_obj(*fltr, gfp);
> if (!fltr)
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123100746.1975030-1-vikas.gupta%40broadcom.com