diff options
Diffstat (limited to 'net/core/dev.c')
| -rw-r--r-- | net/core/dev.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 563ddc28139d..3da9fb06d47a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -1454,6 +1454,27 @@ static inline void net_timestamp_check(struct sk_buff *skb) | |||
| 1454 | __net_timestamp(skb); | 1454 | __net_timestamp(skb); |
| 1455 | } | 1455 | } |
| 1456 | 1456 | ||
| 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 | |||
| 1457 | /** | 1478 | /** |
| 1458 | * dev_forward_skb - loopback an skb to another netif | 1479 | * dev_forward_skb - loopback an skb to another netif |
| 1459 | * | 1480 | * |
| @@ -1477,8 +1498,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) | |||
| 1477 | skb_orphan(skb); | 1498 | skb_orphan(skb); |
| 1478 | nf_reset(skb); | 1499 | nf_reset(skb); |
| 1479 | 1500 | ||
| 1480 | if (unlikely(!(dev->flags & IFF_UP) || | 1501 | if (unlikely(!is_skb_forwardable(dev, skb))) { |
| 1481 | (skb->len > (dev->mtu + dev->hard_header_len + VLAN_HLEN)))) { | ||
| 1482 | atomic_long_inc(&dev->rx_dropped); | 1502 | atomic_long_inc(&dev->rx_dropped); |
| 1483 | kfree_skb(skb); | 1503 | kfree_skb(skb); |
| 1484 | return NET_RX_DROP; | 1504 | return NET_RX_DROP; |
