Re: [B.A.T.M.A.N.] editing the routing information

2012-08-24 Thread Dominic Follett-Smith
Hi Sven, thank you,

I will have a closer look at the code and send some more details over
the weekend. Essentially I understand that neighbor ranking for a
destination node 'D'  is performed on the number of OGM's received in
the sliding window. What I want to do is introduce an extra metric say
X that alters the number of OGM's in the sliding window (a kind of
penalty), then when BATMAN calculates the next best hop for that
destination 'D', this information will reflect that:

For example,  N1: node that wishes to route a packet to destination D
 D: Destination node
 N2, N3: Neighbours of N1 and D

[1] at t = 0:
(N2)
   /  \___
  /  \
(N1)(D)
 \ /
  \   /
   (N3)
-
[2] at t = t_1: N2 and N3 broadcast their OGM's with some metric about
themselves (X_n) attached. N(1) keeps a list of neighbours, with their
associated metric X_n at any time- it will be used for neighbour
ranking.

   (N2)
 ogm+x_2/  \___
 /  \
   (N1)(D)
\ /
ogm+x_3\   /
   (N3)
-
[3] at t = t_2: D Broadcasts its OGM

(N2)
   /  \_OGM
  /  \
(N1)(D)
 \  OGM_/
  \   /
   (N3)
-
[4] at t = t_3: N2 forward D's OGM onto N1

(N2)
OGM/  \___
  /  \
(N1)(D)
 \ /
  \   /
   (N3)
-
[5] at t = t_4:

sliding window of neigbour N2 for Destination D is:

|__10._|-- ten sequence numbers have been received
from D over N2 but we penalize this count with x_2, which leaves it at
6

sliding window of neigbour N3 for Destination D is:

|__8._|-- eight sequence numbers have been received
from D over N3 but we penalize this with x_3, which leaves it at 6

at this point the next best hop to route a packet to destination D is N2 or N3

and lastly in this time interval, N3 forward D's OGM onto N1

   (N2)
  /  \___
 /  \
  (N1)(D)
OGM\ /
 \   /
  (N3)
-
 [6]  at t = t_5:

sliding window of neigbour N2 for Destination D is:

|__10._|-- ten sequence numbers have been received
from D over N2 but we penalize this count with x_2, which leaves it at
6

sliding window of neigbour N3 for Destination D is:

|__9._|-- nine sequence numbers have been received
from D over N3 but we penalize this with x_3, which leaves it at 7

at this point the next best hop to route a packet to destination D is
the link over N3
-

Again, thank you for your kind assistance.

Dominic
UCT

On Tue, Aug 21, 2012 at 12:32 AM, Sven Eckelmann s...@narfation.org wrote:

 On Sunday 19 August 2012 17:13:28 Dominic Follett-Smith wrote:
  I am using the batmand release and I trying to edit where batman keeps
  a statistic of next best hops to a destination node.

 The development focus of many people changed to batman-adv. Therefore, most
 people aren't knowing the code very well (or have to read a while to get into
 the code again).

  I want to change
  the metric in some way to alter the choices that batman makes when
  routing a packet to its destination. However I am rather stuck, and
  would appreciate some direction on where the updating of this
  statistic of next best hops for a destination is done in the batman
  code.

 You're request is a little bit too general. Maybe you can go a little bit more
 in detail. Otherwise I can only recommend batman(void) in batman.c and
 update_orig(...) in originator.c

 Kind regards,
 Sven


Re: [B.A.T.M.A.N.] editing the routing information

2012-08-24 Thread Marek Lindner
On Friday, August 24, 2012 14:01:15 Dominic Follett-Smith wrote:
 I will have a closer look at the code and send some more details over
 the weekend. Essentially I understand that neighbor ranking for a
 destination node 'D'  is performed on the number of OGM's received in
 the sliding window.

This is not entirely correct. Only single hop neighbors will count the 
received OGMs and also count the re-broadcasted OGMs repeated by its 
neighbors. Then they derive the TQ from that which is then propagated through 
the network (plus hop penalty and asym penalty).
In other words: N1 will never count the OGMs originating at D.

Cheers,
Marek


Re: [B.A.T.M.A.N.] pull request: batman-adv 2012-08-23

2012-08-24 Thread David Miller
From: Antonio Quartulli or...@autistici.org
Date: Thu, 23 Aug 2012 15:10:09 +0200

 this is our set of changes intended for net-next/linux-3.7.
 It is mostly composed by style fixes and cleanups. Other than that you have a
 patch introducing a new table in debugfs (backbone gateways table for the 
 Bridge
 Loop Avoidance) and a new mechanism for the TranslationTable component. The
 latter allows mesh nodes to immediately detect new clients joining the 
 network,
 without waiting for any periodic advertisement.

