[packages_10.03.2] olsrd: merge r27914, r29065, r29131, r29134, r29135, r29172
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 15:45:51 +0000 (15:45 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 15:45:51 +0000 (15:45 +0000)
SVN-Revision: 30231

net/olsrd/Makefile
net/olsrd/files/olsrd.init
net/olsrd/patches/200-txtinfo_gateways_formatting.patch [deleted file]

index 94c5f6651d800d7ba23088179cb297c009e3bb46..0dbf32ce84930f080cf6506a1c386f7445fb8e9a 100644 (file)
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2009-2011 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=olsrd
-PKG_VERSION:=0.6.1
-PKG_RELEASE:=3
+PKG_VERSION:=0.6.2
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://www.olsr.org/releases/0.6
-PKG_MD5SUM:=a75fc9b6252df5b5f49f13418fafeff1
+PKG_MD5SUM:=1f55bbbaf0737364b53daaeecc2cd50c
 
 PKG_BUILD_PARALLEL:=1
 PKG_INSTALL:=1
index dd82bb5619eca09eebdeff76d9d3e21ee0fa682b..ed6455da42241d78dc88f7dbee5ad1e8aba8da3e 100644 (file)
@@ -1,8 +1,15 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2008  Alina Friedrichsen <x-alina@gmx.net>
-# Special thanks to bittorf wireless ))
+# Copyright (C) 2008-2011 OpenWrt.org 
+
 START=65
 
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+CONF=/var/etc/olsrd.conf
+PID=/var/run/olsrd.pid
+PID6=/var/run/olsrd.ipv6.pid
+
 OLSRD_OLSRD_SCHEMA='ignore:internal config_file:internal DebugLevel=0 AllowNoInt=yes'
 OLSRD_IPCCONNECT_SCHEMA='ignore:internal Host:list Net:list2'
 OLSRD_LOADPLUGIN_SCHEMA='ignore:internal library:internal Host4:list Net4:list2 Host:list Net:list2 Host6:list Net6:list2 Ping:list redistribute:list NonOlsrIf:list name:list lat lon latlon_infile HNA:list2 hosts:list2'
@@ -40,7 +47,6 @@ get_ifname() {
        config_get ifname "$interface" ifname
        validate_ifname "$ifname" || return 1
        IFNAME="$ifname"
-
        return 0
 }
 
@@ -319,7 +325,6 @@ olsrd_write_olsrd() {
        local cfg="$1"
        validate_varname "$cfg" || return 0
        local ignore
-       local ipversion
 
        config_get_bool ignore "$cfg" ignore 0
        [ "$ignore" -ne 0 ] && return 0
@@ -331,11 +336,12 @@ olsrd_write_olsrd() {
                OLSRD_IPVERSION_6AND4=1
                config_set "$cfg" IpVersion '6'
        fi
+       config_get smartgateway "$cfg" SmartGateway
+       config_get smartgatewayuplink "$cfg" SmartGatewayUplink
 
        config_write_options "$OLSRD_OLSRD_SCHEMA" "$cfg" olsrd_write_option
        echo
        OLSRD_COUNT=$((OLSRD_COUNT + 1))
-
        return 0
 }
 
@@ -456,9 +462,15 @@ olsrd_write_loadplugin() {
                                fi
                        fi
 
-                       config_get latlon_file "$cfg" latlon_file
+                       for f in latlon_file hosts_file services_file resolv_file macs_file; do
+                               config_get $f "$cfg" $f
+                       done
+
                        [ -z "$latlon_file" ] && config_set "$cfg" latlon_file '/var/run/latlon.js'
                ;;
+               olsrd_watchdog.*)
+                       config_get wd_file "$cfg" file
+               ;;
        esac
 
        echo -n "${N}LoadPlugin \"$library\"${N}{"
@@ -485,6 +497,7 @@ olsrd_write_interface() {
                if validate_varname "$interface"; then
                        if get_ifname "$interface"; then
                                ifnames="$ifnames \"$IFNAME\""
+                               ifsglobal="$ifsglobal $IFNAME"
                        else
                                echo "Warning: Interface '$interface' not found, skipped" 1>&2
                        fi
@@ -557,6 +570,80 @@ olsrd_write_config() {
        return 0
 }
 
+olsrd_setup_smartgw_rules() {
+       # Check if ipip is installed
+       [ ! -e /etc/modules.d/[0-9]*-ipip ] && echo "Warning: kmod-ipip is missing. SmartGateway will not work until you install it."
+
+       wanifnames=$(ip r l e 0/0 t all | sed -e 's/^.* dev //' |cut -d " " -f 1 | sort | uniq)
+       nowan=0
+       if [ -z "$wanifnames" ]; then
+               nowan=1
+       fi
+
+       IP4T=$(which iptables)
+       IP6T=$(which ip6tables)
+
+       # Delete smartgw firewall rules first
+       for IPT in $IP4T $IP6T; do
+               while $IPT -D forwarding_rule -o tnl_+ -j ACCEPT 2> /dev/null; do :;done
+               for IFACE in $wanifnames; do
+                       while $IPT -D forwarding_rule -i tunl0 -o $IFACE -j ACCEPT 2> /dev/null; do :; done
+               done
+               for IFACE in $ifsglobal; do
+                       while $IPT -D input_rule -i $IFACE -p 4 -j ACCEPT 2> /dev/null; do :; done
+               done
+       done
+       while $IP4T -t nat -D postrouting_rule -o tnl_+ -j MASQUERADE 2> /dev/null; do :;done
+
+       if [ "$smartgateway" == "yes" ]; then
+               echo "Notice: Inserting firewall rules for SmartGateway"
+               if [ ! "$smartgatewayuplink" == "none" ]; then
+                       if [ "$smartgatewayuplink" == "ipv4" ]; then
+                               # Allow everything to be forwarded to tnl_+ and use NAT for it
+                               $IP4T -I forwarding_rule -o tnl_+ -j ACCEPT
+                               $IP4T -t nat -I postrouting_rule -o tnl_+ -j MASQUERADE
+                               # Allow forwarding from tunl0 to (all) wan-interfaces
+                               if [ "$nowan"="0" ]; then
+                                       for IFACE in $wanifnames; do
+                                               $IP4T -A forwarding_rule -i tunl0 -o $IFACE -j ACCEPT
+                                       done
+                               fi
+                               # Allow incoming ipip on all olsr-interfaces
+                               for IFACE in $ifsglobal; do
+                                       $IP4T -I input_rule -i $IFACE -p 4 -j ACCEPT
+                               done
+                       elif [ "$smartgatewayuplink" == "ipv6" ]; then
+                               $IP6T -I forwarding_rule -o tnl_+ -j ACCEPT
+                               if [ "$nowan"="0" ]; then
+                                       for IFACE in $wanifnames; do
+                                               $IP6T -A forwarding_rule -i tunl0 -o $IFACE -j ACCEPT
+                                       done
+                               fi
+                               for IFACE in $ifsglobal; do
+                                       $IP6T -I input_rule -i $IFACE -p 4 -j ACCEPT
+                               done
+                       else
+                               for IPT in $IP4T $IP6T; do
+                                       $IPT -I forwarding_rule -o tnl_+ -j ACCEPT
+                                       $IPT -t nat -I postrouting_rule -o tnl_+ -j MASQUERADE
+                                       if [ "$nowan"="0" ]; then
+                                               for IFACE in $wanifnames; do
+                                                       $IPT -A forwarding_rule -i tunl0 -o $IFACE -j ACCEPT
+                                               done
+                                       fi
+                                       for IFACE in $ifsglobal; do
+                                               $IPT -I input_rule -i $IFACE -p 4 -j ACCEPT
+                                       done
+                               done
+                       fi
+               fi
+       fi
+}
+
+error() {
+       echo "${initscript}:" "$@" 1>&2
+}
+
 start() {
        SYSTEM_HOSTNAME=
        SYSTEM_LAT=
@@ -593,20 +680,55 @@ start() {
        local bindv6only='0'
        if [ "$OLSRD_IPVERSION_6AND4" -ne 0 ]; then
                bindv6only="$(sysctl -n net.ipv6.bindv6only)"
-               sysctl -w net.ipv6.bindv6only=1
-               sed -e 's/^\t\t[0-9.]*[ ][0-9.]*$//' < "$OLSRD_CONFIG_FILE" > /var/etc/olsrd.conf.ipv6
-               sed -i '/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' /var/etc/olsrd.conf.ipv6
-               olsrd -f /var/etc/olsrd.conf.ipv6 -nofork < /dev/null > /dev/null &
-
+               sysctl -w net.ipv6.bindv6only=1 > /dev/null
+               sed -e '/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' < "$OLSRD_CONFIG_FILE" > /var/etc/olsrd.conf.ipv6
                sed -e 's/^IpVersion[ ][ ]*6$/IpVersion 4/' -e 's/^\t\t[A-Fa-f0-9.:]*[:][A-Fa-f0-9.:]*[ ][0-9]*$//' < "$OLSRD_CONFIG_FILE" > /var/etc/olsrd.conf.ipv4
-               olsrd -f /var/etc/olsrd.conf.ipv4 -nofork < /dev/null > /dev/null &
+               rm $OLSRD_CONFIG_FILE
+
+               # some filenames should get the suffix .ipv6
+               for file in $latlon_file $hosts_file $services_file $resolv_file $macs_file $wd_file;do
+                       f=$(echo $file|sed 's/\//\\\//g')
+                       sed -i "s/$f/$f.ipv6/g" /var/etc/olsrd.conf.ipv6
+               done
+
+               SERVICE_PID_FILE="$PID6"
+               if service_check /usr/sbin/olsrd; then
+                       error "there already is an IPv6 instance of olsrd running ($(cat $PID6)), not starting."
+               else
+                       service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv6 -nofork
+               fi
+
+               SERVICE_PID_FILE="$PID"
+               if service_check /usr/sbin/olsrd; then
+                       error "there already is an IPv4 instance of olsrd running ($(cat $PID)), not starting."
+               else
+                       service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv4 -nofork
+               fi
+
                sleep 3
-               sysctl -w net.ipv6.bindv6only="$bindv6only"
+               sysctl -w net.ipv6.bindv6only="$bindv6only" > /dev/null
+
        else
-               olsrd -f "$OLSRD_CONFIG_FILE" -nofork < /dev/null > /dev/null &
+
+               if [ "$ipversion" = "6" ]; then
+                       sed -i '/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' "$OLSRD_CONFIG_FILE"
+               fi
+
+               SERVICE_PID_FILE="$PID"
+               if service_check /usr/sbin/olsrd; then
+                       error "there already is an IPv4 instance of olsrd running ($(cat $PID)), not starting."
+                       return 1
+               else
+                       service_start /usr/sbin/olsrd -f "$OLSRD_CONFIG_FILE" -nofork
+               fi
        fi
+       olsrd_setup_smartgw_rules
 }
 
 stop() {
-       killall olsrd
+       SERVICE_PID_FILE="$PID"
+       service_stop /usr/sbin/olsrd
+
+       SERVICE_PID_FILE="$PID6"
+       service_stop /usr/sbin/olsrd
 }
diff --git a/net/olsrd/patches/200-txtinfo_gateways_formatting.patch b/net/olsrd/patches/200-txtinfo_gateways_formatting.patch
deleted file mode 100644 (file)
index caf4253..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/lib/txtinfo/src/olsrd_txtinfo.c
-+++ b/lib/txtinfo/src/olsrd_txtinfo.c
-@@ -562,7 +562,7 @@ ipc_print_gateway(struct autobuf *abuf)
-   struct lqtextbuffer lqbuf;
-   // Status IP ETX Hopcount Uplink-Speed Downlink-Speed ipv4/ipv4-nat/- ipv6/- ipv6-prefix/-
--  abuf_puts(abuf, "Table: Gateways\n   Gateway\tETX\tHopcnt\tUplink\tDownlnk\tIPv4\tIPv6\tPrefix\n");
-+  abuf_puts(abuf, "Table: Gateways\nGateway\tETX\tHopcnt\tUplink\tDownlnk\tIPv4\tIPv6\tPrefix\n");
-   OLSR_FOR_ALL_GATEWAY_ENTRIES(gw) {
-     char v4 = '-', v6 = '-';
-     bool autoV4 = false, autoV6 = false;
-@@ -595,7 +595,7 @@ ipc_print_gateway(struct autobuf *abuf)
-       v6type = IPV6;
-     }
--    abuf_appendf(abuf, "%c%c %s\t%s\t%d\t%u\t%u\t%s\t%s\t%s\n",
-+    abuf_appendf(abuf, "%c%c\t%s\t%s\t%d\t%u\t%u\t%s\t%s\t%s\n",
-         v4, v6, olsr_ip_to_string(&buf, &gw->originator),
-         get_linkcost_text(tc->path_cost, true, &lqbuf), tc->hops,
-         gw->uplink, gw->downlink, v4type, v6type,