Bug 6746

Summary: udhcpc >= v1.19 (mipsel) does not respond to DHCP packet from server
Product: Busybox Reporter: NickR <ma.ya.sav>
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.21.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description NickR 2013-12-29 19:11:53 UTC
I am running Busybox on a FRITZ!Box 7570 router (mipsel).

I am experiencing difficulties with udhcpc v1.21.1, as it keeps failing to recognize DHCPOFFER replies from the server. 

I have tested with multiple servers. In server logs, it can be seen that DHCPDISCOVER is received, and corresponding DHCPOFFER is sent, however, udhcpc fails react accordingly:

   root@7570_red:/var/media/ftp/uStor01# udhcpc -i wan -v
   Adapter index 4
   MAC 00:11:22:33:44:55
   udhcpc (v1.21.1) started
   Executing /usr/share/udhcpc/default.script deconfig
   Entering listen mode: raw
   Opening raw socket on ifindex 4
   Got raw socket fd
   Attached filter to raw socket fd
   Created raw socket
   Adapter index 4
   MAC 00:11:22:33:44:55
   Sending discover...
   Waiting on select 3 seconds
   Adapter index 4
   MAC 00:11:22:33:44:55
   Sending discover...
   Waiting on select 3 seconds
   (etc)

Then I tested older busybox builds, available for download as precompiled binaries. It seems that the last working version of udhcpc was in 1.18.4, i.e. version 1.19.0 fails as well. This is the output I get from version 1.18.4:

   root@7570_red:/var/media/ftp/uStor01# ./busybox-mipsel1.18.4 udhcpc -i wan -v
   Adapter index 4
   MAC 00:11:22:33:44:55
   udhcpc (v1.18.4) started
   Executing /usr/share/udhcpc/default.script deconfig
   Entering listen mode: raw
   Opening raw socket on ifindex 4
   Got raw socket fd 5
   Attached filter to raw socket fd 5
   Created raw socket
   Adapter index 4
   MAC 00:11:22:33:44:55
   Sending discover...
   Waiting on select...
   Got valid DHCP packet
   Adapter index 4
   MAC 00:11:22:33:44:55
   Sending select for 192.166.4.115...
   Waiting on select...
   Got valid DHCP packet
   Lease of 192.166.4.115 obtained, lease time 86400
   Executing /usr/share/udhcpc/default.script bound
   Entering listen mode: none

Unless there was a change between versions 1.18.4 and 1.19.0 that implies different parameters to achieve the same basic behavior, it appears to be a bug.
Comment 1 Denys Vlasenko 2014-01-13 12:50:24 UTC
(In reply to comment #0)
> I am running Busybox on a FRITZ!Box 7570 router (mipsel).
> 
> I am experiencing difficulties with udhcpc v1.21.1, as it keeps failing to
> recognize DHCPOFFER replies from the server. 
> 
> I have tested with multiple servers. In server logs, it can be seen that
> DHCPDISCOVER is received, and corresponding DHCPOFFER is sent, however, udhcpc
> fails react accordingly:
> 
>    root@7570_red:/var/media/ftp/uStor01# udhcpc -i wan -v
>    Adapter index 4
>    MAC 00:11:22:33:44:55
>    udhcpc (v1.21.1) started
>    Executing /usr/share/udhcpc/default.script deconfig
>    Entering listen mode: raw
>    Opening raw socket on ifindex 4
>    Got raw socket fd
>    Attached filter to raw socket fd
>    Created raw socket
>    Adapter index 4
>    MAC 00:11:22:33:44:55
>    Sending discover...
>    Waiting on select 3 seconds
>    Adapter index 4
>    MAC 00:11:22:33:44:55
>    Sending discover...
>    Waiting on select 3 seconds
>    (etc)
> 
> Then I tested older busybox builds, available for download as precompiled
> binaries. It seems that the last working version of udhcpc was in 1.18.4, i.e.
> version 1.19.0 fails as well. This is the output I get from version 1.18.4:
> 
>    root@7570_red:/var/media/ftp/uStor01# ./busybox-mipsel1.18.4 udhcpc -i wan
> -v
>    Adapter index 4
>    MAC 00:11:22:33:44:55
>    udhcpc (v1.18.4) started
>    Executing /usr/share/udhcpc/default.script deconfig
>    Entering listen mode: raw
>    Opening raw socket on ifindex 4
>    Got raw socket fd 5
>    Attached filter to raw socket fd 5
>    Created raw socket
>    Adapter index 4
>    MAC 00:11:22:33:44:55
>    Sending discover...
>    Waiting on select...
>    Got valid DHCP packet
>    Adapter index 4
>    MAC 00:11:22:33:44:55
>    Sending select for 192.166.4.115...
>    Waiting on select...
>    Got valid DHCP packet
>    Lease of 192.166.4.115 obtained, lease time 86400
>    Executing /usr/share/udhcpc/default.script bound
>    Entering listen mode: none
> 
> Unless there was a change between versions 1.18.4 and 1.19.0 that implies
> different parameters to achieve the same basic behavior, it appears to be a
> bug.

I need more data. Between which versions exactly behavior has changed?
Can you show packet dump of last working and first non-working version?
(tcpdump -s0 -xX will do).
Comment 2 NickR 2014-01-16 23:48:04 UTC
> I need more data. Between which versions exactly behavior has changed?
> Can you show packet dump of last working and first non-working version?
> (tcpdump -s0 -xX will do).

Thanks for your reply.

As I badly needed busybox v1.21 up and running ASAP, I went through the source code and experimented a bit. Finally, I was able to fix the issue by commenting out this part of the code:

		if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
				sizeof(filter_prog)) >= 0)
			log1("Attached filter to raw socket fd"); // log?

Apparently my kernel does not support this filter feature. It might make sense to introduce a command line switch with the same effect.

If you still need the tcpdump, please let me know, I will try to produce it.
Comment 3 Denys Vlasenko 2014-02-03 17:05:11 UTC
Fixed in git:

commit e4785ca653d0e219926692c229673b2c1b8d6ac4
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Mon Feb 3 18:03:42 2014 +0100

    udhcpc: don't use BPF filter, users report problems (bugs 4598, 6746)