Subject: bin/3788: DHCP client takes over all interfaces even if given list on cmd. line
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rafal@raptor.com>
List: netbsd-bugs
Date: 06/25/1997 00:37:57
>Number:         3788
>Category:       bin
>Synopsis:       dhclient uses all available interfaces even if told not to
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 24 21:35:01 1997
>Last-Modified:
>Originator:     Rafal Boni
>Organization:
	...me organized?? Ha!
>Release:        NetBSD-current as of 5/23 (but also in 6/15 current)
>Environment:
	NetBSD/i386 machine with 2 interfaces.  One interface has fixed IP addr
	the other interface gets it's IP address via DHCP.

System: NetBSD doppelganger 1.2E NetBSD 1.2E (DOPPELGANGER) #1: Sun Jun 1 23:14:09 EDT 1997 rafal@doppelganger:/home/doppelganger/src/netbsd/src/sys/arch/i386/compile/DOPPELGANGER i386


>Description:
	dhclient takes over all available interfaces on the machine, even if
	it's told to use only a subset of those via the command line.

	This is bad, as it sets the IP address on interfaces if uses to 0.0.0.0
	thus messing up interfaces that might already have been configured.
	Plus, it keeps sending queries on the other interfaces, which is
	annoying and fills up the logs unnecessarily.

	[The usage sting of dhclient is also wrong]

>How-To-Repeat:
	install dhclient.conf and dhclient-script in /etc
	run dhclient ep0 (since you only want it to use that one interface)
	see dhclient log messages about lack of response on other interfaces.

>Fix:

Index: client/dhclient.c
===================================================================
RCS file: /cvs/root/netbsd/src/usr.sbin/dhcp/client/dhclient.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dhclient.c
--- dhclient.c	1997/04/19 21:26:24	1.1.1.1
+++ dhclient.c	1997/06/24 13:50:28
@@ -158,8 +158,9 @@
 #endif
 	inaddr_any.s_addr = INADDR_ANY;
 
-	/* Discover all the network interfaces. */
-	discover_interfaces (DISCOVER_UNCONFIGURED);
+	/* If not passed explicit list, find all available interfaces */
+	if (!interfaces)
+	    discover_interfaces (DISCOVER_UNCONFIGURED);
 
 	/* Parse the dhclient.conf file. */
 	read_client_conf ();
@@ -215,7 +216,7 @@
 
 static void usage ()
 {
-	error ("Usage: dhclient [-c] [-p <port>] [interface]");
+	error ("Usage: dhclient [-d] [-p <port>] [interface]");
 }
 
 void cleanup ()
Index: common/dispatch.c
===================================================================
RCS file: /cvs/root/netbsd/src/usr.sbin/dhcp/common/dispatch.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dispatch.c
--- dispatch.c	1997/04/19 21:26:26	1.1.1.1
+++ dispatch.c	1997/06/24 13:50:29
@@ -98,10 +98,9 @@
 	if (i < 0)
 		error ("ioctl: SIOCGIFCONF: %m");
 
-	/* If we already have a list of interfaces, and we're running as
-	   a DHCP server, the interfaces were requested. */
-	if (interfaces &&
-	    (state == DISCOVER_SERVER || state == DISCOVER_RELAY))
+	/* If we already have a list of interfaces, the interfaces were
+	   specifically requested. */
+	if (interfaces)
 		ir = 0;
 	else
 		ir = INTERFACE_REQUESTED;
>Audit-Trail:
>Unformatted: