Skip to contentSkip to conversation

openvswitch: fix vport packet length check.

PATCH Applied William Tu 3 participants 3 messages Mar 7, 2018 – Mar 8, 2018

Subsystems (3)
lore
Share & tools
lore

William Tu

author
#0 lore raw

PATCH v2 1/1 openvswitch: fix vport packet length check.

When sending a packet to a tunnel device, the dev's hard_header_len could be larger than the skb->len in function packet_length(). In the case of ip6gretap/erspan, hard_header_len = LL_MAX_HEADER + t_hlen, which is around 180, and an ARP packet sent to this tunnel has skb->len = 42. This causes the 'unsign int length' to become super large because it is negative value, causing the later ovs_vport_send to drop it due to over-mtu size. The patch fixes it by setting it to 0.

---
v1->v2:
replace the return type from unsigned int to int

---
 net/openvswitch/vport.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/openvswitch/vport.c +4 -4
index b6c8524032a0..f81c1d0ddff4 100644
@@ -464,10 +464,10 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
 	return 0;
 }
 
-static unsigned int packet_length(const struct sk_buff *skb,
-				  struct net_device *dev)
+static int packet_length(const struct sk_buff *skb,
+			 struct net_device *dev)
 {
-	unsigned int length = skb->len - dev->hard_header_len;
+	int length = skb->len - dev->hard_header_len;
 
 	if (!skb_vlan_tag_present(skb) &&
 	    eth_type_vlan(skb->protocol))
@@ -478,7 +478,7 @@ static unsigned int packet_length(const struct sk_buff *skb,
 	 * account for 802.1ad. e.g. is_skb_forwardable().
 	 */
 
-	return length;
+	return length > 0 ? length : 0;
 }
 
 void ovs_vport_send(struct vport *vport, struct sk_buff *skb, u8 mac_proto)
Signature · 1 line
2.7.4
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · William Tu

When sending a packet to a tunnel device, the dev's hard_header_len could be larger than the skb->len in function packet_length(). In the case of ip6gretap/erspan, hard_header_len = LL_MAX_HEADER + t_hlen, which is around 180, and an ARP packet sent to this tunnel has skb->len = 42. This causes the 'unsign int length' to become super large because it is negative value, causing the later ovs_vport_send to drop it due to over-mtu size. The patch fixes it by setting it to 0.

Quoted 5 lines

---
v1->v2:
replace the return type from unsigned int to int
---

maintainer Applied
#2 lore raw
In reply to William Tu

From: William Tu <[email protected]>
Date: Wed, 7 Mar 2018 15:38:48 -0800

Quoted 8 lines

When sending a packet to a tunnel device, the dev's hard_header_len could be larger than the skb->len in function packet_length(). In the case of ip6gretap/erspan, hard_header_len = LL_MAX_HEADER + t_hlen, which is around 180, and an ARP packet sent to this tunnel has skb->len = 42. This causes the 'unsign int length' to become super large because it is negative value, causing the later ovs_vport_send to drop it due to over-mtu size. The patch fixes it by setting it to 0.

Quoted 4 lines

---
v1->v2:
replace the return type from unsigned int to int

Applied, thanks.