openconnect: make host dependency more resilient
authorNikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Sat, 10 Feb 2024 13:30:12 +0000 (14:30 +0100)
committerNikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Mon, 19 Feb 2024 12:27:06 +0000 (13:27 +0100)
Retry when resolveip fails as it seems to be causing issues
on startup depending on various unpredictable parameters.

Resolves: #23185

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
net/openconnect/Makefile
net/openconnect/files/openconnect.sh

index f3bb6b67337de3e98384dfdda989ce07fb7a920d..ff046a16f90080549bf3e460f323acfa10d692a0 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=openconnect
 PKG_VERSION:=9.12
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://www.infradead.org/openconnect/download
index d318b97e0d455cb8f5a0c7247e56b832380e17a4..707c770e7449000f022fe6eb65712dc492166c8f 100755 (executable)
@@ -46,6 +46,7 @@ proto_openconnect_add_form_entry() {
 
 proto_openconnect_setup() {
        local config="$1"
+       local tmpfile="/tmp/openconnect-server.$$.tmp"
 
        json_get_vars \
                authgroup \
@@ -76,11 +77,21 @@ proto_openconnect_setup() {
        logger -t openconnect "initializing..."
 
        [ -n "$interface" ] && {
+               local trials=5
+
                logger -t "openconnect" "adding host dependency for $server at $config"
-               for ip in $(resolveip -t 10 "$server"); do
-                       logger -t "openconnect" "adding host dependency for $ip at $config"
-                       proto_add_host_dependency "$config" "$ip" "$interface"
+               while resolveip -t 10 "$server" > "$tmpfile" && [ "$trials" -gt 0 ]; do
+                       sleep 5
+                       trials=$((trials - 1))
                done
+
+               if [ -s "$tmpfile" ]; then
+                       for ip in $(cat "$tmpfile"); do
+                               logger -t "openconnect" "adding host dependency for $ip at $config"
+                               proto_add_host_dependency "$config" "$ip" "$interface"
+                       done
+               fi
+               rm -f "$tmpfile"
        }
 
        [ -n "$port" ] && port=":$port"