* Don't use /sys/class/net/*/operstate to find out the active interface,

since there seems to be a delay after the interface is brought up before
  operstate reflects that.

svn path=/nixu/trunk/; revision=7121
This commit is contained in:
Eelco Dolstra 2006-11-24 16:31:01 +00:00
parent 9ac2e48e26
commit 3055ff0ae6
2 changed files with 17 additions and 4 deletions

View File

@ -10,9 +10,21 @@ start on network-interfaces/started
stop on network-interfaces/stop stop on network-interfaces/stop
script script
# Determine the interface on which to start dhclient.
interfaces= interfaces=
for i in $(cd /sys/class/net && ls -d *); do
if test \"$i\" != \"lo\" -a \"$(cat /sys/class/net/$i/operstate)\" != 'down'; then # !!! apparent race; operstate seems to have a slight delay, so
# if dhclient is started right after network-interfaces, we don't
# always see all the interfaces.
#for i in $(cd /sys/class/net && ls -d *); do
# if test \"$i\" != \"lo\" -a \"$(cat /sys/class/net/$i/operstate)\" != 'down'; then
# interfaces=\"$interfaces $i\"
# fi
#done
for i in $(ifconfig | grep '^[^ ]' | sed 's/ .*//'); do
if test \"$i\" != \"lo\"; then
interfaces=\"$interfaces $i\" interfaces=\"$interfaces $i\"
fi fi
done done

View File

@ -17,6 +17,7 @@ start script
echo \"Bringing up network device $i...\" echo \"Bringing up network device $i...\"
${nettools}/sbin/ifconfig $i up || true ${nettools}/sbin/ifconfig $i up || true
done done
end script end script
# Hack: Upstart doesn't yet support what we want: a service that # Hack: Upstart doesn't yet support what we want: a service that
@ -25,7 +26,7 @@ respawn sleep 10000
stop script stop script
for i in $(cd /sys/class/net && ls -d *); do for i in $(cd /sys/class/net && ls -d *); do
echo \"Bringing up network device $i...\" echo \"Taking down network device $i...\"
${nettools}/sbin/ifconfig $i down || true ${nettools}/sbin/ifconfig $i down || true
done done
end script end script