contrib/freifunk-policyrouting: Use a new table 'localnets' for locally attached...
authorManuel Munz <freifunk@somakoma.de>
Mon, 25 Mar 2013 16:36:36 +0000 (16:36 +0000)
committerManuel Munz <freifunk@somakoma.de>
Mon, 25 Mar 2013 16:36:36 +0000 (16:36 +0000)
contrib/package/freifunk-policyrouting/Makefile
contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting
contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting

index 13c770aed2f163bb423239c3aac769a38d76522f..cec08a2f341d54baa7e3430faad3e3ad499002b7 100644 (file)
@@ -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)
 
index c4ae38d9723a7f89f5907b95054ab5e32c2abe69..5c4eb38e980a5ea5e0a0414e3f7c3b72ec753f4e 100644 (file)
@@ -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
index a8e44244b4c0420eff2785e37b5e5500c1656b9c..f31821a240ba63340adac15edef3bdd735599752 100755 (executable)
@@ -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