Skip to contentSkip to conversation

batman-adv multi-hop route

B.A.T.M.A.N. New Xianghua Xiao 4 participants 9 messages Oct 25, 2010 – Oct 28, 2010

lore
Share & tools
lore
#0 lore raw

I'm trying to test how much bandwidth is left after multi-hops using dual-radio as the backbone(interface alternating), I have a few nodes and want to force them cascaded, is there a way to set up 'static hop route' somehow so the nodes will not take a short-cut, the nodes are all close-by.

Basically I want to have A->B->C->D->E and avoid A->E or something alike.

thanks,
xianghua

#1 lore raw
Quoted 7 lines · On Monday 25 October 2010 06:03:01 Xianghua Xiao wrote:

I'm trying to test how much bandwidth is left after multi-hops using dual-radio as the backbone(interface alternating), I have a few nodes and want to force them cascaded, is there a way to set up 'static hop route' somehow so the nodes will not take a short-cut, the nodes are all close-by.

Basically I want to have A->B->C->D->E and avoid A->E or something alike.

You could remove the external antennas (if any) to reduce the signal strength. That is much easier than a software solution. Alternatively you can use ebtables to block unwanted OGMs. Linus might be of help here.

Regards,
Marek

#2 lore raw
In reply to Xianghua Xiao

Hi xianghua,

for such test cases basically this patch had once been made to force batman-adv onto certain routes but needed to be removed again as the way ebtables is used here is not standard-conforming. However, this shouldn't bother you :).

You can then just use ebtables to prohibit certain routes:

Quoted 3 lines

ebtables -I INPUT -s MAC -j DROP or
ebtables -I INPUT -p 0x4305 -j DROP
(and the same for -I OUTPUT)

