summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-30 14:28:47 +0100
committerSimon Rettberg2024-01-30 14:28:47 +0100
commit3d34f0fcd3f9369b6a080dc976dd8252c00e84cd (patch)
treec76216f0748b47c4ad047b1464bd9a0ead2de0b6
parent[slx-dmsetup] Only resize rootfs if no such service exists in stage 4 (diff)
downloadsystemd-init-3d34f0fcd3f9369b6a080dc976dd8252c00e84cd.tar.gz
systemd-init-3d34f0fcd3f9369b6a080dc976dd8252c00e84cd.tar.xz
systemd-init-3d34f0fcd3f9369b6a080dc976dd8252c00e84cd.zip
[slx-network] Retry bringing iface up in wait-loop
-rwxr-xr-xmodules.d/slx-network/hooks/s3-parse-network-kcl.sh1
-rwxr-xr-xmodules.d/slx-network/hooks/s3-setup-bootif-network.sh38
2 files changed, 22 insertions, 17 deletions
diff --git a/modules.d/slx-network/hooks/s3-parse-network-kcl.sh b/modules.d/slx-network/hooks/s3-parse-network-kcl.sh
index daf2e9b7..123d2d03 100755
--- a/modules.d/slx-network/hooks/s3-parse-network-kcl.sh
+++ b/modules.d/slx-network/hooks/s3-parse-network-kcl.sh
@@ -117,3 +117,4 @@ save_network_config &
[ -n "$hostname" ] && echo "$hostname" > /proc/sys/kernel/hostname
wait
+exit 0
diff --git a/modules.d/slx-network/hooks/s3-setup-bootif-network.sh b/modules.d/slx-network/hooks/s3-setup-bootif-network.sh
index 1ae58464..6b75170d 100755
--- a/modules.d/slx-network/hooks/s3-setup-bootif-network.sh
+++ b/modules.d/slx-network/hooks/s3-setup-bootif-network.sh
@@ -13,12 +13,12 @@ type emergency_shell >/dev/null 2>&1 || . /lib/dracut-lib.sh
# do not run until the physical interface exists (driver loaded)
_fails=0
while ! [ -e "/sys/class/net/${SLX_PXE_NETIF}/device" ]; do
- if (( ++_fails > 20 )); then
+ if (( ++_fails > 30 )); then
emergency_shell "Boot interface '${SLX_PXE_NETIF}' did not appear"
exit 1
fi
- (( (_fails % 5) == 0 )) && udevadm trigger
- usleep 500000
+ (( (_fails % 7) == 0 )) && udevadm trigger --subsystem-match=net
+ usleep 333333
done
# wrapper around splashtool to disable it if its not present
@@ -33,7 +33,7 @@ fi
wait_for_iface() {
local _iface="$1"
- local _timeout="${2:-50}"
+ local _timeout="$(( ${2:-50} * 3 ))"
local _fails=0
local _state
if [ "$_iface" = "$SLX_PXE_NETIF" ]; then
@@ -42,6 +42,7 @@ wait_for_iface() {
img="??-bridge"
fi
while (( _timeout-- > 0 )); do
+ ip link set dev "$_iface" up
_state="$(cat "/sys/class/net/${_iface}/operstate" 2> /dev/null)"
[ "$_state" = "up" ] && break
if (( ++_fails > 5 )) && [[ "$_state" = "unknown" || "$_state" = "" ]]; then
@@ -49,8 +50,8 @@ wait_for_iface() {
break
fi
fi
- # every 500ms
- usleep 500000
+ # every 333ms
+ usleep 333333
in=
(( (_timeout % 2) == 0 )) && in=in
_splashtool --icon "/opt/openslx/icons/${in}active/${img}.ppm" &
@@ -68,8 +69,7 @@ wait_for_iface() {
{
set -x
-ip link set dev "$SLX_PXE_NETIF" up
-if ! wait_for_iface "$SLX_PXE_NETIF" 60; then
+if ! wait_for_iface "$SLX_PXE_NETIF" 30; then
warn "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway."
# TODO handle case where we waited for 30sec and it is still not up
fi
@@ -92,14 +92,14 @@ fi
if [ -n "$SLX_BRIDGE" ]; then
for try in {1..10} ""; do
if (
- set -e
- brctl addbr "$SLX_BRIDGE"
- brctl stp "$SLX_BRIDGE" 0
- brctl setfd "$SLX_BRIDGE" 0.000000000001
- ip link set addr "$SLX_PXE_MAC" "$SLX_BRIDGE"
- brctl addif "$SLX_BRIDGE" "$MAIN_NETIF"
- ip link set dev "$SLX_BRIDGE" up
- wait_for_iface "$SLX_BRIDGE"
+ set -e
+ brctl addbr "$SLX_BRIDGE"
+ brctl stp "$SLX_BRIDGE" 0
+ brctl setfd "$SLX_BRIDGE" 0.000000000001
+ ip link set addr "$SLX_PXE_MAC" "$SLX_BRIDGE"
+ brctl addif "$SLX_BRIDGE" "$MAIN_NETIF"
+ ip link set dev "$SLX_BRIDGE" up
+ wait_for_iface "$SLX_BRIDGE"
); then
MAIN_NETIF="$SLX_BRIDGE"
break
@@ -112,7 +112,11 @@ if [ -n "$SLX_BRIDGE" ]; then
fi
warn "Failed to setup main network bridge on try $try. Retrying ..."
# delete bridge, inc try and sleep 100ms before trying again
- [ -e "/sys/class/net/${SLX_BRIDGE}" ] && brctl delbr "$SLX_BRIDGE"
+ if [ -e "/sys/class/net/${SLX_BRIDGE}" ]; then
+ ip link set dev "$SLX_BRIDGE" down
+ brctl delif "$SLX_BRIDGE" "$MAIN_NETIF"
+ brctl delbr "$SLX_BRIDGE"
+ fi
usleep 100000
done
fi