[klibc] ipconfig:About the length of 'options' field of DHCP packet

KUMAAN 9maaan at gmail.com
Mon Aug 22 22:49:32 PDT 2011


I'm sorry for this late reply.

(2011/07/31 18:07), maximilian attems wrote:
> Hmm first I think we should implement missing options in ipconfig:
> domain-search and lease time are the ones that are asked for.
> http://bugs.debian.org/627166

Thank you for your suggestions. I implemented small patches for the options.
With the patches, I verified that ipconfig writes values about the options
to /tmp/net-$DEVICE.conf file, and we can construct resolv.conf which
includes search option and dhclient.leases which includes dhcp-lease-time
option from /tmp/net-$DEVICE.conf file.

Details:

192.168.0.0/24 subnet
|
+- router(192.168.0.2)
|
+- DHCP server(192.168.0.3)
|   hostname: srv
|   os: Debian-squeeze
|   NFS server
|
+- DHCP client
    hostname: cli
    os: Debian-squeeze
    disk-less NFS client which uses ipconfig in initramfs

# update initramfs which includes patched ipconfig for cli
@srv $ cd usr/kinit/ipconfig/static/
@srv $ sudo cp ipconfig /nfs/cli-root/usr/lib/klibc/bin/
@srv $ sudo chroot /nfs/cli-root
@srv # update-initramfs -u

# edit dhcpd.conf for dhcpd to send domain-search option
@srv $ cat /etc/dhcp/dhcpd.conf
...
subnet 192.168.0.0 netmask 255.255.255.0 {
...
  option domain-search "search1.domain.", "search2.domain.";
  default-lease-time 3600;
  max-lease-time 3600;
}
...

# boot cli with break=bottom boot option, and save /tmp/net-$DEVICE.conf
(initramfs) cp /tmp/net-eth0.conf /dev/.initramfs/
(initramfs) exit

# construct resolv.conf with the attachment of this email
@cli $ cat /dev/.initramfs/net-eth0.conf
DEVICE='eth0'
PROTO='dhcp'
IPV4ADDR='192.168.0.51'
IPV4BROADCAST='192.168.0.255'
IPV4NETMASK='255.255.255.0'
IPV4GATEWAY='192.168.0.2'
IPV4DNS0='8.8.8.8'
IPV4DNS1='8.8.4.4'
HOSTNAME='h-name'
DNSDOMAIN='name.domain.'
NISDOMAIN='nis-d'
ROOTSERVER='192.168.0.3'
ROOTPATH='r-path'
filename=''
UPTIME='5'
DHCPLEASETIME='3600'
DOMAINSEARCH='search1.domain. search2.domain.'

@cli $ sh ipconfig_net_conf2resolv_conf.sh /dev/.initramfs/net-eth0.conf
domain name.domain.
search name.domain. search1.domain. search2.domain.
nameserver 8.8.8.8
nameserver 8.8.4.4

# construct dhclient.leases with the attachment of this email
@cli $ sh ipconfig_net_conf2dhclient_leases.sh /dev/.initramfs/net-eth0.conf
lease {
  interface "eth0";
  fixed-address 192.168.0.51;
  option root-path "r-path";
  option subnet-mask 255.255.255.0;
  option dhcp-lease-time 3600;
  option routers 192.168.0.2;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.0.3;
  option domain-name-servers 8.8.8.8,8.8.4.4;
  option domain-search "search1.domain.", "search2.domain.";
  option nis-domain "nis-d";
  option broadcast-address 192.168.0.255;
  option host-name "h-name";
  option domain-name "name.domain.";
  renew 1 2011/08/22 02:20:15;
  rebind 1 2011/08/22 02:42:45;
  expire 1 2011/08/22 02:50:15;
}

# renew the lease obtained by ipconfig without sending DHCPDISCOVER
@cli $ sh ipconfig_net_conf2dhclient_leases.sh \
/dev/.initramfs/net-eth0.conf > /tmp/dhclient.eth0.leases

@cli $ sudo dhclient -lf /tmp/dhclient.eth0.leases -sf /bin/true -d eth0
Internet Systems Consortium DHCP Client 4.1.1-P1
...
Sending on   Socket/fallback
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.3
bound to 192.168.0.51 -- renewal in 1564 seconds.

# obtain a DHCP lease without dhclient.leases file
@cli $ sudo dhclient -lf /dev/null -sf /bin/true -d eth0
Internet Systems Consortium DHCP Client 4.1.1-P1
...
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPOFFER from 192.168.0.3
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.3
bound to 192.168.0.51 -- renewal in 1598 seconds.


>> I inspected the octet length of 'options' field of DHCP Discover and Request packets
>> which other DHCP clients in default settings send by using Wireshark.
>> 'p' means that padding is included.
>>
>> Dis. Req. Client
>>  35   47  ipconfig(master of git)
>>  64p  64p isc-dhclient(4.1.1-P1 in Debian-squeeze)
> If then the padding is still to small, it should be fixed.
> In the ISC dhclient I see a BOOTP_MIN_LEN defined to 300.
> Without checking with current implementation I'd guess we'd fall
> below that?

Requesting domain-search option extends DHCP Discover and Request packets
by one octet. But one octet is too short for the packets to reach 64 octets.

I also see ISC dhclient source. BOOTP_MIN_LEN is defined as the minimum
length of whole BOOTP/DHCP packet on sending. In BOOTP/DHCP packet,
the total length of all fields except 'options' field is fixed, and is
236 octets. DHCP_FIXED_NON_UDP is defined to 236. The difference between
BOOTP_MIN_LEN and DHCP_FIXED_NON_UDP is 64. Therefore, the minimum length
of 'options' field of BOOTP/DHCP packet sent by dhclient is 64 octets.

> the patch by itself has minor Codingstyle errors, which can be seen
> when checked against the scripts/checkpatch.pl in linux source.
> (trailing spaces, missing spaces around operators like `=' or ifs)

I'm sorry that I don't conform to the standard rules.
I fetched and used scripts/checkpatch.pl.

> would you mind giving the asked options a try? and if the length
> then is too small correct the bootp packet length?

I tried for these, though my way might be bad.

Thank you.
--
KUMAAN
9maaan at gmail.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ipconfig_net_conf2resolv_conf.sh
URL: <http://www.zytor.com/pipermail/klibc/attachments/20110823/835cd019/attachment-0002.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ipconfig_net_conf2dhclient_leases.sh
URL: <http://www.zytor.com/pipermail/klibc/attachments/20110823/835cd019/attachment-0003.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: verify_bootp_ext119_decode.c
URL: <http://www.zytor.com/pipermail/klibc/attachments/20110823/835cd019/attachment-0001.c>


More information about the klibc mailing list