diff options
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 103 |
1 files changed, 89 insertions, 14 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 14dac0654f28..9abc503b19b7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2284,7 +2284,7 @@ EXPORT_SYMBOL(skb_checksum_help); | |||
2284 | __be16 skb_network_protocol(struct sk_buff *skb, int *depth) | 2284 | __be16 skb_network_protocol(struct sk_buff *skb, int *depth) |
2285 | { | 2285 | { |
2286 | __be16 type = skb->protocol; | 2286 | __be16 type = skb->protocol; |
2287 | int vlan_depth = ETH_HLEN; | 2287 | int vlan_depth = skb->mac_len; |
2288 | 2288 | ||
2289 | /* Tunnel gso handlers can set protocol to ethernet. */ | 2289 | /* Tunnel gso handlers can set protocol to ethernet. */ |
2290 | if (type == htons(ETH_P_TEB)) { | 2290 | if (type == htons(ETH_P_TEB)) { |
@@ -2418,7 +2418,7 @@ EXPORT_SYMBOL(netdev_rx_csum_fault); | |||
2418 | * 2. No high memory really exists on this machine. | 2418 | * 2. No high memory really exists on this machine. |
2419 | */ | 2419 | */ |
2420 | 2420 | ||
2421 | static int illegal_highdma(const struct net_device *dev, struct sk_buff *skb) | 2421 | static int illegal_highdma(struct net_device *dev, struct sk_buff *skb) |
2422 | { | 2422 | { |
2423 | #ifdef CONFIG_HIGHMEM | 2423 | #ifdef CONFIG_HIGHMEM |
2424 | int i; | 2424 | int i; |
@@ -2493,38 +2493,36 @@ static int dev_gso_segment(struct sk_buff *skb, netdev_features_t features) | |||
2493 | } | 2493 | } |
2494 | 2494 | ||
2495 | static netdev_features_t harmonize_features(struct sk_buff *skb, | 2495 | static netdev_features_t harmonize_features(struct sk_buff *skb, |
2496 | const struct net_device *dev, | 2496 | netdev_features_t features) |
2497 | netdev_features_t features) | ||
2498 | { | 2497 | { |
2499 | int tmp; | 2498 | int tmp; |
2500 | 2499 | ||
2501 | if (skb->ip_summed != CHECKSUM_NONE && | 2500 | if (skb->ip_summed != CHECKSUM_NONE && |
2502 | !can_checksum_protocol(features, skb_network_protocol(skb, &tmp))) { | 2501 | !can_checksum_protocol(features, skb_network_protocol(skb, &tmp))) { |
2503 | features &= ~NETIF_F_ALL_CSUM; | 2502 | features &= ~NETIF_F_ALL_CSUM; |
2504 | } else if (illegal_highdma(dev, skb)) { | 2503 | } else if (illegal_highdma(skb->dev, skb)) { |
2505 | features &= ~NETIF_F_SG; | 2504 | features &= ~NETIF_F_SG; |
2506 | } | 2505 | } |
2507 | 2506 | ||
2508 | return features; | 2507 | return features; |
2509 | } | 2508 | } |
2510 | 2509 | ||
2511 | netdev_features_t netif_skb_dev_features(struct sk_buff *skb, | 2510 | netdev_features_t netif_skb_features(struct sk_buff *skb) |
2512 | const struct net_device *dev) | ||
2513 | { | 2511 | { |
2514 | __be16 protocol = skb->protocol; | 2512 | __be16 protocol = skb->protocol; |
2515 | netdev_features_t features = dev->features; | 2513 | netdev_features_t features = skb->dev->features; |
2516 | 2514 | ||
2517 | if (skb_shinfo(skb)->gso_segs > dev->gso_max_segs) | 2515 | if (skb_shinfo(skb)->gso_segs > skb->dev->gso_max_segs) |
2518 | features &= ~NETIF_F_GSO_MASK; | 2516 | features &= ~NETIF_F_GSO_MASK; |
2519 | 2517 | ||
2520 | if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { | 2518 | if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { |
2521 | struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; | 2519 | struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; |
2522 | protocol = veh->h_vlan_encapsulated_proto; | 2520 | protocol = veh->h_vlan_encapsulated_proto; |
2523 | } else if (!vlan_tx_tag_present(skb)) { | 2521 | } else if (!vlan_tx_tag_present(skb)) { |
2524 | return harmonize_features(skb, dev, features); | 2522 | return harmonize_features(skb, features); |
2525 | } | 2523 | } |
2526 | 2524 | ||
2527 | features &= (dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | | 2525 | features &= (skb->dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | |
2528 | NETIF_F_HW_VLAN_STAG_TX); | 2526 | NETIF_F_HW_VLAN_STAG_TX); |
2529 | 2527 | ||
2530 | if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) | 2528 | if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) |
@@ -2532,9 +2530,9 @@ netdev_features_t netif_skb_dev_features(struct sk_buff *skb, | |||
2532 | NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX | | 2530 | NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX | |
2533 | NETIF_F_HW_VLAN_STAG_TX; | 2531 | NETIF_F_HW_VLAN_STAG_TX; |
2534 | 2532 | ||
2535 | return harmonize_features(skb, dev, features); | 2533 | return harmonize_features(skb, features); |
2536 | } | 2534 | } |
2537 | EXPORT_SYMBOL(netif_skb_dev_features); | 2535 | EXPORT_SYMBOL(netif_skb_features); |
2538 | 2536 | ||
2539 | int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, | 2537 | int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, |
2540 | struct netdev_queue *txq) | 2538 | struct netdev_queue *txq) |
@@ -3953,6 +3951,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff | |||
3953 | } | 3951 | } |
3954 | NAPI_GRO_CB(skb)->count = 1; | 3952 | NAPI_GRO_CB(skb)->count = 1; |
3955 | NAPI_GRO_CB(skb)->age = jiffies; | 3953 | NAPI_GRO_CB(skb)->age = jiffies; |
3954 | NAPI_GRO_CB(skb)->last = skb; | ||
3956 | skb_shinfo(skb)->gso_size = skb_gro_len(skb); | 3955 | skb_shinfo(skb)->gso_size = skb_gro_len(skb); |
3957 | skb->next = napi->gro_list; | 3956 | skb->next = napi->gro_list; |
3958 | napi->gro_list = skb; | 3957 | napi->gro_list = skb; |
@@ -4543,6 +4542,32 @@ void *netdev_adjacent_get_private(struct list_head *adj_list) | |||
4543 | EXPORT_SYMBOL(netdev_adjacent_get_private); | 4542 | EXPORT_SYMBOL(netdev_adjacent_get_private); |
4544 | 4543 | ||
4545 | /** | 4544 | /** |
4545 | * netdev_upper_get_next_dev_rcu - Get the next dev from upper list | ||
4546 | * @dev: device | ||
4547 | * @iter: list_head ** of the current position | ||
4548 | * | ||
4549 | * Gets the next device from the dev's upper list, starting from iter | ||
4550 | * position. The caller must hold RCU read lock. | ||
4551 | */ | ||
4552 | struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev, | ||
4553 | struct list_head **iter) | ||
4554 | { | ||
4555 | struct netdev_adjacent *upper; | ||
4556 | |||
4557 | WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_rtnl_is_held()); | ||
4558 | |||
4559 | upper = list_entry_rcu((*iter)->next, struct netdev_adjacent, list); | ||
4560 | |||
4561 | if (&upper->list == &dev->adj_list.upper) | ||
4562 | return NULL; | ||
4563 | |||
4564 | *iter = &upper->list; | ||
4565 | |||
4566 | return upper->dev; | ||
4567 | } | ||
4568 | EXPORT_SYMBOL(netdev_upper_get_next_dev_rcu); | ||
4569 | |||
4570 | /** | ||
4546 | * netdev_all_upper_get_next_dev_rcu - Get the next dev from upper list | 4571 | * netdev_all_upper_get_next_dev_rcu - Get the next dev from upper list |
4547 | * @dev: device | 4572 | * @dev: device |
4548 | * @iter: list_head ** of the current position | 4573 | * @iter: list_head ** of the current position |
@@ -4624,6 +4649,32 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev, | |||
4624 | EXPORT_SYMBOL(netdev_lower_get_next_private_rcu); | 4649 | EXPORT_SYMBOL(netdev_lower_get_next_private_rcu); |
4625 | 4650 | ||
4626 | /** | 4651 | /** |
4652 | * netdev_lower_get_next - Get the next device from the lower neighbour | ||
4653 | * list | ||
4654 | * @dev: device | ||
4655 | * @iter: list_head ** of the current position | ||
4656 | * | ||
4657 | * Gets the next netdev_adjacent from the dev's lower neighbour | ||
4658 | * list, starting from iter position. The caller must hold RTNL lock or | ||
4659 | * its own locking that guarantees that the neighbour lower | ||
4660 | * list will remain unchainged. | ||
4661 | */ | ||
4662 | void *netdev_lower_get_next(struct net_device *dev, struct list_head **iter) | ||
4663 | { | ||
4664 | struct netdev_adjacent *lower; | ||
4665 | |||
4666 | lower = list_entry((*iter)->next, struct netdev_adjacent, list); | ||
4667 | |||
4668 | if (&lower->list == &dev->adj_list.lower) | ||
4669 | return NULL; | ||
4670 | |||
4671 | *iter = &lower->list; | ||
4672 | |||
4673 | return lower->dev; | ||
4674 | } | ||
4675 | EXPORT_SYMBOL(netdev_lower_get_next); | ||
4676 | |||
4677 | /** | ||
4627 | * netdev_lower_get_first_private_rcu - Get the first ->private from the | 4678 | * netdev_lower_get_first_private_rcu - Get the first ->private from the |
4628 | * lower neighbour list, RCU | 4679 | * lower neighbour list, RCU |
4629 | * variant | 4680 | * variant |
@@ -5073,6 +5124,30 @@ void *netdev_lower_dev_get_private(struct net_device *dev, | |||
5073 | } | 5124 | } |
5074 | EXPORT_SYMBOL(netdev_lower_dev_get_private); | 5125 | EXPORT_SYMBOL(netdev_lower_dev_get_private); |
5075 | 5126 | ||
5127 | |||
5128 | int dev_get_nest_level(struct net_device *dev, | ||
5129 | bool (*type_check)(struct net_device *dev)) | ||
5130 | { | ||
5131 | struct net_device *lower = NULL; | ||
5132 | struct list_head *iter; | ||
5133 | int max_nest = -1; | ||
5134 | int nest; | ||
5135 | |||
5136 | ASSERT_RTNL(); | ||
5137 | |||
5138 | netdev_for_each_lower_dev(dev, lower, iter) { | ||
5139 | nest = dev_get_nest_level(lower, type_check); | ||
5140 | if (max_nest < nest) | ||
5141 | max_nest = nest; | ||
5142 | } | ||
5143 | |||
5144 | if (type_check(dev)) | ||
5145 | max_nest++; | ||
5146 | |||
5147 | return max_nest; | ||
5148 | } | ||
5149 | EXPORT_SYMBOL(dev_get_nest_level); | ||
5150 | |||
5076 | static void dev_change_rx_flags(struct net_device *dev, int flags) | 5151 | static void dev_change_rx_flags(struct net_device *dev, int flags) |
5077 | { | 5152 | { |
5078 | const struct net_device_ops *ops = dev->netdev_ops; | 5153 | const struct net_device_ops *ops = dev->netdev_ops; |
@@ -5542,7 +5617,7 @@ static int dev_new_index(struct net *net) | |||
5542 | 5617 | ||
5543 | /* Delayed registration/unregisteration */ | 5618 | /* Delayed registration/unregisteration */ |
5544 | static LIST_HEAD(net_todo_list); | 5619 | static LIST_HEAD(net_todo_list); |
5545 | static DECLARE_WAIT_QUEUE_HEAD(netdev_unregistering_wq); | 5620 | DECLARE_WAIT_QUEUE_HEAD(netdev_unregistering_wq); |
5546 | 5621 | ||
5547 | static void net_set_todo(struct net_device *dev) | 5622 | static void net_set_todo(struct net_device *dev) |
5548 | { | 5623 | { |