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)
Sep 19 2024, 5:14 PM
Unknown Object (File)
Sep 19 2024, 5:57 AM
Unknown Object (File)
Sep 18 2024, 11:39 PM
Unknown Object (File)
Sep 17 2024, 2:40 PM
Unknown Object (File)
Sep 17 2024, 7:38 AM
Unknown Object (File)
Sep 3 2024, 5:09 AM
Unknown Object (File)
Aug 18 2024, 10:55 AM
Unknown Object (File)
Jul 30 2024, 12:25 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.