diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-05-16 13:37:49 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-05-16 13:37:49 +0000 |
commit | 9d66c5c3428054ae0f1f20ab2fd4754df01ef765 (patch) | |
tree | 9888c9b2f0625db9e9df4eef4de6e5270b2ccd5f /package/firewall/files | |
parent | 8eb607235eb4d2bd6083a62477639933e66962fa (diff) | |
download | upstream-9d66c5c3428054ae0f1f20ab2fd4754df01ef765.tar.gz upstream-9d66c5c3428054ae0f1f20ab2fd4754df01ef765.tar.bz2 upstream-9d66c5c3428054ae0f1f20ab2fd4754df01ef765.zip |
[package] firewall: rework interface address determination to skip ipv6 addresses
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31755 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/firewall/files')
-rw-r--r-- | package/firewall/files/reflection.hotplug | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/package/firewall/files/reflection.hotplug b/package/firewall/files/reflection.hotplug index 73d9c61df8..62f5097291 100644 --- a/package/firewall/files/reflection.hotplug +++ b/package/firewall/files/reflection.hotplug @@ -9,24 +9,34 @@ find_iface_address() local ipaddr="$2" local prefix="$3" + local idx=1 local tmp="$(ubus call network.interface."$iface" status 2>/dev/null)" json_load "${tmp:-{}}" json_get_type tmp address if [ "$tmp" = array ]; then - json_select address - json_get_type tmp 1 - - if [ "$tmp" = object ]; then - json_select 1 - [ -n "$ipaddr" ] && json_get_var "$ipaddr" address - [ -n "$prefix" ] && json_get_var "$prefix" mask - - fi + while true; do + json_get_type tmp $idx + [ "$tmp" = object ] || break + + json_select $((idx++)) + json_get_var tmp address + + case "$tmp" in + *:*) json_select .. ;; + *) + [ -n "$ipaddr" ] && json_get_var $ipaddr address + [ -n "$prefix" ] && json_get_var $prefix mask + return 0 + ;; + esac + done fi + + return 1 } if [ "$ACTION" = "add" ] && [ "$INTERFACE" = "wan" ]; then |