Page MenuHomeFreeBSD

[PATCH 1/2] netconfig: report configuration failures
Needs ReviewPublic

Authored by khorben on Oct 13 2023, 3:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 19, 11:54 PM
Unknown Object (File)
Sep 21 2025, 5:38 PM
Unknown Object (File)
Sep 20 2025, 10:04 PM
Unknown Object (File)
Sep 17 2025, 3:06 AM
Unknown Object (File)
Sep 10 2025, 5:39 AM
Unknown Object (File)
Sep 6 2025, 10:41 AM
Unknown Object (File)
Aug 9 2025, 3:42 AM
Unknown Object (File)
Aug 2 2025, 11:50 AM
Subscribers

Details

Reviewers
emaste
jrtc27
bapt
Summary

The stack-specific network configuration sub-steps called by the netconfig step, netconfig_ipv4 and netconfig_ipv6, may fail to save or apply configuration in different cases. This change tries to be more complete and consistent while tracking and reporting such errors.

This addresses #211617 while the second patch addresses #212396.

Sponsored by: The FreeBSD Foundation

Test Plan

I have created a stand-alone copy of usr.sbin/bsdinstall, slightly modified in order to allow local testing without requiring a new installation image for every change.

$ git clone --branch khorben/netconfig https://github.com/khorben/bsdinstall.git
$ cd bsdinstall
$ less README.md
[...]
$ cat > test.sh << EOF
#!/bin/sh

BSDINSTALLDIR="\$PWD"
DESTDIR="\$BSDINSTALLDIR/destdir"
BSDINSTALL_DISTDIR="\$DESTDIR/usr/freebsd-dist"; export BSDINSTALL_DISTDIR
SRCDIR="/usr/src"

TMPDIR="\$(mktemp -d)"; export TMPDIR
for target in "\$@"; do
    BSDCFG_SHARE="\$SRCDIR/usr.sbin/bsdconfig/share" \
        BSDINSTALL_CHROOT="\$DESTDIR" \
        BSDINSTALL_CONFIGCURRENT="yes" \
        BSDINSTALL_SCRIPTS="\$BSDINSTALLDIR/scripts" \
        LOCAL_DISTRIBUTIONS="base.txz kernel.txz lib32.txz" \
        DISTRIBUTIONS="lib32-dbg.txz" \
        ./bsdinstall "\$target"
done
EOF
$ sh test.sh netconfig

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This is in the khorben/bsdinstall-netconfig branch at https://github.com/khorben/freebsd-src/.

usr.sbin/bsdinstall/scripts/netconfig_ipv4
68

Is this testing the exit code from echo / the redirection?

Should I rebase this patch since D42194 is already merged?

usr.sbin/bsdinstall/scripts/netconfig_ipv4
68

echo should always be successful, but the redirection may fail: insufficient permissions are unlikely when running as root, but the disk may become full, or I/O errors are possible too (hardware issue, bsdinstall over NFS?). As far as I know, in FreeBSD's shell this returns non-zero errors.
However with D42194 already merged, this line is now a call to sysrc instead, which can be expected to report errors with a non-zero exit value; any possible ambiguity between the exit code and the redirection is now gone.