]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
fix: grep not match interface listed by `ip link list`
authorJoshua Brunner <j.brunner@nexbyte.com>
Fri, 3 Oct 2014 08:04:18 +0000 (10:04 +0200)
committerDwight Engen <dwight.engen@oracle.com>
Mon, 6 Oct 2014 16:06:27 +0000 (12:06 -0400)
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 <j.brunner@nexbyte.com>
config/init/common/lxc-containers.in

index 31a2b87fba3a9388a1a83607c00cddc28fa89f98..73ccdbac3bbdba721c51328a31a27ce27e998687 100644 (file)
@@ -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