* [PATCH net] net: stmmac: fix the invalid VID programmed by VLAN perfect filtering
@ 2026-09-17 12:22 Linkui Xiao
2026-09-17 15:57 ` Maxime Chevallier
0 siblings, 1 reply; 3+ messages in thread
From: Linkui Xiao @ 2026-09-17 12:22 UTC (permalink / raw)
To: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
mcoquelin.stm32, alexandre.torgue
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Linkui Xiao, stable
From: Linkui Xiao <xiaolinkui@kylinos.cn>
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@vger.kernel.org
Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 62c3441911e7..af2d38a2bb3d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6844,13 +6844,13 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
crc = bitrev32(~stmmac_vid_crc32_le(vid_le)) >> 28;
hash |= (1 << crc);
count++;
+ pmatch = vid;
}
if (!priv->dma_cap.vlhash) {
if (count > 2) /* VID = 0 always passes filter */
return -EOPNOTSUPP;
- pmatch = vid;
hash = 0;
}
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: stmmac: fix the invalid VID programmed by VLAN perfect filtering
2026-09-17 12:22 [PATCH net] net: stmmac: fix the invalid VID programmed by VLAN perfect filtering Linkui Xiao
@ 2026-09-17 15:57 ` Maxime Chevallier
2026-09-18 7:10 ` Linkui Xiao
0 siblings, 1 reply; 3+ messages in thread
From: Maxime Chevallier @ 2026-09-17 15:57 UTC (permalink / raw)
To: Linkui Xiao, andrew+netdev, davem, edumazet, kuba, pabeni,
mcoquelin.stm32, alexandre.torgue, Ovidiu Panait
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Linkui Xiao, stable
Hi,
+Ovidiu
On 9/17/26 14:22, Linkui Xiao wrote:
> From: Linkui Xiao <xiaolinkui@kylinos.cn>
>
> 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@vger.kernel.org
> Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
Thank you for proposing this fix, however this code is currently being removed :
https://lore.kernel.org/r/20260908164309.59282-1-ovidiu.panait.rb@renesas.com
So no need for this patch :)
Maxime
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: stmmac: fix the invalid VID programmed by VLAN perfect filtering
2026-09-17 15:57 ` Maxime Chevallier
@ 2026-09-18 7:10 ` Linkui Xiao
0 siblings, 0 replies; 3+ messages in thread
From: Linkui Xiao @ 2026-09-18 7:10 UTC (permalink / raw)
To: Maxime Chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
mcoquelin.stm32, alexandre.torgue, Ovidiu Panait
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Linkui Xiao, stable
Hi Maxime,
On 2026/9/17 23:57, Maxime Chevallier wrote:
> Hi,
>
> +Ovidiu
>
> On 9/17/26 14:22, Linkui Xiao wrote:
>> From: Linkui Xiao <xiaolinkui@kylinos.cn>
>>
>> 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@vger.kernel.org
>> Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
>
> Thank you for proposing this fix, however this code is currently being removed :
>
> https://lore.kernel.org/r/20260908164309.59282-1-ovidiu.panait.rb@renesas.com
>
> So no need for this patch :)
Thanks for the heads-up. I'll drop this patch then.
Ovidiu, I'll keep an eye on your series. If the fallback path
still needs a valid VID after the removal, feel free to ping me.
Thanks,
Linkui
>
> Maxime
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-18 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 12:22 [PATCH net] net: stmmac: fix the invalid VID programmed by VLAN perfect filtering Linkui Xiao
2026-09-17 15:57 ` Maxime Chevallier
2026-09-18 7:10 ` Linkui Xiao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®