bond: Handle multicast mac address of ad_actor_system
Raise NmstateValueError when desire state is using an IANA multicast MAC address(with prefix of `01-00-5E`) as bond `ad_actor_system` option. Integration test case included. Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
parent
1101bb0cf1
commit
57f97403c7
@ -32,6 +32,8 @@ from .base_iface import BaseIface
|
||||
|
||||
DEPRECATED_SLAVES = "slaves"
|
||||
|
||||
IANA_MULTICAST_MAC_ADDRESS_PREFIX = "01:00:5E"
|
||||
|
||||
|
||||
class BondIface(BaseIface):
|
||||
_MODE_CHANGE_METADATA = "_bond_mode_changed"
|
||||
@ -93,6 +95,7 @@ class BondIface(BaseIface):
|
||||
self._validate_bond_mode()
|
||||
self._fix_mac_restriced_mode()
|
||||
self._validate_miimon_conflict_with_arp_interval()
|
||||
self._validate_ad_actor_system_mac_address()
|
||||
|
||||
def _discard_bond_option_when_mode_change(self):
|
||||
if self.is_bond_mode_changed:
|
||||
@ -234,6 +237,21 @@ class BondIface(BaseIface):
|
||||
else:
|
||||
return current_value, value
|
||||
|
||||
def _validate_ad_actor_system_mac_address(self):
|
||||
desire_mac = (
|
||||
self.original_dict.get(Bond.CONFIG_SUBTREE, {})
|
||||
.get(Bond.OPTIONS_SUBTREE, {})
|
||||
.get("ad_actor_system")
|
||||
)
|
||||
if desire_mac and desire_mac.upper().startswith(
|
||||
IANA_MULTICAST_MAC_ADDRESS_PREFIX
|
||||
):
|
||||
raise NmstateValueError(
|
||||
"The ad_actor_system bond option cannot be an IANA "
|
||||
"multicast address(prefix with "
|
||||
f"{IANA_MULTICAST_MAC_ADDRESS_PREFIX})"
|
||||
)
|
||||
|
||||
|
||||
class _BondNamedOptions:
|
||||
AD_SELECT = "ad_select"
|
||||
|
@ -1134,3 +1134,15 @@ def test_bond_mac_restriction_check_only_impact_desired(eth1_up, eth2_up):
|
||||
finally:
|
||||
dummy_iface_state[Interface.STATE] = InterfaceState.ABSENT
|
||||
libnmstate.apply({Interface.KEY: [dummy_iface_state]})
|
||||
|
||||
|
||||
def test_bond_ad_actor_system_with_multicast_mac_address(bond99_with_2_port):
|
||||
desired_state = bond99_with_2_port
|
||||
bond_state = desired_state[Interface.KEY][0]
|
||||
bond_state[Bond.CONFIG_SUBTREE][Bond.MODE] = BondMode.LACP
|
||||
bond_state[Bond.CONFIG_SUBTREE][Bond.OPTIONS_SUBTREE] = {
|
||||
"ad_actor_system": "01:00:5E:00:0f:01"
|
||||
}
|
||||
|
||||
with pytest.raises(NmstateValueError):
|
||||
libnmstate.apply(desired_state)
|
||||
|
Loading…
x
Reference in New Issue
Block a user