diff options
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 152 | ||||
-rw-r--r-- | net/core/dst.c | 34 | ||||
-rw-r--r-- | net/core/ethtool.c | 104 | ||||
-rw-r--r-- | net/core/fib_rules.c | 3 | ||||
-rw-r--r-- | net/core/filter.c | 65 | ||||
-rw-r--r-- | net/core/net-sysfs.c | 24 | ||||
-rw-r--r-- | net/core/net_namespace.c | 12 | ||||
-rw-r--r-- | net/core/netpoll.c | 28 | ||||
-rw-r--r-- | net/core/pktgen.c | 199 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 25 | ||||
-rw-r--r-- | net/core/sysctl_net_core.c | 9 | ||||
-rw-r--r-- | net/core/utils.c | 24 |
12 files changed, 299 insertions, 380 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 92009440d28b..75898a32c038 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 | } |
949 | EXPORT_SYMBOL(dev_alloc_name); | 949 | EXPORT_SYMBOL(dev_alloc_name); |
950 | 950 | ||
951 | static int dev_get_valid_name(struct net_device *dev, const char *name, bool fmt) | 951 | static 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 | ||
@@ -1317,7 +1317,8 @@ void dev_disable_lro(struct net_device *dev) | |||
1317 | return; | 1317 | return; |
1318 | 1318 | ||
1319 | __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO); | 1319 | __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO); |
1320 | WARN_ON(dev->features & NETIF_F_LRO); | 1320 | if (unlikely(dev->features & NETIF_F_LRO)) |
1321 | netdev_WARN(dev, "failed to disable LRO!\n"); | ||
1321 | } | 1322 | } |
1322 | EXPORT_SYMBOL(dev_disable_lro); | 1323 | EXPORT_SYMBOL(dev_disable_lro); |
1323 | 1324 | ||
@@ -2504,8 +2505,8 @@ static inline void ____napi_schedule(struct softnet_data *sd, | |||
2504 | __u32 __skb_get_rxhash(struct sk_buff *skb) | 2505 | __u32 __skb_get_rxhash(struct sk_buff *skb) |
2505 | { | 2506 | { |
2506 | int nhoff, hash = 0, poff; | 2507 | int nhoff, hash = 0, poff; |
2507 | struct ipv6hdr *ip6; | 2508 | const struct ipv6hdr *ip6; |
2508 | struct iphdr *ip; | 2509 | const struct iphdr *ip; |
2509 | u8 ip_proto; | 2510 | u8 ip_proto; |
2510 | u32 addr1, addr2, ihl; | 2511 | u32 addr1, addr2, ihl; |
2511 | union { | 2512 | union { |
@@ -2520,7 +2521,7 @@ __u32 __skb_get_rxhash(struct sk_buff *skb) | |||
2520 | if (!pskb_may_pull(skb, sizeof(*ip) + nhoff)) | 2521 | if (!pskb_may_pull(skb, sizeof(*ip) + nhoff)) |
2521 | goto done; | 2522 | goto done; |
2522 | 2523 | ||
2523 | ip = (struct iphdr *) (skb->data + nhoff); | 2524 | ip = (const struct iphdr *) (skb->data + nhoff); |
2524 | if (ip->frag_off & htons(IP_MF | IP_OFFSET)) | 2525 | if (ip->frag_off & htons(IP_MF | IP_OFFSET)) |
2525 | ip_proto = 0; | 2526 | ip_proto = 0; |
2526 | else | 2527 | else |
@@ -2533,7 +2534,7 @@ __u32 __skb_get_rxhash(struct sk_buff *skb) | |||
2533 | if (!pskb_may_pull(skb, sizeof(*ip6) + nhoff)) | 2534 | if (!pskb_may_pull(skb, sizeof(*ip6) + nhoff)) |
2534 | goto done; | 2535 | goto done; |
2535 | 2536 | ||
2536 | ip6 = (struct ipv6hdr *) (skb->data + nhoff); | 2537 | ip6 = (const struct ipv6hdr *) (skb->data + nhoff); |
2537 | ip_proto = ip6->nexthdr; | 2538 | ip_proto = ip6->nexthdr; |
2538 | addr1 = (__force u32) ip6->saddr.s6_addr32[3]; | 2539 | addr1 = (__force u32) ip6->saddr.s6_addr32[3]; |
2539 | addr2 = (__force u32) ip6->daddr.s6_addr32[3]; | 2540 | addr2 = (__force u32) ip6->daddr.s6_addr32[3]; |
@@ -3078,25 +3079,6 @@ void netdev_rx_handler_unregister(struct net_device *dev) | |||
3078 | } | 3079 | } |
3079 | EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); | 3080 | EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); |
3080 | 3081 | ||
3081 | static void vlan_on_bond_hook(struct sk_buff *skb) | ||
3082 | { | ||
3083 | /* | ||
3084 | * Make sure ARP frames received on VLAN interfaces stacked on | ||
3085 | * bonding interfaces still make their way to any base bonding | ||
3086 | * device that may have registered for a specific ptype. | ||
3087 | */ | ||
3088 | if (skb->dev->priv_flags & IFF_802_1Q_VLAN && | ||
3089 | vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING && | ||
3090 | skb->protocol == htons(ETH_P_ARP)) { | ||
3091 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); | ||
3092 | |||
3093 | if (!skb2) | ||
3094 | return; | ||
3095 | skb2->dev = vlan_dev_real_dev(skb->dev); | ||
3096 | netif_rx(skb2); | ||
3097 | } | ||
3098 | } | ||
3099 | |||
3100 | static int __netif_receive_skb(struct sk_buff *skb) | 3082 | static int __netif_receive_skb(struct sk_buff *skb) |
3101 | { | 3083 | { |
3102 | struct packet_type *ptype, *pt_prev; | 3084 | struct packet_type *ptype, *pt_prev; |
@@ -3132,6 +3114,12 @@ another_round: | |||
3132 | 3114 | ||
3133 | __this_cpu_inc(softnet_data.processed); | 3115 | __this_cpu_inc(softnet_data.processed); |
3134 | 3116 | ||
3117 | if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) { | ||
3118 | skb = vlan_untag(skb); | ||
3119 | if (unlikely(!skb)) | ||
3120 | goto out; | ||
3121 | } | ||
3122 | |||
3135 | #ifdef CONFIG_NET_CLS_ACT | 3123 | #ifdef CONFIG_NET_CLS_ACT |
3136 | if (skb->tc_verd & TC_NCLS) { | 3124 | if (skb->tc_verd & TC_NCLS) { |
3137 | skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); | 3125 | skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); |
@@ -3179,15 +3167,13 @@ ncls: | |||
3179 | ret = deliver_skb(skb, pt_prev, orig_dev); | 3167 | ret = deliver_skb(skb, pt_prev, orig_dev); |
3180 | pt_prev = NULL; | 3168 | pt_prev = NULL; |
3181 | } | 3169 | } |
3182 | if (vlan_hwaccel_do_receive(&skb)) { | 3170 | if (vlan_do_receive(&skb)) { |
3183 | ret = __netif_receive_skb(skb); | 3171 | ret = __netif_receive_skb(skb); |
3184 | goto out; | 3172 | goto out; |
3185 | } else if (unlikely(!skb)) | 3173 | } else if (unlikely(!skb)) |
3186 | goto out; | 3174 | goto out; |
3187 | } | 3175 | } |
3188 | 3176 | ||
3189 | vlan_on_bond_hook(skb); | ||
3190 | |||
3191 | /* deliver only exact match when indicated */ | 3177 | /* deliver only exact match when indicated */ |
3192 | null_or_dev = deliver_exact ? skb->dev : NULL; | 3178 | null_or_dev = deliver_exact ? skb->dev : NULL; |
3193 | 3179 | ||
@@ -4512,6 +4498,30 @@ void dev_set_rx_mode(struct net_device *dev) | |||
4512 | } | 4498 | } |
4513 | 4499 | ||
4514 | /** | 4500 | /** |
4501 | * dev_ethtool_get_settings - call device's ethtool_ops::get_settings() | ||
4502 | * @dev: device | ||
4503 | * @cmd: memory area for ethtool_ops::get_settings() result | ||
4504 | * | ||
4505 | * The cmd arg is initialized properly (cleared and | ||
4506 | * ethtool_cmd::cmd field set to ETHTOOL_GSET). | ||
4507 | * | ||
4508 | * Return device's ethtool_ops::get_settings() result value or | ||
4509 | * -EOPNOTSUPP when device doesn't expose | ||
4510 | * ethtool_ops::get_settings() operation. | ||
4511 | */ | ||
4512 | int dev_ethtool_get_settings(struct net_device *dev, | ||
4513 | struct ethtool_cmd *cmd) | ||
4514 | { | ||
4515 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings) | ||
4516 | return -EOPNOTSUPP; | ||
4517 | |||
4518 | memset(cmd, 0, sizeof(struct ethtool_cmd)); | ||
4519 | cmd->cmd = ETHTOOL_GSET; | ||
4520 | return dev->ethtool_ops->get_settings(dev, cmd); | ||
4521 | } | ||
4522 | EXPORT_SYMBOL(dev_ethtool_get_settings); | ||
4523 | |||
4524 | /** | ||
4515 | * dev_get_flags - get flags reported to userspace | 4525 | * dev_get_flags - get flags reported to userspace |
4516 | * @dev: device | 4526 | * @dev: device |
4517 | * | 4527 | * |
@@ -5242,11 +5252,13 @@ u32 netdev_fix_features(struct net_device *dev, u32 features) | |||
5242 | } | 5252 | } |
5243 | EXPORT_SYMBOL(netdev_fix_features); | 5253 | EXPORT_SYMBOL(netdev_fix_features); |
5244 | 5254 | ||
5245 | void netdev_update_features(struct net_device *dev) | 5255 | int __netdev_update_features(struct net_device *dev) |
5246 | { | 5256 | { |
5247 | u32 features; | 5257 | u32 features; |
5248 | int err = 0; | 5258 | int err = 0; |
5249 | 5259 | ||
5260 | ASSERT_RTNL(); | ||
5261 | |||
5250 | features = netdev_get_wanted_features(dev); | 5262 | features = netdev_get_wanted_features(dev); |
5251 | 5263 | ||
5252 | if (dev->netdev_ops->ndo_fix_features) | 5264 | if (dev->netdev_ops->ndo_fix_features) |
@@ -5256,7 +5268,7 @@ void netdev_update_features(struct net_device *dev) | |||
5256 | features = netdev_fix_features(dev, features); | 5268 | features = netdev_fix_features(dev, features); |
5257 | 5269 | ||
5258 | if (dev->features == features) | 5270 | if (dev->features == features) |
5259 | return; | 5271 | return 0; |
5260 | 5272 | ||
5261 | netdev_info(dev, "Features changed: 0x%08x -> 0x%08x\n", | 5273 | netdev_info(dev, "Features changed: 0x%08x -> 0x%08x\n", |
5262 | dev->features, features); | 5274 | dev->features, features); |
@@ -5264,12 +5276,23 @@ void netdev_update_features(struct net_device *dev) | |||
5264 | if (dev->netdev_ops->ndo_set_features) | 5276 | if (dev->netdev_ops->ndo_set_features) |
5265 | err = dev->netdev_ops->ndo_set_features(dev, features); | 5277 | err = dev->netdev_ops->ndo_set_features(dev, features); |
5266 | 5278 | ||
5267 | if (!err) | 5279 | if (unlikely(err < 0)) { |
5268 | dev->features = features; | ||
5269 | else if (err < 0) | ||
5270 | netdev_err(dev, | 5280 | netdev_err(dev, |
5271 | "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n", | 5281 | "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n", |
5272 | err, features, dev->features); | 5282 | err, features, dev->features); |
5283 | return -1; | ||
5284 | } | ||
5285 | |||
5286 | if (!err) | ||
5287 | dev->features = features; | ||
5288 | |||
5289 | return 1; | ||
5290 | } | ||
5291 | |||
5292 | void netdev_update_features(struct net_device *dev) | ||
5293 | { | ||
5294 | if (__netdev_update_features(dev)) | ||
5295 | netdev_features_change(dev); | ||
5273 | } | 5296 | } |
5274 | EXPORT_SYMBOL(netdev_update_features); | 5297 | EXPORT_SYMBOL(netdev_update_features); |
5275 | 5298 | ||
@@ -5399,8 +5422,8 @@ int register_netdevice(struct net_device *dev) | |||
5399 | } | 5422 | } |
5400 | } | 5423 | } |
5401 | 5424 | ||
5402 | ret = dev_get_valid_name(dev, dev->name, 0); | 5425 | ret = dev_get_valid_name(dev, dev->name); |
5403 | if (ret) | 5426 | if (ret < 0) |
5404 | goto err_uninit; | 5427 | goto err_uninit; |
5405 | 5428 | ||
5406 | dev->ifindex = dev_new_index(net); | 5429 | dev->ifindex = dev_new_index(net); |
@@ -5420,6 +5443,14 @@ int register_netdevice(struct net_device *dev) | |||
5420 | dev->features &= ~NETIF_F_GSO; | 5443 | dev->features &= ~NETIF_F_GSO; |
5421 | } | 5444 | } |
5422 | 5445 | ||
5446 | /* Turn on no cache copy if HW is doing checksum */ | ||
5447 | dev->hw_features |= NETIF_F_NOCACHE_COPY; | ||
5448 | if ((dev->features & NETIF_F_ALL_CSUM) && | ||
5449 | !(dev->features & NETIF_F_NO_CSUM)) { | ||
5450 | dev->wanted_features |= NETIF_F_NOCACHE_COPY; | ||
5451 | dev->features |= NETIF_F_NOCACHE_COPY; | ||
5452 | } | ||
5453 | |||
5423 | /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, | 5454 | /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, |
5424 | * vlan_dev_init() will do the dev->features check, so these features | 5455 | * vlan_dev_init() will do the dev->features check, so these features |
5425 | * are enabled only if supported by underlying device. | 5456 | * are enabled only if supported by underlying device. |
@@ -5436,7 +5467,7 @@ int register_netdevice(struct net_device *dev) | |||
5436 | goto err_uninit; | 5467 | goto err_uninit; |
5437 | dev->reg_state = NETREG_REGISTERED; | 5468 | dev->reg_state = NETREG_REGISTERED; |
5438 | 5469 | ||
5439 | netdev_update_features(dev); | 5470 | __netdev_update_features(dev); |
5440 | 5471 | ||
5441 | /* | 5472 | /* |
5442 | * Default initial state at registry is that the | 5473 | * Default initial state at registry is that the |
@@ -5533,19 +5564,7 @@ int register_netdev(struct net_device *dev) | |||
5533 | int err; | 5564 | int err; |
5534 | 5565 | ||
5535 | rtnl_lock(); | 5566 | rtnl_lock(); |
5536 | |||
5537 | /* | ||
5538 | * If the name is a format string the caller wants us to do a | ||
5539 | * name allocation. | ||
5540 | */ | ||
5541 | if (strchr(dev->name, '%')) { | ||
5542 | err = dev_alloc_name(dev, dev->name); | ||
5543 | if (err < 0) | ||
5544 | goto out; | ||
5545 | } | ||
5546 | |||
5547 | err = register_netdevice(dev); | 5567 | err = register_netdevice(dev); |
5548 | out: | ||
5549 | rtnl_unlock(); | 5568 | rtnl_unlock(); |
5550 | return err; | 5569 | return err; |
5551 | } | 5570 | } |
@@ -6027,7 +6046,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
6027 | /* We get here if we can't use the current device name */ | 6046 | /* We get here if we can't use the current device name */ |
6028 | if (!pat) | 6047 | if (!pat) |
6029 | goto out; | 6048 | goto out; |
6030 | if (dev_get_valid_name(dev, pat, 1)) | 6049 | if (dev_get_valid_name(dev, pat) < 0) |
6031 | goto out; | 6050 | goto out; |
6032 | } | 6051 | } |
6033 | 6052 | ||
@@ -6159,29 +6178,20 @@ static int dev_cpu_callback(struct notifier_block *nfb, | |||
6159 | */ | 6178 | */ |
6160 | u32 netdev_increment_features(u32 all, u32 one, u32 mask) | 6179 | u32 netdev_increment_features(u32 all, u32 one, u32 mask) |
6161 | { | 6180 | { |
6162 | /* If device needs checksumming, downgrade to it. */ | 6181 | if (mask & NETIF_F_GEN_CSUM) |
6163 | if (all & NETIF_F_NO_CSUM && !(one & NETIF_F_NO_CSUM)) | 6182 | mask |= NETIF_F_ALL_CSUM; |
6164 | all ^= NETIF_F_NO_CSUM | (one & NETIF_F_ALL_CSUM); | 6183 | mask |= NETIF_F_VLAN_CHALLENGED; |
6165 | else if (mask & NETIF_F_ALL_CSUM) { | ||
6166 | /* If one device supports v4/v6 checksumming, set for all. */ | ||
6167 | if (one & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM) && | ||
6168 | !(all & NETIF_F_GEN_CSUM)) { | ||
6169 | all &= ~NETIF_F_ALL_CSUM; | ||
6170 | all |= one & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); | ||
6171 | } | ||
6172 | 6184 | ||
6173 | /* If one device supports hw checksumming, set for all. */ | 6185 | all |= one & (NETIF_F_ONE_FOR_ALL|NETIF_F_ALL_CSUM) & mask; |
6174 | if (one & NETIF_F_GEN_CSUM && !(all & NETIF_F_GEN_CSUM)) { | 6186 | all &= one | ~NETIF_F_ALL_FOR_ALL; |
6175 | all &= ~NETIF_F_ALL_CSUM; | ||
6176 | all |= NETIF_F_HW_CSUM; | ||
6177 | } | ||
6178 | } | ||
6179 | 6187 | ||
6180 | one |= NETIF_F_ALL_CSUM; | 6188 | /* If device needs checksumming, downgrade to it. */ |
6189 | if (all & (NETIF_F_ALL_CSUM & ~NETIF_F_NO_CSUM)) | ||
6190 | all &= ~NETIF_F_NO_CSUM; | ||
6181 | 6191 | ||
6182 | one |= all & NETIF_F_ONE_FOR_ALL; | 6192 | /* If one device supports hw checksumming, set for all. */ |
6183 | all &= one | NETIF_F_LLTX | NETIF_F_GSO | NETIF_F_UFO; | 6193 | if (all & NETIF_F_GEN_CSUM) |
6184 | all |= one & mask & NETIF_F_ONE_FOR_ALL; | 6194 | all &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM); |
6185 | 6195 | ||
6186 | return all; | 6196 | return all; |
6187 | } | 6197 | } |
diff --git a/net/core/dst.c b/net/core/dst.c index 91104d35de7d..30f009327b62 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
@@ -166,7 +166,8 @@ EXPORT_SYMBOL(dst_discard); | |||
166 | 166 | ||
167 | const u32 dst_default_metrics[RTAX_MAX]; | 167 | const u32 dst_default_metrics[RTAX_MAX]; |
168 | 168 | ||
169 | void *dst_alloc(struct dst_ops *ops, int initial_ref) | 169 | void *dst_alloc(struct dst_ops *ops, struct net_device *dev, |
170 | int initial_ref, int initial_obsolete, int flags) | ||
170 | { | 171 | { |
171 | struct dst_entry *dst; | 172 | struct dst_entry *dst; |
172 | 173 | ||
@@ -174,15 +175,36 @@ void *dst_alloc(struct dst_ops *ops, int initial_ref) | |||
174 | if (ops->gc(ops)) | 175 | if (ops->gc(ops)) |
175 | return NULL; | 176 | return NULL; |
176 | } | 177 | } |
177 | dst = kmem_cache_zalloc(ops->kmem_cachep, GFP_ATOMIC); | 178 | dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC); |
178 | if (!dst) | 179 | if (!dst) |
179 | return NULL; | 180 | return NULL; |
180 | atomic_set(&dst->__refcnt, initial_ref); | 181 | dst->child = NULL; |
182 | dst->dev = dev; | ||
183 | if (dev) | ||
184 | dev_hold(dev); | ||
181 | dst->ops = ops; | 185 | dst->ops = ops; |
182 | dst->lastuse = jiffies; | ||
183 | dst->path = dst; | ||
184 | dst->input = dst->output = dst_discard; | ||
185 | dst_init_metrics(dst, dst_default_metrics, true); | 186 | dst_init_metrics(dst, dst_default_metrics, true); |
187 | dst->expires = 0UL; | ||
188 | dst->path = dst; | ||
189 | dst->neighbour = NULL; | ||
190 | dst->hh = NULL; | ||
191 | #ifdef CONFIG_XFRM | ||
192 | dst->xfrm = NULL; | ||
193 | #endif | ||
194 | dst->input = dst_discard; | ||
195 | dst->output = dst_discard; | ||
196 | dst->error = 0; | ||
197 | dst->obsolete = initial_obsolete; | ||
198 | dst->header_len = 0; | ||
199 | dst->trailer_len = 0; | ||
200 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
201 | dst->tclassid = 0; | ||
202 | #endif | ||
203 | atomic_set(&dst->__refcnt, initial_ref); | ||
204 | dst->__use = 0; | ||
205 | dst->lastuse = jiffies; | ||
206 | dst->flags = flags; | ||
207 | dst->next = NULL; | ||
186 | #if RT_CACHE_DEBUG >= 2 | 208 | #if RT_CACHE_DEBUG >= 2 |
187 | atomic_inc(&dst_total); | 209 | atomic_inc(&dst_total); |
188 | #endif | 210 | #endif |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 74ead9eca126..b6f405888538 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/uaccess.h> | 21 | #include <linux/uaccess.h> |
22 | #include <linux/vmalloc.h> | 22 | #include <linux/vmalloc.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/rtnetlink.h> | ||
25 | #include <linux/sched.h> | ||
24 | 26 | ||
25 | /* | 27 | /* |
26 | * Some useful ethtool_ops methods that're device independent. | 28 | * Some useful ethtool_ops methods that're device independent. |
@@ -317,7 +319,7 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr) | |||
317 | 319 | ||
318 | dev->wanted_features &= ~features[0].valid; | 320 | dev->wanted_features &= ~features[0].valid; |
319 | dev->wanted_features |= features[0].valid & features[0].requested; | 321 | dev->wanted_features |= features[0].valid & features[0].requested; |
320 | netdev_update_features(dev); | 322 | __netdev_update_features(dev); |
321 | 323 | ||
322 | if ((dev->wanted_features ^ dev->features) & features[0].valid) | 324 | if ((dev->wanted_features ^ dev->features) & features[0].valid) |
323 | ret |= ETHTOOL_F_WISH; | 325 | ret |= ETHTOOL_F_WISH; |
@@ -359,8 +361,8 @@ static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GS | |||
359 | /* NETIF_F_NTUPLE */ "rx-ntuple-filter", | 361 | /* NETIF_F_NTUPLE */ "rx-ntuple-filter", |
360 | /* NETIF_F_RXHASH */ "rx-hashing", | 362 | /* NETIF_F_RXHASH */ "rx-hashing", |
361 | /* NETIF_F_RXCSUM */ "rx-checksum", | 363 | /* NETIF_F_RXCSUM */ "rx-checksum", |
362 | "", | 364 | /* NETIF_F_NOCACHE_COPY */ "tx-nocache-copy" |
363 | "", | 365 | /* NETIF_F_LOOPBACK */ "loopback", |
364 | }; | 366 | }; |
365 | 367 | ||
366 | static int __ethtool_get_sset_count(struct net_device *dev, int sset) | 368 | static int __ethtool_get_sset_count(struct net_device *dev, int sset) |
@@ -499,7 +501,7 @@ static int ethtool_set_one_feature(struct net_device *dev, | |||
499 | else | 501 | else |
500 | dev->wanted_features &= ~mask; | 502 | dev->wanted_features &= ~mask; |
501 | 503 | ||
502 | netdev_update_features(dev); | 504 | __netdev_update_features(dev); |
503 | return 0; | 505 | return 0; |
504 | } | 506 | } |
505 | 507 | ||
@@ -544,14 +546,14 @@ int __ethtool_set_flags(struct net_device *dev, u32 data) | |||
544 | } | 546 | } |
545 | 547 | ||
546 | /* allow changing only bits set in hw_features */ | 548 | /* allow changing only bits set in hw_features */ |
547 | changed = (data ^ dev->wanted_features) & flags_dup_features; | 549 | changed = (data ^ dev->features) & flags_dup_features; |
548 | if (changed & ~dev->hw_features) | 550 | if (changed & ~dev->hw_features) |
549 | return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP; | 551 | return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP; |
550 | 552 | ||
551 | dev->wanted_features = | 553 | dev->wanted_features = |
552 | (dev->wanted_features & ~changed) | data; | 554 | (dev->wanted_features & ~changed) | (data & dev->hw_features); |
553 | 555 | ||
554 | netdev_update_features(dev); | 556 | __netdev_update_features(dev); |
555 | 557 | ||
556 | return 0; | 558 | return 0; |
557 | } | 559 | } |
@@ -908,6 +910,9 @@ static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev, | |||
908 | struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL; | 910 | struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL; |
909 | int ret; | 911 | int ret; |
910 | 912 | ||
913 | if (!ops->set_rx_ntuple) | ||
914 | return -EOPNOTSUPP; | ||
915 | |||
911 | if (!(dev->features & NETIF_F_NTUPLE)) | 916 | if (!(dev->features & NETIF_F_NTUPLE)) |
912 | return -EINVAL; | 917 | return -EINVAL; |
913 | 918 | ||
@@ -1441,6 +1446,35 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) | |||
1441 | return dev->ethtool_ops->set_ringparam(dev, &ringparam); | 1446 | return dev->ethtool_ops->set_ringparam(dev, &ringparam); |
1442 | } | 1447 | } |
1443 | 1448 | ||
1449 | static noinline_for_stack int ethtool_get_channels(struct net_device *dev, | ||
1450 | void __user *useraddr) | ||
1451 | { | ||
1452 | struct ethtool_channels channels = { .cmd = ETHTOOL_GCHANNELS }; | ||
1453 | |||
1454 | if (!dev->ethtool_ops->get_channels) | ||
1455 | return -EOPNOTSUPP; | ||
1456 | |||
1457 | dev->ethtool_ops->get_channels(dev, &channels); | ||
1458 | |||
1459 | if (copy_to_user(useraddr, &channels, sizeof(channels))) | ||
1460 | return -EFAULT; | ||
1461 | return 0; | ||
1462 | } | ||
1463 | |||
1464 | static noinline_for_stack int ethtool_set_channels(struct net_device *dev, | ||
1465 | void __user *useraddr) | ||
1466 | { | ||
1467 | struct ethtool_channels channels; | ||
1468 | |||
1469 | if (!dev->ethtool_ops->set_channels) | ||
1470 | return -EOPNOTSUPP; | ||
1471 | |||
1472 | if (copy_from_user(&channels, useraddr, sizeof(channels))) | ||
1473 | return -EFAULT; | ||
1474 | |||
1475 | return dev->ethtool_ops->set_channels(dev, &channels); | ||
1476 | } | ||
1477 | |||
1444 | static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr) | 1478 | static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr) |
1445 | { | 1479 | { |
1446 | struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM }; | 1480 | struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM }; |
@@ -1618,14 +1652,60 @@ out: | |||
1618 | static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | 1652 | static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) |
1619 | { | 1653 | { |
1620 | struct ethtool_value id; | 1654 | struct ethtool_value id; |
1655 | static bool busy; | ||
1656 | int rc; | ||
1621 | 1657 | ||
1622 | if (!dev->ethtool_ops->phys_id) | 1658 | if (!dev->ethtool_ops->set_phys_id) |
1623 | return -EOPNOTSUPP; | 1659 | return -EOPNOTSUPP; |
1624 | 1660 | ||
1661 | if (busy) | ||
1662 | return -EBUSY; | ||
1663 | |||
1625 | if (copy_from_user(&id, useraddr, sizeof(id))) | 1664 | if (copy_from_user(&id, useraddr, sizeof(id))) |
1626 | return -EFAULT; | 1665 | return -EFAULT; |
1627 | 1666 | ||
1628 | return dev->ethtool_ops->phys_id(dev, id.data); | 1667 | rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE); |
1668 | if (rc < 0) | ||
1669 | return rc; | ||
1670 | |||
1671 | /* Drop the RTNL lock while waiting, but prevent reentry or | ||
1672 | * removal of the device. | ||
1673 | */ | ||
1674 | busy = true; | ||
1675 | dev_hold(dev); | ||
1676 | rtnl_unlock(); | ||
1677 | |||
1678 | if (rc == 0) { | ||
1679 | /* Driver will handle this itself */ | ||
1680 | schedule_timeout_interruptible( | ||
1681 | id.data ? (id.data * HZ) : MAX_SCHEDULE_TIMEOUT); | ||
1682 | } else { | ||
1683 | /* Driver expects to be called at twice the frequency in rc */ | ||
1684 | int n = rc * 2, i, interval = HZ / n; | ||
1685 | |||
1686 | /* Count down seconds */ | ||
1687 | do { | ||
1688 | /* Count down iterations per second */ | ||
1689 | i = n; | ||
1690 | do { | ||
1691 | rtnl_lock(); | ||
1692 | rc = dev->ethtool_ops->set_phys_id(dev, | ||
1693 | (i & 1) ? ETHTOOL_ID_OFF : ETHTOOL_ID_ON); | ||
1694 | rtnl_unlock(); | ||
1695 | if (rc) | ||
1696 | break; | ||
1697 | schedule_timeout_interruptible(interval); | ||
1698 | } while (!signal_pending(current) && --i != 0); | ||
1699 | } while (!signal_pending(current) && | ||
1700 | (id.data == 0 || --id.data != 0)); | ||
1701 | } | ||
1702 | |||
1703 | rtnl_lock(); | ||
1704 | dev_put(dev); | ||
1705 | busy = false; | ||
1706 | |||
1707 | (void)dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_INACTIVE); | ||
1708 | return rc; | ||
1629 | } | 1709 | } |
1630 | 1710 | ||
1631 | static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) | 1711 | static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) |
@@ -1953,6 +2033,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) | |||
1953 | case ETHTOOL_SGRO: | 2033 | case ETHTOOL_SGRO: |
1954 | rc = ethtool_set_one_feature(dev, useraddr, ethcmd); | 2034 | rc = ethtool_set_one_feature(dev, useraddr, ethcmd); |
1955 | break; | 2035 | break; |
2036 | case ETHTOOL_GCHANNELS: | ||
2037 | rc = ethtool_get_channels(dev, useraddr); | ||
2038 | break; | ||
2039 | case ETHTOOL_SCHANNELS: | ||
2040 | rc = ethtool_set_channels(dev, useraddr); | ||
2041 | break; | ||
1956 | default: | 2042 | default: |
1957 | rc = -EOPNOTSUPP; | 2043 | rc = -EOPNOTSUPP; |
1958 | } | 2044 | } |
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 8248ebb5891d..3911586e12e4 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -590,7 +590,8 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb, | |||
590 | int idx = 0; | 590 | int idx = 0; |
591 | struct fib_rule *rule; | 591 | struct fib_rule *rule; |
592 | 592 | ||
593 | list_for_each_entry(rule, &ops->rules_list, list) { | 593 | rcu_read_lock(); |
594 | list_for_each_entry_rcu(rule, &ops->rules_list, list) { | ||
594 | if (idx < cb->args[1]) | 595 | if (idx < cb->args[1]) |
595 | goto skip; | 596 | goto skip; |
596 | 597 | ||
diff --git a/net/core/filter.c b/net/core/filter.c index afb8afb066bb..0eb8c4466eaa 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -39,65 +39,6 @@ | |||
39 | #include <linux/filter.h> | 39 | #include <linux/filter.h> |
40 | #include <linux/reciprocal_div.h> | 40 | #include <linux/reciprocal_div.h> |
41 | 41 | ||
42 | enum { | ||
43 | BPF_S_RET_K = 1, | ||
44 | BPF_S_RET_A, | ||
45 | BPF_S_ALU_ADD_K, | ||
46 | BPF_S_ALU_ADD_X, | ||
47 | BPF_S_ALU_SUB_K, | ||
48 | BPF_S_ALU_SUB_X, | ||
49 | BPF_S_ALU_MUL_K, | ||
50 | BPF_S_ALU_MUL_X, | ||
51 | BPF_S_ALU_DIV_X, | ||
52 | BPF_S_ALU_AND_K, | ||
53 | BPF_S_ALU_AND_X, | ||
54 | BPF_S_ALU_OR_K, | ||
55 | BPF_S_ALU_OR_X, | ||
56 | BPF_S_ALU_LSH_K, | ||
57 | BPF_S_ALU_LSH_X, | ||
58 | BPF_S_ALU_RSH_K, | ||
59 | BPF_S_ALU_RSH_X, | ||
60 | BPF_S_ALU_NEG, | ||
61 | BPF_S_LD_W_ABS, | ||
62 | BPF_S_LD_H_ABS, | ||
63 | BPF_S_LD_B_ABS, | ||
64 | BPF_S_LD_W_LEN, | ||
65 | BPF_S_LD_W_IND, | ||
66 | BPF_S_LD_H_IND, | ||
67 | BPF_S_LD_B_IND, | ||
68 | BPF_S_LD_IMM, | ||
69 | BPF_S_LDX_W_LEN, | ||
70 | BPF_S_LDX_B_MSH, | ||
71 | BPF_S_LDX_IMM, | ||
72 | BPF_S_MISC_TAX, | ||
73 | BPF_S_MISC_TXA, | ||
74 | BPF_S_ALU_DIV_K, | ||
75 | BPF_S_LD_MEM, | ||
76 | BPF_S_LDX_MEM, | ||
77 | BPF_S_ST, | ||
78 | BPF_S_STX, | ||
79 | BPF_S_JMP_JA, | ||
80 | BPF_S_JMP_JEQ_K, | ||
81 | BPF_S_JMP_JEQ_X, | ||
82 | BPF_S_JMP_JGE_K, | ||
83 | BPF_S_JMP_JGE_X, | ||
84 | BPF_S_JMP_JGT_K, | ||
85 | BPF_S_JMP_JGT_X, | ||
86 | BPF_S_JMP_JSET_K, | ||
87 | BPF_S_JMP_JSET_X, | ||
88 | /* Ancillary data */ | ||
89 | BPF_S_ANC_PROTOCOL, | ||
90 | BPF_S_ANC_PKTTYPE, | ||
91 | BPF_S_ANC_IFINDEX, | ||
92 | BPF_S_ANC_NLATTR, | ||
93 | BPF_S_ANC_NLATTR_NEST, | ||
94 | BPF_S_ANC_MARK, | ||
95 | BPF_S_ANC_QUEUE, | ||
96 | BPF_S_ANC_HATYPE, | ||
97 | BPF_S_ANC_RXHASH, | ||
98 | BPF_S_ANC_CPU, | ||
99 | }; | ||
100 | |||
101 | /* No hurry in this branch */ | 42 | /* No hurry in this branch */ |
102 | static void *__load_pointer(const struct sk_buff *skb, int k, unsigned int size) | 43 | static void *__load_pointer(const struct sk_buff *skb, int k, unsigned int size) |
103 | { | 44 | { |
@@ -145,7 +86,7 @@ int sk_filter(struct sock *sk, struct sk_buff *skb) | |||
145 | rcu_read_lock(); | 86 | rcu_read_lock(); |
146 | filter = rcu_dereference(sk->sk_filter); | 87 | filter = rcu_dereference(sk->sk_filter); |
147 | if (filter) { | 88 | if (filter) { |
148 | unsigned int pkt_len = sk_run_filter(skb, filter->insns); | 89 | unsigned int pkt_len = SK_RUN_FILTER(filter, skb); |
149 | 90 | ||
150 | err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM; | 91 | err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM; |
151 | } | 92 | } |
@@ -638,6 +579,7 @@ void sk_filter_release_rcu(struct rcu_head *rcu) | |||
638 | { | 579 | { |
639 | struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu); | 580 | struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu); |
640 | 581 | ||
582 | bpf_jit_free(fp); | ||
641 | kfree(fp); | 583 | kfree(fp); |
642 | } | 584 | } |
643 | EXPORT_SYMBOL(sk_filter_release_rcu); | 585 | EXPORT_SYMBOL(sk_filter_release_rcu); |
@@ -672,6 +614,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) | |||
672 | 614 | ||
673 | atomic_set(&fp->refcnt, 1); | 615 | atomic_set(&fp->refcnt, 1); |
674 | fp->len = fprog->len; | 616 | fp->len = fprog->len; |
617 | fp->bpf_func = sk_run_filter; | ||
675 | 618 | ||
676 | err = sk_chk_filter(fp->insns, fp->len); | 619 | err = sk_chk_filter(fp->insns, fp->len); |
677 | if (err) { | 620 | if (err) { |
@@ -679,6 +622,8 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) | |||
679 | return err; | 622 | return err; |
680 | } | 623 | } |
681 | 624 | ||
625 | bpf_jit_compile(fp); | ||
626 | |||
682 | old_fp = rcu_dereference_protected(sk->sk_filter, | 627 | old_fp = rcu_dereference_protected(sk->sk_filter, |
683 | sock_owned_by_user(sk)); | 628 | sock_owned_by_user(sk)); |
684 | rcu_assign_pointer(sk->sk_filter, fp); | 629 | rcu_assign_pointer(sk->sk_filter, fp); |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 5ceb257e860c..381813eae46c 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -28,6 +28,7 @@ | |||
28 | static const char fmt_hex[] = "%#x\n"; | 28 | static const char fmt_hex[] = "%#x\n"; |
29 | static const char fmt_long_hex[] = "%#lx\n"; | 29 | static const char fmt_long_hex[] = "%#lx\n"; |
30 | static const char fmt_dec[] = "%d\n"; | 30 | static const char fmt_dec[] = "%d\n"; |
31 | static const char fmt_udec[] = "%u\n"; | ||
31 | static const char fmt_ulong[] = "%lu\n"; | 32 | static const char fmt_ulong[] = "%lu\n"; |
32 | static const char fmt_u64[] = "%llu\n"; | 33 | static const char fmt_u64[] = "%llu\n"; |
33 | 34 | ||
@@ -145,13 +146,10 @@ static ssize_t show_speed(struct device *dev, | |||
145 | if (!rtnl_trylock()) | 146 | if (!rtnl_trylock()) |
146 | return restart_syscall(); | 147 | return restart_syscall(); |
147 | 148 | ||
148 | if (netif_running(netdev) && | 149 | if (netif_running(netdev)) { |
149 | netdev->ethtool_ops && | 150 | struct ethtool_cmd cmd; |
150 | netdev->ethtool_ops->get_settings) { | 151 | if (!dev_ethtool_get_settings(netdev, &cmd)) |
151 | struct ethtool_cmd cmd = { ETHTOOL_GSET }; | 152 | ret = sprintf(buf, fmt_udec, ethtool_cmd_speed(&cmd)); |
152 | |||
153 | if (!netdev->ethtool_ops->get_settings(netdev, &cmd)) | ||
154 | ret = sprintf(buf, fmt_dec, ethtool_cmd_speed(&cmd)); | ||
155 | } | 153 | } |
156 | rtnl_unlock(); | 154 | rtnl_unlock(); |
157 | return ret; | 155 | return ret; |
@@ -166,13 +164,11 @@ static ssize_t show_duplex(struct device *dev, | |||
166 | if (!rtnl_trylock()) | 164 | if (!rtnl_trylock()) |
167 | return restart_syscall(); | 165 | return restart_syscall(); |
168 | 166 | ||
169 | if (netif_running(netdev) && | 167 | if (netif_running(netdev)) { |
170 | netdev->ethtool_ops && | 168 | struct ethtool_cmd cmd; |
171 | netdev->ethtool_ops->get_settings) { | 169 | if (!dev_ethtool_get_settings(netdev, &cmd)) |
172 | struct ethtool_cmd cmd = { ETHTOOL_GSET }; | 170 | ret = sprintf(buf, "%s\n", |
173 | 171 | cmd.duplex ? "full" : "half"); | |
174 | if (!netdev->ethtool_ops->get_settings(netdev, &cmd)) | ||
175 | ret = sprintf(buf, "%s\n", cmd.duplex ? "full" : "half"); | ||
176 | } | 172 | } |
177 | rtnl_unlock(); | 173 | rtnl_unlock(); |
178 | return ret; | 174 | return ret; |
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 3f860261c5ee..1abb50841046 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
@@ -216,11 +216,14 @@ static void net_free(struct net *net) | |||
216 | kmem_cache_free(net_cachep, net); | 216 | kmem_cache_free(net_cachep, net); |
217 | } | 217 | } |
218 | 218 | ||
219 | static struct net *net_create(void) | 219 | struct net *copy_net_ns(unsigned long flags, struct net *old_net) |
220 | { | 220 | { |
221 | struct net *net; | 221 | struct net *net; |
222 | int rv; | 222 | int rv; |
223 | 223 | ||
224 | if (!(flags & CLONE_NEWNET)) | ||
225 | return get_net(old_net); | ||
226 | |||
224 | net = net_alloc(); | 227 | net = net_alloc(); |
225 | if (!net) | 228 | if (!net) |
226 | return ERR_PTR(-ENOMEM); | 229 | return ERR_PTR(-ENOMEM); |
@@ -239,13 +242,6 @@ static struct net *net_create(void) | |||
239 | return net; | 242 | return net; |
240 | } | 243 | } |
241 | 244 | ||
242 | struct net *copy_net_ns(unsigned long flags, struct net *old_net) | ||
243 | { | ||
244 | if (!(flags & CLONE_NEWNET)) | ||
245 | return get_net(old_net); | ||
246 | return net_create(); | ||
247 | } | ||
248 | |||
249 | static DEFINE_SPINLOCK(cleanup_list_lock); | 245 | static DEFINE_SPINLOCK(cleanup_list_lock); |
250 | static LIST_HEAD(cleanup_list); /* Must hold cleanup_list_lock to touch */ | 246 | static LIST_HEAD(cleanup_list); /* Must hold cleanup_list_lock to touch */ |
251 | 247 | ||
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 06be2431753e..2d7d6d473781 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -539,7 +539,7 @@ int __netpoll_rx(struct sk_buff *skb) | |||
539 | { | 539 | { |
540 | int proto, len, ulen; | 540 | int proto, len, ulen; |
541 | int hits = 0; | 541 | int hits = 0; |
542 | struct iphdr *iph; | 542 | const struct iphdr *iph; |
543 | struct udphdr *uh; | 543 | struct udphdr *uh; |
544 | struct netpoll_info *npinfo = skb->dev->npinfo; | 544 | struct netpoll_info *npinfo = skb->dev->npinfo; |
545 | struct netpoll *np, *tmp; | 545 | struct netpoll *np, *tmp; |
@@ -698,32 +698,8 @@ int netpoll_parse_options(struct netpoll *np, char *opt) | |||
698 | 698 | ||
699 | if (*cur != 0) { | 699 | if (*cur != 0) { |
700 | /* MAC address */ | 700 | /* MAC address */ |
701 | if ((delim = strchr(cur, ':')) == NULL) | 701 | if (!mac_pton(cur, np->remote_mac)) |
702 | goto parse_failed; | ||
703 | *delim = 0; | ||
704 | np->remote_mac[0] = simple_strtol(cur, NULL, 16); | ||
705 | cur = delim + 1; | ||
706 | if ((delim = strchr(cur, ':')) == NULL) | ||
707 | goto parse_failed; | ||
708 | *delim = 0; | ||
709 | np->remote_mac[1] = simple_strtol(cur, NULL, 16); | ||
710 | cur = delim + 1; | ||
711 | if ((delim = strchr(cur, ':')) == NULL) | ||
712 | goto parse_failed; | 702 | goto parse_failed; |
713 | *delim = 0; | ||
714 | np->remote_mac[2] = simple_strtol(cur, NULL, 16); | ||
715 | cur = delim + 1; | ||
716 | if ((delim = strchr(cur, ':')) == NULL) | ||
717 | goto parse_failed; | ||
718 | *delim = 0; | ||
719 | np->remote_mac[3] = simple_strtol(cur, NULL, 16); | ||
720 | cur = delim + 1; | ||
721 | if ((delim = strchr(cur, ':')) == NULL) | ||
722 | goto parse_failed; | ||
723 | *delim = 0; | ||
724 | np->remote_mac[4] = simple_strtol(cur, NULL, 16); | ||
725 | cur = delim + 1; | ||
726 | np->remote_mac[5] = simple_strtol(cur, NULL, 16); | ||
727 | } | 703 | } |
728 | 704 | ||
729 | netpoll_print_options(np); | 705 | netpoll_print_options(np); |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index aeeece72b72f..379270f14771 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -449,7 +449,6 @@ static void pktgen_stop(struct pktgen_thread *t); | |||
449 | static void pktgen_clear_counters(struct pktgen_dev *pkt_dev); | 449 | static void pktgen_clear_counters(struct pktgen_dev *pkt_dev); |
450 | 450 | ||
451 | static unsigned int scan_ip6(const char *s, char ip[16]); | 451 | static unsigned int scan_ip6(const char *s, char ip[16]); |
452 | static unsigned int fmt_ip6(char *s, const char ip[16]); | ||
453 | 452 | ||
454 | /* Module parameters, defaults. */ | 453 | /* Module parameters, defaults. */ |
455 | static int pg_count_d __read_mostly = 1000; | 454 | static int pg_count_d __read_mostly = 1000; |
@@ -556,21 +555,13 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
556 | pkt_dev->skb_priority); | 555 | pkt_dev->skb_priority); |
557 | 556 | ||
558 | if (pkt_dev->flags & F_IPV6) { | 557 | if (pkt_dev->flags & F_IPV6) { |
559 | char b1[128], b2[128], b3[128]; | ||
560 | fmt_ip6(b1, pkt_dev->in6_saddr.s6_addr); | ||
561 | fmt_ip6(b2, pkt_dev->min_in6_saddr.s6_addr); | ||
562 | fmt_ip6(b3, pkt_dev->max_in6_saddr.s6_addr); | ||
563 | seq_printf(seq, | 558 | seq_printf(seq, |
564 | " saddr: %s min_saddr: %s max_saddr: %s\n", b1, | 559 | " saddr: %pI6c min_saddr: %pI6c max_saddr: %pI6c\n" |
565 | b2, b3); | 560 | " daddr: %pI6c min_daddr: %pI6c max_daddr: %pI6c\n", |
566 | 561 | &pkt_dev->in6_saddr, | |
567 | fmt_ip6(b1, pkt_dev->in6_daddr.s6_addr); | 562 | &pkt_dev->min_in6_saddr, &pkt_dev->max_in6_saddr, |
568 | fmt_ip6(b2, pkt_dev->min_in6_daddr.s6_addr); | 563 | &pkt_dev->in6_daddr, |
569 | fmt_ip6(b3, pkt_dev->max_in6_daddr.s6_addr); | 564 | &pkt_dev->min_in6_daddr, &pkt_dev->max_in6_daddr); |
570 | seq_printf(seq, | ||
571 | " daddr: %s min_daddr: %s max_daddr: %s\n", b1, | ||
572 | b2, b3); | ||
573 | |||
574 | } else { | 565 | } else { |
575 | seq_printf(seq, | 566 | seq_printf(seq, |
576 | " dst_min: %s dst_max: %s\n", | 567 | " dst_min: %s dst_max: %s\n", |
@@ -706,10 +697,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
706 | pkt_dev->cur_src_mac_offset); | 697 | pkt_dev->cur_src_mac_offset); |
707 | 698 | ||
708 | if (pkt_dev->flags & F_IPV6) { | 699 | if (pkt_dev->flags & F_IPV6) { |
709 | char b1[128], b2[128]; | 700 | seq_printf(seq, " cur_saddr: %pI6c cur_daddr: %pI6c\n", |
710 | fmt_ip6(b1, pkt_dev->cur_in6_daddr.s6_addr); | 701 | &pkt_dev->cur_in6_saddr, |
711 | fmt_ip6(b2, pkt_dev->cur_in6_saddr.s6_addr); | 702 | &pkt_dev->cur_in6_daddr); |
712 | seq_printf(seq, " cur_saddr: %s cur_daddr: %s\n", b2, b1); | ||
713 | } else | 703 | } else |
714 | seq_printf(seq, " cur_saddr: 0x%x cur_daddr: 0x%x\n", | 704 | seq_printf(seq, " cur_saddr: 0x%x cur_daddr: 0x%x\n", |
715 | pkt_dev->cur_saddr, pkt_dev->cur_daddr); | 705 | pkt_dev->cur_saddr, pkt_dev->cur_daddr); |
@@ -1309,7 +1299,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1309 | buf[len] = 0; | 1299 | buf[len] = 0; |
1310 | 1300 | ||
1311 | scan_ip6(buf, pkt_dev->in6_daddr.s6_addr); | 1301 | scan_ip6(buf, pkt_dev->in6_daddr.s6_addr); |
1312 | fmt_ip6(buf, pkt_dev->in6_daddr.s6_addr); | 1302 | snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->in6_daddr); |
1313 | 1303 | ||
1314 | ipv6_addr_copy(&pkt_dev->cur_in6_daddr, &pkt_dev->in6_daddr); | 1304 | ipv6_addr_copy(&pkt_dev->cur_in6_daddr, &pkt_dev->in6_daddr); |
1315 | 1305 | ||
@@ -1332,7 +1322,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1332 | buf[len] = 0; | 1322 | buf[len] = 0; |
1333 | 1323 | ||
1334 | scan_ip6(buf, pkt_dev->min_in6_daddr.s6_addr); | 1324 | scan_ip6(buf, pkt_dev->min_in6_daddr.s6_addr); |
1335 | fmt_ip6(buf, pkt_dev->min_in6_daddr.s6_addr); | 1325 | snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->min_in6_daddr); |
1336 | 1326 | ||
1337 | ipv6_addr_copy(&pkt_dev->cur_in6_daddr, | 1327 | ipv6_addr_copy(&pkt_dev->cur_in6_daddr, |
1338 | &pkt_dev->min_in6_daddr); | 1328 | &pkt_dev->min_in6_daddr); |
@@ -1355,7 +1345,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1355 | buf[len] = 0; | 1345 | buf[len] = 0; |
1356 | 1346 | ||
1357 | scan_ip6(buf, pkt_dev->max_in6_daddr.s6_addr); | 1347 | scan_ip6(buf, pkt_dev->max_in6_daddr.s6_addr); |
1358 | fmt_ip6(buf, pkt_dev->max_in6_daddr.s6_addr); | 1348 | snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->max_in6_daddr); |
1359 | 1349 | ||
1360 | if (debug) | 1350 | if (debug) |
1361 | printk(KERN_DEBUG "pktgen: dst6_max set to: %s\n", buf); | 1351 | printk(KERN_DEBUG "pktgen: dst6_max set to: %s\n", buf); |
@@ -1376,7 +1366,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1376 | buf[len] = 0; | 1366 | buf[len] = 0; |
1377 | 1367 | ||
1378 | scan_ip6(buf, pkt_dev->in6_saddr.s6_addr); | 1368 | scan_ip6(buf, pkt_dev->in6_saddr.s6_addr); |
1379 | fmt_ip6(buf, pkt_dev->in6_saddr.s6_addr); | 1369 | snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->in6_saddr); |
1380 | 1370 | ||
1381 | ipv6_addr_copy(&pkt_dev->cur_in6_saddr, &pkt_dev->in6_saddr); | 1371 | ipv6_addr_copy(&pkt_dev->cur_in6_saddr, &pkt_dev->in6_saddr); |
1382 | 1372 | ||
@@ -1430,11 +1420,6 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1430 | return count; | 1420 | return count; |
1431 | } | 1421 | } |
1432 | if (!strcmp(name, "dst_mac")) { | 1422 | if (!strcmp(name, "dst_mac")) { |
1433 | char *v = valstr; | ||
1434 | unsigned char old_dmac[ETH_ALEN]; | ||
1435 | unsigned char *m = pkt_dev->dst_mac; | ||
1436 | memcpy(old_dmac, pkt_dev->dst_mac, ETH_ALEN); | ||
1437 | |||
1438 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); | 1423 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); |
1439 | if (len < 0) | 1424 | if (len < 0) |
1440 | return len; | 1425 | return len; |
@@ -1442,35 +1427,16 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1442 | memset(valstr, 0, sizeof(valstr)); | 1427 | memset(valstr, 0, sizeof(valstr)); |
1443 | if (copy_from_user(valstr, &user_buffer[i], len)) | 1428 | if (copy_from_user(valstr, &user_buffer[i], len)) |
1444 | return -EFAULT; | 1429 | return -EFAULT; |
1445 | i += len; | ||
1446 | |||
1447 | for (*m = 0; *v && m < pkt_dev->dst_mac + 6; v++) { | ||
1448 | int value; | ||
1449 | |||
1450 | value = hex_to_bin(*v); | ||
1451 | if (value >= 0) | ||
1452 | *m = *m * 16 + value; | ||
1453 | |||
1454 | if (*v == ':') { | ||
1455 | m++; | ||
1456 | *m = 0; | ||
1457 | } | ||
1458 | } | ||
1459 | 1430 | ||
1431 | if (!mac_pton(valstr, pkt_dev->dst_mac)) | ||
1432 | return -EINVAL; | ||
1460 | /* Set up Dest MAC */ | 1433 | /* Set up Dest MAC */ |
1461 | if (compare_ether_addr(old_dmac, pkt_dev->dst_mac)) | 1434 | memcpy(&pkt_dev->hh[0], pkt_dev->dst_mac, ETH_ALEN); |
1462 | memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, ETH_ALEN); | ||
1463 | 1435 | ||
1464 | sprintf(pg_result, "OK: dstmac"); | 1436 | sprintf(pg_result, "OK: dstmac %pM", pkt_dev->dst_mac); |
1465 | return count; | 1437 | return count; |
1466 | } | 1438 | } |
1467 | if (!strcmp(name, "src_mac")) { | 1439 | if (!strcmp(name, "src_mac")) { |
1468 | char *v = valstr; | ||
1469 | unsigned char old_smac[ETH_ALEN]; | ||
1470 | unsigned char *m = pkt_dev->src_mac; | ||
1471 | |||
1472 | memcpy(old_smac, pkt_dev->src_mac, ETH_ALEN); | ||
1473 | |||
1474 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); | 1440 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); |
1475 | if (len < 0) | 1441 | if (len < 0) |
1476 | return len; | 1442 | return len; |
@@ -1478,26 +1444,13 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1478 | memset(valstr, 0, sizeof(valstr)); | 1444 | memset(valstr, 0, sizeof(valstr)); |
1479 | if (copy_from_user(valstr, &user_buffer[i], len)) | 1445 | if (copy_from_user(valstr, &user_buffer[i], len)) |
1480 | return -EFAULT; | 1446 | return -EFAULT; |
1481 | i += len; | ||
1482 | |||
1483 | for (*m = 0; *v && m < pkt_dev->src_mac + 6; v++) { | ||
1484 | int value; | ||
1485 | |||
1486 | value = hex_to_bin(*v); | ||
1487 | if (value >= 0) | ||
1488 | *m = *m * 16 + value; | ||
1489 | |||
1490 | if (*v == ':') { | ||
1491 | m++; | ||
1492 | *m = 0; | ||
1493 | } | ||
1494 | } | ||
1495 | 1447 | ||
1448 | if (!mac_pton(valstr, pkt_dev->src_mac)) | ||
1449 | return -EINVAL; | ||
1496 | /* Set up Src MAC */ | 1450 | /* Set up Src MAC */ |
1497 | if (compare_ether_addr(old_smac, pkt_dev->src_mac)) | 1451 | memcpy(&pkt_dev->hh[6], pkt_dev->src_mac, ETH_ALEN); |
1498 | memcpy(&(pkt_dev->hh[6]), pkt_dev->src_mac, ETH_ALEN); | ||
1499 | 1452 | ||
1500 | sprintf(pg_result, "OK: srcmac"); | 1453 | sprintf(pg_result, "OK: srcmac %pM", pkt_dev->src_mac); |
1501 | return count; | 1454 | return count; |
1502 | } | 1455 | } |
1503 | 1456 | ||
@@ -2514,7 +2467,6 @@ static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev) | |||
2514 | { | 2467 | { |
2515 | struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x; | 2468 | struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x; |
2516 | int err = 0; | 2469 | int err = 0; |
2517 | struct iphdr *iph; | ||
2518 | 2470 | ||
2519 | if (!x) | 2471 | if (!x) |
2520 | return 0; | 2472 | return 0; |
@@ -2524,7 +2476,6 @@ static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev) | |||
2524 | return 0; | 2476 | return 0; |
2525 | 2477 | ||
2526 | spin_lock(&x->lock); | 2478 | spin_lock(&x->lock); |
2527 | iph = ip_hdr(skb); | ||
2528 | 2479 | ||
2529 | err = x->outer_mode->output(x, skb); | 2480 | err = x->outer_mode->output(x, skb); |
2530 | if (err) | 2481 | if (err) |
@@ -2624,6 +2575,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, | |||
2624 | } else { | 2575 | } else { |
2625 | int frags = pkt_dev->nfrags; | 2576 | int frags = pkt_dev->nfrags; |
2626 | int i, len; | 2577 | int i, len; |
2578 | int frag_len; | ||
2627 | 2579 | ||
2628 | 2580 | ||
2629 | if (frags > MAX_SKB_FRAGS) | 2581 | if (frags > MAX_SKB_FRAGS) |
@@ -2635,6 +2587,8 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, | |||
2635 | } | 2587 | } |
2636 | 2588 | ||
2637 | i = 0; | 2589 | i = 0; |
2590 | frag_len = (datalen/frags) < PAGE_SIZE ? | ||
2591 | (datalen/frags) : PAGE_SIZE; | ||
2638 | while (datalen > 0) { | 2592 | while (datalen > 0) { |
2639 | if (unlikely(!pkt_dev->page)) { | 2593 | if (unlikely(!pkt_dev->page)) { |
2640 | int node = numa_node_id(); | 2594 | int node = numa_node_id(); |
@@ -2648,38 +2602,18 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, | |||
2648 | skb_shinfo(skb)->frags[i].page = pkt_dev->page; | 2602 | skb_shinfo(skb)->frags[i].page = pkt_dev->page; |
2649 | get_page(pkt_dev->page); | 2603 | get_page(pkt_dev->page); |
2650 | skb_shinfo(skb)->frags[i].page_offset = 0; | 2604 | skb_shinfo(skb)->frags[i].page_offset = 0; |
2651 | skb_shinfo(skb)->frags[i].size = | 2605 | /*last fragment, fill rest of data*/ |
2652 | (datalen < PAGE_SIZE ? datalen : PAGE_SIZE); | 2606 | if (i == (frags - 1)) |
2607 | skb_shinfo(skb)->frags[i].size = | ||
2608 | (datalen < PAGE_SIZE ? datalen : PAGE_SIZE); | ||
2609 | else | ||
2610 | skb_shinfo(skb)->frags[i].size = frag_len; | ||
2653 | datalen -= skb_shinfo(skb)->frags[i].size; | 2611 | datalen -= skb_shinfo(skb)->frags[i].size; |
2654 | skb->len += skb_shinfo(skb)->frags[i].size; | 2612 | skb->len += skb_shinfo(skb)->frags[i].size; |
2655 | skb->data_len += skb_shinfo(skb)->frags[i].size; | 2613 | skb->data_len += skb_shinfo(skb)->frags[i].size; |
2656 | i++; | 2614 | i++; |
2657 | skb_shinfo(skb)->nr_frags = i; | 2615 | skb_shinfo(skb)->nr_frags = i; |
2658 | } | 2616 | } |
2659 | |||
2660 | while (i < frags) { | ||
2661 | int rem; | ||
2662 | |||
2663 | if (i == 0) | ||
2664 | break; | ||
2665 | |||
2666 | rem = skb_shinfo(skb)->frags[i - 1].size / 2; | ||
2667 | if (rem == 0) | ||
2668 | break; | ||
2669 | |||
2670 | skb_shinfo(skb)->frags[i - 1].size -= rem; | ||
2671 | |||
2672 | skb_shinfo(skb)->frags[i] = | ||
2673 | skb_shinfo(skb)->frags[i - 1]; | ||
2674 | get_page(skb_shinfo(skb)->frags[i].page); | ||
2675 | skb_shinfo(skb)->frags[i].page = | ||
2676 | skb_shinfo(skb)->frags[i - 1].page; | ||
2677 | skb_shinfo(skb)->frags[i].page_offset += | ||
2678 | skb_shinfo(skb)->frags[i - 1].size; | ||
2679 | skb_shinfo(skb)->frags[i].size = rem; | ||
2680 | i++; | ||
2681 | skb_shinfo(skb)->nr_frags = i; | ||
2682 | } | ||
2683 | } | 2617 | } |
2684 | 2618 | ||
2685 | /* Stamp the time, and sequence number, | 2619 | /* Stamp the time, and sequence number, |
@@ -2917,79 +2851,6 @@ static unsigned int scan_ip6(const char *s, char ip[16]) | |||
2917 | return len; | 2851 | return len; |
2918 | } | 2852 | } |
2919 | 2853 | ||
2920 | static char tohex(char hexdigit) | ||
2921 | { | ||
2922 | return hexdigit > 9 ? hexdigit + 'a' - 10 : hexdigit + '0'; | ||
2923 | } | ||
2924 | |||
2925 | static int fmt_xlong(char *s, unsigned int i) | ||
2926 | { | ||
2927 | char *bak = s; | ||
2928 | *s = tohex((i >> 12) & 0xf); | ||
2929 | if (s != bak || *s != '0') | ||
2930 | ++s; | ||
2931 | *s = tohex((i >> 8) & 0xf); | ||
2932 | if (s != bak || *s != '0') | ||
2933 | ++s; | ||
2934 | *s = tohex((i >> 4) & 0xf); | ||
2935 | if (s != bak || *s != '0') | ||
2936 | ++s; | ||
2937 | *s = tohex(i & 0xf); | ||
2938 | return s - bak + 1; | ||
2939 | } | ||
2940 | |||
2941 | static unsigned int fmt_ip6(char *s, const char ip[16]) | ||
2942 | { | ||
2943 | unsigned int len; | ||
2944 | unsigned int i; | ||
2945 | unsigned int temp; | ||
2946 | unsigned int compressing; | ||
2947 | int j; | ||
2948 | |||
2949 | len = 0; | ||
2950 | compressing = 0; | ||
2951 | for (j = 0; j < 16; j += 2) { | ||
2952 | |||
2953 | #ifdef V4MAPPEDPREFIX | ||
2954 | if (j == 12 && !memcmp(ip, V4mappedprefix, 12)) { | ||
2955 | inet_ntoa_r(*(struct in_addr *)(ip + 12), s); | ||
2956 | temp = strlen(s); | ||
2957 | return len + temp; | ||
2958 | } | ||
2959 | #endif | ||
2960 | temp = ((unsigned long)(unsigned char)ip[j] << 8) + | ||
2961 | (unsigned long)(unsigned char)ip[j + 1]; | ||
2962 | if (temp == 0) { | ||
2963 | if (!compressing) { | ||
2964 | compressing = 1; | ||
2965 | if (j == 0) { | ||
2966 | *s++ = ':'; | ||
2967 | ++len; | ||
2968 | } | ||
2969 | } | ||
2970 | } else { | ||
2971 | if (compressing) { | ||
2972 | compressing = 0; | ||
2973 | *s++ = ':'; | ||
2974 | ++len; | ||
2975 | } | ||
2976 | i = fmt_xlong(s, temp); | ||
2977 | len += i; | ||
2978 | s += i; | ||
2979 | if (j < 14) { | ||
2980 | *s++ = ':'; | ||
2981 | ++len; | ||
2982 | } | ||
2983 | } | ||
2984 | } | ||
2985 | if (compressing) { | ||
2986 | *s++ = ':'; | ||
2987 | ++len; | ||
2988 | } | ||
2989 | *s = 0; | ||
2990 | return len; | ||
2991 | } | ||
2992 | |||
2993 | static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | 2854 | static struct sk_buff *fill_packet_ipv6(struct net_device *odev, |
2994 | struct pktgen_dev *pkt_dev) | 2855 | struct pktgen_dev *pkt_dev) |
2995 | { | 2856 | { |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index d7c4bb4b1820..d2ba2597c75a 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -1007,10 +1007,11 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | |||
1007 | s_h = cb->args[0]; | 1007 | s_h = cb->args[0]; |
1008 | s_idx = cb->args[1]; | 1008 | s_idx = cb->args[1]; |
1009 | 1009 | ||
1010 | rcu_read_lock(); | ||
1010 | for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { | 1011 | for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { |
1011 | idx = 0; | 1012 | idx = 0; |
1012 | head = &net->dev_index_head[h]; | 1013 | head = &net->dev_index_head[h]; |
1013 | hlist_for_each_entry(dev, node, head, index_hlist) { | 1014 | hlist_for_each_entry_rcu(dev, node, head, index_hlist) { |
1014 | if (idx < s_idx) | 1015 | if (idx < s_idx) |
1015 | goto cont; | 1016 | goto cont; |
1016 | if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, | 1017 | if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, |
@@ -1023,6 +1024,7 @@ cont: | |||
1023 | } | 1024 | } |
1024 | } | 1025 | } |
1025 | out: | 1026 | out: |
1027 | rcu_read_unlock(); | ||
1026 | cb->args[1] = idx; | 1028 | cb->args[1] = idx; |
1027 | cb->args[0] = h; | 1029 | cb->args[0] = h; |
1028 | 1030 | ||
@@ -1499,6 +1501,7 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
1499 | char ifname[IFNAMSIZ]; | 1501 | char ifname[IFNAMSIZ]; |
1500 | struct nlattr *tb[IFLA_MAX+1]; | 1502 | struct nlattr *tb[IFLA_MAX+1]; |
1501 | int err; | 1503 | int err; |
1504 | LIST_HEAD(list_kill); | ||
1502 | 1505 | ||
1503 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); | 1506 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); |
1504 | if (err < 0) | 1507 | if (err < 0) |
@@ -1522,7 +1525,9 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
1522 | if (!ops) | 1525 | if (!ops) |
1523 | return -EOPNOTSUPP; | 1526 | return -EOPNOTSUPP; |
1524 | 1527 | ||
1525 | ops->dellink(dev, NULL); | 1528 | ops->dellink(dev, &list_kill); |
1529 | unregister_netdevice_many(&list_kill); | ||
1530 | list_del(&list_kill); | ||
1526 | return 0; | 1531 | return 0; |
1527 | } | 1532 | } |
1528 | 1533 | ||
@@ -1570,12 +1575,6 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net, | |||
1570 | dev->rtnl_link_state = RTNL_LINK_INITIALIZING; | 1575 | dev->rtnl_link_state = RTNL_LINK_INITIALIZING; |
1571 | dev->real_num_tx_queues = real_num_queues; | 1576 | dev->real_num_tx_queues = real_num_queues; |
1572 | 1577 | ||
1573 | if (strchr(dev->name, '%')) { | ||
1574 | err = dev_alloc_name(dev, dev->name); | ||
1575 | if (err < 0) | ||
1576 | goto err_free; | ||
1577 | } | ||
1578 | |||
1579 | if (tb[IFLA_MTU]) | 1578 | if (tb[IFLA_MTU]) |
1580 | dev->mtu = nla_get_u32(tb[IFLA_MTU]); | 1579 | dev->mtu = nla_get_u32(tb[IFLA_MTU]); |
1581 | if (tb[IFLA_ADDRESS]) | 1580 | if (tb[IFLA_ADDRESS]) |
@@ -1595,8 +1594,6 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net, | |||
1595 | 1594 | ||
1596 | return dev; | 1595 | return dev; |
1597 | 1596 | ||
1598 | err_free: | ||
1599 | free_netdev(dev); | ||
1600 | err: | 1597 | err: |
1601 | return ERR_PTR(err); | 1598 | return ERR_PTR(err); |
1602 | } | 1599 | } |
@@ -1879,7 +1876,6 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1879 | int min_len; | 1876 | int min_len; |
1880 | int family; | 1877 | int family; |
1881 | int type; | 1878 | int type; |
1882 | int err; | ||
1883 | 1879 | ||
1884 | type = nlh->nlmsg_type; | 1880 | type = nlh->nlmsg_type; |
1885 | if (type > RTM_MAX) | 1881 | if (type > RTM_MAX) |
@@ -1906,11 +1902,8 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1906 | if (dumpit == NULL) | 1902 | if (dumpit == NULL) |
1907 | return -EOPNOTSUPP; | 1903 | return -EOPNOTSUPP; |
1908 | 1904 | ||
1909 | __rtnl_unlock(); | ||
1910 | rtnl = net->rtnl; | 1905 | rtnl = net->rtnl; |
1911 | err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL); | 1906 | return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL); |
1912 | rtnl_lock(); | ||
1913 | return err; | ||
1914 | } | 1907 | } |
1915 | 1908 | ||
1916 | memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *))); | 1909 | memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *))); |
@@ -1980,7 +1973,7 @@ static int __net_init rtnetlink_net_init(struct net *net) | |||
1980 | { | 1973 | { |
1981 | struct sock *sk; | 1974 | struct sock *sk; |
1982 | sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX, | 1975 | sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX, |
1983 | rtnetlink_rcv, &rtnl_mutex, THIS_MODULE); | 1976 | rtnetlink_rcv, NULL, THIS_MODULE); |
1984 | if (!sk) | 1977 | if (!sk) |
1985 | return -ENOMEM; | 1978 | return -ENOMEM; |
1986 | net->rtnl = sk; | 1979 | net->rtnl = sk; |
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 385b6095fdc4..a829e3f60aeb 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c | |||
@@ -122,6 +122,15 @@ static struct ctl_table net_core_table[] = { | |||
122 | .mode = 0644, | 122 | .mode = 0644, |
123 | .proc_handler = proc_dointvec | 123 | .proc_handler = proc_dointvec |
124 | }, | 124 | }, |
125 | #ifdef CONFIG_BPF_JIT | ||
126 | { | ||
127 | .procname = "bpf_jit_enable", | ||
128 | .data = &bpf_jit_enable, | ||
129 | .maxlen = sizeof(int), | ||
130 | .mode = 0644, | ||
131 | .proc_handler = proc_dointvec | ||
132 | }, | ||
133 | #endif | ||
125 | { | 134 | { |
126 | .procname = "netdev_tstamp_prequeue", | 135 | .procname = "netdev_tstamp_prequeue", |
127 | .data = &netdev_tstamp_prequeue, | 136 | .data = &netdev_tstamp_prequeue, |
diff --git a/net/core/utils.c b/net/core/utils.c index 5fea0ab21902..2012bc797f9c 100644 --- a/net/core/utils.c +++ b/net/core/utils.c | |||
@@ -296,3 +296,27 @@ void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | |||
296 | csum_unfold(*sum))); | 296 | csum_unfold(*sum))); |
297 | } | 297 | } |
298 | EXPORT_SYMBOL(inet_proto_csum_replace4); | 298 | EXPORT_SYMBOL(inet_proto_csum_replace4); |
299 | |||
300 | int mac_pton(const char *s, u8 *mac) | ||
301 | { | ||
302 | int i; | ||
303 | |||
304 | /* XX:XX:XX:XX:XX:XX */ | ||
305 | if (strlen(s) < 3 * ETH_ALEN - 1) | ||
306 | return 0; | ||
307 | |||
308 | /* Don't dirty result unless string is valid MAC. */ | ||
309 | for (i = 0; i < ETH_ALEN; i++) { | ||
310 | if (!strchr("0123456789abcdefABCDEF", s[i * 3])) | ||
311 | return 0; | ||
312 | if (!strchr("0123456789abcdefABCDEF", s[i * 3 + 1])) | ||
313 | return 0; | ||
314 | if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':') | ||
315 | return 0; | ||
316 | } | ||
317 | for (i = 0; i < ETH_ALEN; i++) { | ||
318 | mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]); | ||
319 | } | ||
320 | return 1; | ||
321 | } | ||
322 | EXPORT_SYMBOL(mac_pton); | ||