From: Joshua Brunner Date: Fri, 3 Oct 2014 08:04:18 +0000 (+0200) Subject: fix: grep not match interface listed by `ip link list` X-Git-Tag: lxc-1.1.0.alpha3~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f422613e6941580a6e3559e062be0052ba95b76b;p=thirdparty%2Flxc.git fix: grep not match interface listed by `ip link list` Interfaces listed by `ip link list` are prefixed with the index identifier. The pattern "^$BRNAME" does not match. - dependencies to ifconfig and ip removed - wait until interface flagged with IFF_UP Ref: https://github.com/torvalds/linux/blob/master/include/uapi/linux/if.h Signed-off-by: Joshua Brunner --- diff --git a/config/init/common/lxc-containers.in b/config/init/common/lxc-containers.in index 31a2b87fb..73ccdbac3 100644 --- a/config/init/common/lxc-containers.in +++ b/config/init/common/lxc-containers.in @@ -51,28 +51,18 @@ fi # to start wait_for_bridge() { + local BRNAME try flags [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; } - which ifconfig >/dev/null 2>&1 - if [ $? = 0 ]; then - cmd="ifconfig -a" - else - which ip >/dev/null 2>&1 - if [ $? = 0 ]; then - cmd="ip link list" - fi - fi - [ -n cmd ] || { return 0; } - BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'` if [ -z "$BRNAME" ]; then return 0 fi for try in `seq 1 30`; do - eval $cmd |grep "^$BRNAME" >/dev/null 2>&1 - if [ $? = 0 ]; then - return + if [ -r /sys/class/net/$BRNAME/flags ]; then + read flags < /sys/class/net/$BRNAME/flags + [ $((flags & 0x1)) -eq 1 ] && { return 0; } fi sleep 1 done