aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-07-27 03:54:47 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-07-27 03:54:47 -0400
commitaa7eb8e78d8ecd6cd0475d86ea8385ff9cb47ece (patch)
tree3f9e98fadd5124fb05e8f6f9b06aa23698d4f215 /net/core/dev.c
parentcca8edfd2ec2a34d9f50f593bc753bb11e1bc1f5 (diff)
parent3c6b50141ef9f0a8844bf1357b80c0cdf518bf05 (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c275
1 files changed, 160 insertions, 115 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 956d3b006e8b..9c58c1ec41a9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -948,7 +948,7 @@ int dev_alloc_name(struct net_device *dev, const char *name)
948} 948}
949EXPORT_SYMBOL(dev_alloc_name); 949EXPORT_SYMBOL(dev_alloc_name);
950 950
951static int dev_get_valid_name(struct net_device *dev, const char *name, bool fmt) 951static int dev_get_valid_name(struct net_device *dev, const char *name)
952{ 952{
953 struct net *net; 953 struct net *net;
954 954
@@ -958,7 +958,7 @@ static int dev_get_valid_name(struct net_device *dev, const char *name, bool fmt
958 if (!dev_valid_name(name)) 958 if (!dev_valid_name(name))
959 return -EINVAL; 959 return -EINVAL;
960 960
961 if (fmt && strchr(name, '%')) 961 if (strchr(name, '%'))
962 return dev_alloc_name(dev, name); 962 return dev_alloc_name(dev, name);
963 else if (__dev_get_by_name(net, name)) 963 else if (__dev_get_by_name(net, name))
964 return -EEXIST; 964 return -EEXIST;
@@ -995,7 +995,7 @@ int dev_change_name(struct net_device *dev, const char *newname)
995 995
996 memcpy(oldname, dev->name, IFNAMSIZ); 996 memcpy(oldname, dev->name, IFNAMSIZ);
997 997
998 err = dev_get_valid_name(dev, newname, 1); 998 err = dev_get_valid_name(dev, newname);
999 if (err < 0) 999 if (err < 0)
1000 return err; 1000 return err;
1001 1001
@@ -1007,7 +1007,7 @@ rollback:
1007 } 1007 }
1008 1008
1009 write_lock_bh(&dev_base_lock); 1009 write_lock_bh(&dev_base_lock);
1010 hlist_del(&dev->name_hlist); 1010 hlist_del_rcu(&dev->name_hlist);
1011 write_unlock_bh(&dev_base_lock); 1011 write_unlock_bh(&dev_base_lock);
1012 1012
1013 synchronize_rcu(); 1013 synchronize_rcu();
@@ -1284,11 +1284,13 @@ static int dev_close_many(struct list_head *head)
1284 */ 1284 */
1285int dev_close(struct net_device *dev) 1285int dev_close(struct net_device *dev)
1286{ 1286{
1287 LIST_HEAD(single); 1287 if (dev->flags & IFF_UP) {
1288 LIST_HEAD(single);
1288 1289
1289 list_add(&dev->unreg_list, &single); 1290 list_add(&dev->unreg_list, &single);
1290 dev_close_many(&single); 1291 dev_close_many(&single);
1291 list_del(&single); 1292 list_del(&single);
1293 }
1292 return 0; 1294 return 0;
1293} 1295}
1294EXPORT_SYMBOL(dev_close); 1296EXPORT_SYMBOL(dev_close);
@@ -1306,6 +1308,13 @@ void dev_disable_lro(struct net_device *dev)
1306{ 1308{
1307 u32 flags; 1309 u32 flags;
1308 1310
1311 /*
1312 * If we're trying to disable lro on a vlan device
1313 * use the underlying physical device instead
1314 */
1315 if (is_vlan_dev(dev))
1316 dev = vlan_dev_real_dev(dev);
1317
1309 if (dev->ethtool_ops && dev->ethtool_ops->get_flags) 1318 if (dev->ethtool_ops && dev->ethtool_ops->get_flags)
1310 flags = dev->ethtool_ops->get_flags(dev); 1319 flags = dev->ethtool_ops->get_flags(dev);
1311 else 1320 else
@@ -1315,7 +1324,8 @@ void dev_disable_lro(struct net_device *dev)
1315 return; 1324 return;
1316 1325
1317 __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO); 1326 __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO);
1318 WARN_ON(dev->features & NETIF_F_LRO); 1327 if (unlikely(dev->features & NETIF_F_LRO))
1328 netdev_WARN(dev, "failed to disable LRO!\n");
1319} 1329}
1320EXPORT_SYMBOL(dev_disable_lro); 1330EXPORT_SYMBOL(dev_disable_lro);
1321 1331
@@ -2086,6 +2096,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2086{ 2096{
2087 const struct net_device_ops *ops = dev->netdev_ops; 2097 const struct net_device_ops *ops = dev->netdev_ops;
2088 int rc = NETDEV_TX_OK; 2098 int rc = NETDEV_TX_OK;
2099 unsigned int skb_len;
2089 2100
2090 if (likely(!skb->next)) { 2101 if (likely(!skb->next)) {
2091 u32 features; 2102 u32 features;
@@ -2136,8 +2147,9 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2136 } 2147 }
2137 } 2148 }
2138 2149
2150 skb_len = skb->len;
2139 rc = ops->ndo_start_xmit(skb, dev); 2151 rc = ops->ndo_start_xmit(skb, dev);
2140 trace_net_dev_xmit(skb, rc); 2152 trace_net_dev_xmit(skb, rc, dev, skb_len);
2141 if (rc == NETDEV_TX_OK) 2153 if (rc == NETDEV_TX_OK)
2142 txq_trans_update(txq); 2154 txq_trans_update(txq);
2143 return rc; 2155 return rc;
@@ -2157,8 +2169,9 @@ gso:
2157 if (dev->priv_flags & IFF_XMIT_DST_RELEASE) 2169 if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
2158 skb_dst_drop(nskb); 2170 skb_dst_drop(nskb);
2159 2171
2172 skb_len = nskb->len;
2160 rc = ops->ndo_start_xmit(nskb, dev); 2173 rc = ops->ndo_start_xmit(nskb, dev);
2161 trace_net_dev_xmit(nskb, rc); 2174 trace_net_dev_xmit(nskb, rc, dev, skb_len);
2162 if (unlikely(rc != NETDEV_TX_OK)) { 2175 if (unlikely(rc != NETDEV_TX_OK)) {
2163 if (rc & ~NETDEV_TX_MASK) 2176 if (rc & ~NETDEV_TX_MASK)
2164 goto out_kfree_gso_skb; 2177 goto out_kfree_gso_skb;
@@ -2502,8 +2515,8 @@ static inline void ____napi_schedule(struct softnet_data *sd,
2502__u32 __skb_get_rxhash(struct sk_buff *skb) 2515__u32 __skb_get_rxhash(struct sk_buff *skb)
2503{ 2516{
2504 int nhoff, hash = 0, poff; 2517 int nhoff, hash = 0, poff;
2505 struct ipv6hdr *ip6; 2518 const struct ipv6hdr *ip6;
2506 struct iphdr *ip; 2519 const struct iphdr *ip;
2507 u8 ip_proto; 2520 u8 ip_proto;
2508 u32 addr1, addr2, ihl; 2521 u32 addr1, addr2, ihl;
2509 union { 2522 union {
@@ -2518,7 +2531,7 @@ __u32 __skb_get_rxhash(struct sk_buff *skb)
2518 if (!pskb_may_pull(skb, sizeof(*ip) + nhoff)) 2531 if (!pskb_may_pull(skb, sizeof(*ip) + nhoff))
2519 goto done; 2532 goto done;
2520 2533
2521 ip = (struct iphdr *) (skb->data + nhoff); 2534 ip = (const struct iphdr *) (skb->data + nhoff);
2522 if (ip->frag_off & htons(IP_MF | IP_OFFSET)) 2535 if (ip->frag_off & htons(IP_MF | IP_OFFSET))
2523 ip_proto = 0; 2536 ip_proto = 0;
2524 else 2537 else
@@ -2531,7 +2544,7 @@ __u32 __skb_get_rxhash(struct sk_buff *skb)
2531 if (!pskb_may_pull(skb, sizeof(*ip6) + nhoff)) 2544 if (!pskb_may_pull(skb, sizeof(*ip6) + nhoff))
2532 goto done; 2545 goto done;
2533 2546
2534 ip6 = (struct ipv6hdr *) (skb->data + nhoff); 2547 ip6 = (const struct ipv6hdr *) (skb->data + nhoff);
2535 ip_proto = ip6->nexthdr; 2548 ip_proto = ip6->nexthdr;
2536 addr1 = (__force u32) ip6->saddr.s6_addr32[3]; 2549 addr1 = (__force u32) ip6->saddr.s6_addr32[3];
2537 addr2 = (__force u32) ip6->daddr.s6_addr32[3]; 2550 addr2 = (__force u32) ip6->daddr.s6_addr32[3];
@@ -3076,25 +3089,6 @@ void netdev_rx_handler_unregister(struct net_device *dev)
3076} 3089}
3077EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); 3090EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister);
3078 3091
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) 3092static int __netif_receive_skb(struct sk_buff *skb)
3099{ 3093{
3100 struct packet_type *ptype, *pt_prev; 3094 struct packet_type *ptype, *pt_prev;
@@ -3120,7 +3114,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
3120 3114
3121 skb_reset_network_header(skb); 3115 skb_reset_network_header(skb);
3122 skb_reset_transport_header(skb); 3116 skb_reset_transport_header(skb);
3123 skb->mac_len = skb->network_header - skb->mac_header; 3117 skb_reset_mac_len(skb);
3124 3118
3125 pt_prev = NULL; 3119 pt_prev = NULL;
3126 3120
@@ -3130,6 +3124,12 @@ another_round:
3130 3124
3131 __this_cpu_inc(softnet_data.processed); 3125 __this_cpu_inc(softnet_data.processed);
3132 3126
3127 if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) {
3128 skb = vlan_untag(skb);
3129 if (unlikely(!skb))
3130 goto out;
3131 }
3132
3133#ifdef CONFIG_NET_CLS_ACT 3133#ifdef CONFIG_NET_CLS_ACT
3134 if (skb->tc_verd & TC_NCLS) { 3134 if (skb->tc_verd & TC_NCLS) {
3135 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); 3135 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
@@ -3177,15 +3177,13 @@ ncls:
3177 ret = deliver_skb(skb, pt_prev, orig_dev); 3177 ret = deliver_skb(skb, pt_prev, orig_dev);
3178 pt_prev = NULL; 3178 pt_prev = NULL;
3179 } 3179 }
3180 if (vlan_hwaccel_do_receive(&skb)) { 3180 if (vlan_do_receive(&skb)) {
3181 ret = __netif_receive_skb(skb); 3181 ret = __netif_receive_skb(skb);
3182 goto out; 3182 goto out;
3183 } else if (unlikely(!skb)) 3183 } else if (unlikely(!skb))
3184 goto out; 3184 goto out;
3185 } 3185 }
3186 3186
3187 vlan_on_bond_hook(skb);
3188
3189 /* deliver only exact match when indicated */ 3187 /* deliver only exact match when indicated */
3190 null_or_dev = deliver_exact ? skb->dev : NULL; 3188 null_or_dev = deliver_exact ? skb->dev : NULL;
3191 3189
@@ -4306,10 +4304,8 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
4306 4304
4307 slave->master = master; 4305 slave->master = master;
4308 4306
4309 if (old) { 4307 if (old)
4310 synchronize_net();
4311 dev_put(old); 4308 dev_put(old);
4312 }
4313 return 0; 4309 return 0;
4314} 4310}
4315EXPORT_SYMBOL(netdev_set_master); 4311EXPORT_SYMBOL(netdev_set_master);
@@ -4510,6 +4506,30 @@ void dev_set_rx_mode(struct net_device *dev)
4510} 4506}
4511 4507
4512/** 4508/**
4509 * dev_ethtool_get_settings - call device's ethtool_ops::get_settings()
4510 * @dev: device
4511 * @cmd: memory area for ethtool_ops::get_settings() result
4512 *
4513 * The cmd arg is initialized properly (cleared and
4514 * ethtool_cmd::cmd field set to ETHTOOL_GSET).
4515 *
4516 * Return device's ethtool_ops::get_settings() result value or
4517 * -EOPNOTSUPP when device doesn't expose
4518 * ethtool_ops::get_settings() operation.
4519 */
4520int dev_ethtool_get_settings(struct net_device *dev,
4521 struct ethtool_cmd *cmd)
4522{
4523 if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings)
4524 return -EOPNOTSUPP;
4525
4526 memset(cmd, 0, sizeof(struct ethtool_cmd));
4527 cmd->cmd = ETHTOOL_GSET;
4528 return dev->ethtool_ops->get_settings(dev, cmd);
4529}
4530EXPORT_SYMBOL(dev_ethtool_get_settings);
4531
4532/**
4513 * dev_get_flags - get flags reported to userspace 4533 * dev_get_flags - get flags reported to userspace
4514 * @dev: device 4534 * @dev: device
4515 * 4535 *
@@ -4773,7 +4793,7 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm
4773 * is never reached 4793 * is never reached
4774 */ 4794 */
4775 WARN_ON(1); 4795 WARN_ON(1);
4776 err = -EINVAL; 4796 err = -ENOTTY;
4777 break; 4797 break;
4778 4798
4779 } 4799 }
@@ -5041,7 +5061,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
5041 /* Set the per device memory buffer space. 5061 /* Set the per device memory buffer space.
5042 * Not applicable in our case */ 5062 * Not applicable in our case */
5043 case SIOCSIFLINK: 5063 case SIOCSIFLINK:
5044 return -EINVAL; 5064 return -ENOTTY;
5045 5065
5046 /* 5066 /*
5047 * Unknown or private ioctl. 5067 * Unknown or private ioctl.
@@ -5062,7 +5082,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
5062 /* Take care of Wireless Extensions */ 5082 /* Take care of Wireless Extensions */
5063 if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) 5083 if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
5064 return wext_handle_ioctl(net, &ifr, cmd, arg); 5084 return wext_handle_ioctl(net, &ifr, cmd, arg);
5065 return -EINVAL; 5085 return -ENOTTY;
5066 } 5086 }
5067} 5087}
5068 5088
@@ -5114,7 +5134,7 @@ static void rollback_registered_many(struct list_head *head)
5114 list_del(&dev->unreg_list); 5134 list_del(&dev->unreg_list);
5115 continue; 5135 continue;
5116 } 5136 }
5117 5137 dev->dismantle = true;
5118 BUG_ON(dev->reg_state != NETREG_REGISTERED); 5138 BUG_ON(dev->reg_state != NETREG_REGISTERED);
5119 } 5139 }
5120 5140
@@ -5184,33 +5204,37 @@ u32 netdev_fix_features(struct net_device *dev, u32 features)
5184 /* Fix illegal checksum combinations */ 5204 /* Fix illegal checksum combinations */
5185 if ((features & NETIF_F_HW_CSUM) && 5205 if ((features & NETIF_F_HW_CSUM) &&
5186 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { 5206 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
5187 netdev_info(dev, "mixed HW and IP checksum settings.\n"); 5207 netdev_warn(dev, "mixed HW and IP checksum settings.\n");
5188 features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); 5208 features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM);
5189 } 5209 }
5190 5210
5191 if ((features & NETIF_F_NO_CSUM) && 5211 if ((features & NETIF_F_NO_CSUM) &&
5192 (features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { 5212 (features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
5193 netdev_info(dev, "mixed no checksumming and other settings.\n"); 5213 netdev_warn(dev, "mixed no checksumming and other settings.\n");
5194 features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM); 5214 features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM);
5195 } 5215 }
5196 5216
5197 /* Fix illegal SG+CSUM combinations. */ 5217 /* Fix illegal SG+CSUM combinations. */
5198 if ((features & NETIF_F_SG) && 5218 if ((features & NETIF_F_SG) &&
5199 !(features & NETIF_F_ALL_CSUM)) { 5219 !(features & NETIF_F_ALL_CSUM)) {
5200 netdev_info(dev, 5220 netdev_dbg(dev,
5201 "Dropping NETIF_F_SG since no checksum feature.\n"); 5221 "Dropping NETIF_F_SG since no checksum feature.\n");
5202 features &= ~NETIF_F_SG; 5222 features &= ~NETIF_F_SG;
5203 } 5223 }
5204 5224
5205 /* TSO requires that SG is present as well. */ 5225 /* TSO requires that SG is present as well. */
5206 if ((features & NETIF_F_TSO) && !(features & NETIF_F_SG)) { 5226 if ((features & NETIF_F_ALL_TSO) && !(features & NETIF_F_SG)) {
5207 netdev_info(dev, "Dropping NETIF_F_TSO since no SG feature.\n"); 5227 netdev_dbg(dev, "Dropping TSO features since no SG feature.\n");
5208 features &= ~NETIF_F_TSO; 5228 features &= ~NETIF_F_ALL_TSO;
5209 } 5229 }
5210 5230
5231 /* TSO ECN requires that TSO is present as well. */
5232 if ((features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN)
5233 features &= ~NETIF_F_TSO_ECN;
5234
5211 /* Software GSO depends on SG. */ 5235 /* Software GSO depends on SG. */
5212 if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) { 5236 if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) {
5213 netdev_info(dev, "Dropping NETIF_F_GSO since no SG feature.\n"); 5237 netdev_dbg(dev, "Dropping NETIF_F_GSO since no SG feature.\n");
5214 features &= ~NETIF_F_GSO; 5238 features &= ~NETIF_F_GSO;
5215 } 5239 }
5216 5240
@@ -5220,13 +5244,13 @@ u32 netdev_fix_features(struct net_device *dev, u32 features)
5220 if (!((features & NETIF_F_GEN_CSUM) || 5244 if (!((features & NETIF_F_GEN_CSUM) ||
5221 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) 5245 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
5222 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { 5246 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
5223 netdev_info(dev, 5247 netdev_dbg(dev,
5224 "Dropping NETIF_F_UFO since no checksum offload features.\n"); 5248 "Dropping NETIF_F_UFO since no checksum offload features.\n");
5225 features &= ~NETIF_F_UFO; 5249 features &= ~NETIF_F_UFO;
5226 } 5250 }
5227 5251
5228 if (!(features & NETIF_F_SG)) { 5252 if (!(features & NETIF_F_SG)) {
5229 netdev_info(dev, 5253 netdev_dbg(dev,
5230 "Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n"); 5254 "Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
5231 features &= ~NETIF_F_UFO; 5255 features &= ~NETIF_F_UFO;
5232 } 5256 }
@@ -5236,11 +5260,13 @@ u32 netdev_fix_features(struct net_device *dev, u32 features)
5236} 5260}
5237EXPORT_SYMBOL(netdev_fix_features); 5261EXPORT_SYMBOL(netdev_fix_features);
5238 5262
5239void netdev_update_features(struct net_device *dev) 5263int __netdev_update_features(struct net_device *dev)
5240{ 5264{
5241 u32 features; 5265 u32 features;
5242 int err = 0; 5266 int err = 0;
5243 5267
5268 ASSERT_RTNL();
5269
5244 features = netdev_get_wanted_features(dev); 5270 features = netdev_get_wanted_features(dev);
5245 5271
5246 if (dev->netdev_ops->ndo_fix_features) 5272 if (dev->netdev_ops->ndo_fix_features)
@@ -5250,24 +5276,60 @@ void netdev_update_features(struct net_device *dev)
5250 features = netdev_fix_features(dev, features); 5276 features = netdev_fix_features(dev, features);
5251 5277
5252 if (dev->features == features) 5278 if (dev->features == features)
5253 return; 5279 return 0;
5254 5280
5255 netdev_info(dev, "Features changed: 0x%08x -> 0x%08x\n", 5281 netdev_dbg(dev, "Features changed: 0x%08x -> 0x%08x\n",
5256 dev->features, features); 5282 dev->features, features);
5257 5283
5258 if (dev->netdev_ops->ndo_set_features) 5284 if (dev->netdev_ops->ndo_set_features)
5259 err = dev->netdev_ops->ndo_set_features(dev, features); 5285 err = dev->netdev_ops->ndo_set_features(dev, features);
5260 5286
5261 if (!err) 5287 if (unlikely(err < 0)) {
5262 dev->features = features;
5263 else if (err < 0)
5264 netdev_err(dev, 5288 netdev_err(dev,
5265 "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n", 5289 "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n",
5266 err, features, dev->features); 5290 err, features, dev->features);
5291 return -1;
5292 }
5293
5294 if (!err)
5295 dev->features = features;
5296
5297 return 1;
5298}
5299
5300/**
5301 * netdev_update_features - recalculate device features
5302 * @dev: the device to check
5303 *
5304 * Recalculate dev->features set and send notifications if it
5305 * has changed. Should be called after driver or hardware dependent
5306 * conditions might have changed that influence the features.
5307 */
5308void netdev_update_features(struct net_device *dev)
5309{
5310 if (__netdev_update_features(dev))
5311 netdev_features_change(dev);
5267} 5312}
5268EXPORT_SYMBOL(netdev_update_features); 5313EXPORT_SYMBOL(netdev_update_features);
5269 5314
5270/** 5315/**
5316 * netdev_change_features - recalculate device features
5317 * @dev: the device to check
5318 *
5319 * Recalculate dev->features set and send notifications even
5320 * if they have not changed. Should be called instead of
5321 * netdev_update_features() if also dev->vlan_features might
5322 * have changed to allow the changes to be propagated to stacked
5323 * VLAN devices.
5324 */
5325void netdev_change_features(struct net_device *dev)
5326{
5327 __netdev_update_features(dev);
5328 netdev_features_change(dev);
5329}
5330EXPORT_SYMBOL(netdev_change_features);
5331
5332/**
5271 * netif_stacked_transfer_operstate - transfer operstate 5333 * netif_stacked_transfer_operstate - transfer operstate
5272 * @rootdev: the root or lower level device to transfer state from 5334 * @rootdev: the root or lower level device to transfer state from
5273 * @dev: the device to transfer operstate to 5335 * @dev: the device to transfer operstate to
@@ -5383,6 +5445,10 @@ int register_netdevice(struct net_device *dev)
5383 5445
5384 dev->iflink = -1; 5446 dev->iflink = -1;
5385 5447
5448 ret = dev_get_valid_name(dev, dev->name);
5449 if (ret < 0)
5450 goto out;
5451
5386 /* Init, if this function is available */ 5452 /* Init, if this function is available */
5387 if (dev->netdev_ops->ndo_init) { 5453 if (dev->netdev_ops->ndo_init) {
5388 ret = dev->netdev_ops->ndo_init(dev); 5454 ret = dev->netdev_ops->ndo_init(dev);
@@ -5393,10 +5459,6 @@ int register_netdevice(struct net_device *dev)
5393 } 5459 }
5394 } 5460 }
5395 5461
5396 ret = dev_get_valid_name(dev, dev->name, 0);
5397 if (ret)
5398 goto err_uninit;
5399
5400 dev->ifindex = dev_new_index(net); 5462 dev->ifindex = dev_new_index(net);
5401 if (dev->iflink == -1) 5463 if (dev->iflink == -1)
5402 dev->iflink = dev->ifindex; 5464 dev->iflink = dev->ifindex;
@@ -5408,10 +5470,12 @@ int register_netdevice(struct net_device *dev)
5408 dev->features |= NETIF_F_SOFT_FEATURES; 5470 dev->features |= NETIF_F_SOFT_FEATURES;
5409 dev->wanted_features = dev->features & dev->hw_features; 5471 dev->wanted_features = dev->features & dev->hw_features;
5410 5472
5411 /* Avoid warning from netdev_fix_features() for GSO without SG */ 5473 /* Turn on no cache copy if HW is doing checksum */
5412 if (!(dev->wanted_features & NETIF_F_SG)) { 5474 dev->hw_features |= NETIF_F_NOCACHE_COPY;
5413 dev->wanted_features &= ~NETIF_F_GSO; 5475 if ((dev->features & NETIF_F_ALL_CSUM) &&
5414 dev->features &= ~NETIF_F_GSO; 5476 !(dev->features & NETIF_F_NO_CSUM)) {
5477 dev->wanted_features |= NETIF_F_NOCACHE_COPY;
5478 dev->features |= NETIF_F_NOCACHE_COPY;
5415 } 5479 }
5416 5480
5417 /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, 5481 /* Enable GRO and NETIF_F_HIGHDMA for vlans by default,
@@ -5430,7 +5494,7 @@ int register_netdevice(struct net_device *dev)
5430 goto err_uninit; 5494 goto err_uninit;
5431 dev->reg_state = NETREG_REGISTERED; 5495 dev->reg_state = NETREG_REGISTERED;
5432 5496
5433 netdev_update_features(dev); 5497 __netdev_update_features(dev);
5434 5498
5435 /* 5499 /*
5436 * Default initial state at registry is that the 5500 * Default initial state at registry is that the
@@ -5527,19 +5591,7 @@ int register_netdev(struct net_device *dev)
5527 int err; 5591 int err;
5528 5592
5529 rtnl_lock(); 5593 rtnl_lock();
5530
5531 /*
5532 * If the name is a format string the caller wants us to do a
5533 * name allocation.
5534 */
5535 if (strchr(dev->name, '%')) {
5536 err = dev_alloc_name(dev, dev->name);
5537 if (err < 0)
5538 goto out;
5539 }
5540
5541 err = register_netdevice(dev); 5594 err = register_netdevice(dev);
5542out:
5543 rtnl_unlock(); 5595 rtnl_unlock();
5544 return err; 5596 return err;
5545} 5597}
@@ -5912,7 +5964,10 @@ EXPORT_SYMBOL(free_netdev);
5912void synchronize_net(void) 5964void synchronize_net(void)
5913{ 5965{
5914 might_sleep(); 5966 might_sleep();
5915 synchronize_rcu(); 5967 if (rtnl_is_locked())
5968 synchronize_rcu_expedited();
5969 else
5970 synchronize_rcu();
5916} 5971}
5917EXPORT_SYMBOL(synchronize_net); 5972EXPORT_SYMBOL(synchronize_net);
5918 5973
@@ -6021,7 +6076,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
6021 /* We get here if we can't use the current device name */ 6076 /* We get here if we can't use the current device name */
6022 if (!pat) 6077 if (!pat)
6023 goto out; 6078 goto out;
6024 if (dev_get_valid_name(dev, pat, 1)) 6079 if (dev_get_valid_name(dev, pat) < 0)
6025 goto out; 6080 goto out;
6026 } 6081 }
6027 6082
@@ -6123,6 +6178,11 @@ static int dev_cpu_callback(struct notifier_block *nfb,
6123 oldsd->output_queue = NULL; 6178 oldsd->output_queue = NULL;
6124 oldsd->output_queue_tailp = &oldsd->output_queue; 6179 oldsd->output_queue_tailp = &oldsd->output_queue;
6125 } 6180 }
6181 /* Append NAPI poll list from offline CPU. */
6182 if (!list_empty(&oldsd->poll_list)) {
6183 list_splice_init(&oldsd->poll_list, &sd->poll_list);
6184 raise_softirq_irqoff(NET_RX_SOFTIRQ);
6185 }
6126 6186
6127 raise_softirq_irqoff(NET_TX_SOFTIRQ); 6187 raise_softirq_irqoff(NET_TX_SOFTIRQ);
6128 local_irq_enable(); 6188 local_irq_enable();
@@ -6153,29 +6213,20 @@ static int dev_cpu_callback(struct notifier_block *nfb,
6153 */ 6213 */
6154u32 netdev_increment_features(u32 all, u32 one, u32 mask) 6214u32 netdev_increment_features(u32 all, u32 one, u32 mask)
6155{ 6215{
6156 /* If device needs checksumming, downgrade to it. */ 6216 if (mask & NETIF_F_GEN_CSUM)
6157 if (all & NETIF_F_NO_CSUM && !(one & NETIF_F_NO_CSUM)) 6217 mask |= NETIF_F_ALL_CSUM;
6158 all ^= NETIF_F_NO_CSUM | (one & NETIF_F_ALL_CSUM); 6218 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 6219
6167 /* If one device supports hw checksumming, set for all. */ 6220 all |= one & (NETIF_F_ONE_FOR_ALL|NETIF_F_ALL_CSUM) & mask;
6168 if (one & NETIF_F_GEN_CSUM && !(all & NETIF_F_GEN_CSUM)) { 6221 all &= one | ~NETIF_F_ALL_FOR_ALL;
6169 all &= ~NETIF_F_ALL_CSUM;
6170 all |= NETIF_F_HW_CSUM;
6171 }
6172 }
6173 6222
6174 one |= NETIF_F_ALL_CSUM; 6223 /* If device needs checksumming, downgrade to it. */
6224 if (all & (NETIF_F_ALL_CSUM & ~NETIF_F_NO_CSUM))
6225 all &= ~NETIF_F_NO_CSUM;
6175 6226
6176 one |= all & NETIF_F_ONE_FOR_ALL; 6227 /* If one device supports hw checksumming, set for all. */
6177 all &= one | NETIF_F_LLTX | NETIF_F_GSO | NETIF_F_UFO; 6228 if (all & NETIF_F_GEN_CSUM)
6178 all |= one & mask & NETIF_F_ONE_FOR_ALL; 6229 all &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);
6179 6230
6180 return all; 6231 return all;
6181} 6232}
@@ -6218,29 +6269,23 @@ err_name:
6218/** 6269/**
6219 * netdev_drivername - network driver for the device 6270 * netdev_drivername - network driver for the device
6220 * @dev: network device 6271 * @dev: network device
6221 * @buffer: buffer for resulting name
6222 * @len: size of buffer
6223 * 6272 *
6224 * Determine network driver for device. 6273 * Determine network driver for device.
6225 */ 6274 */
6226char *netdev_drivername(const struct net_device *dev, char *buffer, int len) 6275const char *netdev_drivername(const struct net_device *dev)
6227{ 6276{
6228 const struct device_driver *driver; 6277 const struct device_driver *driver;
6229 const struct device *parent; 6278 const struct device *parent;
6230 6279 const char *empty = "";
6231 if (len <= 0 || !buffer)
6232 return buffer;
6233 buffer[0] = 0;
6234 6280
6235 parent = dev->dev.parent; 6281 parent = dev->dev.parent;
6236
6237 if (!parent) 6282 if (!parent)
6238 return buffer; 6283 return empty;
6239 6284
6240 driver = parent->driver; 6285 driver = parent->driver;
6241 if (driver && driver->name) 6286 if (driver && driver->name)
6242 strlcpy(buffer, driver->name, len); 6287 return driver->name;
6243 return buffer; 6288 return empty;
6244} 6289}
6245 6290
6246static int __netdev_printk(const char *level, const struct net_device *dev, 6291static int __netdev_printk(const char *level, const struct net_device *dev,