Merge branch 'master' into bmx6_testing

This commit is contained in:
Axel Neumann 2014-02-25 16:03:15 +01:00
commit aaab7c2671
29 changed files with 916 additions and 22 deletions

View file

@ -20,4 +20,5 @@ Nicolás Echániz <nicoechaniz@altermundi.net>
Pau Escrich <pau@dabax.net>
Saverio Proto <zioproto@gmail.com>
Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
Steven Barth <cyrus@openwrt.org>
Vasilis "acinonyx" Tsiligiannis <acinonyx@openwrt.gr>

63
babels/Makefile Normal file
View file

@ -0,0 +1,63 @@
#
# Copyright (C) 2007-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=babels
PKG_SOURCE_VERSION:=757af8018a6e51ba64994d4834d41d4da8377e09
PKG_VERSION:=2013-12-18-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git://git.wifi.pps.univ-paris-diderot.fr/babels
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/babels
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=A loop-free distance-vector routing protocol (source-specific)
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
MAINTAINER:=Steven Barth <cyrus@openwrt.org>
DEPENDS:=+kmod-ipv6
endef
define Package/babels/description
Babel is a loop-avoiding distance-vector routing protocol roughly based
on DSDV and AODV, but with provisions for link cost estimation and
redistribution of routes from other routing protocols.
While it is optimised for wireless mesh networks, Babel will also work
efficiently on wired networks. It will generate between 1.2 and 2.4 times
the amount of routing traffic that RIPng would generate, while
never counting to infinity.
This is experimental source routing branch, and should be only used if you
know what you are doing.
endef
define Package/babels/conffiles
/etc/babeld.conf
/etc/config/babeld
endef
MAKE_FLAGS+= \
CFLAGS="$(TARGET_CFLAGS) -DIPV6_SUBTREES" \
LDLIBS="" \
define Package/babels/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/babeld $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc
$(INSTALL_CONF) ./files/babeld.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/babeld.config $(1)/etc/config/babeld
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/babeld.init $(1)/etc/init.d/babeld
endef
$(eval $(call BuildPackage,babels))

38
babels/files/babeld.conf Normal file
View file

@ -0,0 +1,38 @@
# babel config file
#
# This config file simply documents sample entries.
# "redistribute" means: redistribute routes from other routing protocols
# into babel. "local" means addresses assigned to local interfaces.
#
# You do not need to edit this file: you can use /etc/config/babeld
# instead (sections "interface" and "filter"). Both files can be used
# simultaneously (the rules of this file are executed first).
# the default rules are:
#
## redistribute local
## redistribute deny
#
# this says, redistribute local addresses but no other routes
# redistribute IPv4 default route into babel
## redistribute local ip 0.0.0.0/0 le 0 metric 128
# same but for IPv6
## redistribute local ip ::/0 le 0 metric 128
# don't redistribute all local addresses, only selected ones
# after the first line, the "deny" rules kicks in. After the "deny"
# no redistribute local rules are going to match
## redistribute local ip 192.160.4.0/24
## redistribute local deny
# Babel refuses to redistribute routes with a protocol number of "boot";
# this is standard practice, and means that you cannot easily
# redistribute the default route installed by dhcp. It is however
# possible to redistribute such route by explicitly specifying "proto 3"
# on the redistribute line.
## redistribute ip 0.0.0.0/0 le 0 proto 3 metric 128

View file

