fix device duplication in firewall if the balancing of ifup and ifdown is broken
[openwrt.git] / package / firewall / files / 20-firewall
1 . /lib/firewall/uci_firewall.sh
2 unset ZONE
3 config_get ifname $INTERFACE ifname
4 INTERFACE=$ifname
5 [ "$INTERFACE" == "lo" ] && exit 0
6 load_zones() {
7 local name
8 local network
9 config_get name $1 name
10 config_get network $1 network
11 [ -z "$network" ] && network=$name
12 for n in $network; do
13 local ifname
14 config_get ifname $n ifname
15 list_contains ifname $INTERFACE && {
16 list_contains ZONE $name || ZONE="$ZONE $name"
17 }
18 done
19 }
20
21 config_foreach load_zones zone
22
23 [ -z "$ZONE" ] && exit 0
24
25 [ ifup = "$ACTION" ] && {
26 for z in $ZONE; do
27 local loaded
28 config_get loaded core loaded
29 [ -n "$loaded" ] && addif $INTERFACE $z
30 done
31 }
32
33 [ ifdown = "$ACTION" ] && {
34 for z in $ZONE; do
35 local up
36 config_get up $z up
37 [ "$up" == "1" ] && delif $INTERFACE $z
38 done
39 }
This page took 0.055175 seconds and 5 git commands to generate.