[BusyBox] DHCP: u-boot vs. busybox

Paul Fox pgf at brightstareng.com
Thu Sep 30 21:24:24 UTC 2004


hi -- i've just found the root cause for this udhcp misbehavior,
since it was affecting us, too.

steven.scholz wrote:
 > I just noticed that my board get's different IPs from the DHCP server
 > depending on wether U-Boot (the boot loader) or busybox udhcpc
 > did the request.
 > 
 > The dhcp server log shows that they're using the same MAC:
 ...

the problem is that if no "--clientid" option is passed to udhcp,
it will set up a default client id to pass to the server.  while
this default is based on the system's MAC address, it is _not_
the MAC address, and in any case, providing any client-id is
different than not providing one at all.  neither U-Boot nor
the linux kernel pass a client-id in their dhcp requests.
(if you're running the ISC dhcpd, you can examine
/var/lib/dhcp/dhcpd.leases and see the difference between leases
granted to U-Boot or the kernel, and leases granted to udhcp.)

the patch for what i believe to be correct behavior is below,
diff'ed against the rc3 codebase (imported into a local
repository).  i've left the code in, ifdef'ed, but it's my belief
that the ifdef'ed section in dhcpc.c should simply be removed.

paul

cvs server: Diffing .
Index: clientpacket.c
===================================================================
RCS file: /cvs/thirdparty/busybox-1.00-rc3/networking/udhcp/clientpacket.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 clientpacket.c
--- clientpacket.c	14 Apr 2004 17:51:25 -0000	1.1.1.1
+++ clientpacket.c	30 Sep 2004 21:17:19 -0000
@@ -76,7 +76,10 @@
 
 	init_header(packet, type);
 	memcpy(packet->chaddr, client_config.arp, 6);
-	add_option_string(packet->options, client_config.clientid);
+#if ! ALWAYS_SET_CLIENT_ID
+	if (client_config.clientid)
+	    add_option_string(packet->options, client_config.clientid);
+#endif
 	if (client_config.hostname) add_option_string(packet->options, client_config.hostname);
 	add_option_string(packet->options, (uint8_t *) &vendor_id);
 }
Index: dhcpc.c
===================================================================
RCS file: /cvs/thirdparty/busybox-1.00-rc3/networking/udhcp/dhcpc.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dhcpc.c
--- dhcpc.c	19 May 2004 08:29:05 -0000	1.1.1.1
+++ dhcpc.c	30 Sep 2004 21:17:19 -0000
@@ -273,6 +273,7 @@
 			   NULL, client_config.arp) < 0)
 		return 1;
 
+#if ALWAYS_SET_CLIENT_ID
 	if (!client_config.clientid) {
 		client_config.clientid = xmalloc(6 + 3);
 		client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
@@ -280,6 +281,8 @@
 		client_config.clientid[OPT_DATA] = 1;
 		memcpy(client_config.clientid + 3, client_config.arp, 6);
 	}
+#endif
+
 
 	/* setup the signal pipe */
 	udhcp_sp_setup();

=---------------------
 paul fox, pgf at brightstareng.com



More information about the busybox mailing list