When a port is manually created with an invalid mac address like
'00:00:00:00:00:00' and associated to neutron router, we see an
exception in L3-agent logs. Since we do not have any valid use-case
to have a port with a mac_address of all zeros, this patch disables
the corresponding port creation/updation request.
Along with all zeros MAC, validation aganist broadcast MAC is also
included in this patch.
DocImpact
Closes-Bug: #
1472243
Change-Id: I93875716550dbc1f299aee95c45144e4904af233
valid_mac = netaddr.valid_mac(_validate_no_whitespace(data))
except Exception:
valid_mac = False
+
+ if valid_mac:
+ valid_mac = not netaddr.EUI(data) in map(netaddr.EUI,
+ constants.INVALID_MAC_ADDRESSES)
# TODO(arosen): The code in this file should be refactored
# so it catches the correct exceptions. _validate_no_whitespace
# raises AttributeError if data is None.
IPv4_BITS = 32
IPv6_BITS = 128
+INVALID_MAC_ADDRESSES = ['00:00:00:00:00:00', 'FF:FF:FF:FF:FF:FF']
+
IPv4_ANY = '0.0.0.0/0'
IPv6_ANY = '::/0'
IP_ANY = {IP_VERSION_4: IPv4_ANY, IP_VERSION_6: IPv6_ANY}
import mock
from neutron.api.v2 import attributes
+from neutron.common import constants
from neutron.common import exceptions as n_exc
from neutron.tests import base
from neutron.tests import tools
err_msg = "'%s' is not a valid MAC address"
self.assertEqual(err_msg % mac_addr, msg)
+ for invalid_mac_addr in constants.INVALID_MAC_ADDRESSES:
+ msg = validator(invalid_mac_addr)
+ self.assertEqual(err_msg % invalid_mac_addr, msg)
+
mac_addr = "123"
msg = validator(mac_addr)
self.assertEqual(err_msg % mac_addr, msg)