[ovs-dev] [PATCH] vswitch: Consistently set Nicira OUI.

Jesse Gross jesse at nicira.com
Mon Feb 1 15:30:24 PST 2010


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.
---
 lib/packets.h       |   12 ++++++++++++
 ofproto/fail-open.c |    2 +-
 ofproto/ofproto.c   |    5 +----
 vswitchd/bridge.c   |    2 +-
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/lib/packets.h b/lib/packets.h
index f61c20c..2d2764b 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -83,6 +83,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 bits to indicate random Nicira address. */
+    ea[3] |= 0xc0;
+}
 /* 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])
diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index 48f7069..54a91cd 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -99,7 +99,7 @@ send_bogus_packet_in(struct fail_open *fo)
 
     /* Compose ofp_packet_in. */
     ofpbuf_init(&b, 128);
-    eth_addr_random(mac);
+    eth_addr_nicira_random(mac);
     compose_benign_packet(&b, "Open vSwitch Controller Probe", 0xa033, mac);
     opi = make_packet_in(pktbuf_get_null(), OFPP_LOCAL, OFPR_NO_MATCH, &b, 64);
     ofpbuf_uninit(&b);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 10b4796..55f8169 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -3389,10 +3389,7 @@ static uint64_t
 pick_fallback_dpid(void)
 {
     uint8_t ea[ETH_ADDR_LEN];
-    eth_addr_random(ea);
-    ea[0] = 0x00;               /* Set Nicira OUI. */
-    ea[1] = 0x23;
-    ea[2] = 0x20;
+    eth_addr_nicira_random(ea);
     return eth_addr_to_uint64(ea);
 }
 
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 66f0884..a5f4831 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1113,7 +1113,7 @@ bridge_create(const struct ovsrec_bridge *br_cfg)
     br->cfg = br_cfg;
     br->ml = mac_learning_create();
     br->sent_config_request = false;
-    eth_addr_random(br->default_ea);
+    eth_addr_nicira_random(br->default_ea);
 
     port_array_init(&br->ifaces);
 
-- 
1.6.3.3





More information about the dev mailing list