All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: libwx: disable TX VLAN offload for packets with >2 VLAN tags
@ 2026-07-13  6:04 Jiawen Wu
  2026-07-15  0:26 ` Jacob Keller
  0 siblings, 1 reply; 3+ messages in thread
From: Jiawen Wu @ 2026-07-13  6:04 UTC (permalink / raw)
  To: netdev
  Cc: Duanqiang Wen, Mengyuan Lou, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Jacob Keller, Kees Cook, Przemek Kitszel, Jiawen Wu

The current hardware does not support TX VLAN offload for packets with
three or more VLAN tags. When such packets are transmitted with hardware
VLAN offload enabled, the hardware may malfunction or produce corrupted
frames.

Add a check in wx_features_check() to parse the VLAN depth of the
skb. If more than two VLAN tags are detected (including both the
hardware tag and in-band tags), strip NETIF_F_HW_VLAN_CTAG_TX and
NETIF_F_HW_VLAN_STAG_TX from the feature set. This forces the
kernel networking stack to handle VLAN insertion in software for
these specific packets, ensuring correct transmission.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
v2:
- Remove redundant 'parse_depth'.
- Optimize the loop.

v1: https://lore.kernel.org/all/C1BF77C0E073A40C+20260710071831.210196-1-jiawenwu@trustnetic.com
---
 drivers/net/ethernet/wangxun/libwx/wx_lib.c | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
index 814d88d2aee4..34542b3dc884 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
@@ -3228,6 +3228,30 @@ netdev_features_t wx_features_check(struct sk_buff *skb,
 				    netdev_features_t features)
 {
 	struct wx *wx = netdev_priv(netdev);
+	__be16 type = skb->protocol;
+	u16 vlan_depth = ETH_HLEN;
+	u32 vlan_num = 0;
+
+	if (skb_vlan_tag_present(skb))
+		vlan_num++;
+
+	while (eth_type_vlan(type)) {
+		struct vlan_hdr vhdr, *vh;
+
+		vh = skb_header_pointer(skb, vlan_depth, sizeof(vhdr), &vhdr);
+		if (unlikely(!vh))
+			break;
+
+		type = vh->h_vlan_encapsulated_proto;
+		vlan_depth += VLAN_HLEN;
+		vlan_num++;
+
+		if (vlan_num > 2) {
+			features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
+				      NETIF_F_HW_VLAN_STAG_TX);
+			break;
+		}
+	}
 
 	if (!skb->encapsulation)
 		return features;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] net: libwx: disable TX VLAN offload for packets with >2 VLAN tags
  2026-07-13  6:04 [PATCH net-next v2] net: libwx: disable TX VLAN offload for packets with >2 VLAN tags Jiawen Wu
@ 2026-07-15  0:26 ` Jacob Keller
  2026-07-15  1:41   ` Jiawen Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Jacob Keller @ 2026-07-15  0:26 UTC (permalink / raw)
  To: Jiawen Wu, netdev
  Cc: Duanqiang Wen, Mengyuan Lou, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Kees Cook, Przemek Kitszel

On 7/12/2026 11:04 PM, Jiawen Wu wrote:
> The current hardware does not support TX VLAN offload for packets with
> three or more VLAN tags. When such packets are transmitted with hardware
> VLAN offload enabled, the hardware may malfunction or produce corrupted
> frames.
> 
> Add a check in wx_features_check() to parse the VLAN depth of the
> skb. If more than two VLAN tags are detected (including both the
> hardware tag and in-band tags), strip NETIF_F_HW_VLAN_CTAG_TX and
> NETIF_F_HW_VLAN_STAG_TX from the feature set. This forces the
> kernel networking stack to handle VLAN insertion in software for
> these specific packets, ensuring correct transmission.
> 
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>


Is there a reason this was targeted at net-next instead of as a bug fix
to net with a Fixes tag to the commit which first introduced VLAN tagging?

Thanks,
Jake

> ---
> v2:
> - Remove redundant 'parse_depth'.
> - Optimize the loop.
> 
> v1: https://lore.kernel.org/all/C1BF77C0E073A40C+20260710071831.210196-1-jiawenwu@trustnetic.com
> ---
>  drivers/net/ethernet/wangxun/libwx/wx_lib.c | 24 +++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index 814d88d2aee4..34542b3dc884 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> @@ -3228,6 +3228,30 @@ netdev_features_t wx_features_check(struct sk_buff *skb,
>  				    netdev_features_t features)
>  {
>  	struct wx *wx = netdev_priv(netdev);
> +	__be16 type = skb->protocol;
> +	u16 vlan_depth = ETH_HLEN;
> +	u32 vlan_num = 0;
> +
> +	if (skb_vlan_tag_present(skb))
> +		vlan_num++;
> +
> +	while (eth_type_vlan(type)) {
> +		struct vlan_hdr vhdr, *vh;
> +
> +		vh = skb_header_pointer(skb, vlan_depth, sizeof(vhdr), &vhdr);
> +		if (unlikely(!vh))
> +			break;
> +
> +		type = vh->h_vlan_encapsulated_proto;
> +		vlan_depth += VLAN_HLEN;
> +		vlan_num++;
> +
> +		if (vlan_num > 2) {
> +			features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
> +				      NETIF_F_HW_VLAN_STAG_TX);
> +			break;
> +		}
> +	}
>  
>  	if (!skb->encapsulation)
>  		return features;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net-next v2] net: libwx: disable TX VLAN offload for packets with >2 VLAN tags
  2026-07-15  0:26 ` Jacob Keller
