summaryrefslogtreecommitdiff
path: root/package/firewall/files/lib/core_interface.sh
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-06-02 00:59:35 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-06-02 00:59:35 +0000
commit3b07b2b809e18cd405a7c0576f505bcc4b0455ee (patch)
tree79179e2c391a92d471cf204ca4603260883ccf7b /package/firewall/files/lib/core_interface.sh
parent796dcb6b2ea7bc246b6e31024ab2f0f8c14338ca (diff)
[package] firewall:
- support alias ifnames different from parent ifname - properly handle multiple subnets per alias (v4+v6) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21656 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/firewall/files/lib/core_interface.sh')
-rw-r--r--package/firewall/files/lib/core_interface.sh33
1 files changed, 23 insertions, 10 deletions
diff --git a/package/firewall/files/lib/core_interface.sh b/package/firewall/files/lib/core_interface.sh
index 56ff1a118d..e6630a5ca5 100644
--- a/package/firewall/files/lib/core_interface.sh
+++ b/package/firewall/files/lib/core_interface.sh
@@ -11,7 +11,11 @@ fw_configure_interface() {
[ "$status" == 1 ] || [ -n "$aliasnet" ] || return 0
}
- [ -n "$ifname" ] || ifname=$(uci_get_state network "$iface" ifname "$iface")
+ [ -n "$ifname" ] || {
+ ifname=$(uci_get_state network "$iface" ifname "$iface")
+ ifname="${ifname%%:*}"
+ }
+
[ "$ifname" == "lo" ] && return 0
fw_callback pre interface
@@ -64,18 +68,21 @@ fw_configure_interface() {
fw $action $mode r PREROUTING ${chain}_notrack ^ $inet { -i "$ifname" }
}
- local old_zones old_ifname old_subnet
+ local old_zones old_ifname old_subnets
config_get old_zones core "${iface}_zone"
[ -n "$old_zones" ] && {
config_get old_ifname core "${iface}_ifname"
- config_get old_subnet core "${iface}_subnet"
+ config_get old_subnets core "${iface}_subnets"
local z
for z in $old_zones; do
- fw_log info "removing $iface ($old_ifname${old_subnet:+ alias $old_subnet}) from zone $z"
- fw__do_rules del $z $old_ifname $old_subnet
+ local n
+ for n in ${old_subnets:-""}; do
+ fw_log info "removing $iface ($old_ifname${n:+ alias $n}) from zone $z"
+ fw__do_rules del $z $old_ifname $n
+ done
- [ -n "$old_subnet" ] || ACTION=remove ZONE="$z" INTERFACE="$iface" DEVICE="$ifname" /sbin/hotplug-call firewall
+ [ -n "$old_subnets" ] || ACTION=remove ZONE="$z" INTERFACE="$iface" DEVICE="$ifname" /sbin/hotplug-call firewall
done
local old_aliases
@@ -88,7 +95,7 @@ fw_configure_interface() {
uci_revert_state firewall core "${iface}_zone"
uci_revert_state firewall core "${iface}_ifname"
- uci_revert_state firewall core "${iface}_subnet"
+ uci_revert_state firewall core "${iface}_subnets"
uci_revert_state firewall core "${iface}_aliases"
}
@@ -118,19 +125,25 @@ fw_configure_interface() {
config_get netmask "$a" netmask
config_get ip6addr "$a" ip6addr
- [ -n "$ipaddr" ] && fw_configure_interface "$a" add "$ifname" "$ipaddr${netmask:+/$netmask}"
- [ -n "$ip6addr" ] && fw_configure_interface "$a" add "$ifname" "$ip6addr"
+ [ -n "$ipaddr" ] && fw_configure_interface "$a" add "" "$ipaddr${netmask:+/$netmask}"
+ [ -n "$ip6addr" ] && fw_configure_interface "$a" add "" "$ip6addr"
done
fw_sysctl_interface $ifname
fw_callback post interface
uci_set_state firewall core "${iface}_aliases" "$aliases"
+ } || {
+ local subnets=
+ config_get subnets core "${iface}_subnets"
+ append subnets "$aliasnet"
+
+ config_set core "${iface}_subnets" "$subnets"
+ uci_set_state firewall core "${iface}_subnets" "$subnets"
}
uci_set_state firewall core "${iface}_zone" "$new_zones"
uci_set_state firewall core "${iface}_ifname" "$ifname"
- uci_set_state firewall core "${iface}_subnet" "$aliasnet"
}
fw_sysctl_interface() {