git.samba.org
/
kai
/
samba-autobuild
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b41c1bd
)
ctdb-scripts: Add IPv6 addresses support in ip_maskbits_iface()
author
Martin Schwenke
<martin@meltin.net>
Fri, 21 Nov 2014 03:37:54 +0000
(14:37 +1100)
committer
Martin Schwenke
<martins@samba.org>
Fri, 5 Dec 2014 20:02:40 +0000
(21:02 +0100)
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>
ctdb/config/functions
patch
|
blob
|
history
diff --git
a/ctdb/config/functions
b/ctdb/config/functions
index 6e986be2baa4caf29c4488f6860c844cf736d3f4..eb98ce8a170483a77c4809a362e521d424d6e3bf 100755
(executable)
--- 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 ()