Changeset 31754


Ignore:
Timestamp:
2012-05-16T15:03:54+02:00 (6 years ago)
Author:
jow
Message:

[package] firewall: fix nat reflection after netifd switch (#11460)

Location:
trunk/package/firewall
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/firewall/Makefile

    r31014 r31754  
    1010 
    1111PKG_VERSION:=2 
    12 PKG_RELEASE:=49 
     12PKG_RELEASE:=50 
    1313 
    1414include $(INCLUDE_DIR)/package.mk 
  • trunk/package/firewall/files/reflection.hotplug

    r27979 r31754  
    22 
    33. /etc/functions.sh 
     4. /usr/share/libubox/jshn.sh 
     5 
     6find_iface_address() 
     7{ 
     8        local iface="$1" 
     9        local ipaddr="$2" 
     10        local prefix="$3" 
     11 
     12        local tmp="$(ubus call network.interface."$iface" status 2>/dev/null)" 
     13 
     14        json_load "${tmp:-{}}" 
     15        json_get_type tmp address 
     16 
     17        if [ "$tmp" = array ]; then 
     18 
     19                json_select address 
     20                json_get_type tmp 1 
     21 
     22                if [ "$tmp" = object ]; then 
     23 
     24                        json_select 1 
     25                        [ -n "$ipaddr" ] && json_get_var "$ipaddr" address 
     26                        [ -n "$prefix" ] && json_get_var "$prefix" mask 
     27 
     28                fi 
     29        fi 
     30} 
    431 
    532if [ "$ACTION" = "add" ] && [ "$INTERFACE" = "wan" ]; then 
    6         local wanip=$(uci -P/var/state get network.wan.ipaddr) 
     33        local wanip 
     34        find_iface_address wan wanip 
     35        [ -n "$wanip" ] || return 
    736 
    837        iptables -t nat -F nat_reflection_in 2>/dev/null || { 
     
    6190                        local net 
    6291                        for net in $(find_networks "$dest"); do 
    63                                 local lanip=$(uci -P/var/state get network.$net.ipaddr) 
    64                                 local lanmk=$(uci -P/var/state get network.$net.netmask) 
     92                                local lanip lanmk 
     93                                find_iface_address "$net" lanip lanmk 
     94                                [ -n "$lanip" ] || return 
    6595 
    6696                                local proto 
Note: See TracChangeset for help on using the changeset viewer.