changeset 1085:9646b4a23a8a draft dhcpcd-4.0.5

Backport r1074 to dhcpcd-4.0 which stops sending a ClientID by default. If CMDLINE_COMPAT is enabled then we keep the prior behaviour.
author Roy Marples <roy@marples.name>
date Fri, 21 Nov 2008 08:05:55 +0000
parents 87307f137a82
children 9dd9b004e8dd
files README client.c dhcpcd.8.in dhcpcd.c dhcpcd.conf.5.in
diffstat 5 files changed, 41 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/README	Fri Nov 14 19:18:57 2008 +0000
+++ b/README	Fri Nov 21 08:05:55 2008 +0000
@@ -56,6 +56,13 @@
 the dhcpcd.duid file exits. This keeps the clients working as they were,
 which is good.
 
+dhcpcd no longer sends a default ClientID for ethernet interfaces. 
+This is so we can re-use the address the kernel DHCP client found. 
+To retain the old behaviour of sending a default ClientID based on the 
+hardware address for interface, simply add the keyword clientid to dhcpcd.conf.
+If CMDLINE_COMPAT is defined, we renable the sending of ClientID by default
+AND adding clientid to dhcpcd.conf causes it NOT to be sent.
+
 dhcpcd-4 is NOT fully commandline compatible with dhcpcd-2 and older and
 changes the meaning of some options.
 
--- a/client.c	Fri Nov 14 19:18:57 2008 +0000
+++ b/client.c	Fri Nov 21 08:05:55 2008 +0000
@@ -520,12 +520,18 @@
 		iface->net.s_addr = lease->net.s_addr;
 	}
 
+       /* If we haven't specified a ClientID and our hardware address 
+	* length is greater than DHCP_CHADDR_LEN then we enforce a ClientID 
+	* of the hardware address family and the hardware address. */ 
+	if (!(state->options & DHCPCD_CLIENTID) && iface->hwlen > DHCP_CHADDR_LEN) 
+		state->options |= DHCPCD_CLIENTID; 
+ 
 	if (*options->clientid) {
 		iface->clientid = xmalloc(options->clientid[0] + 1);
 		memcpy(iface->clientid,
 		       options->clientid, options->clientid[0] + 1);
-	} else if (options->options & DHCPCD_CLIENTID) {
-		if (options->options & DHCPCD_DUID) {
+	} else if (state->options & DHCPCD_CLIENTID) {
+		if (state->options & DHCPCD_DUID) {
 			duid = xmalloc(DUID_LEN);
 			if ((len = get_duid(duid, iface)) == 0)
 				logger(LOG_ERR, "get_duid: %s",
--- a/dhcpcd.8.in	Fri Nov 14 19:18:57 2008 +0000
+++ b/dhcpcd.8.in	Fri Nov 21 08:05:55 2008 +0000
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 20, 2008
+.Dd November 18, 2008
 .Dt DHCPCD 8 SMM
 .Sh NAME
 .Nm dhcpcd
@@ -324,9 +324,16 @@
 encodes the FQDN hostname as specified in
 .Li RFC1035 .
 .It Fl I , -clientid Ar clientid
-Change the default clientid sent from the interface hardware address.
+Send the
+.Ar clientid .
 If the string is of the format 01:02:03 then it is encoded as hex.
-If not set then none is sent.
+For interfaces whose hardware address is longer than 8 bytes, or if the
+.Ar clientid
+is an empty string then
+.Nm
+sends a default
+.Ar clientid
+of the hardware family and the hardware address.
 .El
 .Ss Restriciting behaviour
 .Nm
--- a/dhcpcd.c	Fri Nov 14 19:18:57 2008 +0000
+++ b/dhcpcd.c	Fri Nov 21 08:05:55 2008 +0000
@@ -521,10 +521,14 @@
 			return -1;
 		}
 		options->clientid[0] = (uint8_t)s;
+#ifdef CMDLINE_COMPAT
 		if (s == 0) {
 			options->options &= ~DHCPCD_DUID;
 			options->options &= ~DHCPCD_CLIENTID;
 		}
+#else
+		options->options |= DHCPCD_CLIENTID;
+#endif
 		break;
 	case 'K':
 		options->options &= ~DHCPCD_LINK;
@@ -618,7 +622,7 @@
 	setlogprefix(PACKAGE ": ");
 
 	options = xzalloc(sizeof(*options));
-	options->options |= DHCPCD_CLIENTID | DHCPCD_GATEWAY | DHCPCD_DAEMONISE;
+	options->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE;
 	options->options |= DHCPCD_ARP | DHCPCD_IPV4LL | DHCPCD_LINK;
 	options->timeout = DEFAULT_TIMEOUT;
 	strlcpy(options->script, SCRIPT, sizeof(options->script));
@@ -628,6 +632,7 @@
 					     "%s %s", PACKAGE, VERSION);
 
 #ifdef CMDLINE_COMPAT
+	options->options |= DHCPCD_CLIENTID;
 	add_option_mask(options->requestmask, DHO_DNSSERVER);
 	add_option_mask(options->requestmask, DHO_DNSDOMAIN);
 	add_option_mask(options->requestmask, DHO_DNSSEARCH);
--- a/dhcpcd.conf.5.in	Fri Nov 14 19:18:57 2008 +0000
+++ b/dhcpcd.conf.5.in	Fri Nov 21 08:05:55 2008 +0000
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 18, 2008
+.Dd November 18, 2008
 .Dt DHCPCD.CONF 5 SMM
 .Sh NAME
 .Nm dhcpcd.conf
@@ -48,9 +48,16 @@
 This is useful for startup scripts which don't disable link messages for
 carrier status.
 .It Ic clientid Ar string
-Change the default clientid sent from the interface hardware address.
+Send the
+.Ar clientid .
 If the string is of the format 01:02:03 then it is encoded as hex.
-If not set then none is sent.
+For interfaces whose hardware address is longer than 8 bytes, or if the
+.Ar clientid
+is an empty string then
+.Nm dhcpcd
+sends a default
+.Ar clientid
+of the hardware family and the hardware address.
 .It Ic duid
 Generate an
 .Rs