Skip to contentSkip to conversation

hyperv: Fix vlan_proto setting in netvsc_recv_callback()

PATCH Applied Haiyang Zhang 3 participants 4 messages May 28, 2013 – Jun 14, 2013

Subsystems (3)
lore
Share & tools
lore

Haiyang Zhang

author maintainer
#0 lore raw

PATCH 1/1 hyperv: Fix vlan_proto setting in netvsc_recv_callback()

Since the recent addition of 8021AD, we need to set the new field vlan_proto in sk_buff. Otherwise, it will trigger BUG() call in vlan_proto_idx().

This patch fixes the problem.

---
 drivers/net/hyperv/netvsc_drv.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/hyperv/netvsc_drv.c +2 -1
index 088c554..ab2307b 100644
@@ -31,6 +31,7 @@
 #include <linux/inetdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/if_vlan.h>
 #include <linux/in.h>
 #include <linux/slab.h>
 #include <net/arp.h>
@@ -284,7 +285,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 
 	skb->protocol = eth_type_trans(skb, net);
 	skb->ip_summed = CHECKSUM_NONE;
-	skb->vlan_tci = packet->vlan_tci;
+	__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet->vlan_tci);
 
 	net->stats.rx_packets++;
 	net->stats.rx_bytes += packet->total_data_buflen;
Signature · 1 line
1.7.4.1
#2 lore raw
In reply to Haiyang Zhang

drivers/net/hyperv/netvsc_drv.c int netvsc_recv_callback(struct hv_device *device_obj, · line 288

Quoted 9 lines · Haiyang Zhang

Since the recent addition of 8021AD, we need to set the new field vlan_proto in sk_buff. Otherwise, it will trigger BUG() call in vlan_proto_idx().

drivers/net/hyperv/netvsc_drv.c +1 -1
@@ -284,7 +285,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 
 	skb->protocol = eth_type_trans(skb, net);
 	skb->ip_summed = CHECKSUM_NONE;
-	skb->vlan_tci = packet->vlan_tci;
+	__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet->vlan_tci);

Just curious:

Doesnt that change behaviour in the sense that __vlan_hwaccel_put_tag() now always adds VLAN_TAG_PRESENT to skb->vlan_tci, while before that change packet->vlan_tci may or may not had this flag?

In other words, should a variant of this patch be backported if it was a bug not not use __vlan_hwaccel_put_tag right from the start?

Olaf

author maintainer
#3 lore raw
Quoted 30 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, June 14, 2013 11:29 AM
To: Haiyang Zhang
Cc: [email protected]; [email protected]; KY Srinivasan; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net] hyperv: Fix vlan_proto setting in netvsc_recv_callback()

Quoted 2 lines · Haiyang Zhang

Since the recent addition of 8021AD, we need to set the new field vlan_proto in sk_buff. Otherwise, it will trigger BUG() call in

vlan_proto_idx().

drivers/net/hyperv/netvsc_drv.c int netvsc_recv_callback(struct hv_device · line 290

Quoted 8 lines
drivers/net/hyperv/netvsc_drv.c +1 -1
@@ -284,7 +285,7 @@ int netvsc_recv_callback(struct hv_device
 *device_obj,
 
 	skb->protocol = eth_type_trans(skb, net);
 	skb->ip_summed = CHECKSUM_NONE;
-	skb->vlan_tci = packet->vlan_tci;
+	__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet-
 vlan_tci);

Just curious:

Quoted 7 lines

Doesnt that change behaviour in the sense that __vlan_hwaccel_put_tag() now always adds VLAN_TAG_PRESENT to skb->vlan_tci, while before that change packet->vlan_tci may or may not had this flag?

In other words, should a variant of this patch be backported if it was a bug not not use __vlan_hwaccel_put_tag right from the start?

Thanks for looking at this. Actually, the previous code was correct, because I add the VLAN_TAG_PRESENT if the packet comes from vlan in function rndis_filter_receive_data():

        if (vlan) {
                pkt->vlan_tci = VLAN_TAG_PRESENT | vlan->vlanid |
                        (vlan->pri << VLAN_PRIO_SHIFT);
        } else {
                pkt->vlan_tci = 0;
        }

But, the new code should be updated below, so the VLAN_TAG_PRESENT won't be set when it's not from a vlan:
If (VLAN_TAG_PRESENT & packet->vlan_tci)

	__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet- vlan_tci);

I will submit a patch soon.

Thanks,
- Haiyang