summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/freifunk-policyrouting/files
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2012-07-01 00:01:38 +0000
committerManuel Munz <freifunk@somakoma.de>2012-07-01 00:01:38 +0000
commit9b1f4dfee38395e99009be5f1276153d2d052506 (patch)
treeb05974be6ed560dbe3f6bd08fc1e40e7e1b8fb89 /contrib/package/freifunk-policyrouting/files
parent76106a11b9a9bc58dee9e729954572e7f870a166 (diff)
contrib/freifunk-policyrouting: Fix deletion of rules; add fallback option to use the mesh gateway if the own gateway is not available
Diffstat (limited to 'contrib/package/freifunk-policyrouting/files')
-rw-r--r--contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting1
-rw-r--r--contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting39
2 files changed, 26 insertions, 14 deletions
diff --git a/contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting b/contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting
index ba58625bc..3dd2998f9 100644
--- a/contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting
+++ b/contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting
@@ -2,5 +2,6 @@
config 'settings' 'pr'
option 'enable' '0'
option 'strict' '1'
+ option 'fallback' '1'
option 'zones' ''
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 acce98113..dc5e69e59 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,10 +1,11 @@
[ "$INTERFACE" != "wan" ] && exit 0
+[ -f /proc/net/ipv6_route ] && has_ipv6=1
case $ACTION in
ifup)
- pr=`uci get freifunk-policyrouting.pr.enable`
+ pr="`uci get freifunk-policyrouting.pr.enable`"
+ fallback="`uci get freifunk-policyrouting.pr.fallback`"
# check if ipv6 is enabled:
- [ -f /proc/net/ipv6_route ] && has_ipv6=1
if [ $pr = "1" ]; then
logger -t policyrouting "Starting policy routing on $INTERFACE"
@@ -58,24 +59,30 @@ case $ACTION in
ip route add $NETWORK/$NETMASK dev $device table default
ip route add default via $gw dev $device table default
- #if [ "$has_ipv6" = 1 ]; then
- # local ip6gw=$(ip -6 r |grep default |cut -d " " -f 3)
- # test -n "`ip -6 r s t default`" && ip -6 r d default t default
- # test -n "`ip -6 r s |grep default`" && ip -6 route del default
- # ip -6 r a $ip6gw via $ip6gw dev $dev table default
- # ip -6 route add default via $ip6gw dev $device table default
- #fi
-
+ if [ "$has_ipv6" = 1 ]; then
+ local ip6gw=$(ip -6 r |grep default |cut -d " " -f 3)
+ test -n "`ip -6 r s t default`" && ip -6 r d default t default
+ if [ -n "`ip -6 r s |grep default`" ]; then
+ ip -6 route del default
+ ip -6 r a $ip6gw via $ip6gw dev $dev table default
+ ip -6 route add default via $ip6gw dev $device table default
+ fi
+ fi
ip rule del lookup main
ip rule add fwmark 1 lookup olsr-default
ip rule add lookup main
ip rule add lookup olsr
+ # Fallback via mesh if no ipv4 gateway is found in default table
+ [ "$fallback" = 1 ] && ip rule add lookup olsr-default prio 32800
+
if [ "$has_ipv6" = 1 ]; then
ip -6 rule del lookup main
- ip -6 rule add fwmark 1 lookup olsr-default prio 16385
- ip -6 rule add lookup main prio 16383
ip -6 rule add lookup olsr prio 16380
+ ip -6 rule add lookup main prio 16390
+ ip -6 rule add fwmark 1 lookup olsr-default prio 16400
+ ip -6 rule add lookup default prio 16410
+ [ "$fallback" = 1 ] && ip -6 rule add lookup olsr-default prio 16420
fi
else
# Remove custom routing tables from olsrd
@@ -89,12 +96,16 @@ case $ACTION in
;;
ifdown)
- logger -t policyrouting "Deleting policy rules for $INTERFACE"
+ logger -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"
ip -6 rule del fwmark 1 lookup olsr-default > /dev/null 2>&1
- ip -6 rule del lookup olsr > /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
+ ip -6 rule del lookup default > /dev/null 2>&1
fi
;;
esac