Skip to content

Commit 854ee6e

Browse files
committed
T3871: make boot-time interface naming deterministic and hw-id aware
Multi-vendor PCIe NIC systems could lose or rename Ethernet/wireless interfaces on boot, because naming was decided from a single per-device udev event before all hardware had a chance to enumerate. Replace that with one authoritative pass, run once configuration is available during router startup: wait for configured hardware, apply every hw-id binding, and name whatever has none yet by PCIe distance from the root complex and MAC address - the same result every boot. A node with its hw-id deleted (NIC replacement) or its whole configuration removed is treated as an ordinary open slot, filled the same way - recovering its original hardware whenever the interfaces that vacated slots this boot also show up as candidates. Boot now reports any interface still unresolved, and the pass is covered by a new test suite in vyos-build named: make testifname Assisted-by: Claude:claude-sonnet-5
1 parent 879207a commit 854ee6e

7 files changed

Lines changed: 2269 additions & 105 deletions

File tree

src/helpers/vyos-interface-rescan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def get_interface_type(intf: str) -> str:
9797
return intf_type
9898

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

src/init/vyos-router

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,26 @@ update_interface_config ()
367367
fi
368368
}
369369

370+
# warn (but do not fail boot) about configured hw-id interfaces whose
371+
# hardware was not found by vyos-net-name-resolve.service
372+
warn_missing_interface_hardware ()
373+
{
374+
local status_file="/run/vyos-net-name-resolve.json"
375+
[ -f "${status_file}" ] || return 0
376+
377+
jq -r '.missing // {} | to_entries[] | "\(.value) \(.key)"' "${status_file}" \
378+
2>/dev/null | while read -r intf hwid; do
379+
[ -n "${intf}" ] || continue
380+
log_failure_msg "hw-id ${hwid} configured as '${intf}' was not found during boot - check cabling, hardware and driver/firmware"
381+
done
382+
383+
jq -r '.pending_unresolved // [] | .[]' "${status_file}" 2>/dev/null | \
384+
while read -r intf; do
385+
[ -n "${intf}" ] || continue
386+
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"
387+
done
388+
}
389+
370390
cleanup_post_commit_hooks () {
371391
# Remove links from the post-commit hooks directory.
372392
# note that this approach only supports hooks that are "configured",
@@ -610,13 +630,20 @@ start ()
610630

611631
disabled migrate || migrate_bootfile || overall_status=1
612632

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

615641
run_preconfig_script
616642

617643
run_postupgrade_script
618644

619645
update_interface_config || overall_status=1
646+
warn_missing_interface_hardware
620647

621648
disabled system_activate || system_activate || overall_status=1
622649

0 commit comments

Comments
 (0)