Subject: | Bug found and tracked down in dhclient 4.2.4 and 4.2.5 at least (not present in 2.0pl5) |
Date: | Wed, 20 Mar 2013 09:09:27 +0000 |
To: | "dhcp-bugs@isc.org" <dhcp-bugs@isc.org> |
From: | LAHAYE Olivier <olivier.lahaye@cea.fr> |
Dear all,
I've just found and identified a bug in dhclient while trying to create my own initrd for the systemimager project.
When starting dhclient without argument, dhclient ignores the eth0 network card and fails with error "No broadcast interfaces found - exiting".
It's because eth0 at this moment has flag 0x1002. It is down but it is a BROADCAST interface.
If I strart "dhclient eth0", it correctly get an IP address for eth0.
If I reset the eth0 iface to its previous state (down + IP=0.0.0.0), and If I assign a non null IP address (a random non null address), dhclient without specifying the interface on the command line will succeed.
So this is clearly a bug when calling discover_interfaces(DISCOVER_UNCONFIGURED), as it works when are in the discover_interfaces(DISCOVER_RUNNING) case.
The problem is in file dhcp-4.2.4-P2/common/discover.c:576 (same for 4.2.5)
If the ioctl trying to get the IP address of the network card fails (needed to check if there is already a lease maybe?), then it is skipped (continue statement).
The code does not check flags to see that the interface is down (thus uncondfigured).
Another problem is that at this point, we do not have the flags.
I've tested to move the flags retreival code before the get address section, and replace the continue with a return. This partially work. The interface is not ignored anymore, unfortunately, later on, line 1003, when testing info.addr.ss_family, the value is uninitialized, and the interface is not configured.....
I'm unfortunately not enough skilled to fix this, so if one can fix this, that would be cool.
Best regards,
--
Olivier LAHAYE
CEA DRT/LIST/DCSI/DIR
CEA DRT/LIST/DCSI/DIR