Pulled, thanks Antonio.


[B.A.T.M.A.N.] [PATCH] batman-adv: properly store the roaming time

2012-08-24 Thread Antonio Quartulli
in case of a new global entry added because of roaming, the roam_at field must
be properly initiated with the current time. This value will be later use to
purge this entry out on time out (if nobody claims it). Instead roam_at field
is now set to zero in this situation leading to an immediate purging of the
related entry.

Signed-off-by: Antonio Quartulli or...@autistici.org
---
 translation-table.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/translation-table.c b/translation-table.c
index cacf7b7..ce3bf00 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -744,6 +744,12 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
 
common-flags = flags;
tt_global_entry-roam_at = 0;
+   /* node must store current time in case of roaming. This is
+* needed to purge this entry out on timeout (if nobody claims
+* it)
+*/
+   if (flags  BATADV_TT_CLIENT_ROAM)
+   tt_global_entry-roam_at = jiffies;
atomic_set(common-refcount, 2);
common-added_at = jiffies;
 
-- 
1.7.9.4



[B.A.T.M.A.N.] [PATCH] batman-adv: print packets re-routing on DBG_TT and ratelimit it

2012-08-24 Thread Antonio Quartulli
To simplify TranslationTable debugging it is better to print the packet
rerouting message on the DBG_TT log level. In this way a developer interested in
packets rerouting doesn't need to filter it out of the whole ROUTES log.

Moreover, since this message will appear for each rerouted message, it is now
ratelimited.

Signed-off-by: Antonio Quartulli or...@autistici.org
---
 routing.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/routing.c b/routing.c
index e7a4e25..f9751a0 100644
--- a/routing.c
+++ b/routing.c
@@ -972,10 +972,11 @@ static int batadv_check_unicast_ttvn(struct batadv_priv 
*bat_priv,
batadv_orig_node_free_ref(orig_node);
}
 
-   batadv_dbg(BATADV_DBG_ROUTES, bat_priv,
-  TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting 
unicast packet (for %pM) to %pM\n,
-  unicast_packet-ttvn, curr_ttvn, ethhdr-h_dest,
-  unicast_packet-dest);
+   if (net_ratelimit())
+   batadv_dbg(BATADV_DBG_TT, bat_priv,
+  TTVN mismatch (old_ttvn %u new_ttvn %u)! 
Rerouting unicast packet (for %pM) to %pM\n,
+  unicast_packet-ttvn, curr_ttvn,
+  ethhdr-h_dest, unicast_packet-dest);
 
unicast_packet-ttvn = curr_ttvn;
}
-- 
1.7.9.4



Re: [B.A.T.M.A.N.] [PATCH] batman-adv: print packets re-routing on DBG_TT and ratelimit it

2012-08-24 Thread Antonio Quartulli
On Fri, Aug 24, 2012 at 06:18:42PM +0200, Antonio Quartulli wrote:
 To simplify TranslationTable debugging it is better to print the packet
 rerouting message on the DBG_TT log level. In this way a developer interested 
 in
 packets rerouting doesn't need to filter it out of the whole ROUTES log.
 
 Moreover, since this message will appear for each rerouted message, it is now
 ratelimited.
 
 Signed-off-by: Antonio Quartulli or...@autistici.org

Sorry, drop this patch, I should have used net_ratelimited_function, as I told
to Martin.

Will send v2.

Cheers,


-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto Che Guevara


pgpF7daA2Skwz.pgp
Description: PGP signature


[B.A.T.M.A.N.] [PATCHv2] batman-adv: print packets re-routing on DBG_TT and ratelimit it

2012-08-24 Thread Antonio Quartulli
To simplify TranslationTable debugging it is better to print the packet
rerouting message on the DBG_TT log level. In this way a developer interested in
packets rerouting doesn't need to filter it out of the whole ROUTES log.

Moreover, since this message will appear for each rerouted message, it is now
ratelimited.

Signed-off-by: Antonio Quartulli or...@autistici.org
---

v2:
- use net_ratelimited_function() macro

 routing.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/routing.c b/routing.c
index e7a4e25..9b8ff61 100644
--- a/routing.c
+++ b/routing.c
@@ -972,10 +972,10 @@ static int batadv_check_unicast_ttvn(struct batadv_priv 
*bat_priv,
batadv_orig_node_free_ref(orig_node);
}
 
-   batadv_dbg(BATADV_DBG_ROUTES, bat_priv,
-  TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting 
unicast packet (for %pM) to %pM\n,
-  unicast_packet-ttvn, curr_ttvn, ethhdr-h_dest,
-  unicast_packet-dest);
+   net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv,
+TTVN mismatch (old_ttvn %u new_ttvn 
%u)! Rerouting unicast packet (for %pM) to %pM\n,
+unicast_packet-ttvn, curr_ttvn,
+ethhdr-h_dest, unicast_packet-dest);
 
