Page MenuHomeFreeBSD

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

Authored by khorben_defora.org on Oct 13 2023, 3:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 5, 9:31 AM
Unknown Object (File)
Apr 30 2024, 9:07 AM
Unknown Object (File)
Apr 30 2024, 9:07 AM
Unknown Object (File)
Apr 30 2024, 5:48 AM
Unknown Object (File)
Apr 27 2024, 3:57 AM
Unknown Object (File)
Jan 12 2024, 4:00 PM
Unknown Object (File)
Jan 10 2024, 5:04 AM
Unknown Object (File)
Dec 20 2023, 4:42 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

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.