Fix DAD and gateway detection in ifupdown/ifupdown-extra, improve logs

The scripts in ifupdown-0.8.36 and ifupdown-extra-0.32, as they are
distributed, don't work correctly for detecting duplicate IP addresses
and gateway reachability in the interfaces. Because of this, error
messages are thrown in daemon.log even if error conditions don't exist.
This commit fixes the detection logic and also improves the log logic,
so that messages carry useful and accurate information.

Test plan

Systems: AIO-SX IPv4, AIO-SX IPv6

Scenarios without error/warning conditions
------------------------------------------

For these scenarios, OAM is over a regular ethernet interface, gateway
is reachable and there are no duplicate IP addresses. Log messages
must reflect this.

[PASS] mgmt and cluster-host over same eth port, pxe unassigned
[PASS] mgmt and cluster-host over same bond port, pxe unassigned
[PASS] mgmt and cluster-host over same vlan port, pxe unassigned
[PASS] mgmt and cluster-host over same vlan port, pxe assigned to
       base eth
[PASS] mgmt and cluster-host over different vlan ports, pxe assigned
       to base bond

Scenarios with error/warning conditions
---------------------------------------

For these scenarios, error/warning messages must appear and reflect
the real conditions.

[PASS] Cable disconnected in ethernet interface
[PASS] Cable disconnected in bonding interface
[PASS] Duplicate address in ethernet interface
[PASS] Duplicate address in vlan interface
[PASS] Duplicate address in bonding interface
[PASS] Missing gateway in ethernet interface
[PASS] Missing gateway in vlan interface
[PASS] Missing gateway in bonding interface

Closes-Bug: #2052534
Change-Id: Ie9152eff51f21bdcb8693f554eb696d63e2bab34
Signed-off-by: Lucas Ratusznei Fonseca <lucas.ratuszneifonseca@windriver.com>
This commit is contained in:
Lucas Ratusznei Fonseca 2024-02-06 13:42:30 -03:00
parent 92e7b2fce3
commit 1ac33ded8a
10 changed files with 519 additions and 33 deletions

View File

@ -145,7 +145,8 @@ haproxy-config
#helm #helm
helm helm
#ifupdown-extra #ifupdown
ifupdown
ifupdown-extra ifupdown-extra
kdump-tools kdump-tools

View File

@ -82,6 +82,7 @@ kubernetes/runc
ldap/ldapscripts ldap/ldapscripts
ldap/openldap ldap/openldap
networking/dpdk networking/dpdk
networking/ifupdown
networking/ifupdown-extra networking/ifupdown-extra
networking/iputils networking/iputils
networking/lldpd networking/lldpd

View File

@ -1,29 +0,0 @@
From 3623134b09353d8d43575cb2ab8ed240a268202f Mon Sep 17 00:00:00 2001
From: Charles Short <charles.short@windriver.com>
Date: Tue, 2 Aug 2022 08:25:36 -0400
Subject: [PATCH] Install 00check-network-cable in the correct spot
Update debian/rules to install the 00check-network-cable in the
correct spot.
Signed-off-by: Charles Short <charles.short@windriver.com>
---
debian/rules | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/debian/rules b/debian/rules
index 32ae425..6dee5a7 100755
--- a/debian/rules
+++ b/debian/rules
@@ -18,7 +18,7 @@ override_dh_install:
install -m644 debian/network-routes $(CURDIR)/debian/ifupdown-extra/etc/network/routes
install -m644 debian/network-test-default $(CURDIR)/debian/ifupdown-extra/etc/default/network-test
# Network scripts for ifupdown
- install -m755 if-up-scripts/check-network-cable $(CURDIR)/debian/ifupdown-extra/etc/network/if-up.d/00check-network-cable
+ install -m755 if-up-scripts/check-network-cable $(CURDIR)/debian/ifupdown-extra/etc/network/if-pre-up.d/00check-network-cable
install -m755 if-up-scripts/check-duplicate-ip $(CURDIR)/debian/ifupdown-extra/etc/network/if-up.d/10check-duplicate-ip
install -m755 if-up-scripts/check-duplicate-ip6 $(CURDIR)/debian/ifupdown-extra/etc/network/if-up.d/10check-duplicate-ip6
install -m755 if-up-scripts/static-routes $(CURDIR)/debian/ifupdown-extra/etc/network/if-up.d/20static-routes
--
2.25.1

View File

