NetBSD Problem Report #56598

From gson@gson.org  Sun Jan  2 11:10:44 2022
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id A537F1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  2 Jan 2022 11:10:44 +0000 (UTC)
Message-Id: <20220102111033.8BADA25415D@guava.gson.org>
Date: Sun,  2 Jan 2022 13:10:33 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: dhcpcd now fails to detect carrier already present
X-Send-Pr-Version: 3.95

>Number:         56598
>Category:       bin
>Synopsis:       dhcpcd now fails to detect carrier already present
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 02 11:15:00 +0000 2022
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current, source date >= 2020.10.12.14.09.03
>Organization:

>Environment:
System: NetBSD
Architecture: x86_64
Machine: amd64
>Description:

On a freshly installed and booted NetBSD-current system connected to
an Ethernet network with a DHCP server but not yet configured to use
it, you used to be able to run dhcpcd and then immediately use the
network, for example in a shell script like this:

  dhcpcd
  ftp http://www.example/...

This no longer works: dhcpcd will now report "no interfaces have a
carrier" even though there is an interface that does, and the ftp
command will fail because no interface has a routable address (yet).

When this happens, dhcpcd enters the background and will eventually
succeed in leasing an address, but by then it's too late for the
script which has already failed.

The problem can be worked around by either inserting a sleep between
the two commands or specifying the "-w" option to dhcpcd, but neither
should be necessary when the interface does in fact already have a
carrier.  Also, printing the message "no interfaces have a carrier"
when one does is confusing to say the least.

The problem appeared with this set of commits:

  2020.10.12.14.07.55 roy src/external/bsd/dhcpcd/dist/src/arp.c 1.1.1.18
  2020.10.12.14.07.55 roy src/external/bsd/dhcpcd/dist/src/defs.h 1.1.1.48
  2020.10.12.14.07.55 roy src/external/bsd/dhcpcd/dist/src/duid.c 1.1.1.11
  2020.10.12.14.07.55 roy src/external/bsd/dhcpcd/dist/src/if.c 1.1.1.26
  2020.10.12.14.07.56 roy src/external/bsd/dhcpcd/dist/src/dhcpcd.h 1.1.1.20
  2020.10.12.14.07.56 roy src/external/bsd/dhcpcd/dist/src/if-options.h 1.1.1.20
  2020.10.12.14.07.56 roy src/external/bsd/dhcpcd/dist/src/if.h 1.1.1.21
  2020.10.12.14.07.56 roy src/external/bsd/dhcpcd/dist/src/privsep-bpf.c 1.1.1.7
  2020.10.12.14.07.56 roy src/external/bsd/dhcpcd/dist/src/privsep-inet.c 1.1.1.9
  2020.10.12.14.07.56 roy src/external/bsd/dhcpcd/dist/src/privsep-inet.h 1.1.1.3
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/dhcp.c 1.41
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/dhcp6.c 1.24
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/dhcpcd.c 1.44
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/if-bsd.c 1.25
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/ipv6.c 1.15
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/ipv6nd.c 1.25
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/logerr.c 1.10
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/privsep.c 1.9
  2020.10.12.14.09.03 roy src/external/bsd/dhcpcd/dist/src/script.c 1.11

>How-To-Repeat:

Install emulators/qemu and misc/py-anita from pkgsrc and run:

  $ anita interact http://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/latest/amd64/
  login: root
  # dhcpcd; ifconfig -a

Note the "no interfaces have a carrier" message from dhcpcd and the
lack of an IP address on wm0.

Alternatively, install -current on real hardware using sysinst,
without specifying a network configuration for the installed system,
connect a physical Ethernet interface to a network, verify that the
link LED of the interface is lit, and run the same test:

  login: root
  # dhcpcd; ifconfig -a

>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.