ctdb-tests: Be more careful when building public IP addresses
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Sep 2018 05:26:08 +0000 (15:26 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 8 Oct 2018 00:46:23 +0000 (02:46 +0200)
The goal is to allow more local daemons by expanding the address range
rather than generating invalid addresses.

For IPv6, use a separate address space instead of an offset for the
2nd address.

For IPv4, use the last 2 octets with addresses starting at
192.168.100.1 and 192.168.200.1.  Avoid addresses with 0 and 255 in
the last octet by using a maximum of 100 addresses per "subnet"
starting at .1.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/scripts/local_daemons.bash

index 5b58dda05fc6300f726313f086d1b25021d4e748..116fa40f424872c1360ffd0f5e4500bf583354f5 100644 (file)
@@ -67,20 +67,22 @@ setup_public_addresses ()
        local pnn_no_ips="$1"
 
        local i
-       for i in $(seq 1 $TEST_LOCAL_DAEMONS) ; do
-               if  [ $((i - 1)) -eq $pnn_no_ips ] ; then
+       for i in $(seq 0 $((TEST_LOCAL_DAEMONS - 1)) ) ; do
+               if  [ $i -eq $pnn_no_ips ] ; then
                        continue
                fi
 
                # 2 public addresses on most nodes, just to make
                # things interesting
-               local j=$((i + TEST_LOCAL_DAEMONS))
                if [ -n "$CTDB_USE_IPV6" ]; then
-                       printf "fc00:10::1:%x/64 lo\n" "$i"
-                       printf "fc00:10::1:%x/64 lo\n" "$j"
+                       printf "fc00:10::1:%x/64 lo\n" $((1 + i))
+                       printf "fc00:10::2:%x/64 lo\n" $((1 + i))
                else
-                       printf "192.168.234.${i}/24 lo\n"
-                       printf "192.168.234.${j}/24 lo\n"
+                       local c1=$(( 100 + (i / 100) ))
+                       local c2=$(( 200 + (i / 100) ))
+                       local d=$(( 1 + (i % 100) ))
+                       printf "192.168.${c1}.${d}/24 lo\n"
+                       printf "192.168.${c2}.${d}/24 lo\n"
                fi
        done
 }