@ -0,0 +1,435 @@
From 301be9cc3629927620206132dc00dba8b83045eb Mon Sep 17 00:00:00 2001
From: Lucas Ratusznei Fonseca <lucas.ratuszneifonseca@windriver.com>
Date: Mon, 5 Feb 2024 01:15:33 -0300
Subject: [PATCH] Fix DAD and gateway detection, improve logs
---
if-up-scripts/check-duplicate-ip | 51 ++++++++++++----------
if-up-scripts/check-duplicate-ip6 | 34 ++++++++++-----
if-up-scripts/check-gateway | 72 +++++++++++++++++++++++--------
if-up-scripts/check-network-cable | 54 +++++++++++++----------
4 files changed, 138 insertions(+), 73 deletions(-)
diff --git a/if-up-scripts/check-duplicate-ip b/if-up-scripts/check-duplicate-ip
index 347639d..a975a90 100755
--- a/if-up-scripts/check-duplicate-ip
+++ b/if-up-scripts/check-duplicate-ip
@@ -56,11 +56,22 @@ VERBOSITY=${VERBOSITY:-0}
LC_ALL=C
export LC_ALL
-if [ "$DO_SYSLOG" = "yes" ] ; then
- OUTPUT="logger -i -p daemon.err -s"
-else
- OUTPUT="echo"
-fi
+do_output() {
+ local REDIR_ECHO=""
+ if [[ " err warning " =~ " $1 " ]] ; then
+ REDIR_ECHO="1>&2"
+ fi
+
+ if [ "$DO_SYSLOG" = "yes" ] ; then
+ logger -i -p daemon.$1 ifupdown: "${@:2}"
+ else
+ eval echo 'ifupdown: "${@:2}"' $REDIR_ECHO
+ fi
+}
+
+OUT_ERR="do_output err"
+OUT_WARN="do_output warning"
+OUT_DEBUG="do_output debug"
do_arping() {
# Send ARP pings to detect if there is a duplicate address "out there"
@@ -74,18 +85,18 @@ do_arping() {
# First determine physical interface in case aliased interfaces are used
real_iface=$(echo "$IFACE" | sed -e 's|:[[:digit:]]\+||')
-
- if [ -z "`ip link show $real_iface up 2>/dev/null`" ]; then
+ if [ ! -f /sys/class/net/${real_iface}/operstate ] || [[ $(< /sys/class/net/${real_iface}/operstate) != "up" ]] ; then
+ [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Interface $real_iface (for $IFACE) is not in UP state, skipping duplicate IPv4 address check"
return
fi
for ADDR in $IF_ADDRESS; do
# Skip interface is address is IPv6, arping only works for IPv4
if ! echo ${ADDR} | grep -q ":" ; then
- [ "$VERBOSITY" -eq 1 ] && $OUTPUT "DEBUG: Sending arp pings through $real_iface (for $IFACE) to detect other systems using $ADDR"
- $ARPING -c $ARP_COUNT -w $ARP_TIMEOUT -D -I $real_iface $ADDR $ARPING_EXTRAOPTS >$ARPING_REDIR
+ [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Sending arp pings through $real_iface (for $IFACE) to detect other systems using $ADDR"
+ $ARPING -c $ARP_COUNT -w $ARP_TIMEOUT -D -I $real_iface $ADDR $ARPING_EXTRAOPTS >/dev/null
if [ $? -ne 0 ] ; then
- $OUTPUT "ERROR: Duplicate address $ADDR assigned in the network where $real_iface is connected to."
+ $OUT_ERR "Duplicate address $ADDR assigned in the network where $real_iface is connected to."
fi
fi
done
@@ -99,7 +110,7 @@ find_ip() {
}
if [ -z "$IFACE" ] ; then
- echo "ERROR: Do not know what interface to check. IFACE environment variable is not defined!" >&2
+ $OUT_ERR "Do not know what interface to check. IFACE environment variable is not defined!"
exit 0
fi
@@ -111,6 +122,12 @@ case $IFACE in
*) ;;
esac
+[ -z "$IF_ADDRESS" ] && find_ip
+# Still no IP? Bail out
+if [ -z "$IF_ADDRESS" ] ; then
+ $OUT_WARN "Cannot check for duplicate IPv4 address in the network as the script could not find the IPv4 address of $IFACE. You can disable this test by setting DO_ARPING to 'no' in $DEFAULT ."
+ exit 0
+fi
# For arping:
# Two possible arpings: iputils-arping or arping, with different
@@ -120,30 +137,20 @@ if [ -x /usr/bin/arping ] ; then
ARPING=/usr/bin/arping
ARP_TIMEOUT=${ARP_TIMEOUT:-3} # Time here is measured in seconds
ARPING_EXTRAOPTS="-q" # Use -q(uiet) in iputil's arping
- ARPING_REDIR="/dev/stdout" # Do not redirect output
else
if [ -x /usr/sbin/arping ] ; then
ARPING=/usr/sbin/arping
ARP_TIMEOUT=${ARP_TIMEOUT:-1500} # Time here is measures in milliseconds
# experiments show anything less than 1500 is unreliable.
ARPING_EXTRAOPTS="" # No '-q' option in arping
- ARPING_REDIR="/dev/null" # Send output to /dev/null if using this program
else
# Do not continue if ARPING is not available
- echo "WARNING: Cannot check for duplicate IP address in the network. The script cannot find the 'arping' program (tried /usr/bin/arping and /usr/sbin/arping. Please either install the iputils-arping or arping packages or disable this test by setting DO_ARPING to 'no' in $DEFAULT ." >&2
+ $OUT_WARN "Cannot check for duplicate IP address in the network. The script cannot find the 'arping' program (tried /usr/bin/arping and /usr/sbin/arping. Please either install the iputils-arping or arping packages or disable this test by setting DO_ARPING to 'no' in $DEFAULT ."
exit 0
fi
fi
ARP_COUNT=${ARP_COUNT:-2}
-
-
-[ -z "$IF_ADDRESS" ] && find_ip
-# Still no IP? Bail out
-if [ -z "$IF_ADDRESS" ] ; then
- echo "WARNING: Cannot check for duplicate IP address in the network as the script could not find the ip address of $IFACE. You can disable this test by setting DO_ARPING to 'no' in $DEFAULT ." >&2
- exit 0
-fi
do_arping
exit 0
diff --git a/if-up-scripts/check-duplicate-ip6 b/if-up-scripts/check-duplicate-ip6
index b9ff87a..fd4b453 100755
--- a/if-up-scripts/check-duplicate-ip6
+++ b/if-up-scripts/check-duplicate-ip6
@@ -54,11 +54,22 @@ VERBOSITY=${VERBOSITY:-0}
LC_ALL=C
export LC_ALL
-if [ "$DO_SYSLOG" = "yes" ] ; then
- OUTPUT="logger -i -p daemon.err -s"
-else
- OUTPUT="echo"
-fi
+do_output() {
+ local REDIR_ECHO=""
+ if [[ " err warning " =~ " $1 " ]] ; then
+ REDIR_ECHO="1>&2"
+ fi
+
+ if [ "$DO_SYSLOG" = "yes" ] ; then
+ logger -i -p daemon.$1 ifupdown: "${@:2}"
+ else
+ eval echo 'ifupdown: "${@:2}"' $REDIR_ECHO
+ fi
+}
+
+OUT_ERR="do_output err"
+OUT_WARN="do_output warning"
+OUT_DEBUG="do_output debug"
do_ndisc() {
# Use the Network Discovery Protocol to detect if there is a duplicate address
@@ -70,23 +81,24 @@ do_ndisc() {
# First determine physical interface in case aliased interfaces are used
real_iface=$(echo "$IFACE" | sed -e 's|:[[:digit:]]\+||')
- link_address=$(ip link show wlan0 | grep link | awk '{print toupper($2)}')
-
- if [ -z "`ip link show $real_iface up`" ]; then
+ if [ ! -f /sys/class/net/${real_iface}/operstate ] || [[ $(< /sys/class/net/${real_iface}/operstate) != "up" ]] ; then
+ [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Interface $real_iface (for $IFACE) is not in UP state, skipping duplicate IPv6 address check"
return
fi
+ link_address=$(ip link show "$real_iface" | grep link | awk '{print toupper($2)}')
+
for ADDR in $IF_ADDRESS; do
# Only check IP address if it is IPv6
if echo ${ADDR} | grep -q ":" ; then
- [ "$VERBOSITY" -eq 1 ] && $OUTPUT "DEBUG: Sending arp pings through $real_iface (for $IFACE) to detect other systems using $ADDR"
+ [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Sending arp pings through $real_iface (for $IFACE) to detect other systems using $ADDR"
dup_link_address=$($NDISC -q $ADDR $real_iface)
if [ $? -eq 0 ] ; then
# If the link address is the same as our address this is not a problem
# (ndisc returns it in at least Wireless interfaces), only report if the link
# address does not match
if [ "$link_address" != "$dup_link_address" ] ; then
- $OUTPUT "ERROR: Duplicate address $ADDR assigned in the network where $real_iface is connected to."
+ $OUT_ERR "Duplicate address $ADDR assigned in the network where $real_iface is connected to."
fi
fi
fi
@@ -101,7 +113,7 @@ find_ip6() {
}
if [ -z "$IFACE" ] ; then
- echo "ERROR: Do not know what interface to check. IFACE environment variable is not defined!" >&2
+ $OUT_ERR "Do not know what interface to check. IFACE environment variable is not defined!"
exit 1
fi
diff --git a/if-up-scripts/check-gateway b/if-up-scripts/check-gateway
index 97c93b1..d2c45c1 100755
--- a/if-up-scripts/check-gateway
+++ b/if-up-scripts/check-gateway
@@ -42,13 +42,18 @@
# Defaults
ARPING=/usr/bin/arping
+NDISC=/usr/bin/ndisc6
ARP_COUNT=${ARP_COUNT:-2}
ARP_TIMEOUT=${ARP_TIMEOUT:-3}
DO_SYSLOG=${DO_SYSLOG:-yes}
VERBOSITY=${VERBOSITY:-0}
-# Do not continue if ARPING is not available
-[ ! -x "$ARPING" ] && exit 0
+[ -x "$ARPING" ]
+HAS_ARPING=$?
+
+[ -x "$NDISC" ]
+HAS_NDISC=$?
+
# or if the user has told us to not do arpings
[ "$DO_ARPING" = "no" ] && exit 0
@@ -58,17 +63,28 @@ VERBOSITY=${VERBOSITY:-0}
# Ignore "--all"
[ "$IFACE" = "--all" ] && exit 0
-if [ "$DO_SYSLOG" = "yes" ] ; then
- OUTPUT="logger -i -p daemon.err -s"
-else
- OUTPUT="echo"
-fi
+do_output() {
+ local REDIR_ECHO=""
+ if [[ " err warning " =~ " $1 " ]] ; then
+ REDIR_ECHO="1>&2"
+ fi
+
+ if [ "$DO_SYSLOG" = "yes" ] ; then
+ logger -i -p daemon.$1 ifupdown: "${@:2}"
+ else
+ eval echo 'ifupdown: "${@:2}"' $REDIR_ECHO
+ fi
+}
+
+OUT_ERR="do_output err"
+OUT_WARN="do_output warning"
+OUT_DEBUG="do_output debug"
# Try to obtain the IP address of our gateway (DHCP case)
if [ -z "$IF_GATEWAY" ] ; then
IF_GATEWAY=$(ip route list | grep "^default " | grep "dev $IFACE" | awk '{print $3}')
# Warn if there are multiple gateways
- echo $IF_GATEWAY | grep -q " " && [ "$VERBOSITY" -eq 1 ] && $OUTPUT "Found multiple gateways as default routes for $IFACE"
+ echo $IF_GATEWAY | grep -q " " && [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Found multiple gateways as default routes for $IFACE"
fi
# Still no IP? Bail out
[ -z "$IF_GATEWAY" ] && exit 0
@@ -92,12 +108,7 @@ do_arping() {
local ARPING_OPTIONS="-q -c $ARP_COUNT -w $ARP_TIMEOUT -f -I $IFACE"
local GATEWAY_FOUND=1
- # Check if the interface is up
- if [ -z "`ip link show $real_iface up 2>/dev/null`" ]; then
- return 0
- fi
-
- [ "$VERBOSITY" -eq 1 ] && $OUTPUT "DEBUG: Sending arp pings through $IFACE to detect if the gateway $GATEWAY is present"
+ [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Sending arp pings through $IFACE to detect if the gateway $GATEWAY is present"
if [ "`id -u`" = 0 ] ; then
if $ARPING $ARPING_OPTIONS $GATEWAY ; then
GATEWAY_FOUND=0
@@ -112,10 +123,23 @@ do_arping() {
fi
if [ "$GATEWAY_FOUND" = 1 ] ; then
- $OUTPUT "ERROR: Cannot find default gateway $GATEWAY in the network where $IFACE is connected to"
+ $OUT_ERR "Cannot find default gateway $GATEWAY in the network where $IFACE is connected to"
fi
}
+do_ndisc() {
+
+ local GATEWAY=$1
+
+ [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Sending ICMP6 pings through $IFACE to detect if the gateway $GATEWAY is present"
+
+ $NDISC -q $GATEWAY $real_iface >/dev/null 2>&1
+ if [ $? -ne 0 ] ; then
+ $OUT_ERR "Cannot find default gateway $GATEWAY in the network where $IFACE is connected to"
+ fi
+
+}
+
# Check our IFACE name, if it is a serial line or loopback skip it as ARP ping is not possible there
case "$IFACE" in
@@ -123,8 +147,22 @@ case "$IFACE" in
*) ;;
esac
-for gateway in $IF_GATEWAY ; do
- do_arping $gateway
+real_iface=$(echo "$IFACE" | sed -e 's|:[[:digit:]]\+||')
+if [ ! -f /sys/class/net/${real_iface}/operstate ] || [[ $(< /sys/class/net/${real_iface}/operstate) != "up" ]] ; then
+ [ "$VERBOSITY" -eq 1 ] && $OUT_DEBUG "Interface $real_iface (for $IFACE) is not in UP state, skipping gateway detection"
+ exit 0
+fi
+
+for gateway in $IF_GATEWAY ; do
+ if [[ "$gateway" =~ ":" ]] ; then
+ if [ $HAS_NDISC -eq 0 ] ; then
+ do_ndisc $gateway
+ fi
+ else
+ if [ $HAS_ARPING -eq 0 ] ; then
+ do_arping $gateway
+ fi
+ fi
done
exit 0
diff --git a/if-up-scripts/check-network-cable b/if-up-scripts/check-network-cable
index f8e9044..be3d5b3 100755
--- a/if-up-scripts/check-network-cable
+++ b/if-up-scripts/check-network-cable
@@ -58,11 +58,22 @@ if [ "$DO_CABLETEST" = "no" ]; then
exit 0
fi
-if [ "$DO_SYSLOG" = yes ]; then
- OUTPUT="logger -i -p daemon.err -s"
-else
- OUTPUT=echo
-fi
+do_output() {
+ local REDIR_ECHO=""
+ if [[ " err warning " =~ " $1 " ]] ; then
+ REDIR_ECHO="1>&2"
+ fi
+
+ if [ "$DO_SYSLOG" = "yes" ] ; then
+ logger -i -p daemon.$1 ifupdown: "${@:2}"
+ else
+ eval echo 'ifupdown: "${@:2}"' $REDIR_ECHO
+ fi
+}
+
+OUT_ERR="do_output err"
+OUT_WARN="do_output warning"
+OUT_DEBUG="do_output debug"
# Set our locale environment, just in case any of the tools get translated
LC_ALL=C
@@ -91,16 +102,8 @@ check_status_ethtool() {
return $status
}
-check_status_iplink() {
- local status=0
- local info=""
-
- [ -x "$IPTOOL" ] || return 0
- info=$($IPTOOL link show "$IFACE" up 2>&1)
- if [ -z "$info" ] ; then
- status=1
- fi
- return $status
+check_status_sysfs() {
+ [ -f /sys/class/net/${IFACE}/operstate ] && [[ $(< /sys/class/net/${IFACE}/operstate) != "down" ]]
}
# Status check function for all types of interfaces
@@ -108,14 +111,14 @@ check_status () {
local status=0 myid=$(id -u)
$IPTOOL link show "$IFACE" >/dev/null 2>&1 || {
- $OUTPUT "ERROR: Interface $IFACE does not seem to be present" \
+ $OUT_ERR "Interface $IFACE does not seem to be present" \
"in the system"
return 0
}
- check_status_iplink || status=$?
+ check_status_sysfs || status=$?
[ $status -eq 0 ] ||
- $OUTPUT "WARNING: Initialising interface $IFACE which does" \
+ $OUT_WARN "Initialising interface $IFACE which does" \
"not have a link"
return $status
}
@@ -126,7 +129,7 @@ check_ethernet_status() {
local status=0 myid=$(id -u)
$IPTOOL link show "$IFACE" >/dev/null 2>&1 || {
- $OUTPUT "ERROR: Interface $IFACE does not seem to be present" \
+ $OUT_ERR "Interface $IFACE does not seem to be present" \
"in the system"
return 0
}
@@ -138,10 +141,10 @@ check_ethernet_status() {
elif [ -x "$MIITOOL" ] && [ $myid -eq 0 ]; then
check_status_miitool || status=$?
else
- check_status_iplink || status=$?
+ check_status_sysfs || status=$?
fi
[ $status -eq 0 ] ||
- $OUTPUT "WARNING: Initialising interface $IFACE which does" \
+ $OUT_WARN "Initialising interface $IFACE which does" \
"not have a link"
return $status
}
@@ -162,16 +165,21 @@ check_bond_status() {
[ $status -ne 0 ] || return 0
done
done <$slaves
- $OUTPUT "WARNING: Initialising bond $IFACE which does not have link" \
+ $OUT_WARN "Initialising bond $IFACE which does not have link" \
"on any slave"
return $status
}
[ "$IFACE" ] || {
- $OUTPUT "ERROR: Variable IFACE not set in environment"
+ $OUT_ERR "Variable IFACE not set in environment"
exit 1
}
+# If it is a labeled interface, skip
+if [[ "$IFACE" =~ ":" ]] ; then
+ exit 0
+fi
+
# Check our IFACE name, run the status check depending on the type of interface
case $IFACE in
en* | eth*)
--
2.34.1

View File

@ -1,4 +1,4 @@
0001-Accept-netmask-or-prefix-length-on-etc-network-route.patch 0001-Accept-netmask-or-prefix-length-on-etc-network-route.patch
0002-Install-00check-network-cable-in-the-correct-spot.patch 0002-ignore-IFACE-all-for-ifupdown-scripts.patch
0003-ignore-IFACE-all-for-ifupdown-scripts.patch 0003-Handle-default-route-creation.patch
0004-Handle-default-route-creation.patch 0004-Fix-DAD-and-gateway-detection-improve-logs.patch

View File

@ -0,0 +1,70 @@
From 382eb354d6b6ceee52fb2dd6d8845b9a313a3f78 Mon Sep 17 00:00:00 2001
From: Lucas Ratusznei Fonseca <lucas.ratuszneifonseca@windriver.com>
Date: Thu, 8 Feb 2024 14:52:17 -0300
Subject: [PATCH] Fix detection logic
---
settle-dad.sh | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/settle-dad.sh b/settle-dad.sh
index 37cb516..4cdbc8e 100644
--- a/settle-dad.sh
+++ b/settle-dad.sh
@@ -6,26 +6,38 @@ delay=${IF_DAD_INTERVAL:-0.1}
[ $attempts -eq 0 ] && exit 0
-echo -n "Waiting for DAD... "
+echo -n "Attempting DAD test for ${IF_ADDRESS}/${IF_NETMASK} on ${IFACE}... "
+
+real_iface=${IFACE%:*}
+no_link=0
+
for attempt in $(seq 1 $attempts); do
- tentative=$(ip -o -6 address list dev "$IFACE" to "${IF_ADDRESS}/${IF_NETMASK}" tentative | wc -l)
- if [ $tentative -eq 0 ]; then
- attempt=0 # This might have been our last attempt, but successful
- break
+ if [ ! -f /sys/class/net/${real_iface}/operstate ] || [[ $(< /sys/class/net/${real_iface}/operstate) == "down" ]] ; then
+ no_link=0
+ else
+ no_link=1
+ tentative=$(ip -o -6 address list dev "$IFACE" to "${IF_ADDRESS}/${IF_NETMASK}" tentative)
+ if [ -z "$tentative" ]; then
+ attempt=0 # This might have been our last attempt, but successful
+ break
+ fi
+ if [[ "$tentative" =~ "dadfailed tentative" ]] ; then
+ echo "Failed"
+ exit 1
+ fi
fi
- sleep $delay
+
+ sleep $delay
done
if [ $attempt -eq $attempts ]; then
- echo "Timed out"
- exit 1
-fi
-
-dadfailed=$(ip -o -6 address list dev "$IFACE" to "${IF_ADDRESS}/${IF_NETMASK}" dadfailed | wc -l)
-
-if [ $dadfailed -ge 1 ]; then
- echo "Failed"
- exit 1
+ if [ $no_link -eq 0 ]; then
+ echo "No link"
+ exit 0
+ else
+ echo "Timed out"
+ exit 1
+ fi
fi
echo Done
--
2.34.1

View File

@ -0,0 +1 @@
0001-Fix-detection-logic.patch

View File

@ -0,0 +1,7 @@
---
debver: 0.8.36
debname: ifupdown
archive: https://snapshot.debian.org/archive/debian/20220519T084715Z/pool/main/i/ifupdown/
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true