summaryrefslogtreecommitdiffstats
path: root/dev-tools/debugging-tools/network.functions
diff options
context:
space:
mode:
authortorben2016-03-24 16:30:57 +0100
committertorben2016-03-24 16:30:57 +0100
commite939f4947587959d6082b7b4e404477ed950f86e (patch)
treed8ffc93d75df25d541ed687552ecd63d3032abe6 /dev-tools/debugging-tools/network.functions
parentadd performance tests (diff)
downloadsystemd-init-e939f4947587959d6082b7b4e404477ed950f86e.tar.gz
systemd-init-e939f4947587959d6082b7b4e404477ed950f86e.tar.xz
systemd-init-e939f4947587959d6082b7b4e404477ed950f86e.zip
Tidy up.
Diffstat (limited to 'dev-tools/debugging-tools/network.functions')
-rw-r--r--dev-tools/debugging-tools/network.functions23
1 files changed, 23 insertions, 0 deletions
diff --git a/dev-tools/debugging-tools/network.functions b/dev-tools/debugging-tools/network.functions
new file mode 100644
index 00000000..89ca5a20
--- /dev/null
+++ b/dev-tools/debugging-tools/network.functions
@@ -0,0 +1,23 @@
+wait_for_iface() {
+ local DEVICE=$1
+ local TIMEOUT=10
+ echo -n "Waiting for interface $DEVICE: "
+ # Some systems don't have operstate. Seems to be hardware dependent
+ [ ! -e "/sys/class/net/${DEVICE}/operstate" ] && usleep 10000
+ if [ -e "/sys/class/net/${DEVICE}/operstate" ]; then
+ while true; do
+ # check linkstate
+ [ "x$(cat "/sys/class/net/${DEVICE}/operstate")" == "xup" ] && break
+ TIMEOUT=$(( $TIMEOUT - 1 )) # don't wait forever, the pcnet iface of vmware will never be "up" although it's working
+ [ "$TIMEOUT" -le 0 ] && break
+ # else
+ echo -n "."
+ usleep 500000
+ done
+ else
+ # we really don't have a operstate .. then just wait a sec and hope for the best.
+ sleep 1
+ fi
+ echo ".$(cat "/sys/class/net/${DEVICE}/operstate" 2>/dev/null)"
+}
+true