When installing 12-CURRENT to a laptop I had forgotten to plug in the network cable so the DHCP configuration failed. I then plugged in the network cable and selected DHCP again and configuration succeeded as expected. However, when examining the rc.conf after reboot I noticed dual entries like 'ifconfig_re0="DHCP"'. Maybe we should check if an entry already exists before adding again or add it after success is confirmed. There are many reason the network configuration could fail...
While it would be more tidy to clear out the old entries when the user retries, it doesn't actually hurt anyway to have two entries, the earlier ones are overridden by the last entry.
With sysrc in the base OS it should be possible to prevent duplicate entries. I haven't looked at the source of the installer and bsdconfig so I cannot tell how many effort it is to use sysrc in both tools.
in 11-RELEASE the same
Created attachment 243630 [details] 0001-netconfig-avoid-duplicate-entries-in-rc.conf.patch This uses sysrc to write and update configuration variables in the temporary configuration file for network access, ._rc.conf.net. This replaces the previous mechanism, which was simply appending new values as they were updated. I found sysrc to be available in the minimal ISO image for the FreeBSD installer (13.2/amd64). I am not yet familiar with the image generation process though, especially for other architectures where bsdinstall is also used.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=60b37735f305e72e67695ead029e59ea29b2bc29 commit 60b37735f305e72e67695ead029e59ea29b2bc29 Author: Pierre Pronchery <pierre@freebsdfoundation.org> AuthorDate: 2023-10-13 15:45:19 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-10-13 16:45:54 +0000 bsdinstall netconfig: avoid duplicate entries in rc.conf This uses sysrc to write and update configuration variables in the temporary configuration file for network access, ._rc.conf.net. This replaces the previous mechanism, which was simply appending new values as they were updated. PR: 212396 Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42194 usr.sbin/bsdinstall/scripts/netconfig | 4 ++-- usr.sbin/bsdinstall/scripts/netconfig_ipv4 | 2 +- usr.sbin/bsdinstall/scripts/netconfig_ipv6 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
^Triage: assign to committer that resolved. Set optional mfc-stable13 flag.