diff options
author | Jo-Philipp Wich <jo@mein.io> | 2017-06-08 12:02:36 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2017-06-08 12:06:01 +0200 |
commit | 7f91cabd0d5b6e1a716d9e3fab4103730d9d2888 (patch) | |
tree | 7b5bfdef6f626fd8ecaf2ec5eb4b917812bc176d /package/base-files/files | |
parent | 737b063cc2e562485e624cda0fb42fb47f1b90c7 (diff) | |
download | mtk-20170518-7f91cabd0d5b6e1a716d9e3fab4103730d9d2888.zip mtk-20170518-7f91cabd0d5b6e1a716d9e3fab4103730d9d2888.tar.gz mtk-20170518-7f91cabd0d5b6e1a716d9e3fab4103730d9d2888.tar.bz2 |
base-files: network.sh: properly report local IPv6 addresses
Rework the network_get_ipaddr6() and network_get_ipaddrs6() functions to
fetch the effective local IPv6 address of delegated prefix from the
"local-address" field instead of naively hardcoding ":1" as static suffix.
Fixes FS#829.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'package/base-files/files')
-rw-r--r-- | package/base-files/files/lib/functions/network.sh | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 1b0c717..4b61fe3 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -29,18 +29,9 @@ network_get_ipaddr() { # 1: destination variable # 2: interface network_get_ipaddr6() { - local __addr - - if __network_ifstatus "__addr" "$2" "['ipv6-address','ipv6-prefix-assignment'][0].address"; then - case "$__addr" in - *:) export "$1=${__addr}1" ;; - *) export "$1=${__addr}" ;; - esac - return 0 - fi - - unset $1 - return 1 + __network_ifstatus "$1" "$2" "['ipv6-address'][0].address" || \ + __network_ifstatus "$1" "$2" "['ipv6-prefix-assignment'][0]['local-address'].address" || \ + return 1 } # determine first IPv4 subnet of given logical interface @@ -78,14 +69,19 @@ network_get_ipaddrs6() { local __addr local __list="" - if __network_ifstatus "__addr" "$2" "['ipv6-address','ipv6-prefix-assignment'][*].address"; then + if __network_ifstatus "__addr" "$2" "['ipv6-address'][*].address"; then for __addr in $__addr; do - case "$__addr" in - *:) __list="${__list:+$__list }${__addr}1" ;; - *) __list="${__list:+$__list }${__addr}" ;; - esac + __list="${__list:+$__list }${__addr}" + done + fi + + if __network_ifstatus "__addr" "$2" "['ipv6-prefix-assignment'][*]['local-address'].address"; then + for __addr in $__addr; do + __list="${__list:+$__list }${__addr}" done + fi + if [ -n "$__list" ]; then export "$1=$__list" return 0 fi |