Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Sep 2000 14:53:04 -0600 (MDT)
From:      lyndon@messagingdirect.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/21375: [PATCH] dhclient runs away on interface removal
Message-ID:  <20000918205304.BF8069936C@gollum.esys.ca>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000918205304.BF8069936C>