summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-11-21 14:37:54 +1100
committerMartin Schwenke <martins@samba.org>2014-12-05 21:02:40 +0100
commited029ae0a1faa56bf882a71d10828e2a90ab0bc7 (patch)
treec8228d64ac581ddb042c377e7b8907970fa0b6bf
parentb41c1bdaa1df92ee6c510ae6749d0524b88ef828 (diff)
downloadsamba-ed029ae0a1faa56bf882a71d10828e2a90ab0bc7.tar.gz
samba-ed029ae0a1faa56bf882a71d10828e2a90ab0bc7.tar.xz
samba-ed029ae0a1faa56bf882a71d10828e2a90ab0bc7.zip
ctdb-scripts: Add IPv6 addresses support in ip_maskbits_iface()
It also prints a third word, the address family. This is either "inet" or "inet6". Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rwxr-xr-xctdb/config/functions11
1 files changed, 9 insertions, 2 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 6e986be2ba..eb98ce8a17 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -889,8 +889,15 @@ ip_maskbits_iface ()
{
_addr="$1"
- ip addr show to "${_addr}/32" 2>/dev/null | \
- awk '$1 == "inet" { print gensub(".*/", "", 1, $2), $NF }'
+ case "$_addr" in
+ *:*) _family="inet6" ; _bits=128 ;;
+ *) _family="inet" ; _bits=32 ;;
+ esac
+
+ ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
+ awk -v family="${_family}" \
+ 'NR == 1 { iface = gensub(":$", "", 1, $2) } \
+ $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }'
}
drop_ip ()