diff options
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 563ddc28139..956d3b006e8 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; |
@@ -2071,7 +2091,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, | |||
2071 | u32 features; | 2091 | u32 features; |
2072 | 2092 | ||
2073 | /* | 2093 | /* |
2074 | * If device doesnt need skb->dst, release it right now while | 2094 | * If device doesn't need skb->dst, release it right now while |
2075 | * its hot in this cpu cache | 2095 | * its hot in this cpu cache |
2076 | */ | 2096 | */ |
2077 | if (dev->priv_flags & IFF_XMIT_DST_RELEASE) | 2097 | if (dev->priv_flags & IFF_XMIT_DST_RELEASE) |
@@ -2131,7 +2151,7 @@ gso: | |||
2131 | nskb->next = NULL; | 2151 | nskb->next = NULL; |
2132 | 2152 | ||
2133 | /* | 2153 | /* |
2134 | * If device doesnt need nskb->dst, release it right now while | 2154 | * If device doesn't need nskb->dst, release it right now while |
2135 | * its hot in this cpu cache | 2155 | * its hot in this cpu cache |
2136 | */ | 2156 | */ |
2137 | if (dev->priv_flags & IFF_XMIT_DST_RELEASE) | 2157 | if (dev->priv_flags & IFF_XMIT_DST_RELEASE) |
@@ -2950,8 +2970,8 @@ EXPORT_SYMBOL_GPL(br_fdb_test_addr_hook); | |||
2950 | * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions | 2970 | * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions |
2951 | * a compare and 2 stores extra right now if we dont have it on | 2971 | * a compare and 2 stores extra right now if we dont have it on |
2952 | * but have CONFIG_NET_CLS_ACT | 2972 | * but have CONFIG_NET_CLS_ACT |
2953 | * NOTE: This doesnt stop any functionality; if you dont have | 2973 | * NOTE: This doesn't stop any functionality; if you dont have |
2954 | * the ingress scheduler, you just cant add policies on ingress. | 2974 | * the ingress scheduler, you just can't add policies on ingress. |
2955 | * | 2975 | * |
2956 | */ | 2976 | */ |
2957 | static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq) | 2977 | static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq) |
@@ -3780,7 +3800,7 @@ static void net_rx_action(struct softirq_action *h) | |||
3780 | * with netpoll's poll_napi(). Only the entity which | 3800 | * with netpoll's poll_napi(). Only the entity which |
3781 | * obtains the lock and sees NAPI_STATE_SCHED set will | 3801 | * obtains the lock and sees NAPI_STATE_SCHED set will |
3782 | * actually make the ->poll() call. Therefore we avoid | 3802 | * actually make the ->poll() call. Therefore we avoid |
3783 | * accidently calling ->poll() when NAPI is not scheduled. | 3803 | * accidentally calling ->poll() when NAPI is not scheduled. |
3784 | */ | 3804 | */ |
3785 | work = 0; | 3805 | work = 0; |
3786 | if (test_bit(NAPI_STATE_SCHED, &n->state)) { | 3806 | if (test_bit(NAPI_STATE_SCHED, &n->state)) { |
@@ -6316,7 +6336,7 @@ static void __net_exit default_device_exit(struct net *net) | |||
6316 | if (dev->rtnl_link_ops) | 6336 | if (dev->rtnl_link_ops) |
6317 | continue; | 6337 | continue; |
6318 | 6338 | ||
6319 | /* Push remaing network devices to init_net */ | 6339 | /* Push remaining network devices to init_net */ |
6320 | snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); | 6340 | snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); |
6321 | err = dev_change_net_namespace(dev, &init_net, fb_name); | 6341 | err = dev_change_net_namespace(dev, &init_net, fb_name); |
6322 | if (err) { | 6342 | if (err) { |