contrib/freifunk-policyrouting: Fix deletion of rules; add fallback option to use the mesh gateway if the own gateway is not available

This commit is contained in:
Manuel Munz 2012-07-01 00:01:38 +00:00
parent 76106a11b9
commit 9b1f4dfee3
26 changed files with 227 additions and 21 deletions

View file

@ -28,6 +28,10 @@ local strict = c:option(Flag, "strict", translate("Strict Filtering"), translate
"select this option."))
strict.rmempty = false
local fallback = c:option(Flag, "fallback", translate("Fallback to mesh"),
translate("If your own gateway is not available then fallback to the mesh default gateway."))
strict.rmempty = false
local zones = c:option(MultiValue, "zones", translate("Firewall zones"), translate("All traffic from interfaces belonging to these zones will be sent via "..
"a gateway in the mesh network."))
uci:foreach("firewall", "zone", function(section)

View file

@ -2,5 +2,6 @@
config 'settings' 'pr'
option 'enable' '0'
option 'strict' '1'
option 'fallback' '1'
option 'zones' ''

View file

@ -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-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

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -3,6 +3,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -15,6 +16,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr "Zóny firewallu"
@ -25,6 +29,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -5,10 +5,10 @@ msgstr ""
"PO-Revision-Date: \n"
"Last-Translator: Manuel Munz <freifunk@somakoma.de>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: \n"
msgid ""
"All traffic from interfaces belonging to these zones will be sent via a "
@ -20,6 +20,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr "Policy Routing aktivieren"
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr "Firewallzonen"
@ -34,6 +37,11 @@ msgstr ""
"Routers geleitet. Wenn das nicht gewünscht ist und dieser Traffic dann "
"stattdessen geblockt werden soll, dann aktiviere diese Option."
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr "Policy Routing"

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -3,6 +3,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -16,6 +17,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -26,6 +30,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -3,6 +3,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -16,6 +17,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -26,6 +30,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,10 +6,10 @@ msgstr ""
"PO-Revision-Date: 2011-10-18 22:26+0200\n"
"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Pootle 2.0.4\n"
@ -23,6 +23,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr "Habilitar a Política de Roteamento"
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr "Zonas do firewall"
@ -37,6 +40,11 @@ msgstr ""
"como solução de contorno. Se você não quer isto e, ao contrário, deseja "
"bloquear este tráfego, então você deve selecionar esta opção."
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr "Política de Roteamento"

View file

@ -3,6 +3,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -17,6 +18,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -27,6 +31,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,12 +6,12 @@ msgstr ""
"PO-Revision-Date: 2011-07-25 12:52+0200\n"
"Last-Translator: Kamal <kamal.aliev@epscom.ru>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ru\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Pootle 2.0.4\n"
msgid ""
@ -24,6 +24,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr "Разрешить политику маршрутизации"
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr "Зоны межсетевого экрана"
@ -38,6 +41,11 @@ msgstr ""
"ячеистой сети. Если Вас это не устраивает, то выберите эту опцию и данный "
"траффик будет заблокирован."
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr "Политика маршрутизации"

View file

@ -9,6 +9,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -19,6 +22,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -3,6 +3,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -16,6 +17,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -26,6 +30,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -3,11 +3,12 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
msgid ""
"All traffic from interfaces belonging to these zones will be sent via a "
@ -17,6 +18,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -27,6 +31,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""

View file

@ -6,6 +6,9 @@ msgstr ""
msgid "Enable Policy Routing"
msgstr ""
msgid "Fallback to mesh"
msgstr ""
msgid "Firewall zones"
msgstr ""
@ -16,6 +19,11 @@ msgid ""
"traffic then you should select this option."
msgstr ""
msgid ""
"If your own gateway is not available then fallback to the mesh default "
"gateway."
msgstr ""
msgid "Policy Routing"
msgstr ""