From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com,
bhutchings@solarflare.com, shemminger@vyatta.com,
sassmann@redhat.com, kaber@trash.net, richard@nod.at
Subject: [patch net-next 6/7] um: net: use eth_hw_addr_random() to generate random mac
Date: Tue, 1 Jan 2013 14:30:18 +0100 [thread overview]
Message-ID: <1357047019-1037-7-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1357047019-1037-1-git-send-email-jiri@resnulli.us>
Also remove unused "mac" from uml_net struct.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
arch/um/drivers/net_kern.c | 22 ++++++++--------------
arch/um/include/shared/net_kern.h | 1 -
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index b1314eb..fd9090d 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)
#endif
}
-static int setup_etheraddr(char *str, unsigned char *addr, char *name)
+static void setup_etheraddr(struct net_device *dev, char *str)
{
+ unsigned char *addr = dev->dev_addr;
char *end;
int i;
@@ -334,13 +335,12 @@ static int setup_etheraddr(char *str, unsigned char *addr, char *name)
addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4],
addr[5]);
}
- return 0;
+ return;
random:
printk(KERN_INFO
- "Choosing a random ethernet address for device %s\n", name);
- eth_random_addr(addr);
- return 1;
+ "Choosing a random ethernet address for device %s\n", dev->name);
+ eth_hw_addr_random(dev);
}
static DEFINE_SPINLOCK(devices_lock);
@@ -392,7 +392,6 @@ static void eth_configure(int n, void *init, char *mac,
struct net_device *dev;
struct uml_net_private *lp;
int err, size;
- int random_mac;
size = transport->private_size + sizeof(struct uml_net_private);
@@ -419,9 +418,9 @@ static void eth_configure(int n, void *init, char *mac,
*/
snprintf(dev->name, sizeof(dev->name), "eth%d", n);
- random_mac = setup_etheraddr(mac, device->mac, dev->name);
+ setup_etheraddr(dev, mac);
- printk(KERN_INFO "Netdevice %d (%pM) : ", n, device->mac);
+ printk(KERN_INFO "Netdevice %d (%pM) : ", n, dev->dev_addr);
lp = netdev_priv(dev);
/* 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,
init_timer(&lp->tl);
spin_lock_init(&lp->lock);
lp->tl.function = uml_net_user_timer_expire;
- memcpy(lp->mac, device->mac, sizeof(lp->mac));
+ memcpy(lp->mac, dev->dev_addr, sizeof(lp->mac));
if ((transport->user->init != NULL) &&
((*transport->user->init)(&lp->user, dev) != 0))
goto out_unregister;
- /* don't use eth_mac_addr, it will not work here */
- memcpy(dev->dev_addr, device->mac, ETH_ALEN);
- if (random_mac)
- dev->addr_assign_type |= NET_ADDR_RANDOM;
-
dev->mtu = transport->user->mtu;
dev->netdev_ops = ¨_netdev_ops;
dev->ethtool_ops = ¨_net_ethtool_ops;
diff --git a/arch/um/include/shared/net_kern.h b/arch/um/include/shared/net_kern.h
index 5c367f2..012ac87 100644
--- a/arch/um/include/shared/net_kern.h
+++ b/arch/um/include/shared/net_kern.h
@@ -18,7 +18,6 @@ struct uml_net {
struct net_device *dev;
struct platform_device pdev;
int index;
- unsigned char mac[ETH_ALEN];
};
struct uml_net_private {
--
1.8.0
next prev parent reply other threads:[~2013-01-01 13:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-01 13:30 [patch net-next 0/7] fix dev->addr_assign_type setting and related code Jiri Pirko
2013-01-01 13:30 ` [patch net-next 1/7] rtnl: use dev_set_mac_address() instead of plain ndo_ Jiri Pirko
2013-01-01 18:33 ` Stephen Hemminger
2013-01-01 19:00 ` Jiri Pirko
2013-01-01 13:30 ` [patch net-next 2/7] net: call add_device_randomness() only after successful mac change Jiri Pirko
2013-01-01 13:30 ` [patch net-next 3/7] net: set dev->addr_assign_type correctly Jiri Pirko
2013-01-01 13:30 ` [patch net-next 4/7] net: add address assign type "SET" Jiri Pirko
2013-01-01 13:30 ` [patch net-next 5/7] net: remove unnecessary NET_ADDR_RANDOM "bitclean" Jiri Pirko
2013-01-10 2:55 ` Antonio Quartulli
2013-01-01 13:30 ` Jiri Pirko [this message]
2013-01-01 13:30 ` [patch net-next 7/7] ll_temac: fix mac address setting Jiri Pirko
2013-01-04 6:43 ` [patch net-next 0/7] fix dev->addr_assign_type setting and related code David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1357047019-1037-7-git-send-email-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=richard@nod.at \
--cc=sassmann@redhat.com \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).