From: Stephen Hemminger <shemminger@vyatta.com>
To: netdev@vger.kernel.org
Subject: [RFC] ethernet: avoid pre-assigned OUI values in random_ether_addr
Date: Fri, 13 May 2011 17:17:29 -0700 [thread overview]
Message-ID: <20110513171729.247b126e@nehalam> (raw)
There are some addresses in the assigned vendor block that don't obey
the locally assigned convention. These should be avoided by random_ether_addr
assignment.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
include/linux/etherdevice.h | 17 +----------------
net/ethernet/eth.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 16 deletions(-)
--- a/include/linux/etherdevice.h 2011-05-13 12:37:08.199257621 -0700
+++ b/include/linux/etherdevice.h 2011-05-13 16:48:46.722745009 -0700
@@ -45,8 +45,7 @@ extern void eth_header_cache_update(stru
extern int eth_mac_addr(struct net_device *dev, void *p);
extern int eth_change_mtu(struct net_device *dev, int new_mtu);
extern int eth_validate_addr(struct net_device *dev);
-
-
+extern void random_ether_addr(u8 *addr);
extern struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
unsigned int rxqs);
@@ -126,20 +125,6 @@ static inline int is_valid_ether_addr(co
}
/**
- * random_ether_addr - Generate software assigned random Ethernet address
- * @addr: Pointer to a six-byte array containing the Ethernet address
- *
- * Generate a random Ethernet address (MAC) that is not multicast
- * and has the local assigned bit set.
- */
-static inline void random_ether_addr(u8 *addr)
-{
- get_random_bytes (addr, ETH_ALEN);
- addr [0] &= 0xfe; /* clear multicast bit */
- addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
-}
-
-/**
* dev_hw_addr_random - Create random MAC and set device flag
* @dev: pointer to net_device structure
* @hwaddr: Pointer to a six-byte array containing the Ethernet address
--- a/net/ethernet/eth.c 2011-05-13 12:37:08.219257985 -0700
+++ b/net/ethernet/eth.c 2011-05-13 17:03:39.412209908 -0700
@@ -392,3 +392,46 @@ ssize_t sysfs_format_mac(char *buf, cons
return (ssize_t)l;
}
EXPORT_SYMBOL(sysfs_format_mac);
+
+/* These vendors are known to violate the local MAC address assignment
+ convention. Avoid using them. */
+static const struct {
+ u8 oui[3];
+} inuse[] = {
+ { .oui = { 0x02, 0x07, 0x01 } }, /* Interlan */
+ { .oui = { 0x02, 0x60, 0x60 } }, /* 3Com */
+ { .oui = { 0x02, 0x60, 0x8c } }, /* 3Com */
+ { .oui = { 0x02, 0xa0, 0xc9 } }, /* Intel */
+ { .oui = { 0x02, 0xaa, 0x3c } }, /* Olivetti */
+ { .oui = { 0x02, 0xcf, 0x1f } }, /* CMC */
+ { .oui = { 0x02, 0xe0, 0x3b } }, /* Prominet */
+ { .oui = { 0x02, 0xe6, 0xd3 } }, /* BTI */
+ { .oui = { 0x52, 0x54, 0x00 } }, /* Realtek */
+ { .oui = { 0x52, 0x54, 0x4c } }, /* Novell 2000 */
+ { .oui = { 0x52, 0x54, 0xab } }, /* Realtec */
+ { .oui = { 0xe2, 0x0c, 0x0f } }, /* Kingston Technologies */
+};
+
+/**
+ * random_ether_addr - Generate software assigned random Ethernet address
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Generate a random Ethernet address (MAC) that is not multicast
+ * and has the local assigned bit set.
+ */
+
+void random_ether_addr(u8 *addr)
+{
+ int i;
+
+ retry:
+ get_random_bytes (addr, ETH_ALEN);
+
+ addr [0] &= 0xfe; /* clear multicast bit */
+ addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
+
+ for (i = 0; i < ARRAY_SIZE(inuse); i++)
+ if (memcmp(inuse[i].oui, addr, 3) == 0)
+ goto retry;
+}
+EXPORT_SYMBOL(random_ether_addr);
next reply other threads:[~2011-05-14 0:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-14 0:17 Stephen Hemminger [this message]
2011-05-14 0:28 ` [RFC] ethernet: avoid pre-assigned OUI values in random_ether_addr Rick Jones
2011-05-14 0:32 ` Stephen Hemminger
2011-05-14 0:44 ` Rick Jones
2011-05-14 1:00 ` Rick Jones
2011-05-14 6:28 ` Bill Fink
2011-05-16 14:29 ` Rick Jones
2011-05-15 19:46 ` Eric Dumazet
2011-05-15 20:20 ` Joe Perches
2011-05-15 21:10 ` Eric Dumazet
2011-05-16 15:46 ` Stephen Hemminger
2011-05-20 19:01 ` Stephen Hemminger
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=20110513171729.247b126e@nehalam \
--to=shemminger@vyatta.com \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.