[ar7] migrate acx to netdev_ops, required for later kernels
[openwrt.git] / package / firewall / files / uci_firewall.sh
index 49e5ca8..8d75382 100755 (executable)
@@ -294,8 +294,11 @@ fw_rule() {
        [ -n "$src" -a -z "$dest" ] && ZONE=zone_$src
        [ -n "$src" -a -n "$dest" ] && ZONE=zone_${src}_forward
        [ -n "$dest" ] && TARGET=zone_${dest}_$target
+
+       eval 'RULE_COUNT=$((++RULE_COUNT_'$ZONE'))'
+
        add_rule() {
-               $IPTABLES -A $ZONE \
+               $IPTABLES -I $ZONE $RULE_COUNT \
                        ${proto:+-p $proto} \
                        ${icmp_type:+--icmp-type $icmp_type} \
                        ${src_ip:+-s $src_ip} \
@@ -343,6 +346,7 @@ fw_redirect() {
 
        config_get src $1 src
        config_get src_ip $1 src_ip
+       config_get src_dip $1 src_dip
        config_get src_port $1 src_port
        config_get src_dport $1 src_dport
        config_get src_mac $1 src_mac
@@ -354,24 +358,25 @@ fw_redirect() {
 
        src_port_first=${src_port%-*}
        src_port_last=${src_port#*-}
-       [ "$src_port_first" -ne "$src_port_last" ] && { \
+       [ "$src_port_first" != "$src_port_last" ] && { \
                src_port="$src_port_first:$src_port_last"; }
 
        src_dport_first=${src_dport%-*}
        src_dport_last=${src_dport#*-}
-       [ "$src_dport_first" -ne "$src_dport_last" ] && { \
+       [ "$src_dport_first" != "$src_dport_last" ] && { \
                src_dport="$src_dport_first:$src_dport_last"; }
 
        dest_port2=${dest_port:-$src_dport}
        dest_port_first=${dest_port2%-*}
        dest_port_last=${dest_port2#*-}
-       [ "$dest_port_first" -ne "$dest_port_last" ] && { \
+       [ "$dest_port_first" != "$dest_port_last" ] && { \
                dest_port2="$dest_port_first:$dest_port_last"; }
 
        add_rule() {
                $IPTABLES -A zone_${src}_prerouting -t nat \
                        ${proto:+-p $proto} \
                        ${src_ip:+-s $src_ip} \
+                       ${src_dip:+-d $src_dip} \
                        ${src_port:+--sport $src_port} \
                        ${src_dport:+--dport $src_dport} \
                        ${src_mac:+-m mac --mac-source $src_mac} \
This page took 0.022436 seconds and 4 git commands to generate.