]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Support interface altnames
authorMartin Schwenke <mschwenke@ddn.com>
Thu, 9 Apr 2026 07:52:20 +0000 (17:52 +1000)
committerMartin Schwenke <martins@samba.org>
Fri, 17 Apr 2026 00:11:50 +0000 (00:11 +0000)
This avoids generating a warning like:

  WARNING: Public IP <ip> hosted on interface <iface> but VNN says <altname>

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 <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Apr 17 00:11:50 UTC 2026 on atb-devel-224

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

index 67d2420e864c36bbeb7c98c23ed87d2d564e78b5..17e5499c9c4d40d2c51044d2948f24b92acaa622 100755 (executable)
@@ -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' \
index b2b3bfdfbac959bfd82cff9c9d3a4c8ff14ab1e9..baa6c9b3d63804e31022c346a0a279adedbe310b 100755 (executable)
@@ -14,8 +14,6 @@ ctdb_get_1_public_address |
                ok_null
                simple_test_event "takeip" "$altname" "$ip" "$bits"
 
-               ok <<EOF
-WARNING: Public IP ${ip} hosted on interface ${dev} but VNN says ${altname}
-EOF
+               ok_null
                simple_test_event "releaseip" "$altname" "$ip" "$bits"
        done