diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-12-19 21:16:22 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2025-12-19 21:51:28 +0100 |
| commit | ba60266ab18969d588179b3acff3bccc078b2ee8 (patch) | |
| tree | 1a1afe788275fcfde0625cdc1e7c98149d5b0674 | |
| parent | e7b65794f82026bb8f02e3ac364c1b5589c00a22 (diff) | |
| download | vyos-1x-ba60266ab18969d588179b3acff3bccc078b2ee8.tar.gz vyos-1x-ba60266ab18969d588179b3acff3bccc078b2ee8.zip | |
ethernet: T8084: prevent MAC changes on ENA interfaces (AWS EC2)
Add a safeguard to block MAC address changes when the underlying driver is ENA
(used on AWS EC2), and display a clear error message instead of raising
"OSError: [Errno 95] Operation not supported."
| -rw-r--r-- | python/vyos/ethtool.py | 8 | ||||
| -rwxr-xr-x | src/conf_mode/interfaces_ethernet.py | 15 |
2 files changed, 23 insertions, 0 deletions
diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py index 22e066def..76c5b29f0 100644 --- a/python/vyos/ethtool.py +++ b/python/vyos/ethtool.py @@ -25,6 +25,10 @@ _drivers_without_speed_duplex_flow = ['vmxnet3', 'virtio_net', 'xen_netfront', 'iavf', 'ice', 'i40e', 'hv_netvsc', 'veth', 'ixgbevf', 'tun', 'vif'] +_drivers_without_mac_change = ['ena'] +# enable interface bonding will change the interface MAC address, thus all drivers +# not supporting MAC address change, also do not support bonding + class Ethtool: """ Class is used to retrive and cache information about an ethernet adapter @@ -222,3 +226,7 @@ class Ethtool: matches = re.findall(rf'{rx_tx_comb}:\s+(\d+)', self._channels) return [int(value) for value in matches] + + def check_mac_change(self) -> bool: + """ Check if ethernet drivers supports changing MAC address """ + return bool(self.get_driver_name() not in _drivers_without_mac_change) diff --git a/src/conf_mode/interfaces_ethernet.py b/src/conf_mode/interfaces_ethernet.py index 8e490884f..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): """ @@ -381,6 +395,7 @@ def verify(ethernet): 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, ethtool) |