@ -0,0 +1,72 @@
package babeld
config general
# option 'multicast_address' 'ff02:0:0:0:0:0:1:6'
# option 'port' '6696'
# option 'state_file' '/var/lib/babel-state'
# option 'hello_interval' '4'
# option 'wired_hello_interval' '20'
# option 'diversity' '0,128'
# option 'smoothing_half_time' '4'
# option 'kernel_priority' '0'
# Do not use this option unless you know what you are doing, as it can
# cause persistent route flapping.
## option 'duplication_priority' '0'
# option 'carrier_sense' 'false'
# option 'assume_wireless' 'false'
# option 'no_split_horizon' 'false'
# option 'debug' '0'
# Listen for connections from a front-end, e.g. on port 33123.
## option 'local_server' '33123'
# option 'random_router_id' 'false'
# Keep unfeasible routes
## option 'keep_unfeasible' 'false'
# Use the given kernel routing table for routes inserted by babeld.
## option 'export_table' '0'
# Export routes from the given kernel routing tables.
## list 'import_table' '0'
## list 'import_table' '42'
# The configuration file is not necessary since you can do everything
# from this file.
# option 'conf_file' '/etc/babeld.conf'
# option 'log_file' '/var/log/babeld.log'
# You can use aliases (like lan, wlan) or real names (like eth0.0).
# If you use an alias, it must be already defined when babeld starts.
# Otherwise, the name is taken literally and the interface can be
# brought up later (useful for tunnels for instance).
config interface wlan
# Remove this line to enable babeld on this interface
option 'ignore' 'true'
# option 'wired' 'auto'
# option 'link_quality' 'auto'
# option 'split_horizon' 'auto'
# The default is 96 for wired interfaces, and 256 for wireless ones
## option 'rxcost' '256'
# The default is specified with the -h and -H command-line flags.
## option 'hello_interval' '4'
# This can be set to a fairly large value, unless significant
# packet loss is expected. The default is four times the hello
# interval.
## option 'update_interval' '16'
config interface lan
option 'ignore' 'true'
# A filter consists in a type ('in', 'out' or 'redistribute'), an action
# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq',
# etc.). See /etc/babeld.conf for more details.
# Here is a sample filter wich redistributes the default route if its
# protocol number is "boot", e.g. when it installed by dhcp. It is
# disabled by default.
config filter
option 'ignore' 'true'
# Type
option 'type' 'redistribute'
# Selectors: ip, eq, le, ge, neigh, id, proto, local, if
option 'ip' '0.0.0.0/0'
option 'le' '0'
option 'proto' '3'
# Action
option 'action' 'metric 128'

154
babels/files/babeld.init Executable file
View file

@ -0,0 +1,154 @@
#!/bin/sh /etc/rc.common
START=70
pidfile='/var/run/babeld.pid'
EXTRA_COMMANDS="status"
EXTRA_HELP=" status Dump Babel's table to the log file."
listen_ifname() {
local ifname=$(uci_get_state network "$1" ifname "$1")
local switch="$2"
append args "$switch $ifname"
append interfaces "$ifname"
}
append_ifname() {
local section="$1"
local option="$2"
local switch="$3"
local _name
config_get _name "$section" "$option"
[ -z "$_name" ] && return 0
local ifname=$(uci_get_state network "$_name" ifname "$_name")
append args "$switch $ifname"
}
append_bool() {
local section="$1"
local option="$2"
local value="$3"
local _loctmp
config_get_bool _loctmp "$section" "$option" 0
[ "$_loctmp" -gt 0 ] && append args "$value"
}
append_switch() {
local value="$1"
local switch="$2"
append args "$switch $value"
}
append_parm() {
local section="$1"
local option="$2"
local switch="$3"
local _loctmp
config_get _loctmp "$section" "$option"
[ -z "$_loctmp" ] && return 0
append args "$switch $_loctmp"
}
babel_filter() {
local cfg="$1"
local _loctmp
local _ignored
config_get_bool _ignored "$cfg" 'ignore' 0
[ "$_ignored" -eq 1 ] && return 0
append args "-C '"
append_parm "$cfg" 'type' ''
append_bool "$cfg" 'local' 'local'
append_parm "$cfg" 'ip' 'ip'
append_parm "$cfg" 'eq' 'eq'
append_parm "$cfg" 'le' 'le'
append_parm "$cfg" 'ge' 'ge'
append_parm "$cfg" 'src_ip' 'src-ip'
append_parm "$cfg" 'src_eq' 'src-eq'
append_parm "$cfg" 'src_le' 'src-le'
append_parm "$cfg" 'src_ge' 'src-ge'
append_parm "$cfg" 'neigh' 'neigh'
append_parm "$cfg" 'id' 'id'
append_parm "$cfg" 'proto' 'proto'
append_ifname "$cfg" 'if' 'if'
append_parm "$cfg" 'action' ''
append args ' ' "'"
}
babel_addif() {
local cfg="$1"
local _ignored
config_get_bool _ignored "$cfg" 'ignore' 0
[ "$_ignored" -eq 1 ] && return 0
listen_ifname "$cfg" "-C 'interface"
append_parm "$cfg" 'wired' 'wired'
append_parm "$cfg" 'link_quality' 'link-quality'
append_parm "$cfg" 'split_horizon' 'split-horizon'
append_parm "$cfg" 'rxcost' 'rxcost'
append_parm "$cfg" 'hello_interval' 'hello-interval'
append_parm "$cfg" 'update_interval' 'update-interval'
append args ' ' "'"
}
babel_config() {
local cfg="$1"
append_bool "$cfg" 'carrier_sense' '-l'
append_bool "$cfg" 'assume_wireless' '-w'
append_bool "$cfg" 'no_split_horizon' '-s'
append_bool "$cfg" 'keep_unfeasible' '-u'
append_bool "$cfg" 'random_router_id' '-r'
append_parm "$cfg" 'multicast_address' '-m'
append_parm "$cfg" 'port' '-p'
append_parm "$cfg" 'state_file' '-S'
append_parm "$cfg" 'hello_interval' '-h'
append_parm "$cfg" 'wired_hello_interval' '-H'
append_parm "$cfg" 'diversity' '-z'
append_parm "$cfg" 'smoothing_half_time' '-M'
append_parm "$cfg" 'kernel_priority' '-k'
append_parm "$cfg" 'duplication_priority' '-A'
append_parm "$cfg" 'debug' '-d'
append_parm "$cfg" 'local_server' '-g'
append_parm "$cfg" 'export_table' '-t'
config_list_foreach "$cfg" 'import_table' append_switch '-T'
append_parm "$cfg" 'conf_file' '-c'
append_parm "$cfg" 'log_file' '-L'
}
start() {
mkdir -p /var/lib
config_load babeld
unset args
unset interfaces
config_foreach babel_config general
config_foreach babel_addif interface
config_foreach babel_filter filter
[ -z "$interfaces" ] && return 0
eval "/usr/sbin/babeld -D -I $pidfile $args $interfaces"
}
stop() {
[ -f "$pidfile" ] && kill $(cat $pidfile)
# avoid race-condition on restart: wait for
# babeld to die for real.
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && exit 42
}
status() {
[ -f "$pidfile" ] && kill -USR1 $(cat $pidfile)
}

