aboutsummaryrefslogtreecommitdiff
path: root/lib/packets.h
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2010-02-01 18:20:22 -0500
committerJesse Gross <jesse@nicira.com>2010-02-08 15:01:20 -0500
commit70150daf2fd88a84f80044a9589e97942b85c25b (patch)
treefbf12edf3960f8deb58ba97adbed594a232695aa /lib/packets.h
parenta91f96d70870e2ba5324d4b5cea5aa9fe874ebee (diff)
vswitch: Consistently set Nicira OUI.
In places where a random Ethernet address needs to be generated we are inconsistent about setting an OUI. This sets an OUI everywhere to allow the source of packets to be easily identified.
Diffstat (limited to 'lib/packets.h')
-rw-r--r--lib/packets.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/packets.h b/lib/packets.h
index f61c20ca..6513f64b 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -44,7 +44,10 @@ static inline bool eth_addr_is_multicast(const uint8_t ea[6])
}
static inline bool eth_addr_is_local(const uint8_t ea[6])
{
- return ea[0] & 2;
+ /* Local if it is either a locally administered address or a Nicira random
+ * address. */
+ return !!(ea[0] & 2)
+ || (ea[0] == 0x00 && ea[1] == 0x23 && ea[2] == 0x20 && !!(ea[3] & 0x80));
}
static inline bool eth_addr_is_zero(const uint8_t ea[6])
{
@@ -83,6 +86,18 @@ static inline void eth_addr_random(uint8_t ea[ETH_ADDR_LEN])
random_bytes(ea, ETH_ADDR_LEN);
eth_addr_mark_random(ea);
}
+static inline void eth_addr_nicira_random(uint8_t ea[ETH_ADDR_LEN])
+{
+ eth_addr_random(ea);
+
+ /* Set the OUI to the Nicira one. */
+ ea[0] = 0x00;
+ ea[1] = 0x23;
+ ea[2] = 0x20;
+
+ /* Set the top bit to indicate random Nicira address. */
+ ea[3] |= 0x80;
+}
/* Returns true if 'ea' is a reserved multicast address, that a bridge must
* never forward, false otherwise. */
static inline bool eth_addr_is_reserved(const uint8_t ea[ETH_ADDR_LEN])