Bug #942
closed
S40network should not run dhcp client on eth0 if it is not connected
Added by Hammel almost 2 years ago.
Updated over 1 year ago.
Category:
04 - Root File System
Description
Will need to test sysfs for connection status.
- Priority changed from Urgent to Immediate
- Severity changed from 01 - Critical to 02 - High
See piboxd:eth.c
#define ETH0_STATE_PATH "/sys/class/net/eth0/carrier"
If this is 1 then we can enable dhcp. At least until we put network startup in the background.
- Status changed from New to In Progress
- % Done changed from 0 to 10
This isn't what I expected. The use of Busybox's ifup places starting of dhcp inside the ifup binary embedded in Busybox. So I can't actually check there for the eth port connection.
What I can do is change S40network to not use ifup -a, but rather ifup <interface> and iterate across all interfaces one at a time. It will look something like this.
#!/bin/sh
myfunc()
{
for ifacep in /sys/class/net/*
do
iface="$(basename ${ifacep})"
if [ "${iface}" == "lo" ]
then
continue
fi
if [ ! -e "${ifacep}/wireless" ]
then
echo "${iface} is not wireless"
carrier=$(cat ${ifacep}/carrier)
if [ ${carrier} -eq 1 ]
then
echo "Do ifup ${iface}"
fi
fi
done
}
( myfunc ) &
Running the function inside () places it in a subshell, which we then background. This is equivalent of the double fork for a daemon process in C. This allows the S40network script to complete even though network startup is in progress, thus speeding up initial bootup.
It's unclear at this point if any system apps will puke because networking is not up yet. An alternative is to only place each instance of ifup <iface> in the double fork though I'm not sure that will help if some app requires networking to be up before it starts. Given that only piboxd will run at boot time (and launcher) on system builds I don't think this will be much of an issue.
- Status changed from In Progress to Rejected
That script doesn't really work, either. If the interface is down'd then there is no carrier value at all (not 0 or 1). So you have to ifconfig <iface> up the interface first just to have a valid value in the carrier (note that the carrier file exists but can't be read if the interface isn't ifconfig up'd). But even that isn't working, possibly because the carrier value doesn't update immediately.
This is all such as hack. I'm going to reject this issue for now, then come back to it when I look at boot time speedups (RM #472).
Also available in: Atom
PDF