View file

@ -0,0 +1,107 @@
From 3fdbb1f797ee9fe9260af92f5d7ea760684cd271 Mon Sep 17 00:00:00 2001
From: Steven Barth <steven@midlink.org>
Date: Tue, 18 Feb 2014 13:18:32 +0100
Subject: [PATCH] Allow routes with source ::/128 for SAS on Linux
Linux uses the source-address :: (unspecified) to lookup routes in the
routing table for connections that are not bound to a specific source
address (e.g. ping6 2001:db8::1). If all default routes are
source-restricted a command like above will result in a "Permission
denied" error and no packets are being sent. Adding a default route with
source ::/128 avoids this issue.
This patch excludes ::/128 from the "martian_prefix" check for source
prefixes and thus allows such auxiliary routes to be distributed.
Signed-off-by: Steven Barth <cyrus@openwrt.org>
---
kernel_netlink.c | 4 ++--
route.c | 4 ++--
util.c | 4 ++--
util.h | 2 +-
xroute.c | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/kernel_netlink.c b/kernel_netlink.c
index 8b9099c..2e174af 100644
--- a/kernel_netlink.c
+++ b/kernel_netlink.c
@@ -1236,8 +1236,8 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data)
if(rc < 0)
return 0;
- if(martian_prefix(current_route->prefix, current_route->plen) ||
- martian_prefix(current_route->src_prefix, current_route->src_plen))
+ if(martian_prefix(current_route->prefix, current_route->plen, 0) ||
+ martian_prefix(current_route->src_prefix, current_route->src_plen, 1))
return 0;
/* Ignore default unreachable routes; no idea where they come from. */
diff --git a/route.c b/route.c
index a97e8ed..c709303 100644
--- a/route.c
+++ b/route.c
@@ -1371,12 +1371,12 @@ update_route(const unsigned char *id,
if(memcmp(id, myid, 8) == 0)
return NULL;
- if(martian_prefix(prefix, plen)) {
+ if(martian_prefix(prefix, plen, 0)) {
fprintf(stderr, "Rejecting martian route to %s through %s.\n",
format_prefix(prefix, plen), format_address(id));
return NULL;
}
- if(src_plen != 0 && martian_prefix(src_prefix, src_plen)) {
+ if(src_plen != 0 && martian_prefix(src_prefix, src_plen, 1)) {
fprintf(stderr, "Rejecting martian route to %s from %s through %s.\n",
format_prefix(prefix, plen),
format_prefix(src_prefix, src_plen), format_address(id));
diff --git a/util.c b/util.c
index cdb4ab2..80930e4 100644
--- a/util.c
+++ b/util.c
@@ -425,13 +425,13 @@ wait_for_fd(int direction, int fd, int msecs)
}
int
-martian_prefix(const unsigned char *prefix, int plen)
+martian_prefix(const unsigned char *prefix, int plen, int is_source)
{
return
(plen >= 8 && prefix[0] == 0xFF) ||
(plen >= 10 && prefix[0] == 0xFE && (prefix[1] & 0xC0) == 0x80) ||
(plen >= 128 && memcmp(prefix, zeroes, 15) == 0 &&
- (prefix[15] == 0 || prefix[15] == 1)) ||
+ ((prefix[15] == 0 && !is_source) || prefix[15] == 1)) ||
(plen >= 96 && v4mapped(prefix) &&
((plen >= 104 && (prefix[12] == 127 || prefix[12] == 0)) ||
(plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
diff --git a/util.h b/util.h
index 935481f..f399b8a 100644
--- a/util.h
+++ b/util.h
@@ -95,7 +95,7 @@ int parse_net(const char *net, unsigned char *prefix_r, unsigned char *plen_r,
int *af_r);
int parse_eui64(const char *eui, unsigned char *eui_r);
int wait_for_fd(int direction, int fd, int msecs);
-int martian_prefix(const unsigned char *prefix, int plen) ATTRIBUTE ((pure));
+int martian_prefix(const unsigned char *prefix, int plen, int is_source) ATTRIBUTE ((pure));
int linklocal(const unsigned char *address) ATTRIBUTE ((pure));
int v4mapped(const unsigned char *address) ATTRIBUTE ((pure));
void v4tov6(unsigned char *dst, const unsigned char *src);
diff --git a/xroute.c b/xroute.c
index e8b3b11..e4bd12a 100644
--- a/xroute.c
+++ b/xroute.c
@@ -259,7 +259,7 @@ check_xroutes(int send_updates)
/* Add any new routes */
for(i = 0; i < numroutes; i++) {
- if(martian_prefix(routes[i].prefix, routes[i].plen))
+ if(martian_prefix(routes[i].prefix, routes[i].plen, 0))
continue;
metric = redistribute_filter(routes[i].prefix, routes[i].plen,
routes[i].src_prefix, routes[i].src_plen,
--
1.8.5.3

View file

@ -12,7 +12,7 @@ PKG_NAME:=batman-adv
PKG_VERSION:=2014.0.0
BATCTL_VERSION:=2014.0.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_MD5SUM:=8d58ecaede17dc05aab1b549dc09fa7d
BATCTL_MD5SUM:=b0bcf29fef80ddcc33769e13f5937d0a

View file

@ -1,7 +1,7 @@
From 746d6436f88899a79c1cb3b27af0614510368bb7 Mon Sep 17 00:00:00 2001
From: Marek Lindner <mareklindner@neomailbox.ch>
Date: Wed, 15 Jan 2014 20:31:18 +0800
Subject: [PATCH 1/5] batman-adv: fix batman-adv header overhead calculation
Subject: [PATCH 01/13] batman-adv: fix batman-adv header overhead calculation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -34,5 +34,5 @@ index 4547bf0..fd85205 100644
/**
--
1.8.5.3
1.9.0.rc3

View file

@ -1,8 +1,8 @@
From 41b38727749a94c1a65cf0f4be9bfe1cbaf0adeb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@web.de>
Date: Mon, 20 Jan 2014 11:06:44 +0100
Subject: [PATCH 2/5] batman-adv: fix potential kernel paging error for unicast
transmissions
Subject: [PATCH 02/13] batman-adv: fix potential kernel paging error for
unicast transmissions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -40,5 +40,5 @@ index b0a3d76..2035bd9 100644
/* inform the destination node that we are still missing a correct route
--
1.8.5.3
1.9.0.rc3

View file

@ -1,7 +1,7 @@
From 2b108ccd0533e1375e44c73ec58c69dde9a71687 Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@meshcoding.com>
Date: Tue, 21 Jan 2014 11:22:05 +0100
Subject: [PATCH 3/5] batman-adv: fix soft-interface MTU computation
Subject: [PATCH 03/13] batman-adv: fix soft-interface MTU computation
The current MTU computation always returns a value
smaller than 1500bytes even if the real interfaces
@ -71,5 +71,5 @@ index 6792e03..0eb0b3b 100644
/* adjusts the MTU if a new interface with a smaller MTU appeared. */
--
1.8.5.3
1.9.0.rc3

View file

@ -1,7 +1,7 @@
From db13d361ff6abf57090acfdeb0f5cedd8dd7f02e Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@meshcoding.com>
Date: Mon, 27 Jan 2014 12:23:28 +0100
Subject: [PATCH 4/5] batman-adv: fix TT-TVLV parsing on OGM reception
Subject: [PATCH 04/13] batman-adv: fix TT-TVLV parsing on OGM reception
When accessing a TT-TVLV container in the OGM RX path
the variable pointing to the list of changes to apply is
@ -31,5 +31,5 @@ index 3fca99d..45b6155 100644
ttvn, tt_change);
--
1.8.5.3
1.9.0.rc3

View file

@ -1,7 +1,7 @@
From dc08c045b46bdd9a5c81068a89f9f2a78d3d4bbd Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@meshcoding.com>
Date: Tue, 28 Jan 2014 02:06:47 +0100
Subject: [PATCH 5/5] batman-adv: release vlan object after checking the CRC
Subject: [PATCH 05/13] batman-adv: release vlan object after checking the CRC
There is a refcounter unbalance in the CRC checking routine
invoked on OGM reception. A vlan object is retrieved (thus
@ -46,5 +46,5 @@ index 45b6155..05c2a9b 100644
}
--
1.8.5.3
1.9.0.rc3

View file

@ -0,0 +1,34 @@
From eabdc3175b1d119cd673f36d06264cddb4803ace Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@meshcoding.com>
Date: Thu, 30 Jan 2014 00:12:24 +0100
Subject: [PATCH 06/13] batman-adv: properly check pskb_may_pull return value
pskb_may_pull() returns 1 on success and 0 in case of failure,
therefore checking for the return value being negative does
not make sense at all.
This way if the function fails we will probably read beyond the current
skb data buffer. Fix this by doing the proper check.
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
routing.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/routing.c b/routing.c
index f28920f..f7579d0 100644
--- a/routing.c
+++ b/routing.c
@@ -833,7 +833,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
int is_old_ttvn;
/* check if there is enough data before accessing it */
- if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0)
+ if (!pskb_may_pull(skb, hdr_len + ETH_HLEN))
return 0;
/* create a copy of the skb (in case of for re-routing) to modify it. */
--
1.9.0.rc3

View file

@ -0,0 +1,30 @@
From 9a91d33c0ea234faf59ee7543d5253e6809a6b6f Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@meshcoding.com>
Date: Thu, 30 Jan 2014 13:57:27 +0100
Subject: [PATCH 07/13] batman-adv: remove useless assignment
Introduced by 41b38727749a94c1a65cf0f4be9bfe1cbaf0adeb
("batman-adv: fix potential kernel paging error for unicast transmissions")
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
send.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/send.c b/send.c
index 2035bd9..75be770 100644
--- a/send.c
+++ b/send.c
@@ -256,7 +256,7 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
unsigned short vid)
{
- struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
+ struct ethhdr *ethhdr;
struct batadv_unicast_packet *unicast_packet;
int ret = NET_XMIT_DROP;
--
1.9.0.rc3

View file

@ -0,0 +1,43 @@
From b921e8f70aa929766856decfe79ee8e78ba21e23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@web.de>
Date: Sun, 2 Feb 2014 22:53:11 +0800
Subject: [PATCH 08/13] batman-adv: backport eth_hdr() compat fix to avoid
kernel oops
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Introduced by 41b38727749a94c1a65cf0f4be9bfe1cbaf0adeb
("batman-adv: fix potential kernel paging error for unicast transmissions")
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
CC: Linus Lüssing <linus.luessing@web.de>
---
compat.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/compat.h b/compat.h
index a4ab202..deea92b 100644
--- a/compat.h
+++ b/compat.h
@@ -289,6 +289,17 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) \
}\
static int __batadv_interface_set_mac_addr(x, y)
+#define batadv_interface_tx(x, y) \
+__batadv_interface_tx(struct sk_buff *skb, struct net_device *soft_iface); \
+static int batadv_interface_tx(struct sk_buff *skb, \
+ struct net_device *soft_iface) \
+{ \
+ skb_reset_mac_header(skb); \
+ return __batadv_interface_tx(skb, soft_iface); \
+} \
+static int __batadv_interface_tx(struct sk_buff *skb, \
+ struct net_device *soft_iface)
+
#define netdev_master_upper_dev_link netdev_set_master
#define netdev_upper_dev_unlink(slave, master) netdev_set_master(slave, NULL)
#define netdev_master_upper_dev_get(dev) \
--
1.9.0.rc3

View file

@ -0,0 +1,34 @@
From cb4d66e6803b854663ee758e3eecbda183b0b007 Mon Sep 17 00:00:00 2001
From: Simon Wunderlich <sw@simonwunderlich.de>
Date: Sat, 8 Feb 2014 16:45:06 +0100
Subject: [PATCH 09/13] batman-adv: fix potential orig_node reference leak
Since batadv_orig_node_new() sets the refcount to two, assuming that
the calling function will use a reference for putting the orig_node into
a hash or similar, both references must be freed if initialization of
the orig_node fails. Otherwise that object may be leaked in that error
case.
Reported-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
bat_iv_ogm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 6f4fcdc..c07e59f 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -256,6 +256,8 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
free_bcast_own:
kfree(orig_node->bat_iv.bcast_own);
free_orig_node:
+ /* free twice, as batadv_orig_node_new sets refcount to 2 */
+ batadv_orig_node_free_ref(orig_node);
batadv_orig_node_free_ref(orig_node);
return NULL;
--
1.9.0.rc3

View file

@ -0,0 +1,44 @@
From df99b07081eeda5cca292afe2dcc5cb3bf5be154 Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@meshcoding.com>
Date: Tue, 11 Feb 2014 11:26:43 +0100
Subject: [PATCH 10/13] batman-adv: fix memory access by setting mac_header in
DAT
In the TX path we now have functions that rely on the
skb->mac_header field. DAT does not set such field when
creating its own ARP packets thus leading to wrong memory
access.
Fix it by always setting the mac_header after having forged
the ARP packet.
Introduced by 41b38727749a94c1a65cf0f4be9bfe1cbaf0adeb
("batman-adv: fix potential kernel paging error for unicast transmissions")
Reported-by: Russel Senior <russell@personaltelco.net>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Tested-by: Russel Senior <russell@personaltelco.net>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
distributed-arp-table.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index 6da587a..0b69b61 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -1028,6 +1028,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
if (!skb_new)
goto out;
+ /* the rest of the TX path assumes that the mac_header offset pointing
+ * to the inner Ethernet header has been set, therefore reset it now.
+ */
+ skb_reset_mac_header(skb_new);
+
if (vid & BATADV_VLAN_HAS_TAG)
skb_new = vlan_insert_tag(skb_new, htons(ETH_P_8021Q),
vid & VLAN_VID_MASK);
--
1.9.0.rc3

View file

@ -0,0 +1,82 @@
From be4385eacf30ad55a5cf4574768624ce8141a0c7 Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@open-mesh.com>
Date: Tue, 11 Feb 2014 17:05:06 +0100
Subject: [PATCH 11/13] batman-adv: fix TT CRC computation by ensuring byte
order
When computing the CRC on a 2byte variable the order of
the bytes obviously alters the final result. This means
that computing the CRC over the same value on two archs
having different endianess leads to different numbers.
The global and local translation table CRC computation
routine makes this mistake while processing the clients
VIDs. The result is a continuous CRC mismatching between
nodes having different endianess.
Fix this by converting the VID to Network Order before
processing it. This guarantees that every node uses the same
byte order.
Introduced by 21a57f6e7a3b4455dfe68ee07a7b901d9e7f200b
("batman-adv: make the TT CRC logic VLAN specific")
Reported-by: Russel Senior <russell@personaltelco.net>
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Tested-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
translation-table.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index 05c2a9b..24e3267 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -1961,6 +1961,7 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
struct hlist_head *head;
uint32_t i, crc_tmp, crc = 0;
uint8_t flags;
+ __be16 tmp_vid;
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
@@ -1997,8 +1998,11 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
orig_node))
continue;
- crc_tmp = crc32c(0, &tt_common->vid,
- sizeof(tt_common->vid));
+ /* use network order to read the VID: this ensures that
+ * every node reads the bytes in the same order.
+ */
+ tmp_vid = htons(tt_common->vid);
+ crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
/* compute the CRC on flags that have to be kept in sync
* among nodes
@@ -2032,6 +2036,7 @@ static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv,
struct hlist_head *head;
uint32_t i, crc_tmp, crc = 0;
uint8_t flags;
+ __be16 tmp_vid;
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
@@ -2050,8 +2055,11 @@ static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv,
if (tt_common->flags & BATADV_TT_CLIENT_NEW)
continue;
- crc_tmp = crc32c(0, &tt_common->vid,
- sizeof(tt_common->vid));
+ /* use network order to read the VID: this ensures that
+ * every node reads the bytes in the same order.
+ */
+ tmp_vid = htons(tt_common->vid);
+ crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
/* compute the CRC on flags that have to be kept in sync
* among nodes
--
1.9.0.rc3

View file

@ -0,0 +1,37 @@
From 9289542085d7e298b90c7b6fb6efb509dab69d8b Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@open-mesh.com>
Date: Tue, 11 Feb 2014 17:05:07 +0100
Subject: [PATCH 12/13] batman-adv: free skb on TVLV parsing success
When the TVLV parsing routine succeed the skb is left
untouched thus leading to a memory leak.
Fix this by consuming the skb in case of success.
Introduced by 0b6aa0d43767889eeda43a132cf5e73df4e63bf2
("batman-adv: tvlv - basic infrastructure")
Reported-by: Russel Senior <russell@personaltelco.net>
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Tested-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
routing.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/routing.c b/routing.c
index f7579d0..71bf698 100644
--- a/routing.c
+++ b/routing.c
@@ -1063,6 +1063,8 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,
if (ret != NET_RX_SUCCESS)
ret = batadv_route_unicast_packet(skb, recv_if);
+ else
+ consume_skb(skb);
return ret;
}
--
1.9.0.rc3

View file

@ -0,0 +1,47 @@
From d4acda1cb9cca135e7b91777bb2680518b3cffa0 Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <antonio@meshcoding.com>
Date: Sat, 15 Feb 2014 02:17:20 +0100
Subject: [PATCH 13/13] batman-adv: avoid double free when orig_node
initialization fails
In the failure path of the orig_node initialization routine
the orig_node->bat_iv.bcast_own field is free'd twice: first
in batadv_iv_ogm_orig_get() and then later in
batadv_orig_node_free_rcu().
Fix it by removing the kfree in batadv_iv_ogm_orig_get().
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
bat_iv_ogm.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index c07e59f..fdf4322 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -243,18 +243,16 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
size = bat_priv->num_ifaces * sizeof(uint8_t);
orig_node->bat_iv.bcast_own_sum = kzalloc(size, GFP_ATOMIC);
if (!orig_node->bat_iv.bcast_own_sum)
- goto free_bcast_own;
+ goto free_orig_node;
hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
batadv_choose_orig, orig_node,
&orig_node->hash_entry);
if (hash_added != 0)
- goto free_bcast_own;
+ goto free_orig_node;
return orig_node;
-free_bcast_own:
- kfree(orig_node->bat_iv.bcast_own);
free_orig_node:
/* free twice, as batadv_orig_node_new sets refcount to 2 */
batadv_orig_node_free_ref(orig_node);
--
1.9.0.rc3

View file

@ -204,7 +204,7 @@ function action_links(host)
devlinks[l.viaDev] = {}
end
for _,l in ipairs(links) do
l.globalId = luci.util.split(l.globalId,'.')[1]
l.name = luci.util.split(l.name,'.')[1]
table.insert(devlinks[l.viaDev],l)
end
end

View file

@ -20,7 +20,7 @@
<table>
<tr><th colspan="2">
<span style="color:grey;font-weight:700;text-align:left;">
<%=l.globalId%>
<%=l.name%>
<br />
</span>
</th></tr>

View file

@ -66,11 +66,9 @@
<th class="cbi-section-table-cell"><%:Network%></th>
<th class="cbi-section-table-cell"><%:Bandwidth%></th>
<th class="cbi-section-table-cell"><%:SearchNet%></th>
<th class="cbi-section-table-cell"><%:Type%></th>
<th class="cbi-section-table-cell"><%:Path Metric%></th>
<th class="cbi-section-table-cell"><%:IP metric%></th>
<th class="cbi-section-table-cell"><%:Tun metric%></th>
<th class="cbi-section-table-cell"><%:Bonus%></th>
<th class="cbi-section-table-cell"><%:Rating%></th>
<th class="cbi-section-table-cell"><%:Src%></th>
<th class="cbi-section-table-cell"><%:Search id%></th>
</tr>
@ -97,8 +95,8 @@
if ( tunnel.tunName != "---" ) status = '<img src="'+tunicon+'"/>';
if ( advnet == "0.0.0.0/0" ) advnet = "<b>Internet</b>";
res.push([status, tunnel.name, nodename, advnet, tunnel.advBw, tunnel.net, tunnel.advType,
tunnel.pathMtc, tunnel.ipMtc, tunnel.tunMtc, tunnel.bonus, tunnel.srcIngress, tunnel.id]);
res.push([status, tunnel.name, nodename, advnet, tunnel.advBw, tunnel.net,
tunnel.pathMtc, tunnel.tunMtc, tunnel.rating, tunnel.srcIngress, tunnel.id]);
}
return res;
});

