[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [patch 3/5] xen: xm/create mac selection



Check for duplicate supplied vif MACs, and make sure
that randomly generated MACs for a domain are all different

Signed-off-by: Jody Belka <knew-xen@xxxxxxxx>


diffstat:
 create.py |   11 +++++++++++
 1 files changed, 11 insertions(+)


diff -durN xen.orig/tools/python/xen/xm/create.py 
xen/tools/python/xen/xm/create.py
--- xen.orig/tools/python/xen/xm/create.py      2005-01-30 00:46:29.000000000 
+0100
+++ xen/tools/python/xen/xm/create.py   2005-01-31 18:33:34.744204752 +0100
@@ -279,10 +279,15 @@
     vifs = vals.vif
     vifs_n = max(vals.nics, len(vifs))
 
+    macs = []
+    mac_vifs = {}
+
     for idx in range(0, vifs_n):
         if idx < len(vifs):
             d = vifs[idx]
             mac = d.get('mac')
+            if mac in macs:
+                gopts.err('Duplicate MAC: %s selected for both vif%i and 
vif%i' % (mac, mac_vifs[mac], idx + 1))
             if not mac:
                 mac = randomMAC()
             bridge = d.get('bridge')
@@ -295,6 +300,12 @@
             script = None
             backend = None
             ip = None
+
+        while mac in macs:
+            mac = randomMAC()
+        macs.append(mac)
+        mac_vifs[mac] = idx + 1
+
         config_vif = ['vif']
         config_vif.append(['mac', mac])
         if bridge:


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.