[klibc] ipconfig bug with multiple interfaces

Michal Sojka sojkam1 at fel.cvut.cz
Fri Feb 22 11:10:54 PST 2008


Hello,

if ipconfig is run as ipconfig :::::: (i.e. long spec with all fields empty) 
and the computer has multiple network interfaces and only one of them is 
connected to dhcp managed network, ipconfig ends up in an infinite loop (see 
the log bellow).

The following patch solved this for me. According to README, if the <device> 
in the long spec is empty, the first interface should be used, but the 
program busy wait for all interfaces.

diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index 50141e5..72bfdaf 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -534,6 +534,7 @@ static int parse_device(struct netdev *dev, const char 
*ip)
        if (dev->name == NULL ||
            dev->name[0] == '\0' || strcmp(dev->name, "all") == 0) {
                add_all_devices(dev);
+               bringup_first = 1;
                return 0;
        }
        return 1;

The ipconfig output with enabled debugging looks like this:

IP-Config: eth0:  setting full-duplex.
parse_device: "::::::"
Trying to bring up eth1
IP-Config: parse_device: "eth1"
IP-Config: eth1 hardware address 00:0c:f1:77:ec:46 mtu 1500 DHCP RARP
Trying to bring up eth0
IP-Config: parse_device: "eth0"
IP-Config: eth0 hardware address 00:50:04:1f:d9:40 mtu 1500 DHCP RARP
eth0: state = 2
timeout
-> dhcp discover xid 276c7476 secs 0 
   udp src 68 dst 67
   ip src 0.0.0usb 1-1: new full speed USB device using uhci_hcd and address 3
.0 dst 255.255.255.255 
   bytes 299
eth1: state = 2
timeout
usb 1-1: configuration #1 chosen from 1 choice
Delta: 1051 ms
Delta: 99 ms
eth0: state = 2
timeout
-> dhcp discover xid 276c7476 secs 1 
   udp src 68 dst 67
   ip src 0.0.0.0 dst 255.255.255.255 
   bytes 299
eth1: state = 2
timeout
-> dhcp discover xid 71040389 secs 1 
   udp src 68 dst 67
   ip src 0.0.0.0 dst 255.255.255.255 
   bytes 299
<- bytes 362 
   ip src 147.32.86.1 dst 147.32.86.65 
   udp src 67 dst 68 
   dhcp xid 71040389 
   dhcp offer
-> dhcp request xid 71040389 secs 1 
   udp src 68 dst 67
   ip src 0.0.0.0 dst 255.255.255.255 
   bytes 311

Delta: 0 ms
Delta: 1003 ms
eth0: state = 2
eth1: state = 3
timeout
-> dhcp request xid 71040389 secs 2 
   udp src 68 dst 67
   ip src 0.0.0.0 dst 255.255.255.255 
   bytes 311
<- bytes 362 
   ip src 147.32.86.1 dst 147.32.86.65 
   udp src 67 dst 68 
   dhcp xid 71040389 
   dhcp ack
IP-Config: eth1 guessed broadcast address 147.32.86.255
IP-Config: eth1 complete (from 147.32.86.1):
 address: 147.32.86.65     broadcast: 147.32.86.255    netmask: 255.255.255.0   
 gateway: 147.32.86.1      dns0     : 147.32.80.9      dns1   : 0.0.0.0         
 host   : sojkam                                                          
 domain : felk.cvut.cz                                                    
 rootserver: 147.32.86.1 rootpath: 
 filename  : 
eth0: state = 2
eth1: state = 4
IP-Config: eth1 complete (from 147.32.86.1):
 address: 147.32.86.65     broadcast: 147.32.86.255    netmask: 255.255.255.0   
 gateway: 147.32.86.1      dns0     : 147.32.80.9      dns1   : 0.0.0.0         
 host   : sojkam                                                          
 domain : felk.cvut.cz                                                    
 rootserver: 147.32.86.1 rootpath: 
 filename  : 
eth0: state = 2
eth1: state = 4
IP-Config: eth1 complete (from 147.32.86.1):
 address: 147.32.86.65     broadcast: 147.32.86.255    netmask: 255.255.255.0   
 gateway: 147.32.86.1      dns0     : 147.32.80.9      dns1   : 0.0.0.0         
 host   : sojkam                                                          
 domain : felk.cvut.cz                                                    
 rootserver: 147.32.86.1 rootpath: 
 filename  : 
eth0: state = 2
eth1: state = 4
IP-Config: eth1 complete (from 147.32.86.1):
 address: 147.32.86.65     broadcast: 147.32.86.255    netmask: 255.255.255.0   
 gateway: 147.32.86.1      dns0     : 147.32.80.9      dns1   : 0.0.0.0         
 host   : sojkam                                                          
 domain : felk.cvut.cz                                                    
 rootserver: 147.32.86.1 rootpath: 
 filename  : 
...
and this repeats very quickly forever.

Regards
Michal Sojka



More information about the klibc mailing list