View file

@ -97,7 +97,7 @@ if [ "$QUERY" == '$neighbours' ]; then
exit 0
else if [ "$QUERY" == '$tunnels' ]; then
bmx6 -c --jshow tunnels
bmx6 -c --jshow tunnels /r=0
exit 0
else

49
ohybridproxy/Makefile Normal file
View file

@ -0,0 +1,49 @@
#
# Copyright (C) 2012-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
PKG_NAME:=ohybridproxy
PKG_SOURCE_VERSION:=504f334e7e718ef696c208f69da35f08f75aeb6c
PKG_VERSION:=2014-02-20-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git://github.com/sbyx/ohybridproxy.git
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/ohybridproxy
SECTION:=net
CATEGORY:=Network
SUBMENU:=IP Addresses and Names
TITLE:=mdns/dns hybrid-proxy
URL:=https://github.com/sbyx/ohybridproxy
DEPENDS+=+libubox +mdnsd
endef
define Package/ohybridproxy/description
This package provides a statically configured daemon for translating DNS
requests to Multicast DNS and back again.
endef
define Package/ohybridproxy/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ohybridproxy $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_DATA) ./files/ohybridproxy.config $(1)/etc/config/ohybridproxy
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) ./files/ohybridproxy.init $(1)/etc/init.d/ohybridproxy
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DATA) ./files/ohybridproxy.hotplug $(1)/etc/hotplug.d/iface/ohybridproxy
endef
$(eval $(call BuildPackage,ohybridproxy))

