Skip to contentSkip to conversation

dev : fix mtu check when TSO is enabled

PATCH Applied Daniel Lezcano 2 participants 2 messages Mar 30, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 dev : fix mtu check when TSO is enabled

From: Daniel Lezcano <[email protected]>

In case the device where is coming from the packet has TSO enabled, we should not check the mtu size value as this one could be bigger than the expected value.

This is the case for the macvlan driver when the lower device has TSO enabled. The macvlan inherit this feature and forward the packets without fragmenting them. Then the packets go through dev_forward_skb and are dropped. This patch fix this by checking TSO is not enabled when we want to check the mtu size.

---
 net/core/dev.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
net/core/dev.c +22 -2
index 563ddc2..3da9fb0 100644
@@ -1454,6 +1454,27 @@ static inline void net_timestamp_check(struct sk_buff *skb)
 		__net_timestamp(skb);
 }
 
+static inline bool is_skb_forwardable(struct net_device *dev,
+				      struct sk_buff *skb)
+{
+	unsigned int len;
+
+	if (!(dev->flags & IFF_UP))
+		return false;
+
+	len = dev->mtu + dev->hard_header_len + VLAN_HLEN;
+	if (skb->len <= len)
+		return true;
+
+	/* if TSO is enabled, we don't care about the length as the packet
+	 * could be forwarded without being segmented before
+	 */
+	if (skb_is_gso(skb))
+		return true;
+
+	return false;
+}
+
 /**
  * dev_forward_skb - loopback an skb to another netif
  *
@@ -1477,8 +1498,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
 	skb_orphan(skb);
 	nf_reset(skb);
 
-	if (unlikely(!(dev->flags & IFF_UP) ||
-		     (skb->len > (dev->mtu + dev->hard_header_len + VLAN_HLEN)))) {
+	if (unlikely(!is_skb_forwardable(dev, skb))) {
 		atomic_long_inc(&dev->rx_dropped);
 		kfree_skb(skb);
 		return NET_RX_DROP;
Signature · 1 line
1.7.1
maintainer Applied
#1 lore raw

From: Daniel Lezcano <[email protected]>
Date: Wed, 30 Mar 2011 11:40:35 +0200

Quoted 6 lines

From: Daniel Lezcano <[email protected]>

In case the device where is coming from the packet has TSO enabled, we should not check the mtu size value as this one could be bigger than the expected value.

Quoted 8 lines

This is the case for the macvlan driver when the lower device has TSO enabled. The macvlan inherit this feature and forward the packets without fragmenting them. Then the packets go through dev_forward_skb and are dropped. This patch fix this by checking TSO is not enabled when we want to check the mtu size.

Applied.