ctdb-scripts: Wait until IPv6 addresses are not "tentative"
authorMartin Schwenke <martin@meltin.net>
Fri, 21 Nov 2014 06:33:21 +0000 (17:33 +1100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 10 Dec 2014 19:56:09 +0000 (20:56 +0100)
There are a few potential failure modes when adding an IPv6 address.
It takes a little while of duplicate address detection to complete, so
wait for a while.  After a timeout, also need to check to see if
duplicate address detection failed - if it did then actually drop the
IP address.

This really needs some careful thinking.  If CTDB disappears on a node
but the node's IP addresses are still on interfaces then the above
failure mode could cause the takeover nodes to become banned.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit d0b2375c3d754da3cd68e34617ab3edd36e9317b)

ctdb/config/functions

index e50e98a248da66f31894ad485d4086c3f8424ec1..1583bfc707527aa5758a653090d1a494609f6e53 100755 (executable)
@@ -844,6 +844,29 @@ add_ip_to_iface ()
        echo "Failed to add $_ip/$_maskbits on dev $_iface"
        return 1
     }
+
+    # Wait 5 seconds for IPv6 addresses to stop being tentative...
+    if [ -z "$_bcast" ] ; then
+       for _x in $(seq 1 10) ; do
+           ip addr show to "${_ip}/128" | grep -q "tentative" || break
+           sleep 0.5
+       done
+
+       # If the address was a duplicate then it won't be on the
+       # interface so flag an error.
+       _t=$(ip addr show to "${_ip}/128")
+       case "$_t" in
+           "")
+               echo "Failed to add $_ip/$_maskbits on dev $_iface"
+               return 1
+               ;;
+           *tentative*|*dadfailed*)
+               echo "Failed to add $_ip/$_maskbits on dev $_iface"
+               ip addr del "$_ip/$_maskbits" dev "$_iface"
+               return 1
+               ;;
+       esac
+    fi
 }
 
 delete_ip_from_iface()