Re: [PATCH net] net: stmmac: fix the invalid VID programmed by VLAN perfect filtering

From: Maxime Chevallier

Date: Thu Sep 17 2026 - 12:18:21 EST


Hi,

+Ovidiu

On 9/17/26 14:22, Linkui Xiao wrote:
> From: Linkui Xiao <xiaolinkui@xxxxxxxxxx>
>
> for_each_set_bit() leaves its iterator equal to the bitmap size once the
> loop terminates, so the 'vid' read after the loop in stmmac_vlan_update()
> is always VLAN_N_VID (4096) and never the last VLAN ID that was found.
>
> Cores that do not support VLAN hash filtering (dma_cap.vlhash == 0) fall
> back to the single VID perfect match filter and hand that value straight
> to the MAC. vlan_update_hash() therefore programs MAC_VLAN_Tag with
> VID 4096, a value that can never match an incoming 802.1Q tag, so the
> perfect filter ends up discarding all VLAN tagged traffic. Both
> stmmac_test_vlanfilt_perfect() and stmmac_test_dvlanfilt_perfect() walk
> this path and fail as a result.
>
> Remember the VID while iterating so that the last active VLAN ID is the
> one passed to the perfect match filter. When hash filtering is available
> 'hash' is non-zero as soon as at least one VID is active, so
> vlan_update_hash() keeps ignoring 'pmatch' and nothing changes there.
>
> Fixes: c7ab0b8088d7 ("net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Linkui Xiao <xiaolinkui@xxxxxxxxxx>

Thank you for proposing this fix, however this code is currently being removed :

https://lore.kernel.org/r/20260908164309.59282-1-ovidiu.panait.rb@xxxxxxxxxxx

So no need for this patch :)

Maxime