Bug 4598 - udhcpc stop getting address from dhcp server from version 1.19.0 and up
Summary: udhcpc stop getting address from dhcp server from version 1.19.0 and up
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.19.x
Hardware: Other Linux
: P5 critical
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-12 12:30 UTC by Gianluca Renzi
Modified: 2014-02-03 17:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Log-A Show how DHCP client fails to react to servers messages (6.04 KB, text/plain)
2012-03-13 07:15 UTC, Bugaboo
Details
Log-B Shows working Busybox (1.12.3) DHCP clients traffic (6.24 KB, text/plain)
2012-03-13 07:19 UTC, Bugaboo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gianluca Renzi 2011-12-12 12:30:40 UTC
I am using for ages busybox in my own cross-build environments all based on ARM.
Last time I upgraded busybox was from an ancient version (pre-1.0 or similar) to 1.18.4. The only thing I had to patch was a fbsplash utility to support screen depth higher than 16bpp. Everything was working fine.
After some months I decided to upgrade to 1.18.5 (with the same configuration files as the procedure is fully automatic). Everything is working fine until I tried the 1.19.2 version, because of an already patched framebuffer utilities to support 24/32 bpp depth.
Now the udhcpc client is not getting any address anymore from my dhcp server.
The same problem appear in version 1.19.2 and 1.19.3.

The only workaround I found is replace the dhcpc.c/.h from 1.18.5 to higher version, and luckily it compiles and runs properly in my hardware.

Here is my specs:

Platform A: Samsung S3C2442 (arm toolchain 4.1.1)
Linux Kernel: 2.6.27

Platform B: Freescale i.MX27 (arm toolchain 4.1.1)
Linux Kernel: 2.6.19.2

Here is an (almost) detailed log of WORKING (1.18.5) busybox installation:

