Skip to contentSkip to conversation

macvtap: fix network header pointer for VLAN tagged pkts

PATCH Superseded Ivan Vecera 2 participants 3 messages Jul 20, 2015 – Jul 21, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 macvtap: fix network header pointer for VLAN tagged pkts

Network header is set with offset ETH_HLEN but it is not true for VLAN (multiple-)tagged and results in checksum issues in lower devices.

---
 drivers/net/macvtap.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/macvtap.c +6 -0
index 3b933bb..cdcbab4 100644
@@ -796,6 +796,12 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
 	skb_reset_mac_header(skb);
 	skb->protocol = eth_hdr(skb)->h_proto;
 
+	if (skb_vlan_tagged(skb)) {
+		int depth;
+		skb->protocol = __vlan_get_protocol(skb, skb->protocol, &depth);
+		skb_set_network_header(skb, depth);
+	}
+
 	if (vnet_hdr_len) {
 		err = macvtap_skb_from_vnet_hdr(q, skb, &vnet_hdr);
 		if (err)
Signature · 1 line
2.3.6
#1 lore raw
Quoted 13 lines · Ivan Vecera

Network header is set with offset ETH_HLEN but it is not true for VLAN (multiple-)tagged and results in checksum issues in lower devices.

---
 drivers/net/macvtap.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/macvtap.c +0 -0
index 3b933bb..cdcbab4 100644

drivers/net/macvtap.c static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · line 801

Quoted 6 lines
drivers/net/macvtap.c +3 -0
@@ -796,6 +796,12 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
 	skb_reset_mac_header(skb);
 	skb->protocol = eth_hdr(skb)->h_proto;
 
+	if (skb_vlan_tagged(skb)) {
+		int depth;
+		skb->protocol = __vlan_get_protocol(skb, skb->protocol, &depth);

I don't think this is right. This would reset the protocol to the encapsulated protocol which isn't really the case since you are not really stripping vlan encapsulations.

-vlad

Quoted 7 lines
drivers/net/macvtap.c +3 -0
+		skb_set_network_header(skb, depth);
+	}
+
 	if (vnet_hdr_len) {
 		err = macvtap_skb_from_vnet_hdr(q, skb, &vnet_hdr);
 		if (err)
#2 lore raw
Quoted 25 lines · Vlad Yasevich
Quoted 13 lines · Ivan Vecera

Network header is set with offset ETH_HLEN but it is not true for VLAN (multiple-)tagged and results in checksum issues in lower devices.

---
  drivers/net/macvtap.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/net/macvtap.c +0 -0
index 3b933bb..cdcbab4 100644

drivers/net/macvtap.c static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · line 801

Quoted 6 lines
drivers/net/macvtap.c +3 -0
@@ -796,6 +796,12 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
  	skb_reset_mac_header(skb);
  	skb->protocol = eth_hdr(skb)->h_proto;
 
+	if (skb_vlan_tagged(skb)) {
+		int depth;
+		skb->protocol = __vlan_get_protocol(skb, skb->protocol, &depth);

I don't think this is right. This would reset the protocol to the encapsulated protocol which isn't really the case since you are not really stripping vlan encapsulations.

Quoted 1 line

-vlad

Yup, you are right, skb->protocol should be untouched. Will post v2.

Ivan