Antonio had been doing tests with this ebtables patch, too (see this mailing list's archive from about the 10 May 2010).

This is a revert of the revert of commit 660d20261343e0b2ff57e51e50d7eb0e557d5e5b. and applies on top of the current git master branch. If you need it for any other version of batman-adv, try 'git revert 660d20261343e0b2ff57e51e50d7eb0e557d5e5b' and if that doesn't work, just bug me again :).

Cheers, Linus

#3 lore raw
Quoted 14 lines · Linus Lüssing

Hi xianghua,

for such test cases basically this patch had once been made to force batman-adv onto certain routes but needed to be removed again as the way ebtables is used here is not standard-conforming. However, this shouldn't bother you :).

You can then just use ebtables to prohibit certain routes:

Quoted 3 lines

ebtables -I INPUT -s MAC -j DROP or
ebtables -I INPUT -p 0x4305 -j DROP
(and the same for -I OUTPUT)

Antonio had been doing tests with this ebtables patch, too (see this mailing list's archive from about the 10 May 2010).

Quoted 7 lines

This is a revert of the revert of commit 660d20261343e0b2ff57e51e50d7eb0e557d5e5b. and applies on top of the current git master branch. If you need it for any other version of batman-adv, try 'git revert 660d20261343e0b2ff57e51e50d7eb0e557d5e5b' and if that doesn't work, just bug me again :).

Cheers, Linus

Thanks!
Will give it a try.
Xianghua

#4 lore raw
Quoted 20 lines · Xianghua Xiao
Quoted 19 lines · Linus Lüssing

Hi xianghua,

for such test cases basically this patch had once been made to force batman-adv onto certain routes but needed to be removed again as the way ebtables is used here is not standard-conforming. However, this shouldn't bother you :).

You can then just use ebtables to prohibit certain routes:

Quoted 3 lines

ebtables -I INPUT -s MAC -j DROP or
ebtables -I INPUT -p 0x4305 -j DROP
(and the same for -I OUTPUT)

Antonio had been doing tests with this ebtables patch, too (see this mailing list's archive from about the 10 May 2010).

This is a revert of the revert of commit 660d20261343e0b2ff57e51e50d7eb0e557d5e5b. and applies on top of the current git master branch. If you need it for any other version of batman-adv, try 'git revert 660d20261343e0b2ff57e51e50d7eb0e557d5e5b' and if that doesn't work, just bug me again :).

Quoted 7 lines
Quoted 2 lines

Cheers, Linus

Thanks!
Will give it a try.
Xianghua

************A*******************

$ git revert 660d20261343e0b2ff57e51e50d7eb0e557d5e5b
Automatic revert failed.  After resolving the conflicts,
mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
and commit the result.
************B*********************
$ git diff
diff --cc send.c
index 16ffd03,283c6bb..0000000
--- a/send.c
+++ b/send.c
@@@ -28,6 -28,8 +28,11 @@@
  #include "types.h"
  #include "vis.h"
  #include "aggregation.h"
++<<<<<<< HEAD
++=======
+ #include "gateway_common.h"
+ #include <linux/netfilter_bridge.h>
++>>>>>>> 660d202... batman-adv: Revert "Adding netfilter-bridge hooks"

#include "compat.h"
****************C*********************
$cat send.c
<snip>
#include "main.h"
#include "send.h"
#include "routing.h"
#include "translation-table.h"
#include "soft-interface.h"
#include "hard-interface.h"
#include "types.h"
#include "vis.h"
#include "aggregation.h"
#include "gateway_common.h"
#include <linux/netfilter_bridge.h>

#include "compat.h"
<snip>
****************D********************* ~/devel/mesh/batman-adv$ make
make -C /lib/modules/2.6.32-25-generic/build REVISION=v2010.1.0-52-gdbfbc90-dirty M=/home/xxiao/devel/mesh/batman-adv PWD=/home/xxiao/devel/mesh/batman-adv -j 1 modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-25-generic'

  CC [M]  /home/xxiao/devel/mesh/batman-adv/main.o
  CC [M]  /home/xxiao/devel/mesh/batman-adv/bat_debugfs.o
  CC [M]  /home/xxiao/devel/mesh/batman-adv/bat_sysfs.o
  CC [M]  /home/xxiao/devel/mesh/batman-adv/send.o

/home/xxiao/devel/mesh/batman-adv/send.c:31:28: error:
gateway_common.h: No such file or directory
make[2]: *** [/home/xxiao/devel/mesh/batman-adv/send.o] Error 1 make[1]: *** [_module_/home/xxiao/devel/mesh/batman-adv] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-25-generic'
make: *** [all] Error 2

so, where is gateway_common.h?

thanks!

#5 lore raw
Quoted 85 lines · Xianghua Xiao
Quoted 20 lines · Xianghua Xiao
Quoted 19 lines · Linus Lüssing

Hi xianghua,

for such test cases basically this patch had once been made to force batman-adv onto certain routes but needed to be removed again as the way ebtables is used here is not standard-conforming. However, this shouldn't bother you :).

You can then just use ebtables to prohibit certain routes:

Quoted 3 lines

ebtables -I INPUT -s MAC -j DROP or
ebtables -I INPUT -p 0x4305 -j DROP
(and the same for -I OUTPUT)

Antonio had been doing tests with this ebtables patch, too (see this mailing list's archive from about the 10 May 2010).

This is a revert of the revert of commit 660d20261343e0b2ff57e51e50d7eb0e557d5e5b. and applies on top of the current git master branch. If you need it for any other version of batman-adv, try 'git revert 660d20261343e0b2ff57e51e50d7eb0e557d5e5b' and if that doesn't work, just bug me again :).

Quoted 7 lines
Quoted 2 lines

Cheers, Linus

Thanks!
Will give it a try.
Xianghua

************A*******************

$ git revert 660d20261343e0b2ff57e51e50d7eb0e557d5e5b
Automatic revert failed.  After resolving the conflicts,
mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
and commit the result.
************B*********************
$ git diff
send.c +0 -0
diff --cc send.c
index 16ffd03,283c6bb..0000000
@@@ -28,6 -28,8 +28,11 @@@

 #include "types.h"
 #include "vis.h"
 #include "aggregation.h"
++<<<<<<< HEAD
++=======
+ #include "gateway_common.h"
+ #include <linux/netfilter_bridge.h>
++>>>>>>> 660d202... batman-adv: Revert "Adding netfilter-bridge hooks"

 #include "compat.h"
****************C*********************
$cat send.c
<snip>
#include "main.h"
#include "send.h"
#include "routing.h"
#include "translation-table.h"
#include "soft-interface.h"
#include "hard-interface.h"
#include "types.h"
#include "vis.h"
#include "aggregation.h"
#include "gateway_common.h"
#include <linux/netfilter_bridge.h>

#include "compat.h"
<snip>
****************D********************* ~/devel/mesh/batman-adv$ make
make -C /lib/modules/2.6.32-25-generic/build REVISION=v2010.1.0-52-gdbfbc90-dirty M=/home/xxiao/devel/mesh/batman-adv PWD=/home/xxiao/devel/mesh/batman-adv -j 1 modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-25-generic' CC [M]  /home/xxiao/devel/mesh/batman-adv/main.o
 CC [M]  /home/xxiao/devel/mesh/batman-adv/bat_debugfs.o
 CC [M]  /home/xxiao/devel/mesh/batman-adv/bat_sysfs.o
 CC [M]  /home/xxiao/devel/mesh/batman-adv/send.o /home/xxiao/devel/mesh/batman-adv/send.c:31:28: error:
gateway_common.h: No such file or directory
make[2]: *** [/home/xxiao/devel/mesh/batman-adv/send.o] Error 1 make[1]: *** [_module_/home/xxiao/devel/mesh/batman-adv] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-25-generic'
make: *** [all] Error 2

Quoted 4 lines

so, where is gateway_common.h?

thanks!

sent out too fast, I removed that offending line and it compiles. never mind.

#6 lore raw

Hi Xianghua,

cool, great that it works now :). Let us know about any findings and interesting results you get out if it. I'd be especially interested if you could confirm the results of the WBMv3 in Italy and maybe could pinpoint the more stable graph of channel alternating to less interference / packet loss for instance.
(http://www.open-mesh.org/wiki/2010-06-13-wbm2010-bracciano).

And of course, we love to get any open feedback (both positive or negative), that's the big advantage of Open Source development :).

Cheers,
Linus

#7 lore raw
Quoted 9 lines · Linus Lüssing

Hi Xianghua,

cool, great that it works now :). Let us know about any findings and interesting results you get out if it. I'd be especially interested if you could confirm the results of the WBMv3 in Italy and maybe could pinpoint the more stable graph of channel alternating to less interference / packet loss for instance.
(http://www.open-mesh.org/wiki/2010-06-13-wbm2010-bracciano).

Quoted 6 lines

And of course, we love to get any open feedback (both positive or negative), that's the big advantage of Open Source development :).

Cheers,
Linus

Linus,
Will test 3 nodes(each have 2 radios at 5Ghz for backhaul) this weekend, after that I will report.I'm using Routerstation/openwrt for the testing.
Xianghua

#8 lore raw

PATCH 1/1 batman-adv: Adding netfilter-bridge hooks

In reply to Xianghua Xiao

batman-adv is receiving and sending the packets of its own ether type on a very early/low level. Therefore we need to add explicit hooks to give netfilter/ebtables a chance to filter them.

//git revert 660d20261343e0b2ff57e51e50d7eb0e557d5e5b

//Signed-off-by: Linus Lüssing <[email protected]> //Reported-by: Antonio Quartulli <[email protected]>

---
 hard-interface.c |   70 ++++++++++++++++++++++++++++++------------------------
 send.c           |    8 ++++-
 2 files changed, 45 insertions(+), 33 deletions(-)
hard-interface.c +39 -31
index ef95680..9153b19 100644
@@ -30,6 +30,7 @@
 #include "hash.h"
 
 #include <linux/if_arp.h>
+#include <linux/netfilter_bridge.h>
 
 #include "compat.h"
 
@@ -539,46 +540,29 @@ out:
 	return NOTIFY_DONE;
 }
 
-/* receive a packet with the batman ethertype coming on a hard
- * interface */
-int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
-	struct packet_type *ptype, struct net_device *orig_dev)
+static int batman_skb_recv_finish(struct sk_buff *skb)
 {
-	struct bat_priv *bat_priv;
 	struct batman_packet *batman_packet;
 	struct batman_if *batman_if;
+	struct bat_priv *bat_priv;
 	int ret;
 
-	batman_if = container_of(ptype, struct batman_if, batman_adv_ptype);
-	skb = skb_share_check(skb, GFP_ATOMIC);
-
-	/* skb was released by skb_share_check() */
-	if (!skb)
-		goto err_out;
-
-	/* packet should hold at least type and version */
-	if (unlikely(!pskb_may_pull(skb, 2)))
+	batman_if = get_batman_if_by_netdev(skb->dev);
+	if (!batman_if)
 		goto err_free;
 
-	/* expect a valid ethernet header here. */
-	if (unlikely(skb->mac_len != sizeof(struct ethhdr)
-				|| !skb_mac_header(skb)))
+	if (!batman_if->soft_iface)
 		goto err_free;
 
-	if (!batman_if->soft_iface)
+	/* discard frames on not active interfaces */
+	if (batman_if->if_status != IF_ACTIVE)
 		goto err_free;
 
 	bat_priv = netdev_priv(batman_if->soft_iface);
-
 	if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
 		goto err_free;
 
-	/* discard frames on not active interfaces */
-	if (batman_if->if_status != IF_ACTIVE)
-		goto err_free;
-
 	batman_packet = (struct batman_packet *)skb->data;
-
 	if (batman_packet->version != COMPAT_VERSION) {
 		bat_dbg(DBG_BATMAN, bat_priv,
 			"Drop packet: incompatible batman version (%i)\n",
@@ -624,18 +608,42 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	}
 
 	if (ret == NET_RX_DROP)
-		kfree_skb(skb);
+		goto err_free;
+
+	return 0;
 
-	/* return NET_RX_SUCCESS in any case as we
-	 * most probably dropped the packet for
-	 * routing-logical reasons. */
+err_free:
+	kfree_skb(skb);
+	return 0;
+}
 
-	return NET_RX_SUCCESS;
+/* receive a packet with the batman ethertype coming on a hard
+ * interface */
+int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
+	struct packet_type *ptype, struct net_device *orig_dev)
+{
+	skb = skb_share_check(skb, GFP_ATOMIC);
 
+	/* skb was released by skb_share_check() */
+	if (!skb)
+		return 0;
+
+	/* packet should hold at least type and version */
+	if (unlikely(!pskb_may_pull(skb, 2)))
+		goto err_free;
+
+	/* expect a valid ethernet header here. */
+	if (unlikely(skb->mac_len != sizeof(struct ethhdr) ||
+	    !skb_mac_header(skb)))
+		goto err_free;
+
+	/* if netfilter/ebtables wants to block incoming batman
+	 * packets then give them a chance to do so here */
+	return NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_IN, skb, dev,
+		       NULL, batman_skb_recv_finish);
 err_free:
 	kfree_skb(skb);
-err_out:
-	return NET_RX_DROP;
+	return 0;
 }
 
 struct notifier_block hard_if_notifier = {
send.c +6 -2
index a96a786..11a009f 100644
@@ -30,6 +30,7 @@
 #include "aggregation.h"
 #include "gateway_common.h"
 #include "originator.h"
+#include <linux/netfilter_bridge.h>
 
 #include "compat.h"
 
@@ -95,9 +96,12 @@ int send_skb_packet(struct sk_buff *skb,
 
 	/* dev_queue_xmit() returns a negative result on error.	 However on
 	 * congestion and traffic shaping, it drops and returns NET_XMIT_DROP
-	 * (which is > 0). This will not be treated as an error. */
+	 * (which is > 0). This will not be treated as an error.
+	 * Also, if netfilter/ebtables wants to block outgoing batman
+	 * packets then giving them a chance to do so here */
 
-	return dev_queue_xmit(skb);
+	return NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
+		       dev_queue_xmit);
 send_skb_err:
 	kfree_skb(skb);
 	return NET_XMIT_DROP;
Signature · 1 line
1.7.1