From: Martin Schwenke Date: Thu, 9 Apr 2026 07:52:20 +0000 (+1000) Subject: ctdb-scripts: Support interface altnames X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b605cc7c88089fc5e2f5cce08543e7dbae148a24;p=thirdparty%2Fsamba.git ctdb-scripts: Support interface altnames This avoids generating a warning like: WARNING: Public IP hosted on interface but VNN says every time a public IP is removed from an interface that is configured via an altname. The new check will nearly always be successful because the IP will be on the expected interface during releaseip/updateip. The original check is now used as a backup when the IP is not on the expected interface. To allow the mask bits check to cover both cases, the original check and the associated interface check needs to be inside the else clause. Update the unit test to reflect the change. Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke Reviewed-by: John Mulligan Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Fri Apr 17 00:11:50 UTC 2026 on atb-devel-224 --- diff --git a/ctdb/config/events/legacy/10.interface.script b/ctdb/config/events/legacy/10.interface.script index 67d2420e864..17e5499c9c4 100755 --- a/ctdb/config/events/legacy/10.interface.script +++ b/ctdb/config/events/legacy/10.interface.script @@ -62,22 +62,40 @@ get_ip_prefix_iface() ip="$2" _maskbits_in="$3" + # This produces output when $ip is on $_iface_in. This works + # for interface altnames. + # # Intentional word splitting here # shellcheck disable=SC2046 - set -- $(ip_prefix_iface "$ip") - if [ -z "$1" ]; then - echo "WARNING: Unable to determine interface for IP ${ip}" - iface="" - return - fi + set -- $(ip -brief addr show to "$ip" dev "$_iface_in" 2>/dev/null) + if [ -n "$3" ]; then + # $ip was on $_iface_in. Ignore looked up interface + # name ($1) and use $_iface_in instead, since it might + # be an altname.. + iface="$_iface_in" + prefix="$3" + else + # $ip was not on $_iface_in. Try again, without + # specifying interface. + + # Intentional word splitting here + # shellcheck disable=SC2046 + set -- $(ip_prefix_iface "$ip") + if [ -z "$1" ]; then + echo "WARNING: Unable to determine interface for IP ${ip}" + iface="" + return + fi - prefix="$1" - iface="$2" + prefix="$1" + iface="$2" - if [ "$iface" != "$_iface_in" ]; then - printf 'WARNING: Public IP %s hosted on interface %s but VNN says %s\n' \ - "$ip" "$iface" "$_iface_in" + if [ "$iface" != "$_iface_in" ]; then + printf 'WARNING: Public IP %s hosted on interface %s but VNN says %s\n' \ + "$ip" "$iface" "$_iface_in" + fi fi + _maskbits="${prefix#*/}" if [ "$_maskbits" != "$_maskbits_in" ]; then printf 'WARNING: Public IP %s has %s bit netmask but VNN says %s\n' \ diff --git a/ctdb/tests/UNIT/eventscripts/10.interface.002.sh b/ctdb/tests/UNIT/eventscripts/10.interface.002.sh index b2b3bfdfbac..baa6c9b3d63 100755 --- a/ctdb/tests/UNIT/eventscripts/10.interface.002.sh +++ b/ctdb/tests/UNIT/eventscripts/10.interface.002.sh @@ -14,8 +14,6 @@ ctdb_get_1_public_address | ok_null simple_test_event "takeip" "$altname" "$ip" "$bits" - ok <