diff --git a/test/upstart-jobs/dhclient.nix b/test/upstart-jobs/dhclient.nix index 3eb71f1745a..dae773ab717 100644 --- a/test/upstart-jobs/dhclient.nix +++ b/test/upstart-jobs/dhclient.nix @@ -10,9 +10,21 @@ start on network-interfaces/started stop on network-interfaces/stop script + # Determine the interface on which to start dhclient. 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\" fi done diff --git a/test/upstart-jobs/network-interfaces.nix b/test/upstart-jobs/network-interfaces.nix index 844ccd3f507..d85c7e02001 100644 --- a/test/upstart-jobs/network-interfaces.nix +++ b/test/upstart-jobs/network-interfaces.nix @@ -12,11 +12,12 @@ start script export MODULE_DIR=${kernel}/lib/modules/ ${module_init_tools}/sbin/modprobe af_packet - + for i in $(cd /sys/class/net && ls -d *); do echo \"Bringing up network device $i...\" ${nettools}/sbin/ifconfig $i up || true done + end script # Hack: Upstart doesn't yet support what we want: a service that @@ -25,7 +26,7 @@ respawn sleep 10000 stop script 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 done end script