Skip to content

Conversation

@pmenzel
Copy link
Owner

@pmenzel pmenzel commented Aug 11, 2026

πŸ€– This PR was written by Claude (operated by Boris), requested by Paul in oc-exchange#18 for mariux64/mxtools#556.

Problem

network.service orders itself only After=sysinit.target and then runs mxnetctl start + ip addr add … dev ${MX_NETDEV} unconditionally. When the NIC driver is still probing (after mxgrub --reboot/kexec, userspace starts ~2 s after the kernel while e.g. the ixgbe SFP+/PHY probe needs ~1 s), the device is not yet in /sys/class/net: mxnetctl start cannot rename it and every ip command fails β€” on fluffybutt net04 was missing after kexec. A cold boot only wins this race by accident, because firmware POST gives the driver a multi-second head start.

Fix

The wait has to happen before mxnetctl start, not just before the ip calls: net04 only exists once mxnetctl start has renamed the kernel device, and it can only do that if the hardware has probed. Waiting for the name alone would therefore spin forever on a first configuration.

  • mxnetctl wait DEVICE (new subcommand): polls every 100 ms until either a device with the target name exists, or hardware whose MAC address is mapped to that name in /etc/local/mxnet shows up (i.e. the NIC has probed but still carries its kernel name). Exits non-zero after --timeout seconds (default 30) so a genuinely missing device still fails visibly instead of hanging boot.
  • network.service: ExecStartPre=/usr/sbin/mxnetctl wait ${MX_NETDEV} (the EnvironmentFile is already loaded at that point).

This is deliberately host-agnostic β€” one unit change fleet-wide, no per-host drop-ins, and it reuses mxnetctl's existing /etc/local/mxnet parsing (option A from the analysis in mariux64#556, moved from a shell loop into mxnetctl so the MAC fallback works on hosts that haven't been renamed yet).

Testing

perl -c passes; functional checks on a Debian 13 VM:

  • mxnetctl wait lo β†’ exit 0 instantly (name match)
  • mxnetctl wait --timeout=1 net99 β†’ exit 1 after ~1 s with timeout waiting for network device net99
  • /etc/local/mxnet mapping eth0's MAC to net99, no device named net99 β†’ mxnetctl wait net99 exit 0 instantly (MAC match β€” the actual race-fix path)

Not tested on real MarIuX hardware; a kexec reboot on fluffybutt with this in place would be the real verification.

Remaining smell (out of scope)

The wait covers ${MX_NETDEV} only. Other NICs that probe late still keep their kernel names for that boot, since mxnetctl start runs once and nothing re-runs it on device add β€” VLAN/secondary interfaces on fast-booting hosts could hit the same class of race. A udev rule invoking the rename logic per device would fix that structurally (that direction is what PR #1's systemd-networkd generator eventually obsoletes anyway).

OnkelClaude added 2 commits August 11, 2026 20:08
`network.service` runs `mxnetctl start` followed by `ip addr add …
dev ${MX_NETDEV}` as soon as sysinit.target is reached. If the NIC
driver is still probing at that point, the device is not yet in
/sys/class/net, so `mxnetctl start` cannot rename it and the ip
commands fail. A kexec reboot regularly loses this race, because it
skips firmware POST and reaches userspace before, for example, the
roughly one second ixgbe probe has finished (issue mariux64#556 [1]).

Add `mxnetctl wait DEVICE`, which polls every 100 ms until the device
exists under its target name, or until hardware with the MAC address
configured for that name in /etc/local/mxnet shows up (the device may
still carry its kernel name before `mxnetctl start` renames it). Exit
non-zero after --timeout seconds (default 30) so a genuinely missing
device still fails visibly.

[1]: mariux64#556

This change was written by an AI (Claude, operated by Boris) on behalf
of Paul Menzel.
`ip addr add … dev ${MX_NETDEV}` fails if the NIC driver has not
finished probing, which regularly happens after a kexec reboot
(issue mariux64#556 [1]): userspace starts within about two seconds, while
for example the ixgbe SFP+/PHY probe needs about one second of
wall-clock time, so on fluffybutt net04 did not exist yet when the
unit ran.

Wait for the device (by target name or by its MAC address from
/etc/local/mxnet) before renaming and configuring it.

[1]: mariux64#556

This change was written by an AI (Claude, operated by Boris) on behalf
of Paul Menzel.
@ARGV>=2 or die USAGE;
my $dev=$ARGV[1];
unless (wait_for_device($dev)) {
warn "timeout waiting for network device $dev\n";
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention the timeout.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ€– (Claude, im Auftrag von Boris)

Done in cd076da: the message now reads timeout waiting for network device $dev after ${opt_timeout}s. The default (30 s) is applied in one place right after option parsing ($opt_timeout //= 30;), so the message always shows the effective value β€” default or --timeout β€” and wait_for_device no longer duplicates the constant. perl -c passes.

β€” bearbeitet mit Claude Fable 5

Say how long we actually waited, so the journal entry can be judged
without looking up the default. The default (30 s) now lives in one
place, applied right after option parsing.

Requested by Paul in PR #2 review.

Written by OnkelClaude (AI) on behalf of Boris Bergenroth.

Co-authored-by: OnkelClaude (AI) <borisbergenroth@googlemail.com>
Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant