|
|
a0a3b4 |
From 17985b2575c10b488e7af2aeef160b41a97b2358 Mon Sep 17 00:00:00 2001
|
|
|
a0a3b4 |
From: Harald Hoyer <harald@redhat.com>
|
|
|
a0a3b4 |
Date: Mon, 14 Dec 2015 13:10:05 +0100
|
|
|
a0a3b4 |
Subject: [PATCH] network: fix carrier detection
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
rename iface_has_link() to iface_has_carrier() to clarify usage
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
Only assign static "wildcard interface" settings, if the interface has a
|
|
|
a0a3b4 |
carrier.
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
If the interface name was specified with a name, do not do carrier
|
|
|
a0a3b4 |
checking for static configurations.
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
(cherry picked from commit df95b1003c8e7564da73de92403013763eb028fe)
|
|
|
a0a3b4 |
---
|
|
|
a0a3b4 |
modules.d/40network/ifup.sh | 42 ++++++++++++++++++++-----------------
|
|
|
a0a3b4 |
modules.d/40network/net-lib.sh | 47 ++++++++++++++++++++++++++----------------
|
|
|
a0a3b4 |
2 files changed, 52 insertions(+), 37 deletions(-)
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
|
|
|
1755ca |
index 7c06cd86..30551987 100755
|
|
|
a0a3b4 |
--- a/modules.d/40network/ifup.sh
|
|
|
a0a3b4 |
+++ b/modules.d/40network/ifup.sh
|
|
|
a0a3b4 |
@@ -105,7 +105,7 @@ do_dhcp() {
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
[ -e /tmp/dhclient.$netif.pid ] && return 0
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
- if ! iface_has_link $netif; then
|
|
|
a0a3b4 |
+ if ! iface_has_carrier $netif; then
|
|
|
a0a3b4 |
warn "No carrier detected on interface $netif"
|
|
|
a0a3b4 |
return 1
|
|
|
a0a3b4 |
fi
|
|
|
a0a3b4 |
@@ -155,7 +155,10 @@ do_ipv6auto() {
|
|
|
a0a3b4 |
do_static() {
|
|
|
a0a3b4 |
strstr $ip '*:*:*' && load_ipv6
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
- if ! linkup $netif; then
|
|
|
a0a3b4 |
+ if [ -z "$dev" ] && ! iface_has_carrier "$netif"; then
|
|
|
a0a3b4 |
+ warn "No carrier detected on interface $netif"
|
|
|
a0a3b4 |
+ return 1
|
|
|
a0a3b4 |
+ elif ! linkup "$netif"; then
|
|
|
a0a3b4 |
warn "Could not bring interface $netif up!"
|
|
|
a0a3b4 |
return 1
|
|
|
a0a3b4 |
fi
|
|
|
a0a3b4 |
@@ -398,27 +401,28 @@ for p in $(getargs ip=); do
|
|
|
a0a3b4 |
done
|
|
|
a0a3b4 |
ret=$?
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
- > /tmp/net.${netif}.up
|
|
|
a0a3b4 |
+ if [ $ret -eq 0 ]; then
|
|
|
a0a3b4 |
+ > /tmp/net.${netif}.up
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
- if [ -e /sys/class/net/${netif}/address ]; then
|
|
|
a0a3b4 |
- > /tmp/net.$(cat /sys/class/net/${netif}/address).up
|
|
|
a0a3b4 |
- fi
|
|
|
a0a3b4 |
+ if [ -e /sys/class/net/${netif}/address ]; then
|
|
|
a0a3b4 |
+ > /tmp/net.$(cat /sys/class/net/${netif}/address).up
|
|
|
a0a3b4 |
+ fi
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
- case $autoconf in
|
|
|
a0a3b4 |
- dhcp|on|any|dhcp6)
|
|
|
a0a3b4 |
+ case $autoconf in
|
|
|
a0a3b4 |
+ dhcp|on|any|dhcp6)
|
|
|
a0a3b4 |
;;
|
|
|
a0a3b4 |
- *)
|
|
|
a0a3b4 |
- if [ $ret -eq 0 ]; then
|
|
|
a0a3b4 |
- setup_net $netif
|
|
|
a0a3b4 |
- source_hook initqueue/online $netif
|
|
|
a0a3b4 |
- if [ -z "$manualup" ]; then
|
|
|
a0a3b4 |
- /sbin/netroot $netif
|
|
|
a0a3b4 |
+ *)
|
|
|
a0a3b4 |
+ if [ $ret -eq 0 ]; then
|
|
|
a0a3b4 |
+ setup_net $netif
|
|
|
a0a3b4 |
+ source_hook initqueue/online $netif
|
|
|
a0a3b4 |
+ if [ -z "$manualup" ]; then
|
|
|
a0a3b4 |
+ /sbin/netroot $netif
|
|
|
a0a3b4 |
+ fi
|
|
|
a0a3b4 |
fi
|
|
|
a0a3b4 |
- fi
|
|
|
a0a3b4 |
- ;;
|
|
|
a0a3b4 |
- esac
|
|
|
a0a3b4 |
-
|
|
|
a0a3b4 |
- exit 0
|
|
|
a0a3b4 |
+ ;;
|
|
|
a0a3b4 |
+ esac
|
|
|
a0a3b4 |
+ exit $ret
|
|
|
a0a3b4 |
+ fi
|
|
|
a0a3b4 |
done
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
# netif isn't the top stack? Then we should exit here.
|
|
|
a0a3b4 |
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
|
|
|
1755ca |
index 995d32f6..07ea5709 100755
|
|
|
a0a3b4 |
--- a/modules.d/40network/net-lib.sh
|
|
|
a0a3b4 |
+++ b/modules.d/40network/net-lib.sh
|
|
|
a0a3b4 |
@@ -531,22 +531,20 @@ wait_for_if_up() {
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
while [ $cnt -lt $timeout ]; do
|
|
|
a0a3b4 |
li=$(ip -o link show up dev $1)
|
|
|
a0a3b4 |
- if ! strstr "$li" "NO-CARRIER"; then
|
|
|
a0a3b4 |
- if [ -n "$li" ]; then
|
|
|
a0a3b4 |
- case "$li" in
|
|
|
a0a3b4 |
- *\
|
|
|
a0a3b4 |
- return 0;;
|
|
|
a0a3b4 |
- *\<*,UP\>*)
|
|
|
a0a3b4 |
- return 0;;
|
|
|
a0a3b4 |
- *\<*,UP,*\>*)
|
|
|
a0a3b4 |
- return 0;;
|
|
|
a0a3b4 |
- esac
|
|
|
a0a3b4 |
- fi
|
|
|
a0a3b4 |
- if strstr "$li" "LOWER_UP" \
|
|
|
a0a3b4 |
- && strstr "$li" "state UNKNOWN" \
|
|
|
a0a3b4 |
- && ! strstr "$li" "DORMANT"; then
|
|
|
a0a3b4 |
- return 0
|
|
|
a0a3b4 |
- fi
|
|
|
a0a3b4 |
+ if [ -n "$li" ]; then
|
|
|
a0a3b4 |
+ case "$li" in
|
|
|
a0a3b4 |
+ *\
|
|
|
a0a3b4 |
+ return 0;;
|
|
|
a0a3b4 |
+ *\<*,UP\>*)
|
|
|
a0a3b4 |
+ return 0;;
|
|
|
a0a3b4 |
+ *\<*,UP,*\>*)
|
|
|
a0a3b4 |
+ return 0;;
|
|
|
a0a3b4 |
+ esac
|
|
|
a0a3b4 |
+ fi
|
|
|
a0a3b4 |
+ if strstr "$li" "LOWER_UP" \
|
|
|
a0a3b4 |
+ && strstr "$li" "state UNKNOWN" \
|
|
|
a0a3b4 |
+ && ! strstr "$li" "DORMANT"; then
|
|
|
a0a3b4 |
+ return 0
|
|
|
a0a3b4 |
fi
|
|
|
a0a3b4 |
sleep 0.1
|
|
|
a0a3b4 |
cnt=$(($cnt+1))
|
|
|
a0a3b4 |
@@ -614,7 +612,7 @@ hostname() {
|
|
|
a0a3b4 |
cat /proc/sys/kernel/hostname
|
|
|
a0a3b4 |
}
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
-iface_has_link() {
|
|
|
a0a3b4 |
+iface_has_carrier() {
|
|
|
a0a3b4 |
local cnt=0
|
|
|
a0a3b4 |
local interface="$1" flags=""
|
|
|
a0a3b4 |
[ -n "$interface" ] || return 2
|
|
|
a0a3b4 |
@@ -625,14 +623,27 @@ iface_has_link() {
|
|
|
a0a3b4 |
timeout=$(($timeout*10))
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
linkup "$1"
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
+ li=$(ip -o link show up dev $1)
|
|
|
a0a3b4 |
+ strstr "$li" "NO-CARRIER" && _no_carrier_flag=1
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
while [ $cnt -lt $timeout ]; do
|
|
|
a0a3b4 |
- [ "$(cat $interface/carrier)" = 1 ] && return 0
|
|
|
a0a3b4 |
+ if [ -n "$_no_carrier_flag" ]; then
|
|
|
a0a3b4 |
+ # NO-CARRIER flag was cleared
|
|
|
a0a3b4 |
+ strstr "$li" "NO-CARRIER" || return 0
|
|
|
a0a3b4 |
+ fi
|
|
|
a0a3b4 |
+ # double check the syscfs carrier flag
|
|
|
a0a3b4 |
+ [ -e "$interface/carrier" ] && [ "$(cat $interface/carrier)" = 1 ] && return 0
|
|
|
a0a3b4 |
sleep 0.1
|
|
|
a0a3b4 |
cnt=$(($cnt+1))
|
|
|
a0a3b4 |
done
|
|
|
a0a3b4 |
return 1
|
|
|
a0a3b4 |
}
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
+iface_has_link() {
|
|
|
a0a3b4 |
+ iface_has_carrier "$@"
|
|
|
a0a3b4 |
+}
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
find_iface_with_link() {
|
|
|
a0a3b4 |
local iface_path="" iface=""
|
|
|
a0a3b4 |
for iface_path in /sys/class/net/*; do
|