Skip to content

Commit 0e73781

Browse files
mschwenke-ddnanoopcs9
authored andcommitted
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 0536d7a (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 <[email protected]> Signed-off-by: Martin Schwenke <[email protected]> Reviewed-by: Anoop C S <[email protected]> Autobuild-User(master): Anoop C S <[email protected]> Autobuild-Date(master): Fri Oct 17 06:28:30 UTC 2025 on atb-devel-224
1 parent 01d3d25 commit 0e73781

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

ctdb/config/events/legacy/10.interface.script

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ get_iface_ip_maskbits()
7878
"$ip" "$maskbits" "$_maskbits_in"
7979
fi
8080
else
81+
if [ "$_iface_in" = "__none__" ]; then
82+
echo "WARNING: Unable to determine interface for IP ${ip}"
83+
iface="$_iface_in"
84+
return
85+
fi
8186
die "ERROR: Unable to determine interface for IP ${ip}"
8287
fi
8388
}
@@ -214,10 +219,14 @@ updateip)
214219
exit 0
215220
fi
216221

217-
ip_block "$ip" "$oiface"
218-
219-
delete_ip_from_iface "$oiface" "$ip" "$maskbits" 2>/dev/null
220-
delete_ip_from_iface "$niface" "$ip" "$maskbits" 2>/dev/null
222+
# Behave more like takeip when the IP is not assigned. No
223+
# need for a similar condition around ip_unblock()s because
224+
# they will silently fail.
225+
if [ "$oiface" != "__none__" ]; then
226+
ip_block "$ip" "$oiface"
227+
delete_ip_from_iface "$oiface" "$ip" "$maskbits" >/dev/null 2>&1
228+
fi
229+
delete_ip_from_iface "$niface" "$ip" "$maskbits" >/dev/null 2>&1
221230

222231
add_ip_to_iface "$niface" "$ip" "$maskbits" || {
223232
ip_unblock "$ip" "$oiface"

ctdb/tests/UNIT/eventscripts/10.interface.updateip.001.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public_address=$(ctdb_get_1_public_address)
1010
ip="${public_address% *}"
1111
ip="${ip#* }"
1212

13-
required_result 1 "ERROR: Unable to determine interface for IP ${ip}"
13+
ok "WARNING: Unable to determine interface for IP ${ip}"
1414
# Want separate words from public_address: interface IP maskbits
1515
# shellcheck disable=SC2086
1616
simple_test "__none__" $public_address

0 commit comments

Comments
 (0)