From: Martin Schwenke Date: Thu, 16 Oct 2025 02:54:22 +0000 (+1100) Subject: ctdb-scripts: Avoid failing updateip when IP is not assigned X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fv4-21-test;p=thirdparty%2Fsamba.git ctdb-scripts: Avoid failing updateip when IP is not assigned 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 Signed-off-by: Martin Schwenke Reviewed-by: Anoop C S Autobuild-User(master): Anoop C S Autobuild-Date(master): Fri Oct 17 06:28:30 UTC 2025 on atb-devel-224 (cherry picked from commit 0e73781bf84a1e8e596d8be3f55eeb5f8f927990) Autobuild-User(v4-21-test): Jule Anger Autobuild-Date(v4-21-test): Wed Oct 22 11:16:15 UTC 2025 on atb-devel-224 --- diff --git a/ctdb/config/events/legacy/10.interface.script b/ctdb/config/events/legacy/10.interface.script index 137d558b3b7..f0545a40455 100755 --- a/ctdb/config/events/legacy/10.interface.script +++ b/ctdb/config/events/legacy/10.interface.script @@ -80,6 +80,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 } @@ -216,10 +221,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" diff --git a/ctdb/tests/UNIT/eventscripts/10.interface.updateip.001.sh b/ctdb/tests/UNIT/eventscripts/10.interface.updateip.001.sh index af87bc14326..e9567a8d114 100755 --- a/ctdb/tests/UNIT/eventscripts/10.interface.updateip.001.sh +++ b/ctdb/tests/UNIT/eventscripts/10.interface.updateip.001.sh @@ -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