aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2012-12-31 22:30:18 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-04 01:37:36 -0500
commit646cbcdae50e9ef40d7b77673a1f1b7eb7c18be5 (patch)
tree38492474e5578dcf2db44e070447b5fbc9a43244 /arch/um
parent15c6ff3bc0ff3464a8c7efcdea09c86454571622 (diff)
um: net: use eth_hw_addr_random() to generate random mac
Also remove unused "mac" from uml_net struct. Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/net_kern.c22
-rw-r--r--arch/um/include/shared/net_kern.h1
2 files changed, 8 insertions, 15 deletions
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index b1314ebf1f72..fd9090df64b6 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -293,8 +293,9 @@ static void uml_net_user_timer_expire(unsigned long _conn)
293#endif 293#endif
294} 294}
295 295
296static int setup_etheraddr(char *str, unsigned char *addr, char *name) 296static void setup_etheraddr(struct net_device *dev, char *str)
297{ 297{
298 unsigned char *addr = dev->dev_addr;
298 char *end; 299 char *end;
299 int i; 300 int i;
300 301
@@ -334,13 +335,12 @@ static int setup_etheraddr(char *str, unsigned char *addr, char *name)
334 addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4], 335 addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4],
335 addr[5]); 336 addr[5]);
336 } 337 }
337 return 0; 338 return;
338 339
339random: 340random:
340 printk(KERN_INFO 341 printk(KERN_INFO
341 "Choosing a random ethernet address for device %s\n", name); 342 "Choosing a random ethernet address for device %s\n", dev->name);
342 eth_random_addr(addr); 343 eth_hw_addr_random(dev);
343 return 1;
344} 344}
345 345
346static DEFINE_SPINLOCK(devices_lock); 346static DEFINE_SPINLOCK(devices_lock);
@@ -392,7 +392,6 @@ static void eth_configure(int n, void *init, char *mac,
392 struct net_device *dev; 392 struct net_device *dev;
393 struct uml_net_private *lp; 393 struct uml_net_private *lp;
394 int err, size; 394 int err, size;
395 int random_mac;
396 395
397 size = transport->private_size + sizeof(struct uml_net_private); 396 size = transport->private_size + sizeof(struct uml_net_private);
398 397
@@ -419,9 +418,9 @@ static void eth_configure(int n, void *init, char *mac,
419 */ 418 */
420 snprintf(dev->name, sizeof(dev->name), "eth%d", n); 419 snprintf(dev->name, sizeof(dev->name), "eth%d", n);
421 420
422 random_mac = setup_etheraddr(mac, device->mac, dev->name); 421 setup_etheraddr(dev, mac);
423 422
424 printk(KERN_INFO "Netdevice %d (%pM) : ", n, device->mac); 423 printk(KERN_INFO "Netdevice %d (%pM) : ", n, dev->dev_addr);
425 424
426 lp = netdev_priv(dev); 425 lp = netdev_priv(dev);
427 /* This points to the transport private data. It's still clear, but we 426 /* This points to the transport private data. It's still clear, but we
@@ -468,17 +467,12 @@ static void eth_configure(int n, void *init, char *mac,
468 init_timer(&lp->tl); 467 init_timer(&lp->tl);
469 spin_lock_init(&lp->lock); 468 spin_lock_init(&lp->lock);
470 lp->tl.function = uml_net_user_timer_expire; 469 lp->tl.function = uml_net_user_timer_expire;
471 memcpy(lp->mac, device->mac, sizeof(lp->mac)); 470 memcpy(lp->mac, dev->dev_addr, sizeof(lp->mac));
472 471
473 if ((transport->user->init != NULL) && 472 if ((transport->user->init != NULL) &&
474 ((*transport->user->init)(&lp->user, dev) != 0)) 473 ((*transport->user->init)(&lp->user, dev) != 0))
475 goto out_unregister; 474 goto out_unregister;
476 475
477 /* don't use eth_mac_addr, it will not work here */
478 memcpy(dev->dev_addr, device->mac, ETH_ALEN);
479 if (random_mac)
480 dev->addr_assign_type |= NET_ADDR_RANDOM;
481
482 dev->mtu = transport->user->mtu; 476 dev->mtu = transport->user->mtu;
483 dev->netdev_ops = &uml_netdev_ops; 477 dev->netdev_ops = &uml_netdev_ops;
484 dev->ethtool_ops = &uml_net_ethtool_ops; 478 dev->ethtool_ops = &uml_net_ethtool_ops;
diff --git a/arch/um/include/shared/net_kern.h b/arch/um/include/shared/net_kern.h
index 5c367f22595b..012ac87d4900 100644
--- a/arch/um/include/shared/net_kern.h
+++ b/arch/um/include/shared/net_kern.h
@@ -18,7 +18,6 @@ struct uml_net {
18 struct net_device *dev; 18 struct net_device *dev;
19 struct platform_device pdev; 19 struct platform_device pdev;
20 int index; 20 int index;
21 unsigned char mac[ETH_ALEN];
22}; 21};
23 22
24struct uml_net_private { 23struct uml_net_private {