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>
This commit is contained in:
parent
737b063cc2
commit
7f91cabd0d
2 changed files with 14 additions and 18 deletions
|
@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
|
||||||
include $(INCLUDE_DIR)/version.mk
|
include $(INCLUDE_DIR)/version.mk
|
||||||
|
|
||||||
PKG_NAME:=base-files
|
PKG_NAME:=base-files
|
||||||
PKG_RELEASE:=172
|
PKG_RELEASE:=173
|
||||||
PKG_FLAGS:=nonshared
|
PKG_FLAGS:=nonshared
|
||||||
|
|
||||||
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
|
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
|
||||||
|
|
|
@ -29,18 +29,9 @@ network_get_ipaddr() {
|
||||||
# 1: destination variable
|
# 1: destination variable
|
||||||
# 2: interface
|
# 2: interface
|
||||||
network_get_ipaddr6() {
|
network_get_ipaddr6() {
|
||||||
local __addr
|
__network_ifstatus "$1" "$2" "['ipv6-address'][0].address" || \
|
||||||
|
__network_ifstatus "$1" "$2" "['ipv6-prefix-assignment'][0]['local-address'].address" || \
|
||||||
if __network_ifstatus "__addr" "$2" "['ipv6-address','ipv6-prefix-assignment'][0].address"; then
|
return 1
|
||||||
case "$__addr" in
|
|
||||||
*:) export "$1=${__addr}1" ;;
|
|
||||||
*) export "$1=${__addr}" ;;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset $1
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# determine first IPv4 subnet of given logical interface
|
# determine first IPv4 subnet of given logical interface
|
||||||
|
@ -78,14 +69,19 @@ network_get_ipaddrs6() {
|
||||||
local __addr
|
local __addr
|
||||||
local __list=""
|
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
|
for __addr in $__addr; do
|
||||||
case "$__addr" in
|
__list="${__list:+$__list }${__addr}"
|
||||||
*:) __list="${__list:+$__list }${__addr}1" ;;
|
|
||||||
*) __list="${__list:+$__list }${__addr}" ;;
|
|
||||||
esac
|
|
||||||
done
|
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"
|
export "$1=$__list"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue