diff options
author | Manuel Munz <freifunk@somakoma.de> | 2013-03-25 16:36:36 +0000 |
---|---|---|
committer | Manuel Munz <freifunk@somakoma.de> | 2013-03-25 16:36:36 +0000 |
commit | 8e9cdbea1411a68645d5e82caa7232c7f0ef2d61 (patch) | |
tree | c16e72876e36c5a079289224d563eaa3a1e082ac | |
parent | 7f3b0af6d90e260ea119cd0a81786a97501c9541 (diff) |
contrib/freifunk-policyrouting: Use a new table 'localnets' for locally attached networks and populate it
3 files changed, 22 insertions, 14 deletions
diff --git a/contrib/package/freifunk-policyrouting/Makefile b/contrib/package/freifunk-policyrouting/Makefile index 13c770aed2..cec08a2f34 100644 --- a/contrib/package/freifunk-policyrouting/Makefile +++ b/contrib/package/freifunk-policyrouting/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=freifunk-policyrouting -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) 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 c4ae38d972..5c4eb38e98 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 @@ -11,6 +11,7 @@ config_get enable pr enable config_get fallback pr fallback config_get zones pr zones + if [ "$ACTION" = "ifup" ] && [ "$enable" = "1" ]; then network_get_subnet net $INTERFACE network_get_subnet6 net6 $INTERFACE @@ -18,27 +19,26 @@ if [ "$ACTION" = "ifup" ] && [ "$enable" = "1" ]; then if [ "$net" != "" -a -n "$dev" ]; then eval $(/bin/ipcalc.sh $net) - if [ "$PREFIX" != "0" ]; then - if [ ! "$(ip r s t olsr-default |grep "throw $NETWORK/$PREFIX")" ]; then - ip r a throw $NETWORK/$PREFIX table olsr-default + if [ "$PREFIX" != "0" -a "$NETWORK" != "127.0.0.0" ]; then + if [ ! "$(ip r s t localnets |grep "$NETWORK/$PREFIX dev")" ]; then + cmd="ip r a $NETWORK/$PREFIX dev $dev table localnets" + $cmd if [ "$?" = 0 ]; then - logger -s -t policyrouting "Add route: throw $NETWORK/$PREFIX table olsr-default" + logger -s -t policyrouting "Add route: $cmd" else - logger -s -t policyrouting "Error! Could not add route: throw $NETWORK/$PREFIX table olsr-default" + logger -s -t policyrouting "Error! Could not add route: $cmd" fi fi + fi if [ -n "$net6" ]; then - if [ ! "$(ip -6 r s t olsr-default |grep "throw $net6")" ]; then - rule="throw $net6 table olsr-default dev $dev" - ip -6 r a $rule - if [ "$?" = 0 ]; then - logger -s -t policyrouting "Add route: $rule (IPv6)" - else - logger -s -t policyrouting "Error! Could not add route: $rule (IPv6)" - fi + cmd="ip -6 r a $net6 dev $dev table localnets" + $cmd 2>&1 > /dev/null + if [ "$?" = 0 ]; then + logger -s -t policyrouting "Add route: $cmd (IPv6)" fi + fi networks="" @@ -68,6 +68,7 @@ if [ "$ACTION" = "ifup" ] && [ "$enable" = "1" ]; then fi done fi + fi if [ "$ACTION" = "ifdown" ]; then diff --git a/contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting b/contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting index a8e44244b4..f31821a240 100755 --- a/contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting +++ b/contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting @@ -33,12 +33,16 @@ olsrd_intalltables() { rt_tables() { tables="/etc/iproute2/rt_tables" + if [ -z "`grep "110" $tables`" ]; then + echo "110 localnets" >> $tables + fi if [ -z "`grep "111" $tables`" ]; then echo "111 olsr" >> $tables fi if [ -z "`grep "112" $tables`" ]; then echo "112 olsr-default" >> $tables fi + } disable_dyngw() { @@ -80,6 +84,9 @@ start() { for p in $proto; do if [ ! "$(ip -$p ru s | grep "1000: from all lookup olsr")" ]; then ip -$p rule add lookup olsr prio 1000 + # add table for routes to local networks + ip -$p rule add lookup localnets prio 2000 + if [ "$?" = "0" ]; then logger -s -t policyrouting "Added rule: lookup olsr prio 1000 (IPv$p)" else |