Skip to content

Commit 066d2be

Browse files
committed
bond: T8084: disallow bond members that do not support MAC changes
Building on commit ba60266 (“ethernet: T8084: prevent MAC changes on ENA interfaces (AWS EC2)”), add safeguards to prevent interfaces from being used as bond members if they: * do not support MAC address changes, or * appear on a denylist of interfaces invalid for bonding (currently empty)
1 parent ba60266 commit 066d2be

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

python/vyos/ethtool.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
_drivers_without_mac_change = ['ena']
2929
# enable interface bonding will change the interface MAC address, thus all drivers
3030
# not supporting MAC address change, also do not support bonding
31+
_drivers_without_bonding_support = _drivers_without_mac_change + []
3132

3233
class Ethtool:
3334
"""
@@ -230,3 +231,7 @@ def get_channels(self, rx_tx_comb):
230231
def check_mac_change(self) -> bool:
231232
""" Check if ethernet drivers supports changing MAC address """
232233
return bool(self.get_driver_name() not in _drivers_without_mac_change)
234+
235+
def check_bonding(self) -> bool:
236+
""" Check if ethernet drivers supports bonding """
237+
return bool(self.get_driver_name() not in _drivers_without_bonding_support)

src/conf_mode/interfaces_bonding.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from vyos.configverify import verify_mtu_ipv6
3131
from vyos.configverify import verify_vlan_config
3232
from vyos.configverify import verify_vrf
33+
from vyos.ethtool import Ethtool
3334
from vyos.frrender import FRRender
3435
from vyos.frrender import get_frrender_dict
3536
from vyos.ifconfig import BondIf
@@ -251,6 +252,10 @@ def verify(bond):
251252
raise ConfigError('Configured MTU is less then member '\
252253
f'interface "{interface}" minimum of {min_mtu}!')
253254

255+
# not all ethernet drivers support interface bonding
256+
if not Ethtool(interface).check_bonding():
257+
raise ConfigError(error_msg + 'driver is not supported!')
258+
254259
if 'primary' in bond:
255260
if bond['primary'] not in bond['member']['interface']:
256261
raise ConfigError(f'Primary interface of bond "{bond_name}" must be a member interface')

0 commit comments

Comments
 (0)