diff options
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 160 |
1 files changed, 32 insertions, 128 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 29101c98399f..0921609dfa81 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2403,28 +2403,6 @@ void netif_schedule_queue(struct netdev_queue *txq) | |||
2403 | } | 2403 | } |
2404 | EXPORT_SYMBOL(netif_schedule_queue); | 2404 | EXPORT_SYMBOL(netif_schedule_queue); |
2405 | 2405 | ||
2406 | /** | ||
2407 | * netif_wake_subqueue - allow sending packets on subqueue | ||
2408 | * @dev: network device | ||
2409 | * @queue_index: sub queue index | ||
2410 | * | ||
2411 | * Resume individual transmit queue of a device with multiple transmit queues. | ||
2412 | */ | ||
2413 | void netif_wake_subqueue(struct net_device *dev, u16 queue_index) | ||
2414 | { | ||
2415 | struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index); | ||
2416 | |||
2417 | if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state)) { | ||
2418 | struct Qdisc *q; | ||
2419 | |||
2420 | rcu_read_lock(); | ||
2421 | q = rcu_dereference(txq->qdisc); | ||
2422 | __netif_schedule(q); | ||
2423 | rcu_read_unlock(); | ||
2424 | } | ||
2425 | } | ||
2426 | EXPORT_SYMBOL(netif_wake_subqueue); | ||
2427 | |||
2428 | void netif_tx_wake_queue(struct netdev_queue *dev_queue) | 2406 | void netif_tx_wake_queue(struct netdev_queue *dev_queue) |
2429 | { | 2407 | { |
2430 | if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state)) { | 2408 | if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state)) { |
@@ -2654,9 +2632,10 @@ EXPORT_SYMBOL(skb_mac_gso_segment); | |||
2654 | static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path) | 2632 | static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path) |
2655 | { | 2633 | { |
2656 | if (tx_path) | 2634 | if (tx_path) |
2657 | return skb->ip_summed != CHECKSUM_PARTIAL; | 2635 | return skb->ip_summed != CHECKSUM_PARTIAL && |
2658 | else | 2636 | skb->ip_summed != CHECKSUM_NONE; |
2659 | return skb->ip_summed == CHECKSUM_NONE; | 2637 | |
2638 | return skb->ip_summed == CHECKSUM_NONE; | ||
2660 | } | 2639 | } |
2661 | 2640 | ||
2662 | /** | 2641 | /** |
@@ -2675,11 +2654,12 @@ static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path) | |||
2675 | struct sk_buff *__skb_gso_segment(struct sk_buff *skb, | 2654 | struct sk_buff *__skb_gso_segment(struct sk_buff *skb, |
2676 | netdev_features_t features, bool tx_path) | 2655 | netdev_features_t features, bool tx_path) |
2677 | { | 2656 | { |
2657 | struct sk_buff *segs; | ||
2658 | |||
2678 | if (unlikely(skb_needs_check(skb, tx_path))) { | 2659 | if (unlikely(skb_needs_check(skb, tx_path))) { |
2679 | int err; | 2660 | int err; |
2680 | 2661 | ||
2681 | skb_warn_bad_offload(skb); | 2662 | /* We're going to init ->check field in TCP or UDP header */ |
2682 | |||
2683 | err = skb_cow_head(skb, 0); | 2663 | err = skb_cow_head(skb, 0); |
2684 | if (err < 0) | 2664 | if (err < 0) |
2685 | return ERR_PTR(err); | 2665 | return ERR_PTR(err); |
@@ -2707,7 +2687,12 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb, | |||
2707 | skb_reset_mac_header(skb); | 2687 | skb_reset_mac_header(skb); |
2708 | skb_reset_mac_len(skb); | 2688 | skb_reset_mac_len(skb); |
2709 | 2689 | ||
2710 | return skb_mac_gso_segment(skb, features); | 2690 | segs = skb_mac_gso_segment(skb, features); |
2691 | |||
2692 | if (unlikely(skb_needs_check(skb, tx_path))) | ||
2693 | skb_warn_bad_offload(skb); | ||
2694 | |||
2695 | return segs; | ||
2711 | } | 2696 | } |
2712 | EXPORT_SYMBOL(__skb_gso_segment); | 2697 | EXPORT_SYMBOL(__skb_gso_segment); |
2713 | 2698 | ||
@@ -3148,9 +3133,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev) | |||
3148 | if (!cl) | 3133 | if (!cl) |
3149 | return skb; | 3134 | return skb; |
3150 | 3135 | ||
3151 | /* skb->tc_verd and qdisc_skb_cb(skb)->pkt_len were already set | 3136 | /* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */ |
3152 | * earlier by the caller. | ||
3153 | */ | ||
3154 | qdisc_bstats_cpu_update(cl->q, skb); | 3137 | qdisc_bstats_cpu_update(cl->q, skb); |
3155 | 3138 | ||
3156 | switch (tc_classify(skb, cl, &cl_res, false)) { | 3139 | switch (tc_classify(skb, cl, &cl_res, false)) { |
@@ -3315,7 +3298,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv) | |||
3315 | 3298 | ||
3316 | qdisc_pkt_len_init(skb); | 3299 | qdisc_pkt_len_init(skb); |
3317 | #ifdef CONFIG_NET_CLS_ACT | 3300 | #ifdef CONFIG_NET_CLS_ACT |
3318 | skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_EGRESS); | 3301 | skb->tc_at_ingress = 0; |
3319 | # ifdef CONFIG_NET_EGRESS | 3302 | # ifdef CONFIG_NET_EGRESS |
3320 | if (static_key_false(&egress_needed)) { | 3303 | if (static_key_false(&egress_needed)) { |
3321 | skb = sch_handle_egress(skb, &rc, dev); | 3304 | skb = sch_handle_egress(skb, &rc, dev); |
@@ -3422,7 +3405,11 @@ EXPORT_SYMBOL(netdev_max_backlog); | |||
3422 | 3405 | ||
3423 | int netdev_tstamp_prequeue __read_mostly = 1; | 3406 | int netdev_tstamp_prequeue __read_mostly = 1; |
3424 | int netdev_budget __read_mostly = 300; | 3407 | int netdev_budget __read_mostly = 300; |
3425 | int weight_p __read_mostly = 64; /* old backlog weight */ | 3408 | int weight_p __read_mostly = 64; /* old backlog weight */ |
3409 | int dev_weight_rx_bias __read_mostly = 1; /* bias for backlog weight */ | ||
3410 | int dev_weight_tx_bias __read_mostly = 1; /* bias for output_queue quota */ | ||
3411 | int dev_rx_weight __read_mostly = 64; | ||
3412 | int dev_tx_weight __read_mostly = 64; | ||
3426 | 3413 | ||
3427 | /* Called with irq disabled */ | 3414 | /* Called with irq disabled */ |
3428 | static inline void ____napi_schedule(struct softnet_data *sd, | 3415 | static inline void ____napi_schedule(struct softnet_data *sd, |
@@ -3911,7 +3898,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret, | |||
3911 | } | 3898 | } |
3912 | 3899 | ||
3913 | qdisc_skb_cb(skb)->pkt_len = skb->len; | 3900 | qdisc_skb_cb(skb)->pkt_len = skb->len; |
3914 | skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_INGRESS); | 3901 | skb->tc_at_ingress = 1; |
3915 | qdisc_bstats_cpu_update(cl->q, skb); | 3902 | qdisc_bstats_cpu_update(cl->q, skb); |
3916 | 3903 | ||
3917 | switch (tc_classify(skb, cl, &cl_res, false)) { | 3904 | switch (tc_classify(skb, cl, &cl_res, false)) { |
@@ -3976,9 +3963,7 @@ int netdev_rx_handler_register(struct net_device *dev, | |||
3976 | rx_handler_func_t *rx_handler, | 3963 | rx_handler_func_t *rx_handler, |
3977 | void *rx_handler_data) | 3964 | void *rx_handler_data) |
3978 | { | 3965 | { |
3979 | ASSERT_RTNL(); | 3966 | if (netdev_is_rx_handler_busy(dev)) |
3980 | |||
3981 | if (dev->rx_handler) | ||
3982 | return -EBUSY; | 3967 | return -EBUSY; |
3983 | 3968 | ||
3984 | /* Note: rx_handler_data must be set before rx_handler */ | 3969 | /* Note: rx_handler_data must be set before rx_handler */ |
@@ -4084,12 +4069,8 @@ another_round: | |||
4084 | goto out; | 4069 | goto out; |
4085 | } | 4070 | } |
4086 | 4071 | ||
4087 | #ifdef CONFIG_NET_CLS_ACT | 4072 | if (skb_skip_tc_classify(skb)) |
4088 | if (skb->tc_verd & TC_NCLS) { | 4073 | goto skip_classify; |
4089 | skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); | ||
4090 | goto ncls; | ||
4091 | } | ||
4092 | #endif | ||
4093 | 4074 | ||
4094 | if (pfmemalloc) | 4075 | if (pfmemalloc) |
4095 | goto skip_taps; | 4076 | goto skip_taps; |
@@ -4117,10 +4098,8 @@ skip_taps: | |||
4117 | goto out; | 4098 | goto out; |
4118 | } | 4099 | } |
4119 | #endif | 4100 | #endif |
4120 | #ifdef CONFIG_NET_CLS_ACT | 4101 | skb_reset_tc(skb); |
4121 | skb->tc_verd = 0; | 4102 | skip_classify: |
4122 | ncls: | ||
4123 | #endif | ||
4124 | if (pfmemalloc && !skb_pfmemalloc_protocol(skb)) | 4103 | if (pfmemalloc && !skb_pfmemalloc_protocol(skb)) |
4125 | goto drop; | 4104 | goto drop; |
4126 | 4105 | ||
@@ -4616,6 +4595,7 @@ static gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb) | |||
4616 | case GRO_MERGED_FREE: | 4595 | case GRO_MERGED_FREE: |
4617 | if (NAPI_GRO_CB(skb)->free == NAPI_GRO_FREE_STOLEN_HEAD) { | 4596 | if (NAPI_GRO_CB(skb)->free == NAPI_GRO_FREE_STOLEN_HEAD) { |
4618 | skb_dst_drop(skb); | 4597 | skb_dst_drop(skb); |
4598 | secpath_reset(skb); | ||
4619 | kmem_cache_free(skbuff_head_cache, skb); | 4599 | kmem_cache_free(skbuff_head_cache, skb); |
4620 | } else { | 4600 | } else { |
4621 | __kfree_skb(skb); | 4601 | __kfree_skb(skb); |
@@ -4656,6 +4636,7 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) | |||
4656 | skb->encapsulation = 0; | 4636 | skb->encapsulation = 0; |
4657 | skb_shinfo(skb)->gso_type = 0; | 4637 | skb_shinfo(skb)->gso_type = 0; |
4658 | skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); | 4638 | skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); |
4639 | secpath_reset(skb); | ||
4659 | 4640 | ||
4660 | napi->skb = skb; | 4641 | napi->skb = skb; |
4661 | } | 4642 | } |
@@ -4830,7 +4811,7 @@ static int process_backlog(struct napi_struct *napi, int quota) | |||
4830 | net_rps_action_and_irq_enable(sd); | 4811 | net_rps_action_and_irq_enable(sd); |
4831 | } | 4812 | } |
4832 | 4813 | ||
4833 | napi->weight = weight_p; | 4814 | napi->weight = dev_rx_weight; |
4834 | while (again) { | 4815 | while (again) { |
4835 | struct sk_buff *skb; | 4816 | struct sk_buff *skb; |
4836 | 4817 | ||
@@ -4897,23 +4878,6 @@ void __napi_schedule_irqoff(struct napi_struct *n) | |||
4897 | } | 4878 | } |
4898 | EXPORT_SYMBOL(__napi_schedule_irqoff); | 4879 | EXPORT_SYMBOL(__napi_schedule_irqoff); |
4899 | 4880 | ||
4900 | bool __napi_complete(struct napi_struct *n) | ||
4901 | { | ||
4902 | BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); | ||
4903 | |||
4904 | /* Some drivers call us directly, instead of calling | ||
4905 | * napi_complete_done(). | ||
4906 | */ | ||
4907 | if (unlikely(test_bit(NAPI_STATE_IN_BUSY_POLL, &n->state))) | ||
4908 | return false; | ||
4909 | |||
4910 | list_del_init(&n->poll_list); | ||
4911 | smp_mb__before_atomic(); | ||
4912 | clear_bit(NAPI_STATE_SCHED, &n->state); | ||
4913 | return true; | ||
4914 | } | ||
4915 | EXPORT_SYMBOL(__napi_complete); | ||
4916 | |||
4917 | bool napi_complete_done(struct napi_struct *n, int work_done) | 4881 | bool napi_complete_done(struct napi_struct *n, int work_done) |
4918 | { | 4882 | { |
4919 | unsigned long flags; | 4883 | unsigned long flags; |
@@ -4940,14 +4904,13 @@ bool napi_complete_done(struct napi_struct *n, int work_done) | |||
4940 | else | 4904 | else |
4941 | napi_gro_flush(n, false); | 4905 | napi_gro_flush(n, false); |
4942 | } | 4906 | } |
4943 | if (likely(list_empty(&n->poll_list))) { | 4907 | if (unlikely(!list_empty(&n->poll_list))) { |
4944 | WARN_ON_ONCE(!test_and_clear_bit(NAPI_STATE_SCHED, &n->state)); | ||
4945 | } else { | ||
4946 | /* If n->poll_list is not empty, we need to mask irqs */ | 4908 | /* If n->poll_list is not empty, we need to mask irqs */ |
4947 | local_irq_save(flags); | 4909 | local_irq_save(flags); |
4948 | __napi_complete(n); | 4910 | list_del_init(&n->poll_list); |
4949 | local_irq_restore(flags); | 4911 | local_irq_restore(flags); |
4950 | } | 4912 | } |
4913 | WARN_ON_ONCE(!test_and_clear_bit(NAPI_STATE_SCHED, &n->state)); | ||
4951 | return true; | 4914 | return true; |
4952 | } | 4915 | } |
4953 | EXPORT_SYMBOL(napi_complete_done); | 4916 | EXPORT_SYMBOL(napi_complete_done); |
@@ -4993,7 +4956,6 @@ bool sk_busy_loop(struct sock *sk, int nonblock) | |||
4993 | { | 4956 | { |
4994 | unsigned long end_time = !nonblock ? sk_busy_loop_end_time(sk) : 0; | 4957 | unsigned long end_time = !nonblock ? sk_busy_loop_end_time(sk) : 0; |
4995 | int (*napi_poll)(struct napi_struct *napi, int budget); | 4958 | int (*napi_poll)(struct napi_struct *napi, int budget); |
4996 | int (*busy_poll)(struct napi_struct *dev); | ||
4997 | void *have_poll_lock = NULL; | 4959 | void *have_poll_lock = NULL; |
4998 | struct napi_struct *napi; | 4960 | struct napi_struct *napi; |
4999 | int rc; | 4961 | int rc; |
@@ -5008,17 +4970,10 @@ restart: | |||
5008 | if (!napi) | 4970 | if (!napi) |
5009 | goto out; | 4971 | goto out; |
5010 | 4972 | ||
5011 | /* Note: ndo_busy_poll method is optional in linux-4.5 */ | ||
5012 | busy_poll = napi->dev->netdev_ops->ndo_busy_poll; | ||
5013 | |||
5014 | preempt_disable(); | 4973 | preempt_disable(); |
5015 | for (;;) { | 4974 | for (;;) { |
5016 | rc = 0; | 4975 | rc = 0; |
5017 | local_bh_disable(); | 4976 | local_bh_disable(); |
5018 | if (busy_poll) { | ||
5019 | rc = busy_poll(napi); | ||
5020 | goto count; | ||
5021 | } | ||
5022 | if (!napi_poll) { | 4977 | if (!napi_poll) { |
5023 | unsigned long val = READ_ONCE(napi->state); | 4978 | unsigned long val = READ_ONCE(napi->state); |
5024 | 4979 | ||
@@ -6151,50 +6106,6 @@ void netdev_lower_state_changed(struct net_device *lower_dev, | |||
6151 | } | 6106 | } |
6152 | EXPORT_SYMBOL(netdev_lower_state_changed); | 6107 | EXPORT_SYMBOL(netdev_lower_state_changed); |
6153 | 6108 | ||
6154 | int netdev_default_l2upper_neigh_construct(struct net_device *dev, | ||
6155 | struct neighbour *n) | ||
6156 | { | ||
6157 | struct net_device *lower_dev, *stop_dev; | ||
6158 | struct list_head *iter; | ||
6159 | int err; | ||
6160 | |||
6161 | netdev_for_each_lower_dev(dev, lower_dev, iter) { | ||
6162 | if (!lower_dev->netdev_ops->ndo_neigh_construct) | ||
6163 | continue; | ||
6164 | err = lower_dev->netdev_ops->ndo_neigh_construct(lower_dev, n); | ||
6165 | if (err) { | ||
6166 | stop_dev = lower_dev; | ||
6167 | goto rollback; | ||
6168 | } | ||
6169 | } | ||
6170 | return 0; | ||
6171 | |||
6172 | rollback: | ||
6173 | netdev_for_each_lower_dev(dev, lower_dev, iter) { | ||
6174 | if (lower_dev == stop_dev) | ||
6175 | break; | ||
6176 | if (!lower_dev->netdev_ops->ndo_neigh_destroy) | ||
6177 | continue; | ||
6178 | lower_dev->netdev_ops->ndo_neigh_destroy(lower_dev, n); | ||
6179 | } | ||
6180 | return err; | ||
6181 | } | ||
6182 | EXPORT_SYMBOL_GPL(netdev_default_l2upper_neigh_construct); | ||
6183 | |||
6184 | void netdev_default_l2upper_neigh_destroy(struct net_device *dev, | ||
6185 | struct neighbour *n) | ||
6186 | { | ||
6187 | struct net_device *lower_dev; | ||
6188 | struct list_head *iter; | ||
6189 | |||
6190 | netdev_for_each_lower_dev(dev, lower_dev, iter) { | ||
6191 | if (!lower_dev->netdev_ops->ndo_neigh_destroy) | ||
6192 | continue; | ||
6193 | lower_dev->netdev_ops->ndo_neigh_destroy(lower_dev, n); | ||
6194 | } | ||
6195 | } | ||
6196 | EXPORT_SYMBOL_GPL(netdev_default_l2upper_neigh_destroy); | ||
6197 | |||
6198 | static void dev_change_rx_flags(struct net_device *dev, int flags) | 6109 | static void dev_change_rx_flags(struct net_device *dev, int flags) |
6199 | { | 6110 | { |
6200 | const struct net_device_ops *ops = dev->netdev_ops; | 6111 | const struct net_device_ops *ops = dev->netdev_ops; |
@@ -6971,13 +6882,6 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, | |||
6971 | features &= ~dev->gso_partial_features; | 6882 | features &= ~dev->gso_partial_features; |
6972 | } | 6883 | } |
6973 | 6884 | ||
6974 | #ifdef CONFIG_NET_RX_BUSY_POLL | ||
6975 | if (dev->netdev_ops->ndo_busy_poll) | ||
6976 | features |= NETIF_F_BUSY_POLL; | ||
6977 | else | ||
6978 | #endif | ||
6979 | features &= ~NETIF_F_BUSY_POLL; | ||
6980 | |||
6981 | return features; | 6885 | return features; |
6982 | } | 6886 | } |
6983 | 6887 | ||