[klibc] ipconfig problem if multiple devices are up

Ulrich Dangel uli at spamt.net
Sun Mar 27 15:09:29 PDT 2011


Hi,
it seems that ipconfig has a problem if multiple devices are up and
connected to the same network. It seems that it uses the wrong
socket/device index to compare it to incoming packet. To be more
precise, the packet gets discarded in do_pkt_recv as the ifindex from
state differs always from the incoming packet

To reproduce create two tap devices:
$ sudo tunctl -u uli -t tap0                                          
Set 'tap0' persistent and owned by uid 1000
$ sudo tunctl -u uli -t tap1                                              
Set 'tap1' persistent and owned by uid 1000
$ 

I am using for the following step the vde2 software as it runs as a
normal user, but you can do it manually (create a bridge, add tap{0,1}
to that bridge, give the bridge a ip address, start a dhcp server)

,----
| # start a switch 
| vde_switch -s /tmp/switch -d
| # connect the tap devices to the switch
| vde_plug2tap -s /tmp/switch tap0 -d
| vde_plug2tap -s /tmp/switch tap1 -d
| # create a dhcp server
| slirpvde -s /tmp/switch -dhcp
| # start the devices
| sudo ifconfig tap0 up
| sudo ifconfig tap1 up
`----

Now you can test everything:

sudo ipconfig -t 10 tap0
IP-Config: no response after 5 secs - giving up
sudo ipconfig -t 10 tap1
IP-Config: no response after 5 secs - giving up

I added additional debug output:
,----
| diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
| index d501bec..8e1b62a 100644
| --- a/usr/kinit/ipconfig/main.c
| +++ b/usr/kinit/ipconfig/main.c
| @@ -312,7 +313,8 @@ static int do_pkt_recv(int pkt_fd, time_t now)
|                 return ret;
|  
|         for (s = slist; s; s = s->next) {
| -               if (s->dev->ifindex == ifindex) {
| +               dprintf("ifindex: %d - s->dev>ifindex: %d - %s\n",ifindex, s->de
| +               if (s->dev->ifindex == (ifindex)) {
|                         ret = process_receive_event(s, now);
|                         break;
|                 }
|
`----

And the output is (for ipconfig tap1):
ifindex: 1105 - s->dev>ifindex: 1106 - tap1

(1105 is tap0)

If you delete on of the two devices (tunctl -d tap0 / don't forget to
kill the corresponding vde_plug2tap process) everything works like
expected.

Ulrich
-- 
twitter: @mr_ud  | identica: @mru
IRCNet:  mru     | freenode: mrud



More information about the klibc mailing list