|
|
a56a5e |
From 34397fe702ae21a3566e166b4001e8121766d5a7 Mon Sep 17 00:00:00 2001
|
|
|
966cef |
From: Harald Hoyer <harald@redhat.com>
|
|
|
966cef |
Date: Mon, 2 Dec 2013 10:36:42 +0100
|
|
|
966cef |
Subject: [PATCH] network/net-lib.sh:iface_has_link() fixup
|
|
|
966cef |
|
|
|
966cef |
Just echo'ing the flags IFF_UP|IFF_RUNNING does _not_ reflect the
|
|
|
966cef |
carrier state immediately. So wait for it to really show up.
|
|
|
966cef |
---
|
|
|
966cef |
modules.d/40network/net-lib.sh | 47 +++++++++++++++++++++---------------------
|
|
|
966cef |
1 file changed, 23 insertions(+), 24 deletions(-)
|
|
|
966cef |
|
|
|
966cef |
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
|
|
|
966cef |
index 0aa312a..7544401 100644
|
|
|
966cef |
--- a/modules.d/40network/net-lib.sh
|
|
|
966cef |
+++ b/modules.d/40network/net-lib.sh
|
|
|
966cef |
@@ -28,30 +28,6 @@ iface_for_mac() {
|
|
|
966cef |
done
|
|
|
966cef |
}
|
|
|
966cef |
|
|
|
966cef |
-iface_has_link() {
|
|
|
966cef |
- local interface="$1" flags=""
|
|
|
966cef |
- [ -n "$interface" ] || return 2
|
|
|
966cef |
- interface="/sys/class/net/$interface"
|
|
|
966cef |
- [ -d "$interface" ] || return 2
|
|
|
966cef |
- flags=$(cat $interface/flags)
|
|
|
966cef |
- echo $(($flags|0x41)) > $interface/flags # 0x41: IFF_UP|IFF_RUNNING
|
|
|
966cef |
- [ "$(cat $interface/carrier)" = 1 ] || return 1
|
|
|
966cef |
- # XXX Do we need to reset the flags here? anaconda never bothered..
|
|
|
966cef |
-}
|
|
|
966cef |
-
|
|
|
966cef |
-find_iface_with_link() {
|
|
|
966cef |
- local iface_path="" iface=""
|
|
|
966cef |
- for iface_path in /sys/class/net/*; do
|
|
|
966cef |
- iface=${iface_path##*/}
|
|
|
966cef |
- str_starts "$iface" "lo" && continue
|
|
|
966cef |
- if iface_has_link $iface; then
|
|
|
966cef |
- echo "$iface"
|
|
|
966cef |
- return 0
|
|
|
966cef |
- fi
|
|
|
966cef |
- done
|
|
|
966cef |
- return 1
|
|
|
966cef |
-}
|
|
|
966cef |
-
|
|
|
966cef |
# get the iface name for the given identifier - either a MAC, IP, or iface name
|
|
|
966cef |
iface_name() {
|
|
|
966cef |
case $1 in
|
|
|
966cef |
@@ -483,3 +459,26 @@ type hostname >/dev/null 2>&1 || \
|
|
|
966cef |
hostname() {
|
|
|
966cef |
cat /proc/sys/kernel/hostname
|
|
|
966cef |
}
|
|
|
966cef |
+
|
|
|
966cef |
+iface_has_link() {
|
|
|
966cef |
+ local interface="$1" flags=""
|
|
|
966cef |
+ [ -n "$interface" ] || return 2
|
|
|
966cef |
+ interface="/sys/class/net/$interface"
|
|
|
966cef |
+ [ -d "$interface" ] || return 2
|
|
|
966cef |
+ linkup "$1"
|
|
|
966cef |
+ [ "$(cat $interface/carrier)" = 1 ] || return 1
|
|
|
966cef |
+ # XXX Do we need to reset the flags here? anaconda never bothered..
|
|
|
966cef |
+}
|
|
|
966cef |
+
|
|
|
966cef |
+find_iface_with_link() {
|
|
|
966cef |
+ local iface_path="" iface=""
|
|
|
966cef |
+ for iface_path in /sys/class/net/*; do
|
|
|
966cef |
+ iface=${iface_path##*/}
|
|
|
966cef |
+ str_starts "$iface" "lo" && continue
|
|
|
966cef |
+ if iface_has_link $iface; then
|
|
|
966cef |
+ echo "$iface"
|
|
|
966cef |
+ return 0
|
|
|
966cef |
+ fi
|
|
|
966cef |
+ done
|
|
|
966cef |
+ return 1
|
|
|
966cef |
+}
|