Skip to content

Commit 79b569f

Browse files
dlezcanodavem330
authored andcommitted
netdev: fix mtu check when TSO is enabled
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. Signed-off-by: Daniel Lezcano <[email protected]> Acked-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7a635ea commit 79b569f

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

net/core/dev.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,27 @@ static inline void net_timestamp_check(struct sk_buff *skb)
14541454
__net_timestamp(skb);
14551455
}
14561456

1457+
static inline bool is_skb_forwardable(struct net_device *dev,
1458+
struct sk_buff *skb)
1459+
{
1460+
unsigned int len;
1461+
1462+
if (!(dev->flags & IFF_UP))
1463+
return false;
1464+
1465+
len = dev->mtu + dev->hard_header_len + VLAN_HLEN;
1466+
if (skb->len <= len)
1467+
return true;
1468+
1469+
/* if TSO is enabled, we don't care about the length as the packet
1470+
* could be forwarded without being segmented before
1471+
*/
1472+
if (skb_is_gso(skb))
1473+
return true;
1474+
1475+
return false;
1476+
}
1477+
14571478
/**
14581479
* dev_forward_skb - loopback an skb to another netif
14591480
*
@@ -1477,8 +1498,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
14771498
skb_orphan(skb);
14781499
nf_reset(skb);
14791500

1480-
if (unlikely(!(dev->flags & IFF_UP) ||
1481-
(skb->len > (dev->mtu + dev->hard_header_len + VLAN_HLEN)))) {
1501+
if (unlikely(!is_skb_forwardable(dev, skb))) {
14821502
atomic_long_inc(&dev->rx_dropped);
14831503
kfree_skb(skb);
14841504
return NET_RX_DROP;

0 commit comments

Comments
 (0)