# busybox
BusyBox v1.18.5 (2011-12-12 12:37:09 GMT) multi-call binary.
Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]...
   or: busybox --list[-full]
   or: function [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  Most people will create a
        link to busybox for each function they wish to use and BusyBox
        will act like whatever it was invoked as.

Currently defined functions:
        [, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash, awk, base64,
        basename, beep, bootchartd, brctl, bunzip2, bzcat, cal, cat, chgrp,
        chmod, chown, chpasswd, chroot, chvt, clear, cmp, comm, cp, cpio,
        crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser,
        depmod, df, dirname, dmesg, dnsdomainname, dos2unix, dpkg, dpkg-deb,
        du, dumpkmap, echo, ed, egrep, env, expr, false, fbset, fbsplash,
        fdisk, fgrep, find, fold, free, ftpget, ftpput, getopt, getty, grep,
        gunzip, gzip, halt, hd, head, hexdump, hostid, hostname, httpd,
        hwclock, id, ifconfig, ifdown, ifenslave, ifplugd, ifup, init,
        inotifyd, insmod, install, ionice, ipcalc, kill, killall, killall5,
        klogd, last, length, less, linuxrc, ln, loadfont, loadkmap, logger,
        login, logread, losetup, ls, lsmod, lsusb, makedevs, md5sum, mkdir,
        mkdosfs, mkfs.vfat, mknod, mkswap, mktemp, modinfo, modprobe, more,
        mount, mv, nameif, nbd-client, nc, netstat, nice, nohup, nslookup, od,
        openvt, passwd, patch, pidof, ping, ping6, pipe_progress, pivot_root,
        poweroff, printf, ps, pwd, rdate, readlink, readprofile, realpath,
        reboot, renice, reset, rm, rmdir, rmmod, route, rpm, run-parts, rx,
        sed, sendmail, seq, setkeycodes, sh, sleep, sort, start-stop-daemon,
        stat, strings, stty, su, sulogin, sum, swapoff, swapon, sync, sysctl,
        syslogd, tail, tee, telnet, telnetd, test, tftp, tftpd, time, top,
        touch, tr, traceroute, traceroute6, true, tty, udhcpc, umount, uname,
        uncompress, uniq, unix2dos, unzip, uptime, usleep, uudecode, uuencode,
        vi, vlock, watchdog, wc, wget, which, who, whoami, xargs, yes, zcat

# udhcpc -v
Adapter index 2
MAC 00:60:35:10:7e:ff
udhcpc (v1.18.5) started
Executing /usr/share/udhcpc/default.script deconfig
eth0: status: link is up
eth0: config: auto-negotiation on, 100FDX, 100HDX, 10FDX, 10HDX.
Entering listen mode: raw
Opening raw socket on ifindex 2
Got raw socket fd 5
Attached filter to raw socket fd 5
Created raw socket
Adapter index 2
MAC 00:60:35:10:7e:ff
Sending discover...
Waiting on select...
Adapter index 2
MAC 00:60:35:10:7e:ff
Sending discover...
Waiting on select...
NETDEV WATCHDOG: eth0: transmit timed out
eth0: transmit timed out.
Got valid DHCP packet
Adapter index 2
MAC 00:60:35:10:7e:ff
Sending select for 192.168.143.151...
Waiting on select...
Got valid DHCP packet
Waiting on select...
Got valid DHCP packet
Lease of 192.168.143.151 obtained, lease time 14400
Executing /usr/share/udhcpc/default.script bound
deleting routers
route: SIOCDELRT: No such process
adding dns 192.168.143.2
adding dns 8.8.8.8
Entering listen mode: none



and now the NON WORKING busybox udhcpc installation on the same hardware:

# busybox 
BusyBox v1.19.0 (2011-12-12 12:44:52 GMT) multi-call binary.
Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]...
   or: busybox --list[-full]
   or: function [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  Most people will create a
        link to busybox for each function they wish to use and BusyBox
        will act like whatever it was invoked as.

Currently defined functions:
        [, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash, awk, base64,
        basename, beep, bootchartd, brctl, bunzip2, bzcat, cal, cat, chgrp,
        chmod, chown, chpasswd, chroot, chvt, clear, cmp, comm, cp, cpio,
        crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser,
        depmod, df, dirname, dmesg, dnsdomainname, dos2unix, dpkg, dpkg-deb,
        du, dumpkmap, echo, ed, egrep, env, expr, false, fbset, fbsplash,
        fdisk, fgrep, find, fold, free, ftpget, ftpput, getopt, getty, grep,
        gunzip, gzip, halt, hd, head, hexdump, hostid, hostname, httpd,
        hwclock, id, ifconfig, ifdown, ifenslave, ifplugd, ifup, init,
        inotifyd, insmod, install, ionice, ipcalc, kill, killall, killall5,
        klogd, last, less, linuxrc, ln, loadfont, loadkmap, logger, login,
        logread, losetup, ls, lsmod, lsusb, makedevs, md5sum, mkdir, mkdosfs,
        mkfs.vfat, mknod, mkswap, mktemp, modinfo, modprobe, more, mount, mv,
        nameif, nbd-client, nc, netstat, nice, nohup, nslookup, od, openvt,
        passwd, patch, pidof, ping, ping6, pipe_progress, pivot_root, poweroff,
        printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,
        renice, reset, rm, rmdir, rmmod, route, rpm, run-parts, rx, sed,
        sendmail, seq, setkeycodes, sh, sleep, sort, start-stop-daemon, stat,
        strings, stty, su, sulogin, sum, swapoff, swapon, sync, sysctl,
        syslogd, tail, tee, telnet, telnetd, test, tftp, tftpd, time, top,
        touch, tr, traceroute, traceroute6, true, tty, udhcpc, umount, uname,
        uncompress, uniq, unix2dos, unzip, uptime, usleep, uudecode, uuencode,
        vi, vlock, watchdog, wc, wget, which, who, whoami, xargs, yes, zcat
        
# udhcpc -v
Adapter index 2
MAC 00:60:35:10:7e:ff
udhcpc (v1.19.0) started
Executing /usr/share/udhcpc/default.script deconfig
eth0: status: link is up
eth0: config: auto-negotiation on, 100FDX, 100HDX, 10FDX, 10HDX.
Entering listen mode: raw
Opening raw socket on ifindex 2
Got raw socket fd 5
Attached filter to raw socket fd 5
Created raw socket
Adapter index 2
MAC 00:60:35:10:7e:ff
Sending discover...
Waiting on select...
Adapter index 2
MAC 00:60:35:10:7e:ff
Sending discover...
Waiting on select...
NETDEV WATCHDOG: eth0: transmit timed out
eth0: transmit timed out.
Adapter index 2
MAC 00:60:35:10:7e:ff
Sending discover...
Waiting on select...
Adapter index 2
MAC 00:60:35:10:7e:ff
Executing /usr/share/udhcpc/default.script leasefail
Waiting on select...

and wait forever (until a CTRL-C)

Can you check what is changed between versions 1.18 and 1.19?
diff gives me a lot of API changes... Maybe some pitfalls in between??

Best regards,
Gianluca
Comment 1 Denys Vlasenko 2011-12-16 00:53:06 UTC
Please attach "tcpdump -nlieth0 -vvv -s0 -exX udp port 67 or port 68" output for both working and non-working cases.
Comment 2 Denys Vlasenko 2012-01-10 17:17:29 UTC
Closing as WORKSFORME (it indeed works for me). Reopen if you have additional information.
Comment 3 Gianluca Renzi 2012-01-13 13:57:46 UTC
(In reply to comment #2)
> Closing as WORKSFORME (it indeed works for me). Reopen if you have additional
> information.

Sorry for answering so late. In the next few days I will able to printout the tcpdump command as you asked.

Best regards,
Comment 4 Gianluca Renzi 2012-01-13 14:01:31 UTC
(In reply to comment #2)
> Closing as WORKSFORME (it indeed works for me). Reopen if you have additional
> information.

Sorry for answering so late. In the next few days I will able to printout the tcpdump command as you asked.

Best regards,
Comment 5 Bugaboo 2012-03-13 07:15:03 UTC
Created attachment 4118 [details]
Log-A Show how DHCP client fails to react to servers messages
Comment 6 Bugaboo 2012-03-13 07:19:31 UTC
Created attachment 4124 [details]
Log-B Shows working Busybox (1.12.3) DHCP clients traffic
Comment 7 Bugaboo 2012-03-13 07:21:34 UTC
I reproduced bug in ARM ESW system using 2.6.19.2 – kernel and Busybox version 1.19.4 (log A).

Using same system but build with Busybox  version 1.3.1 (log B) I couldn’t reproduce bug. Busybox 1.12.3 also didn’t reproduce bug (no log).

When bug appears select()-call in udhcpc.c: udhcpc_main() always ends with timeout. 
My guess is that tcpsocket filter in new Busybox is not compatible with old kernel, and 
prevent socket from receiving DHCP servers packets.

Could my guess be onto something? I’ll commented out the filter to see if it really is the problem cause, 
and it fixed issue. After fix DHCP client worked normally.

Commented out line was in udhcpc.c: udhcp_raw_socket(): setsockopt(...)

Br
Comment 8 Denys Vlasenko 2014-02-03 17:05:19 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)