View file

@ -0,0 +1,7 @@
config main main
option host '::'
option port '53'
#config interface
# option interface lan
# option domain lan.home.

View file

@ -0,0 +1,4 @@
#!/bin/sh
/etc/init.d/ohybridproxy enabled || exit 0
[ "$ACTION" = ifupdate ] && exit 0
/etc/init.d/ohybridproxy restart

View file

@ -0,0 +1,50 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2009-2014 OpenWrt.org
START=60
STOP=10
USE_PROCD=1
HAS_IFACES=
service_triggers()
{
procd_add_reload_trigger "ohybridproxy"
}
ohp_interface()
{
local section="$1"
config_get interface "$section" interface
config_get domain "$section" domain
[ -n "$interface" ] && network_get_device interface "$interface"
if [ -n "$interface" -a -n "$domain" ]; then
procd_append_param command "$interface=$domain"
HAS_IFACES=1
fi
}
start_service()
{
. /lib/functions.sh
. /lib/functions/network.sh
procd_open_instance
procd_set_param command /usr/sbin/ohybridproxy
config_load ohybridproxy
config_get val main host
[ -n "$val" ] && procd_append_param command -a "${val}"
config_get val main port
[ -n "$val" ] && procd_append_param command -p "${val}"
config_foreach ohp_interface interface
[ "$HAS_IFACES" = 1 ] || return 0
procd_close_instance
}

View file

@ -732,9 +732,9 @@ olsrd_setup_smartgw_rules() {
$IP6T -I input_rule -i $IFACE -p 4 -j ACCEPT
done
else
$IP4T -t nat -I postrouting_rule -o tnl_+ -j MASQUERADE
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