diff options
author | Martin Schwenke <martin@meltin.net> | 2014-11-21 14:37:54 +1100 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2014-12-05 21:02:40 +0100 |
commit | ed029ae0a1faa56bf882a71d10828e2a90ab0bc7 (patch) | |
tree | c8228d64ac581ddb042c377e7b8907970fa0b6bf | |
parent | b41c1bdaa1df92ee6c510ae6749d0524b88ef828 (diff) | |
download | samba-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-x | ctdb/config/functions | 11 |
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 () |