conf: forbid use of multicast mac addresses

A few times libvirt users manually setting mac addresses have
complained of a networking failure that ends up being due to a multicast
mac address being used for a guest interface. This patch prevents that
by logging an error and failing if a multicast mac address is
encountered in each of the three following cases:

1) domain xml <interface> mac address.
2) network xml bridge mac address.
3) network xml dhcp/host mac address.

There are several other places where a mac address can be input that
aren't controlled in this manner because failure to do so has no
consequences (e.g., if the address will be used to search through
existing interfaces for a match).

The RNG has been updated to add multiMacAddr and uniMacAddr along with
the existing macAddr, and macAddr was switched to uniMacAddr where
appropriate.
This commit is contained in:
Laine Stump
2012-03-19 12:49:17 -04:00
parent 43d635caf3
commit 0007237301
8 changed files with 69 additions and 17 deletions

View File

@@ -55,9 +55,24 @@
</define>
<!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
<!-- The lowest bit of the 1st byte is the "multicast" bit. a -->
<!-- uniMacAddr requires that bit to be 0, and a multiMacAddr -->
<!-- requires it to be 1. Plain macAddr will accept either. -->
<!-- Currently there is no use of multiMacAddr in libvirt, it -->
<!-- is included here for documentation/comparison purposes. -->
<define name="uniMacAddr">
<data type="string">
<param name="pattern">[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5}</param>
</data>
</define>
<define name="multiMacAddr">
<data type="string">
<param name="pattern">[a-fA-F0-9][13579bBdDfF](:[a-fA-F0-9]{2}){5}</param>
</data>
</define>
<define name="macAddr">
<data type="string">
<param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param>
<param name="pattern">[a-fA-F0-9]{2}(:[a-fA-F0-9]{2}){5}</param>
</data>
</define>

View File

@@ -1391,7 +1391,7 @@
<optional>
<element name="mac">
<attribute name="address">
<ref name="macAddr"/>
<ref name="uniMacAddr"/>
</attribute>
<empty/>
</element>
@@ -1417,7 +1417,7 @@
<optional>
<element name="mac">
<attribute name="address">
<ref name="macAddr"/>
<ref name="uniMacAddr"/>
</attribute>
<empty/>
</element>
@@ -1498,7 +1498,7 @@
<optional>
<element name="mac">
<attribute name="address">
<ref name="macAddr"/>
<ref name="uniMacAddr"/>
</attribute>
<empty/>
</element>

View File

@@ -57,7 +57,7 @@
<!-- <mac> element -->
<optional>
<element name="mac">
<attribute name="address"><ref name="macAddr"/></attribute>
<attribute name="address"><ref name="uniMacAddr"/></attribute>
<empty/>
</element>
</optional>
@@ -218,7 +218,7 @@
</zeroOrMore>
<zeroOrMore>
<element name="host">
<attribute name="mac"><ref name="macAddr"/></attribute>
<attribute name="mac"><ref name="uniMacAddr"/></attribute>
<attribute name="name"><text/></attribute>
<attribute name="ip"><ref name="ipv4Addr"/></attribute>
</element>