summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces_ethernet.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2025-12-23 13:43:55 +0000
committerGitHub <noreply@github.com>2025-12-23 13:43:55 +0000
commit583b29ba947d8c8ab4bdcd02b4af7d4d2bf80ca0 (patch)
tree46980081529dd701ae0f3d5e016266930fadec09 /src/conf_mode/interfaces_ethernet.py
parentf4f19d33b5568fe14117b0c55fc4ccf423541730 (diff)
parent066d2be8b3d57b2171aa2056c7d953810f50dcb8 (diff)
downloadvyos-1x-583b29ba947d8c8ab4bdcd02b4af7d4d2bf80ca0.tar.gz
vyos-1x-583b29ba947d8c8ab4bdcd02b4af7d4d2bf80ca0.zip
Merge pull request #4911 from c-po/bond-ena
bond: T8084: disallow bond members that do not support MAC changes
Diffstat (limited to 'src/conf_mode/interfaces_ethernet.py')
-rwxr-xr-xsrc/conf_mode/interfaces_ethernet.py54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/conf_mode/interfaces_ethernet.py b/src/conf_mode/interfaces_ethernet.py
index edcc6563c..d926c458c 100755
--- a/src/conf_mode/interfaces_ethernet.py
+++ b/src/conf_mode/interfaces_ethernet.py
@@ -273,6 +273,20 @@ def verify_offload(ethernet: dict, ethtool: Ethtool):
raise ConfigError('Xen netback drivers requires scatter-gatter offloading '\
'for MTU size larger then 1500 bytes')
+def verify_mac_change(ethernet: dict, ethtool: Ethtool):
+ """
+ Verify if ethernet card driver supports changing the interface MAC address.
+ AWS ENA driver has no support for MAC address changes.
+
+ :param ethernet: dictionary which is received from get_interface_dict
+ :type ethernet: dict
+ :param ethtool: Ethernet object
+ :type ethtool: Ethtool
+ """
+ if 'mac' not in ethernet:
+ return None
+ if not ethtool.check_mac_change():
+ raise ConfigError(f'Driver does not suport changing MAC address!')
def verify_allowedbond_changes(ethernet: dict):
"""
@@ -371,51 +385,45 @@ def verify(ethernet):
if 'deleted' in ethernet:
return None
+
+ ethtool = Ethtool(ethernet['ifname'])
+ verify_interface_exists(ethernet, ethernet['ifname'])
+ verify_eapol(ethernet)
+ verify_mirror_redirect(ethernet)
+ # No need to check speed and duplex keys as both have default values
+ verify_speed_duplex(ethernet, ethtool)
+ verify_flow_control(ethernet, ethtool)
+ verify_ring_buffer(ethernet, ethtool)
+ verify_offload(ethernet, ethtool)
+ verify_mac_change(ethernet, ethtool)
+
if 'is_bond_member' in ethernet:
- verify_bond_member(ethernet)
+ verify_bond_member(ethernet, ethtool)
else:
- verify_ethernet(ethernet)
+ verify_ethernet(ethernet, ethtool)
-def verify_bond_member(ethernet):
+def verify_bond_member(ethernet: dict, ethtool: Ethtool) -> None:
"""
Verification function for ethernet interface which is in bonding
:param ethernet: dictionary which is received from get_interface_dict
:type ethernet: dict
"""
- ifname = ethernet['ifname']
- verify_interface_exists(ethernet, ifname)
- verify_eapol(ethernet)
- verify_mirror_redirect(ethernet)
- ethtool = Ethtool(ifname)
- verify_speed_duplex(ethernet, ethtool)
- verify_flow_control(ethernet, ethtool)
- verify_ring_buffer(ethernet, ethtool)
- verify_offload(ethernet, ethtool)
verify_allowedbond_changes(ethernet)
+ return None
-def verify_ethernet(ethernet):
+def verify_ethernet(ethernet: dict, ethtool: Ethtool) -> None:
"""
Verification function for simple ethernet interface
:param ethernet: dictionary which is received from get_interface_dict
:type ethernet: dict
"""
- ifname = ethernet['ifname']
- verify_interface_exists(ethernet, ifname)
verify_mtu(ethernet)
verify_mtu_ipv6(ethernet)
verify_dhcpv6(ethernet)
verify_address(ethernet)
verify_vrf(ethernet)
verify_bond_bridge_member(ethernet)
- verify_eapol(ethernet)
- verify_mirror_redirect(ethernet)
- ethtool = Ethtool(ifname)
- # No need to check speed and duplex keys as both have default values.
- verify_speed_duplex(ethernet, ethtool)
- verify_flow_control(ethernet, ethtool)
- verify_ring_buffer(ethernet, ethtool)
- verify_offload(ethernet, ethtool)
# use common function to verify VLAN configuration
verify_vlan_config(ethernet)
return None