summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/freifunk-policyrouting
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2012-08-13 19:03:23 +0000
committerManuel Munz <freifunk@somakoma.de>2012-08-13 19:03:23 +0000
commit4b0b9841de379c6987e914dfd10c93ced11c4398 (patch)
tree412d9b4451d37b5cc551b1a44dd8c573eb98104c /contrib/package/freifunk-policyrouting
parent489e69edfd103de532dfd291d3d30eca1db349c8 (diff)
contrib/freifunk-policyrouting: Make it work with trunk, remove unnecessary setup of network route for the local network at wan
Diffstat (limited to 'contrib/package/freifunk-policyrouting')
-rw-r--r--contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting28
1 files changed, 10 insertions, 18 deletions
diff --git a/contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting b/contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting
index dc5e69e59..d5136841b 100644
--- a/contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting
+++ b/contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting
@@ -1,6 +1,5 @@
[ "$INTERFACE" != "wan" ] && exit 0
[ -f /proc/net/ipv6_route ] && has_ipv6=1
-
case $ACTION in
ifup)
pr="`uci get freifunk-policyrouting.pr.enable`"
@@ -8,7 +7,7 @@ case $ACTION in
# check if ipv6 is enabled:
if [ $pr = "1" ]; then
- logger -t policyrouting "Starting policy routing on $INTERFACE"
+ logger -s -t policyrouting "Starting policy routing on $INTERFACE"
# Setup new tables
tables="/etc/iproute2/rt_tables"
@@ -40,23 +39,16 @@ case $ACTION in
uci commit
fi
- gw=`uci -p /var/state get network.wan.gateway`
- netmask=`uci -p /var/state get network.wan.netmask`
- if [ -z "$netmask" ]; then
- NETMASK="255.255.255.255"
- fi
-
- if [ -n "`uci -p /var/state get network.wan.ifname`" ]; then
- device=`uci -p /var/state get network.wan.ifname`
- else
- device=`uci -p /var/state get network.wan.device`
- fi
-
- eval `ipcalc.sh $gw $netmask`
+ gw="$(ip r |grep default | cut -d " " -f 3)"
+ # if no gateway was found stop now
+ [ -z "$gw" ] && logger -s -t policyrouting "No gateway found" && exit 1
+
+ device="`uci -q -p /var/state get network.wan.ifname`"
+ [ -z "$device" ] && device="`uci -q -p /var/state get network.wan.device`"
+ [ -z "$device" ] && logger -s -t policyrouting "No device found for wan." && exit 1
test -n "`ip r s t default`" && ip r d default t default
test -n "`ip r s |grep default`" && ip route del default
- ip route add $NETWORK/$NETMASK dev $device table default
ip route add default via $gw dev $device table default
if [ "$has_ipv6" = 1 ]; then
@@ -96,12 +88,12 @@ case $ACTION in
;;
ifdown)
- logger -t policyrouting "Deleting ipv4 policy rules for $INTERFACE"
+ logger -s -t policyrouting "Deleting ipv4 policy rules for $INTERFACE"
ip rule del fwmark 1 lookup olsr-default > /dev/null 2>&1
ip rule del lookup olsr-default > /dev/null 2>&1
ip rule del lookup olsr > /dev/null 2>&1
if [ "$has_ipv6" = 1 ]; then
- logger -t policyrouting "Deleting ipv4 policy rules for $INTERFACE"
+ logger -s -t policyrouting "Deleting ipv4 policy rules for $INTERFACE"
ip -6 rule del fwmark 1 lookup olsr-default > /dev/null 2>&1
ip -6 rule del lookup olsr-default > /dev/null 2>&1
ip -6 rule del lookup olsr > /dev/null 2>&1