From owner-freebsd-bugs Mon Sep 18 14: 0: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2DBF837B43C for ; Mon, 18 Sep 2000 14:00:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id OAA39156; Mon, 18 Sep 2000 14:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from gollum.esys.ca (dhcp198-59.esys.ca [198.161.92.59]) by hub.freebsd.org (Postfix) with ESMTP id B472F37B423 for ; Mon, 18 Sep 2000 13:53:11 -0700 (PDT) Received: by gollum.esys.ca (Postfix, from userid 1001) id BF8069936C; Mon, 18 Sep 2000 14:53:04 -0600 (MDT) Message-Id: <20000918205304.BF8069936C@gollum.esys.ca> Date: Mon, 18 Sep 2000 14:53:04 -0600 (MDT) From: lyndon@messagingdirect.com Reply-To: lyndon@messagingdirect.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/21375: [PATCH] dhclient runs away on interface removal Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 21375 >Category: bin >Synopsis: [PATCH] dhclient runs away on interface removal >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Sep 18 14:00:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Lyndon Nerenberg >Release: FreeBSD 4.1-STABLE i386 >Organization: >Environment: 4.1-STABLE laptop with PCCard NIC controlled by pccardd and configured to use DHCP. >Description: Once the NIC is up and dhclient has configured the NIC, removing the card causes dhclient to go into a spin loop on the select() in the dispatch() routine. The call to got_one() gets an error from the read() on the socket, but doesn't do anything special with the error. got_one() returns and the whole thing repeats, grabbing most of the CPU in the process (and generating gobs of syslog cruft). >How-To-Repeat: >Fix: Fixing this correctly would require dhclient be able to handle dynamic interfaces correctly. Short of doing that rewrite, the following patch adds a test for the read() returning ENXIO, and shuts down the application in that event. This is definately a bit if a hack. It's based on the premise that the failing dhclient was launched from pccardd (via pccard_ether) and that pccardd will start another dhclient the next time the NIC is inserted. I think this is safe -- I can't think of another normal dhclient scenario where one of the interfaces would just disappear. An alternative fix would be to invalidate the interface on dhclient's internal interface list (removing it from the FD set), and terminate if the interface count goes to zero. Patch against /usr/src/contrib/isc-dhcp/common/dispatch.c: --- dispatch.c.old Mon Sep 18 14:12:22 2000 +++ dispatch.c Mon Sep 18 14:34:26 2000 @@ -701,7 +701,26 @@ if ((result = receive_packet (ip, u.packbuf, sizeof u, &from, &hfrom)) < 0) { + int save_errno = errno; + warn ("receive_packet failed on %s: %m", ip -> name); + if (save_errno == ENXIO) { + /* + * The interface went away. All we can do for now + * is terminate since there is no support + * here for handling dynamic interfaces. + * + * This behaviour is relatively safe. The + * only time an interface should go away in + * normal operation is when a laptop NIC card + * is removed. If that happens there's no reason + * for us to stick around. The laptop's OS should + * handle restarting us when the interface comes + * back. + */ + error("%s: interface removed?", + ip -> name); + } return; } if (result == 0) >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message