]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network/net-lib.sh:iface_has_link() fixup
authorHarald Hoyer <harald@redhat.com>
Mon, 2 Dec 2013 09:36:42 +0000 (10:36 +0100)
committerHarald Hoyer <harald@redhat.com>
Tue, 3 Dec 2013 15:21:04 +0000 (16:21 +0100)
Just echo'ing the flags IFF_UP|IFF_RUNNING does _not_ reflect the
carrier state immediately. So wait for it to really show up.

modules.d/40network/net-lib.sh

index 0aa312a093fe3b56116ef98743a2d481b896af85..7544401f1c15cd0b6431752a3b1b5b6167921535 100644 (file)
@@ -28,30 +28,6 @@ iface_for_mac() {
     done
 }
 
-iface_has_link() {
-    local interface="$1" flags=""
-    [ -n "$interface" ] || return 2
-    interface="/sys/class/net/$interface"
-    [ -d "$interface" ] || return 2
-    flags=$(cat $interface/flags)
-    echo $(($flags|0x41)) > $interface/flags # 0x41: IFF_UP|IFF_RUNNING
-    [ "$(cat $interface/carrier)" = 1 ] || return 1
-    # XXX Do we need to reset the flags here? anaconda never bothered..
-}
-
-find_iface_with_link() {
-    local iface_path="" iface=""
-    for iface_path in /sys/class/net/*; do
-        iface=${iface_path##*/}
-        str_starts "$iface" "lo" && continue
-        if iface_has_link $iface; then
-            echo "$iface"
-            return 0
-        fi
-    done
-    return 1
-}
-
 # get the iface name for the given identifier - either a MAC, IP, or iface name
 iface_name() {
     case $1 in
@@ -483,3 +459,26 @@ type hostname >/dev/null 2>&1 || \
 hostname() {
        cat /proc/sys/kernel/hostname
 }
+
+iface_has_link() {
+    local interface="$1" flags=""
+    [ -n "$interface" ] || return 2
+    interface="/sys/class/net/$interface"
+    [ -d "$interface" ] || return 2
+    linkup "$1"
+    [ "$(cat $interface/carrier)" = 1 ] || return 1
+    # XXX Do we need to reset the flags here? anaconda never bothered..
+}
+
+find_iface_with_link() {
+    local iface_path="" iface=""
+    for iface_path in /sys/class/net/*; do
+        iface=${iface_path##*/}
+        str_starts "$iface" "lo" && continue
+        if iface_has_link $iface; then
+            echo "$iface"
+            return 0
+        fi
+    done
+    return 1
+}