Bug 212396 - Dual ifconfig DHCP created entries in rc.conf from bsdinstall
Summary: Dual ifconfig DHCP created entries in rc.conf from bsdinstall
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Ed Maste
URL:
Keywords: install
Depends on:
Blocks:
 
Reported: 2016-09-05 23:26 UTC by Johannes Lundberg
Modified: 2023-12-27 12:10 UTC (History)
4 users (show)

See Also:


Attachments
0001-netconfig-avoid-duplicate-entries-in-rc.conf.patch (2.81 KB, patch)
2023-07-26 17:48 UTC, Pierre Pronchery
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Lundberg 2016-09-05 23:26:39 UTC
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...
Comment 1 Allan Jude freebsd_committer freebsd_triage 2016-09-06 17:53:15 UTC
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.
Comment 2 Olli Hauer freebsd_committer freebsd_triage 2016-09-18 16:29:02 UTC
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.
Comment 3 lukash256 2017-01-30 15:58:12 UTC
in 11-RELEASE the same
Comment 4 Pierre Pronchery 2023-07-26 17:48:12 UTC
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.
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-10-13 16:49:56 UTC
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(-)
Comment 6 Mark Linimon freebsd_committer freebsd_triage 2023-12-27 12:10:50 UTC
^Triage: assign to committer that resolved.  Set optional mfc-stable13 flag.