Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/vyos/ethtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def check_speed_duplex(self, speed, duplex):

def check_flow_control(self):
""" Check if the NIC supports flow-control """
if self.get_driver_name() in _drivers_without_speed_duplex_flow:
return False
return bool(self._flow_control)

def get_flow_control(self):
Expand Down
24 changes: 18 additions & 6 deletions smoketest/scripts/cli/test_interfaces_ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ def test_ethtool_coalesce(self):
msg = 'Driver does not fully support coalesce configuration'
with self.assertRaisesRegex(ConfigSessionError, msg):
self.cli_commit()
# the failed commit leaves rx-usecs/tx-usecs staged in
# the candidate config (commit() does not auto-rollback) -
# discard it so it doesn't leak into the next interface
self.cli_discard()
continue

# To find out the supported features
Expand Down Expand Up @@ -287,17 +291,25 @@ def test_ethtool_coalesce(self):

def test_ethtool_flow_control(self):
for interface in self._interfaces:
ethtool = Ethtool(interface)
# Disable flow-control
self.cli_set(self._base_path + [interface, 'disable-flow-control'])
# Check current flow-control state on ethernet interface
out, err = popen(f'sudo ethtool --json --show-pause {interface}')
# Flow-control not supported - test if it bails out with a proper
# this is a dynamic path where err = 1 on VMware, but err = 0 on
# a physical box.
if bool(err):

# Ask the same capability check the CLI commit itself uses,
# rather than a raw ethtool --show-pause probe: some drivers
# (virtio_net, vmxnet3, xen_netfront, ...) support querying
# pause parameters but not changing them, so a bare --show-pause
# exit code is not a reliable predictor of whether the commit
# will succeed.
if not ethtool.check_flow_control():
with self.assertRaises(ConfigSessionError):
self.cli_commit()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
# the failed commit leaves disable-flow-control staged in
# the candidate config (commit() does not auto-rollback) -
# discard it so it doesn't leak into the next interface
self.cli_discard()
else:
out, err = popen(f'sudo ethtool --json --show-pause {interface}')
out = loads(out)
# Flow control is on
self.assertTrue(out[0]['autonegotiate'])
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/vyos-interface-rescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def get_interface_type(intf: str) -> str:
return intf_type

def get_new_interfaces() -> dict:
""" Read any new interface data left in /run/udev/vyos by vyos_net_name
""" Read any new interface data left in /run/udev/vyos by
vyos-net-name-resolve.py for interfaces without a configured hw-id
"""
interfaces = {}

Expand Down
27 changes: 27 additions & 0 deletions src/init/vyos-router
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,26 @@ update_interface_config ()
fi
}

# warn (but do not fail boot) about configured hw-id interfaces whose
# hardware was not found by vyos-net-name-resolve.service
warn_missing_interface_hardware ()
{
local status_file="/run/vyos-net-name-resolve.json"
[ -f "${status_file}" ] || return 0

jq -r '.missing // {} | to_entries[] | "\(.value) \(.key)"' "${status_file}" \
2>/dev/null | while read -r intf hwid; do
[ -n "${intf}" ] || continue
log_failure_msg "hw-id ${hwid} configured as '${intf}' was not found during boot - check cabling, hardware and driver/firmware"
done

jq -r '.pending_unresolved // [] | .[]' "${status_file}" 2>/dev/null | \
while read -r intf; do
[ -n "${intf}" ] || continue
log_failure_msg "interface '${intf}' still has no hw-id configured after this boot's naming pass - bind it manually, e.g. 'set interfaces ethernet ${intf} hw-id <mac>', or remove the node if it is no longer needed"
done
}

cleanup_post_commit_hooks () {
# Remove links from the post-commit hooks directory.
# note that this approach only supports hooks that are "configured",
Expand Down Expand Up @@ -610,13 +630,20 @@ start ()

disabled migrate || migrate_bootfile || overall_status=1

# config.boot is only guaranteed to exist/be current from this point on
# (tmpfs mount + encrypted config unlock + syntax migration have all
# already happened above) - hw-id based interface naming must be
# resolved against it before anything below applies interface config.
systemctl start vyos-net-name-resolve.service || overall_status=1

restore_if_missing_preconfig_script

run_preconfig_script

run_postupgrade_script

update_interface_config || overall_status=1
warn_missing_interface_hardware

disabled system_activate || system_activate || overall_status=1

Expand Down
Loading
Loading