diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-08-06 21:59:21 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-08-08 18:33:38 +0200 |
| commit | 22cfee116c9935f4a33da4923eff189f2f646371 (patch) | |
| tree | d0a125a6178d4bbefd9515003e285479012103f2 /src/init | |
| parent | 3c7aa6d76c4de62f27a0493baefe8e10044c9f9d (diff) | |
| download | vyos-1x-22cfee116c9935f4a33da4923eff189f2f646371.tar.gz vyos-1x-22cfee116c9935f4a33da4923eff189f2f646371.zip | |
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
Diffstat (limited to 'src/init')
| -rwxr-xr-x | src/init/vyos-router | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/init/vyos-router b/src/init/vyos-router index 06ec89d72..8e0a671a6 100755 --- a/src/init/vyos-router +++ b/src/init/vyos-router @@ -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", @@ -610,6 +630,12 @@ 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 @@ -617,6 +643,7 @@ start () run_postupgrade_script update_interface_config || overall_status=1 + warn_missing_interface_hardware disabled system_activate || system_activate || overall_status=1 |
