aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c150
1 files changed, 88 insertions, 62 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 3da9fb06d47a..e95dc30110eb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1315,7 +1315,8 @@ void dev_disable_lro(struct net_device *dev)
1315 return; 1315 return;
1316 1316
1317 __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO); 1317 __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO);
1318 WARN_ON(dev->features & NETIF_F_LRO); 1318 if (unlikely(dev->features & NETIF_F_LRO))
1319 netdev_WARN(dev, "failed to disable LRO!\n");
1319} 1320}
1320EXPORT_SYMBOL(dev_disable_lro); 1321EXPORT_SYMBOL(dev_disable_lro);
1321 1322
@@ -2091,7 +2092,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2091 u32 features; 2092 u32 features;
2092 2093
2093 /* 2094 /*
2094 * If device doesnt need skb->dst, release it right now while 2095 * If device doesn't need skb->dst, release it right now while
2095 * its hot in this cpu cache 2096 * its hot in this cpu cache
2096 */ 2097 */
2097 if (dev->priv_flags & IFF_XMIT_DST_RELEASE) 2098 if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
@@ -2151,7 +2152,7 @@ gso:
2151 nskb->next = NULL; 2152 nskb->next = NULL;
2152 2153
2153 /* 2154 /*
2154 * If device doesnt need nskb->dst, release it right now while 2155 * If device doesn't need nskb->dst, release it right now while
2155 * its hot in this cpu cache 2156 * its hot in this cpu cache
2156 */ 2157 */
2157 if (dev->priv_flags & IFF_XMIT_DST_RELEASE) 2158 if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
@@ -2502,8 +2503,8 @@ static inline void ____napi_schedule(struct softnet_data *sd,
2502__u32 __skb_get_rxhash(struct sk_buff *skb) 2503__u32 __skb_get_rxhash(struct sk_buff *skb)
2503{ 2504{
2504 int nhoff, hash = 0, poff; 2505 int nhoff, hash = 0, poff;
2505 struct ipv6hdr *ip6; 2506 const struct ipv6hdr *ip6;
2506 struct iphdr *ip; 2507 const struct iphdr *ip;
2507 u8 ip_proto; 2508 u8 ip_proto;
2508 u32 addr1, addr2, ihl; 2509 u32 addr1, addr2, ihl;
2509 union { 2510 union {
@@ -2518,7 +2519,7 @@ __u32 __skb_get_rxhash(struct sk_buff *skb)
2518 if (!pskb_may_pull(skb, sizeof(*ip) + nhoff)) 2519 if (!pskb_may_pull(skb, sizeof(*ip) + nhoff))
2519 goto done; 2520 goto done;
2520 2521
2521 ip = (struct iphdr *) (skb->data + nhoff); 2522 ip = (const struct iphdr *) (skb->data + nhoff);
2522 if (ip->frag_off & htons(IP_MF | IP_OFFSET)) 2523 if (ip->frag_off & htons(IP_MF | IP_OFFSET))
2523 ip_proto = 0; 2524 ip_proto = 0;
2524 else 2525 else
@@ -2531,7 +2532,7 @@ __u32 __skb_get_rxhash(struct sk_buff *skb)
2531 if (!pskb_may_pull(skb, sizeof(*ip6) + nhoff)) 2532 if (!pskb_may_pull(skb, sizeof(*ip6) + nhoff))
2532 goto done; 2533 goto done;
2533 2534
2534 ip6 = (struct ipv6hdr *) (skb->data + nhoff); 2535 ip6 = (const struct ipv6hdr *) (skb->data + nhoff);
2535 ip_proto = ip6->nexthdr; 2536 ip_proto = ip6->nexthdr;
2536 addr1 = (__force u32) ip6->saddr.s6_addr32[3]; 2537 addr1 = (__force u32) ip6->saddr.s6_addr32[3];
2537 addr2 = (__force u32) ip6->daddr.s6_addr32[3]; 2538 addr2 = (__force u32) ip6->daddr.s6_addr32[3];
@@ -2970,8 +2971,8 @@ EXPORT_SYMBOL_GPL(br_fdb_test_addr_hook);
2970 * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions 2971 * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions
2971 * a compare and 2 stores extra right now if we dont have it on 2972 * a compare and 2 stores extra right now if we dont have it on
2972 * but have CONFIG_NET_CLS_ACT 2973 * but have CONFIG_NET_CLS_ACT
2973 * NOTE: This doesnt stop any functionality; if you dont have 2974 * NOTE: This doesn't stop any functionality; if you dont have
2974 * the ingress scheduler, you just cant add policies on ingress. 2975 * the ingress scheduler, you just can't add policies on ingress.
2975 * 2976 *
2976 */ 2977 */
2977static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq) 2978static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq)
@@ -3076,25 +3077,6 @@ void netdev_rx_handler_unregister(struct net_device *dev)
3076} 3077}
3077EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); 3078EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister);
3078 3079
3079static void vlan_on_bond_hook(struct sk_buff *skb)
3080{
3081 /*
3082 * Make sure ARP frames received on VLAN interfaces stacked on
3083 * bonding interfaces still make their way to any base bonding
3084 * device that may have registered for a specific ptype.
3085 */
3086 if (skb->dev->priv_flags & IFF_802_1Q_VLAN &&
3087 vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING &&
3088 skb->protocol == htons(ETH_P_ARP)) {
3089 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
3090
3091 if (!skb2)
3092 return;
3093 skb2->dev = vlan_dev_real_dev(skb->dev);
3094 netif_rx(skb2);
3095 }
3096}
3097
3098static int __netif_receive_skb(struct sk_buff *skb) 3080static int __netif_receive_skb(struct sk_buff *skb)
3099{ 3081{
3100 struct packet_type *ptype, *pt_prev; 3082 struct packet_type *ptype, *pt_prev;
@@ -3130,6 +3112,12 @@ another_round:
3130 3112
3131 __this_cpu_inc(softnet_data.processed); 3113 __this_cpu_inc(softnet_data.processed);
3132 3114
3115 if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) {
3116 skb = vlan_untag(skb);
3117 if (unlikely(!skb))
3118 goto out;
3119 }
3120
3133#ifdef CONFIG_NET_CLS_ACT 3121#ifdef CONFIG_NET_CLS_ACT
3134 if (skb->tc_verd & TC_NCLS) { 3122 if (skb->tc_verd & TC_NCLS) {
3135 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); 3123 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
@@ -3177,15 +3165,13 @@ ncls:
3177 ret = deliver_skb(skb, pt_prev, orig_dev); 3165 ret = deliver_skb(skb, pt_prev, orig_dev);
3178 pt_prev = NULL; 3166 pt_prev = NULL;
3179 } 3167 }
3180 if (vlan_hwaccel_do_receive(&skb)) { 3168 if (vlan_do_receive(&skb)) {
3181 ret = __netif_receive_skb(skb); 3169 ret = __netif_receive_skb(skb);
3182 goto out; 3170 goto out;
3183 } else if (unlikely(!skb)) 3171 } else if (unlikely(!skb))
3184 goto out; 3172 goto out;
3185 } 3173 }
3186 3174
3187 vlan_on_bond_hook(skb);
3188
3189 /* deliver only exact match when indicated */ 3175 /* deliver only exact match when indicated */
3190 null_or_dev = deliver_exact ? skb->dev : NULL; 3176 null_or_dev = deliver_exact ? skb->dev : NULL;
3191 3177
@@ -3800,7 +3786,7 @@ static void net_rx_action(struct softirq_action *h)
3800 * with netpoll's poll_napi(). Only the entity which 3786 * with netpoll's poll_napi(). Only the entity which
3801 * obtains the lock and sees NAPI_STATE_SCHED set will 3787 * obtains the lock and sees NAPI_STATE_SCHED set will
3802 * actually make the ->poll() call. Therefore we avoid 3788 * actually make the ->poll() call. Therefore we avoid
3803 * accidently calling ->poll() when NAPI is not scheduled. 3789 * accidentally calling ->poll() when NAPI is not scheduled.
3804 */ 3790 */
3805 work = 0; 3791 work = 0;
3806 if (test_bit(NAPI_STATE_SCHED, &n->state)) { 3792 if (test_bit(NAPI_STATE_SCHED, &n->state)) {
@@ -4510,6 +4496,30 @@ void dev_set_rx_mode(struct net_device *dev)
4510} 4496}
4511 4497
4512/** 4498/**
4499 * dev_ethtool_get_settings - call device's ethtool_ops::get_settings()
4500 * @dev: device
4501 * @cmd: memory area for ethtool_ops::get_settings() result
4502 *
4503 * The cmd arg is initialized properly (cleared and
4504 * ethtool_cmd::cmd field set to ETHTOOL_GSET).
4505 *
4506 * Return device's ethtool_ops::get_settings() result value or
4507 * -EOPNOTSUPP when device doesn't expose
4508 * ethtool_ops::get_settings() operation.
4509 */
4510int dev_ethtool_get_settings(struct net_device *dev,
4511 struct ethtool_cmd *cmd)
4512{
4513 if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings)
4514 return -EOPNOTSUPP;
4515
4516 memset(cmd, 0, sizeof(struct ethtool_cmd));
4517 cmd->cmd = ETHTOOL_GSET;
4518 return dev->ethtool_ops->get_settings(dev, cmd);
4519}
4520EXPORT_SYMBOL(dev_ethtool_get_settings);
4521
4522/**
4513 * dev_get_flags - get flags reported to userspace 4523 * dev_get_flags - get flags reported to userspace
4514 * @dev: device 4524 * @dev: device
4515 * 4525 *
@@ -5203,11 +5213,15 @@ u32 netdev_fix_features(struct net_device *dev, u32 features)
5203 } 5213 }
5204 5214
5205 /* TSO requires that SG is present as well. */ 5215 /* TSO requires that SG is present as well. */
5206 if ((features & NETIF_F_TSO) && !(features & NETIF_F_SG)) { 5216 if ((features & NETIF_F_ALL_TSO) && !(features & NETIF_F_SG)) {
5207 netdev_info(dev, "Dropping NETIF_F_TSO since no SG feature.\n"); 5217 netdev_info(dev, "Dropping TSO features since no SG feature.\n");
5208 features &= ~NETIF_F_TSO; 5218 features &= ~NETIF_F_ALL_TSO;
5209 } 5219 }
5210 5220
5221 /* TSO ECN requires that TSO is present as well. */
5222 if ((features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN)
5223 features &= ~NETIF_F_TSO_ECN;
5224
5211 /* Software GSO depends on SG. */ 5225 /* Software GSO depends on SG. */
5212 if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) { 5226 if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) {
5213 netdev_info(dev, "Dropping NETIF_F_GSO since no SG feature.\n"); 5227 netdev_info(dev, "Dropping NETIF_F_GSO since no SG feature.\n");
@@ -5236,11 +5250,13 @@ u32 netdev_fix_features(struct net_device *dev, u32 features)
5236} 5250}
5237EXPORT_SYMBOL(netdev_fix_features); 5251EXPORT_SYMBOL(netdev_fix_features);
5238 5252
5239void netdev_update_features(struct net_device *dev) 5253int __netdev_update_features(struct net_device *dev)
5240{ 5254{
5241 u32 features; 5255 u32 features;
5242 int err = 0; 5256 int err = 0;
5243 5257
5258 ASSERT_RTNL();
5259
5244 features = netdev_get_wanted_features(dev); 5260 features = netdev_get_wanted_features(dev);
5245 5261
5246 if (dev->netdev_ops->ndo_fix_features) 5262 if (dev->netdev_ops->ndo_fix_features)
@@ -5250,7 +5266,7 @@ void netdev_update_features(struct net_device *dev)
5250 features = netdev_fix_features(dev, features); 5266 features = netdev_fix_features(dev, features);
5251 5267
5252 if (dev->features == features) 5268 if (dev->features == features)
5253 return; 5269 return 0;
5254 5270
5255 netdev_info(dev, "Features changed: 0x%08x -> 0x%08x\n", 5271 netdev_info(dev, "Features changed: 0x%08x -> 0x%08x\n",
5256 dev->features, features); 5272 dev->features, features);
@@ -5258,12 +5274,23 @@ void netdev_update_features(struct net_device *dev)
5258 if (dev->netdev_ops->ndo_set_features) 5274 if (dev->netdev_ops->ndo_set_features)
5259 err = dev->netdev_ops->ndo_set_features(dev, features); 5275 err = dev->netdev_ops->ndo_set_features(dev, features);
5260 5276
5261 if (!err) 5277 if (unlikely(err < 0)) {
5262 dev->features = features;
5263 else if (err < 0)
5264 netdev_err(dev, 5278 netdev_err(dev,
5265 "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n", 5279 "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n",
5266 err, features, dev->features); 5280 err, features, dev->features);
5281 return -1;
5282 }
5283
5284 if (!err)
5285 dev->features = features;
5286
5287 return 1;
5288}
5289
5290void netdev_update_features(struct net_device *dev)
5291{
5292 if (__netdev_update_features(dev))
5293 netdev_features_change(dev);
5267} 5294}
5268EXPORT_SYMBOL(netdev_update_features); 5295EXPORT_SYMBOL(netdev_update_features);
5269 5296
@@ -5414,6 +5441,14 @@ int register_netdevice(struct net_device *dev)
5414 dev->features &= ~NETIF_F_GSO; 5441 dev->features &= ~NETIF_F_GSO;
5415 } 5442 }
5416 5443
5444 /* Turn on no cache copy if HW is doing checksum */
5445 dev->hw_features |= NETIF_F_NOCACHE_COPY;
5446 if ((dev->features & NETIF_F_ALL_CSUM) &&
5447 !(dev->features & NETIF_F_NO_CSUM)) {
5448 dev->wanted_features |= NETIF_F_NOCACHE_COPY;
5449 dev->features |= NETIF_F_NOCACHE_COPY;
5450 }
5451
5417 /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, 5452 /* Enable GRO and NETIF_F_HIGHDMA for vlans by default,
5418 * vlan_dev_init() will do the dev->features check, so these features 5453 * vlan_dev_init() will do the dev->features check, so these features
5419 * are enabled only if supported by underlying device. 5454 * are enabled only if supported by underlying device.
@@ -5430,7 +5465,7 @@ int register_netdevice(struct net_device *dev)
5430 goto err_uninit; 5465 goto err_uninit;
5431 dev->reg_state = NETREG_REGISTERED; 5466 dev->reg_state = NETREG_REGISTERED;
5432 5467
5433 netdev_update_features(dev); 5468 __netdev_update_features(dev);
5434 5469
5435 /* 5470 /*
5436 * Default initial state at registry is that the 5471 * Default initial state at registry is that the
@@ -6153,29 +6188,20 @@ static int dev_cpu_callback(struct notifier_block *nfb,
6153 */ 6188 */
6154u32 netdev_increment_features(u32 all, u32 one, u32 mask) 6189u32 netdev_increment_features(u32 all, u32 one, u32 mask)
6155{ 6190{
6156 /* If device needs checksumming, downgrade to it. */ 6191 if (mask & NETIF_F_GEN_CSUM)
6157 if (all & NETIF_F_NO_CSUM && !(one & NETIF_F_NO_CSUM)) 6192 mask |= NETIF_F_ALL_CSUM;
6158 all ^= NETIF_F_NO_CSUM | (one & NETIF_F_ALL_CSUM); 6193 mask |= NETIF_F_VLAN_CHALLENGED;
6159 else if (mask & NETIF_F_ALL_CSUM) {
6160 /* If one device supports v4/v6 checksumming, set for all. */
6161 if (one & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM) &&
6162 !(all & NETIF_F_GEN_CSUM)) {
6163 all &= ~NETIF_F_ALL_CSUM;
6164 all |= one & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
6165 }
6166 6194
6167 /* If one device supports hw checksumming, set for all. */ 6195 all |= one & (NETIF_F_ONE_FOR_ALL|NETIF_F_ALL_CSUM) & mask;
6168 if (one & NETIF_F_GEN_CSUM && !(all & NETIF_F_GEN_CSUM)) { 6196 all &= one | ~NETIF_F_ALL_FOR_ALL;
6169 all &= ~NETIF_F_ALL_CSUM;
6170 all |= NETIF_F_HW_CSUM;
6171 }
6172 }
6173 6197
6174 one |= NETIF_F_ALL_CSUM; 6198 /* If device needs checksumming, downgrade to it. */
6199 if (all & (NETIF_F_ALL_CSUM & ~NETIF_F_NO_CSUM))
6200 all &= ~NETIF_F_NO_CSUM;
6175 6201
6176 one |= all & NETIF_F_ONE_FOR_ALL; 6202 /* If one device supports hw checksumming, set for all. */
6177 all &= one | NETIF_F_LLTX | NETIF_F_GSO | NETIF_F_UFO; 6203 if (all & NETIF_F_GEN_CSUM)
6178 all |= one & mask & NETIF_F_ONE_FOR_ALL; 6204 all &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);
6179 6205
6180 return all; 6206 return all;
6181} 6207}
@@ -6336,7 +6362,7 @@ static void __net_exit default_device_exit(struct net *net)
6336 if (dev->rtnl_link_ops) 6362 if (dev->rtnl_link_ops)
6337 continue; 6363 continue;
6338 6364
6339 /* Push remaing network devices to init_net */ 6365 /* Push remaining network devices to init_net */
6340 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); 6366 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
6341 err = dev_change_net_namespace(dev, &init_net, fb_name); 6367 err = dev_change_net_namespace(dev, &init_net, fb_name);
6342 if (err) { 6368 if (err) {