[PATCH-suggestion] The pidfile problem of udhcpc
Mats Erik Andersson
mats at blue2net.com
Mon Jul 2 14:54:11 UTC 2007
Hi again,
I have analyzed and located the problem with udhcpc
for todays snapshot of Busybox when one uses
# CONFIG_FEATURE_PIDFILE is not set
Attached are three files:
utsaga_ifdown.txt is a manual recovery and error listing
ifupdown_without_pidfile.diff is a functional patch, see below
bb_udhcpc_script_error_handling.diff mends a related problem
My original issue was that when ENABLE_FEATURE_PIDFILE=0 causes
an error
ifdown eth0 when eth0 is dhcp-controled
--> udhcpc --> ifupdown --> execute -->
--> cat /var/run/udhcpc.eth0.pid has an empty argument
----> kill udhcpc fails and 'ifdown eth0' fails midway
The suggested patch makes one bad choice out of three:
identify process udhcpc using either of pidof/killall/killall5
where I went for pidof. All three function calls have a configuration
option of their own. Least bad solution? Is it worth the risk to scrap
'execute()' and go for exec() directly? You decide! I have found the
culprit and provided a starting point.
Lastly, that manual recovery displays an error message for 'route',
which happens to originate in a script 'default.script' for udhcpc,
but which is not supplied by Busybox. Instead, it comes from Buildroot.
The corresponding patch is my third attached file. It would presumably
look more trustworthy if such a patch would originate from a Busybox
maintainer, so feel free to forward it to Buildroot, since it indeed
does remove said error message. I have tested it on x86-images.
The error was present for a long time on my small systems, long
long before FEATURE_PIDFILE entered the picture.
Best regards, Mats E A
-------------- next part --------------
# ifconfig eth0 down
# ifdown eth0
cat: can't open '/var/run/udhcpc.eth0.pid': No such file or directory
You need to specify whom to kill
# ifup eth0
udhcpc (v1.7.0.svn) started
eth0: Setting 3c5x9/3c5x9B half-duplex mode if_port: 0, sw_info: 1331
eth0: Setting Rx mode to 0 addresses.
eth0: Setting Rx mode to 1 addresses.
Sending discover...
Sending discover...
Sending select for 192.168.7.15...
Lease of 192.168.7.15 obtained, lease time 21600
deleting routers
route: SIOC[ADD|DEL]RT: No such process
adding dns 192.168.7.253
# ls /tmp/
dropbear.pid lastlog messages sdp
ifstate log resolv.conf
# ifdown eth0
cat: can't open '/var/run/udhcpc.eth0.pid': No such file or directory
You need to specify whom to kill
# ps
258 root 688 S /sbin/getty -L ttyS1 115200 vt100
288 root 700 S udhcpc -R -n -p /var/run/udhcpc.eth0.pid -i eth0
298 root 688 R ps
# ls /var/run/
dropbear.pid lastlog messages sdp
ifstate log resolv.conf
# echo 288 > /var/run/udhcpc.eth0.pid
# ifdown eth0
ifdown: interface eth0 not configured
#
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ifupdown_without_pidfile.diff
Type: text/x-patch
Size: 669 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070702/4c46a018/attachment-0004.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bb_udhcpc_script_error_handling.diff
Type: text/x-patch
Size: 1944 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070702/4c46a018/attachment-0005.bin
More information about the busybox
mailing list