unicast_packet-ttvn = curr_ttvn;
}
-- 
1.7.9.4



Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: print packets re-routing on DBG_TT and ratelimit it

2012-08-24 Thread Martin Hundebøll
Hi Antonio,

On Fri, 24 Aug 2012 18:32:31 +0200
Antonio Quartulli or...@autistici.org wrote:

 diff --git a/routing.c b/routing.c
 index e7a4e25..9b8ff61 100644
 --- a/routing.c
 +++ b/routing.c
 @@ -972,10 +972,10 @@ static int batadv_check_unicast_ttvn(struct
 batadv_priv *bat_priv, batadv_orig_node_free_ref(orig_node);
   }
  
 - batadv_dbg(BATADV_DBG_ROUTES, bat_priv,
 -TTVN mismatch (old_ttvn %u new_ttvn %u)!
 Rerouting unicast packet (for %pM) to %pM\n,
 -unicast_packet-ttvn, curr_ttvn,
 ethhdr-h_dest,
 -unicast_packet-dest);
 + net_ratelimited_function(batadv_dbg, BATADV_DBG_TT,
 bat_priv,

Please add net_ratelimited_function() to compat.h, since it didn't make
its way into mainline before 3.5.

// Martin


Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: Set special lockdep classes to avoid lockdep warning

2012-08-24 Thread Marek Lindner
On Monday, August 20, 2012 09:03:59 Sven Eckelmann wrote:
 Transmissions over batman-adv devices always start another nested
 transmission over devices attached to the batman-adv interface. These
 devices usually use the ethernet lockdep class for the tx_queue lock which
 is also set by default for all batman-adv devices. Lockdep will detect a
 nested locking attempt of two locks with the same class and warn about a
 possible deadlock.
 
 This is the default and expected behavior and should not alarm the locking
 correctness prove mechanism. Therefore, the locks for all netdevice
 specific tx queues get a special batman-adv lock class to avoid a false
 positive for each transmission.
 
 Reported-by: Linus Lüssing linus.luess...@web.de
 Signed-off-by: Sven Eckelmann s...@narfation.org
 ---
 * fixed comment style
 * fixed commit message
 
  soft-interface.c |   21 +
  1 file changed, 21 insertions(+)

Applied in revision e27bb6f.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [PATCHv2] batctl: Clear screen using ANSI escape codes

2012-08-24 Thread Marek Lindner
On Monday, August 20, 2012 00:08:44 Sven Eckelmann wrote:
 It is not necessary to call an external binary to clear the screen of a
 default unix terminal emulator. The external call using system(clear)
 may be used by an attacker to get untrusted code called with an higher
 privilege because batctl has to be run as using uid 0.
 
 Reported-by: Antonio Quartulli or...@autistici.org
 Signed-off-by: Sven Eckelmann s...@narfation.org
 ---
 Add comment
 
  functions.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Applied in revision f1fff52.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Remove extra check in batadv_bit_get_packet

2012-08-24 Thread Marek Lindner
On Monday, August 20, 2012 10:26:47 Sven Eckelmann wrote:
 batadv_bit_get_packet checks for all common situations before it decides
 that the new received packet indicates that the host was restarted. This
 extra condition check at the end of the function is not necessary because
 this condition is always true.
 
 This patch addresses Coverity #712296: Logically dead code
 
 Signed-off-by: Sven Eckelmann s...@narfation.org
 ---
  bitarray.c |   23 ++-
  1 file changed, 10 insertions(+), 13 deletions(-)

Applied in revision d2da57c.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [PATCHv3 2/3] batman-adv: Check return value of try_module_get

2012-08-24 Thread Marek Lindner
On Monday, August 20, 2012 23:37:26 Sven Eckelmann wrote:
 New operations should not be started when they need an increased module
 reference counter and try_module_get failed.
 
 This patch addresses Coverity #712284: Unchecked return value
 
 Signed-off-by: Sven Eckelmann s...@narfation.org
 ---
 Removed the wrapper functions
 
  debugfs.c |6 --
  icmp_socket.c |   12 
  main.c|   10 --
  main.h|2 --
  4 files changed, 12 insertions(+), 18 deletions(-)

Applied in revision 2e66c5e.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Only increase refcounter once for alternate router

2012-08-24 Thread Marek Lindner
On Monday, August 20, 2012 10:26:49 Sven Eckelmann wrote:
 The test whether we can use a router for alternating bonding should only be
 done once because it is already known that it is still usable and will not
 be deleted from the list soon.
 
 This patch addresses Coverity #712285: Unchecked return value
 
 Signed-off-by: Sven Eckelmann s...@narfation.org
 ---
  routing.c |   23 ---
  1 file changed, 8 insertions(+), 15 deletions(-)

Applied in revision 534f242.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [PATCH] batman-adv: swap lines to get in sync with networking branch

2012-08-24 Thread Marek Lindner
On Wednesday, August 22, 2012 00:40:05 Antonio Quartulli wrote:
 due to a merge conflict resolution handled differently in the networking
 branch, we now have a small divergence between our next branch and what we
 already have in net/batman-adv/ in the kernel. Since we cannot ask the
 kernel guys to swap two lines, with this patch we fix the problem in our
 repo
 
 Signed-off-by: Antonio Quartulli or...@autistici.org
 ---
 
 - this patch is for next
 
 
  soft-interface.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied in revision 28d246e.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [RFC] batman-adv: don't allow ECTP traffic on batman-adv

2012-08-24 Thread Marek Lindner
On Sunday, August 19, 2012 20:10:09 Simon Wunderlich wrote:
 We have seen this to break networks when used with bridge loop
 avoidance. As we can't see any benefit from sending these ancient frames
 via our mesh, we just drop them.
 
 Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
 ---
  soft-interface.c |   12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

Applied in revision 05d0f6d.

Thanks,
Marek


[B.A.T.M.A.N.] [PATCH 2/2] batctl: make bisect_* a compile time option

2012-08-24 Thread Marek Lindner
Signed-off-by: Marek Lindner lindner_ma...@yahoo.de
---
 Makefile |   16 +---
 main.c   |4 
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index efe57c1..9b2d3ef 100755
--- a/Makefile
+++ b/Makefile
@@ -18,9 +18,14 @@
 # 02110-1301, USA
 #
 
+# changing the CONFIG_* line to 'y' enables the related feature
+# batctl advanced debugging tool bisect:
+export CONFIG_BATCTL_BISECT=n
+
 # batctl build
 BINARY_NAME = batctl
-OBJ = main.o bat-hosts.o functions.o sys.o debug.o ping.o traceroute.o 
tcpdump.o list-batman.o hash.o vis.o debugfs.o bisect_iv.o ioctl.o
+OBJ = main.o bat-hosts.o functions.o sys.o debug.o ping.o traceroute.o 
tcpdump.o  hash.o vis.o debugfs.o ioctl.o list-batman.o
+OBJ_BISECT = bisect_iv.o
 MANPAGE = man/batctl.8
 
 # batctl flags and options
@@ -38,6 +43,11 @@ endif
 endif
 
 # standard build tools
+ifeq ($(CONFIG_BATCTL_BISECT),y)
+OBJ += $(OBJ_BISECT)
+CFLAGS += -DBATCTL_BISECT
+endif
+
 CC ?= gcc
 RM ?= rm -f
 INSTALL ?= install
@@ -70,7 +80,7 @@ $(BINARY_NAME): $(OBJ)
$(LINK.o) $^ $(LDLIBS) -o $@
 
 clean:
-   $(RM) $(BINARY_NAME) $(OBJ) $(DEP)
+   $(RM) $(BINARY_NAME) $(OBJ) $(OBJ_BISECT) $(DEP)
 
 install: $(BINARY_NAME)
$(MKDIR) $(DESTDIR)$(SBINDIR)
@@ -79,7 +89,7 @@ install: $(BINARY_NAME)
$(INSTALL) -m 0644 $(MANPAGE) $(DESTDIR)$(MANDIR)/man8
 
 # load dependencies
-DEP = $(OBJ:.o=.d)
+DEP = $(OBJ:.o=.d) $(OBJ_BISECT:.o=.d)
 -include $(DEP)
 
 .PHONY: all clean install
diff --git a/main.c b/main.c
index 390736d..01a435b 100644
--- a/main.c
+++ b/main.c
@@ -85,7 +85,9 @@ void print_usage(void)
printf( \tping|p destination \tping another 
batman adv host via layer 2\n);
printf( \ttraceroute|tr  destination \ttraceroute 
another batman adv host via layer 2\n);
printf( \ttcpdump|td interface   \ttcpdump layer 
2 traffic on the given interface\n);
+#ifdef BATCTL_BISECT
printf( \tbisect_iv  file1 .. fileN\tanalyze given 
batman iv log files for routing stability\n);
+#endif
 }
 
 int main(int argc, char **argv)
@@ -172,9 +174,11 @@ int main(int argc, char **argv)
 
ret = ioctl_statistics_get(mesh_iface);
 
+#ifdef BATCTL_BISECT
} else if ((strcmp(argv[1], bisect_iv) == 0)) {
 
ret = bisect_iv(argc - 1, argv + 1);
+#endif
 
} else {
 
-- 
1.7.9.1