[klibc] RFC patch: ipconfig and boot filename option
Oleg Verych
olecom at flower.upol.cz
Tue May 27 04:57:42 PDT 2008
> ipconfig is used in ltsp (thin clients) initramfs. Some of the users
> have to have 2 dhcp servers in ltsp environments, so they hit on this
> problem:
> The first dhcp request is from the pxe rom boot code. This code
> ignores any dhcp offers that don't have a filename field. So they
> always get the correct address, from the ltsp server.
>
> The second dhcp request (in initramfs) is done by ipconfig. And here
> is the problem, ipconfig accepts any offered addresses, even those
> that don't have the filename option. So the clients may get their ip
> from the wrong dhcp server (e.g. the adsl router) and fail to boot.
Just to make whole thing on selecting offeres clear:
http://www.tcpipguide.com/free/t_DHCPGeneralOperationandClientFiniteStateMachine.htm
== SELECTING ==
Client Receives Offers, Selects Preferred Offer, Sends DHCPREQUEST: The
client chooses one of the offers it has been sent, and broadcasts a
DHCPREQUEST message to tell DHCP servers what its choice was. It
transitions to the REQUESTING state
== * ==
> What I'm asking for is a command line option,
> that forces ipconfig to ignore all DHCPOFFERs that do not have a
> filename option,
> so that it only accepts ip addresses from ltsp servers.
'-s' (*s*kip: yes/no if bootpath proposed RFC patch) or
'-s bootpath_condition' (*s*elect: todo).
--- usr/kinit/ipconfig/main.c~ 2008-03-28 21:37:36.000000000 +0100
+++ usr/kinit/ipconfig/main.c 2008-05-27 00:58:07.222534500 +0200
@@ -23,8 +23,8 @@
#include "packet.h"
+char do_not_config = 0;
static const char sysfs_class_net[] = "/sys/class/net";
static const char *progname;
static jmp_buf abort_buf;
-static char do_not_config;
static unsigned int default_caps = CAP_DHCP | CAP_BOOTP | CAP_RARP;
static int loop_timeout = -1;
@@ -193,4 +193,6 @@
s->state = DEVST_ERROR;
break;
+ case 0: /* Offer with no needed payload (see '-s') */
+ return 0;
case 1: /* Offer received */
s->state = DEVST_DHCPREQ;
@@ -721,5 +723,5 @@
do {
- c = getopt(argc, argv, "c:d:i:onp:t:");
+ c = getopt(argc, argv, "c:d:i:onsp:t:");
if (c == EOF)
break;
@@ -758,4 +760,7 @@
do_not_config = 1;
break;
+ case 's':
+ do_not_config = 2;
+ break;
case 'd':
dev = add_device(optarg);
--- usr/kinit/ipconfig/dhcp_proto.c~ 2008-03-28 21:37:36.000000000 +0100
+++ usr/kinit/ipconfig/dhcp_proto.c 2008-05-27 00:57:46.285226000 +0200
@@ -16,4 +16,6 @@
#include "packet.h"
+extern char do_not_config;
+
static uint8_t dhcp_params[] = {
1, /* subnet mask */
@@ -105,4 +107,6 @@
if (ret == 1 && serverid != INADDR_NONE)
dev->serverid = serverid;
+ if (do_not_config == 2 && dev->bootpath[0] != '\0')
+ ret = 0;
DEBUG(("\n dhcp offer\n"));
break;
More information about the klibc
mailing list