[PATCH net-next] openvswitch: fix vport packet length check.

Subsystems: networking [general], openvswitch, the rest

STALE3145d

3 messages, 2 authors, 2018-03-07 · open the first message on its own page

[PATCH net-next] openvswitch: fix vport packet length check.

From: William Tu <hidden>
Date: 2018-03-07 01:57:20

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.

Signed-off-by: William Tu <redacted>
---
 net/openvswitch/vport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index b6c8524032a0..7718d5b4cf8a 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -467,7 +467,7 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
 static unsigned 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)
-- 
2.7.4

Re: [PATCH net-next] openvswitch: fix vport packet length check.

From: Pravin Shelar <hidden>
Date: 2018-03-07 21:18:59

On Tue, Mar 6, 2018 at 5:56 PM, William Tu [off-list ref] wrote:
quoted hunk
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.

Signed-off-by: William Tu <redacted>
---
 net/openvswitch/vport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index b6c8524032a0..7718d5b4cf8a 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -467,7 +467,7 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
 static unsigned int packet_length(const struct sk_buff *skb,
                                  struct net_device *dev)
Can you also change return type of this function?
quoted hunk
 {
-       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)
--
2.7.4

Re: [PATCH net-next] openvswitch: fix vport packet length check.

From: William Tu <hidden>
Date: 2018-03-07 22:43:03

On Wed, Mar 7, 2018 at 1:18 PM, Pravin Shelar [off-list ref] wrote:
On Tue, Mar 6, 2018 at 5:56 PM, William Tu [off-list ref] wrote:
quoted
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.

Signed-off-by: William Tu <redacted>
---
 net/openvswitch/vport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index b6c8524032a0..7718d5b4cf8a 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -467,7 +467,7 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
 static unsigned int packet_length(const struct sk_buff *skb,
                                  struct net_device *dev)
Can you also change return type of this function?
OK, I will change to int. Thanks
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help