]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Avoid failing updateip when IP is not assigned
authorMartin Schwenke <mschwenke@ddn.com>
Thu, 16 Oct 2025 02:54:22 +0000 (13:54 +1100)
committerJule Anger <janger@samba.org>
Mon, 27 Oct 2025 14:31:26 +0000 (14:31 +0000)
There is no use failing this when it could behave more like takeip.

Use old interface of "__none__" as a hint that ctdbd doesn't think the
IP is assigned either.  In this case print a warning instead of an
error.  Take some care to avoid spurious errors in updateip.

After commit 0536d7a98b832fc00d26b09c26bf14fb63dbf5fb (which improves
IP address state checking), this will almost certainly not occur on
platforms with getifaddrs(3) (e.g. Linux).  This means it is only
likely to occur in 4.21 when net.ipv4.ip_nonlocal_bind=1.

Update test to match.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15935

Reported-by: Bailey Allison <ballison@45drives.com>
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Fri Oct 17 06:28:30 UTC 2025 on atb-devel-224

(cherry picked from commit 0e73781bf84a1e8e596d8be3f55eeb5f8f927990)

Autobuild-User(v4-22-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-22-test): Mon Oct 27 14:31:26 UTC 2025 on atb-devel-224

ctdb/config/events/legacy/10.interface.script
ctdb/tests/UNIT/eventscripts/10.interface.updateip.001.sh

index 8d2d6968a1db41f654fd868014f2c8dbdbab83d7..1ab39c7e567822cd7542a21258661e7eceed0acf 100755 (executable)
@@ -78,6 +78,11 @@ get_iface_ip_maskbits()
                                "$ip" "$maskbits" "$_maskbits_in"
                fi
        else
+               if [ "$_iface_in" = "__none__" ]; then
+                       echo "WARNING: Unable to determine interface for IP ${ip}"
+                       iface="$_iface_in"
+                       return
+               fi
                die "ERROR: Unable to determine interface for IP ${ip}"
        fi
 }
@@ -214,10 +219,14 @@ updateip)
                exit 0
        fi
 
-       ip_block "$ip" "$oiface"
-
-       delete_ip_from_iface "$oiface" "$ip" "$maskbits" 2>/dev/null
-       delete_ip_from_iface "$niface" "$ip" "$maskbits" 2>/dev/null
+       # Behave more like takeip when the IP is not assigned.  No
+       # need for a similar condition around ip_unblock()s because
+       # they will silently fail.
+       if [ "$oiface" != "__none__" ]; then
+               ip_block "$ip" "$oiface"
+               delete_ip_from_iface "$oiface" "$ip" "$maskbits" >/dev/null 2>&1
+       fi
+       delete_ip_from_iface "$niface" "$ip" "$maskbits" >/dev/null 2>&1
 
        add_ip_to_iface "$niface" "$ip" "$maskbits" || {
                ip_unblock "$ip" "$oiface"
index af87bc14326ea175664b3704c72099d0768401ee..e9567a8d11421dc15c0e9bcb4725566ad222c080 100755 (executable)
@@ -10,7 +10,7 @@ public_address=$(ctdb_get_1_public_address)
 ip="${public_address% *}"
 ip="${ip#* }"
 
-required_result 1 "ERROR: Unable to determine interface for IP ${ip}"
+ok "WARNING: Unable to determine interface for IP ${ip}"
 # Want separate words from public_address: interface IP maskbits
 # shellcheck disable=SC2086
 simple_test "__none__" $public_address