@ 2026-07-15  1:41   ` Jiawen Wu
  0 siblings, 0 replies; 3+ messages in thread
From: Jiawen Wu @ 2026-07-15  1:41 UTC (permalink / raw)
  To: 'Jacob Keller', netdev
  Cc: 'Duanqiang Wen', 'Mengyuan Lou',
	'Andrew Lunn', 'David S. Miller',
	'Eric Dumazet', 'Jakub Kicinski',
	'Paolo Abeni', 'Simon Horman',
	'Kees Cook', 'Przemek Kitszel'

On Wed, Jul 15, 2026 8:27 AM, Jacob Keller wrote:
> On 7/12/2026 11:04 PM, Jiawen Wu wrote:
> > The current hardware does not support TX VLAN offload for packets with
> > three or more VLAN tags. When such packets are transmitted with hardware
> > VLAN offload enabled, the hardware may malfunction or produce corrupted
> > frames.
> >
> > Add a check in wx_features_check() to parse the VLAN depth of the
> > skb. If more than two VLAN tags are detected (including both the
> > hardware tag and in-band tags), strip NETIF_F_HW_VLAN_CTAG_TX and
> > NETIF_F_HW_VLAN_STAG_TX from the feature set. This forces the
> > kernel networking stack to handle VLAN insertion in software for
> > these specific packets, ensuring correct transmission.
> >
> > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> 
> 
> Is there a reason this was targeted at net-next instead of as a bug fix
> to net with a Fixes tag to the commit which first introduced VLAN tagging?
> 
> Thanks,
> Jake

Probably because I couldn't find a Fixes tag for it...

> 
> > ---
> > v2:
> > - Remove redundant 'parse_depth'.
> > - Optimize the loop.
> >
> > v1: https://lore.kernel.org/all/C1BF77C0E073A40C+20260710071831.210196-1-jiawenwu@trustnetic.com
> > ---
> >  drivers/net/ethernet/wangxun/libwx/wx_lib.c | 24 +++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> > index 814d88d2aee4..34542b3dc884 100644
> > --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> > +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> > @@ -3228,6 +3228,30 @@ netdev_features_t wx_features_check(struct sk_buff *skb,
> >  				    netdev_features_t features)
> >  {
> >  	struct wx *wx = netdev_priv(netdev);
> > +	__be16 type = skb->protocol;
> > +	u16 vlan_depth = ETH_HLEN;
> > +	u32 vlan_num = 0;
> > +
> > +	if (skb_vlan_tag_present(skb))
> > +		vlan_num++;
> > +
> > +	while (eth_type_vlan(type)) {
> > +		struct vlan_hdr vhdr, *vh;
> > +
> > +		vh = skb_header_pointer(skb, vlan_depth, sizeof(vhdr), &vhdr);
> > +		if (unlikely(!vh))
> > +			break;
> > +
> > +		type = vh->h_vlan_encapsulated_proto;
> > +		vlan_depth += VLAN_HLEN;
> > +		vlan_num++;
> > +
> > +		if (vlan_num > 2) {
> > +			features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
> > +				      NETIF_F_HW_VLAN_STAG_TX);
> > +			break;
> > +		}
> > +	}
> >
> >  	if (!skb->encapsulation)
> >  		return features;
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-15  1:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13  6:04 [PATCH net-next v2] net: libwx: disable TX VLAN offload for packets with >2 VLAN tags Jiawen Wu
2026-07-15  0:26 ` Jacob Keller
2026-07-15  1:41   ` Jiawen Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.