[B.A.T.M.A.N.] [PATCH] batctl: tcpdump - display new not_best_hop_flag when parsing OGMs

2012-03-16 Thread Marek Lindner
Signed-off-by: Marek Lindner 
---
 tcpdump.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tcpdump.c b/tcpdump.c
index 771e4f0..72c9cf1 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -331,10 +331,11 @@ static void dump_batman_iv_ogm(unsigned char 
*packet_buff, ssize_t buff_len, int
printf("BAT %s: ",
   get_name_by_macaddr((struct ether_addr 
*)batman_ogm_packet->orig, read_opt));
 
-   printf("OGM IV via neigh %s, seq %u, tq %3d, ttvn %d, ttcrc %hu, ttl 
%2d, v %d, flags [%c%c%c%c], length %zu\n",
+   printf("OGM IV via neigh %s, seq %u, tq %3d, ttvn %d, ttcrc %hu, ttl 
%2d, v %d, flags [%c%c%c%c%c], length %zu\n",
   get_name_by_macaddr((struct ether_addr 
*)ether_header->ether_shost, read_opt),
   ntohl(batman_ogm_packet->seqno), batman_ogm_packet->tq, 
batman_ogm_packet->ttvn,
   ntohs(batman_ogm_packet->tt_crc), batman_ogm_packet->header.ttl, 
batman_ogm_packet->header.version,
+  (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP ? 'N' : '.'),
   (batman_ogm_packet->flags & DIRECTLINK ? 'D' : '.'),
   (batman_ogm_packet->flags & VIS_SERVER ? 'V' : '.'),
   (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP ? 'F' : '.'),
-- 
1.7.9.1



Re: [B.A.T.M.A.N.] Meshlinux Download Link - Error 404

2012-03-16 Thread Marek Lindner
On Saturday, March 17, 2012 01:51:15 Elektra wrote:
> the wiki already stated quite clearly that this project is old, outdated
> and unmaintained. The only "new" development is that the link to
> http://zolder.scii.nl/~elektra is broken.  
> 
> http://wiki.c-base.org/coredump/MeshLinux still works and has the ISO
> image.
> 
> The wiki now reads as follows:
>
> [..]

Ok, thanks!

Regards,
Marek


Re: [B.A.T.M.A.N.] Meshlinux Download Link - Error 404

2012-03-16 Thread Austin Williamson
Elektra  writes:

> 
> Hello Austin -
> 
> > I was about to grab a copy of meshlinux for my community's project
> > when I ran straight into 404. I also checked web.archive.org, but no
> > copies were stored. If you happen to have a copy, let me know: I
> > really could use it.
> 
> I'm sorry, the project hasn't been updated in a long time. It is unlikely 
that I will take up development on it
> again. I'd recommend to use OpenWrt for X86.
> 
> Cheers,
> Elektra
> 
> 


Sorry to hear that the project's dead. Do you know how difficult it would be to 
spin a Debian remix similar to the now defunct meshlinux?ed



Re: [B.A.T.M.A.N.] Meshlinux Download Link - Error 404

2012-03-16 Thread Elektra
Hi -

the wiki already stated quite clearly that this project is old, outdated and 
unmaintained. The only "new" development is that the link to 
http://zolder.scii.nl/~elektra is broken.  

http://wiki.c-base.org/coredump/MeshLinux still works and has the ISO image.

The wiki now reads as follows:

MeshLinux

Meshlinux is outdated and really old. The project hasn't been updated in a long 
time. It is unlikely that anyone will take up development on it again. We 
recommend to use OpenWrt for X86 platform.  The only purpose we can think of 
today is software archaeology or the use of very old legacy WiFi hardware.

Nothing is as outdated as old software. Meshlinux was created in the early days 
of mesh networking at the Freifunk community in 2004. It is a CD-Image that can 
be used to convert old PCs into wireless supernodes. There is a old Meshlinux 
version based on Linux (Kernel 2.4.26) available at 
(http://wiki.c-base.org/coredump/MeshLinux)
This old version is based on Slackware and not maintained anymore. However it 
works nicely with old Atmel USB wireless devices (which is a problem nowadays 
with recent kernels), Prism-based Chipsets and Orinoco. But you won't find any 
modern mesh routing protocol implementations in it. If you want to build a 
meshrouter with nothing better than a 486 CPU and this kind of old wireless 
devices because you have them lying around and want to do something useful with 
it, you may still use it and install a recent version of Layer 3 B.A.T.M.A.N. - 
you can download a statically compiled version from this server. You can not 
use Batman-advanced, since this would require a recent Linux kernel. Some 
userland mesh protocol daemons like OLSR might still work with it.

Sooner or later this information will be removed. 



Cheers,
Elektra



[B.A.T.M.A.N.] [PATCHv2] batman-adv: improve unicast packet (re)routing

2012-03-16 Thread Antonio Quartulli
In case of a client X roaming from a generic node A to another node B, it is
possible that a third node C gets A's OGM but not B's. At this point in time, if
C wants to send data to X it will send a unicast packet destined to A. The
packet header will contain A's last ttvn (C got A's OGM and so it knows it).

The packet will travel towards A without being intercepted because the ttvn
contained in its header is the newest for A.

Once A will receive the packet, A's state will not report to be in a "roaming
phase" (because, after a roaming, once A sends out its OGM, all the changes are
committed and the node is considered not to be in the roaming state anymore)
and it will match the ttvn carried by the packet. Therefore there is no reason
for A to try to alter the packet's route, thus dropping the packet because the
destination client is not there anymore.

However, C is well aware that it's routing information towards the client X is
outdated as it received an OGM from A saying that the client roamed away.
Thanks to this detail, this patch introduces a small change in behaviour: as
long as C is in the state of not knowing the new location of client X it will
forward the traffic to its last known location using ttvn-1 of the destination.
By using an older ttvn node A will be forced to re-route the packet.
Intermediate nodes are also allowed to update the packet's destination as long
as they have the information about the client's new location.

Signed-off-by: Antonio Quartulli 
---

- split a wrong two line assignment.

 routing.c   |6 ++
 translation-table.c |   18 ++
 translation-table.h |2 ++
 unicast.c   |8 
 4 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/routing.c b/routing.c
index 576ffb1..0950c53 100644
--- a/routing.c
+++ b/routing.c
@@ -922,6 +922,12 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
 
ethhdr = (struct ethhdr *)(skb->data +
sizeof(struct unicast_packet));
+
+   /* we don't have an updated route for this client, so we should
+* not try to reroute the packet!! */
+   if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
+   return 1;
+
orig_node = transtable_search(bat_priv, NULL, ethhdr->h_dest);
 
if (!orig_node) {
diff --git a/translation-table.c b/translation-table.c
index b4a070f..945de07 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -2113,3 +2113,21 @@ request_table:
}
}
 }
+
+/* returns true whether we know that the client has moved from its old
+ * originator to another one. This entry is kept is still kept for consistency
+ * purposes */
+bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr)
+{
+   bool ret = false;
+   struct tt_global_entry *tt_global_entry;
+   tt_global_entry = tt_global_hash_find(bat_priv, addr);
+
+   if (!tt_global_entry)
+   goto out;
+
+   ret = tt_global_entry->common.flags & TT_CLIENT_ROAM;
+   tt_global_entry_free_ref(tt_global_entry);
+out:
+   return ret;
+}
diff --git a/translation-table.h b/translation-table.h
index 593d1b3..c43374d 100644
--- a/translation-table.h
+++ b/translation-table.h
@@ -53,5 +53,7 @@ bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, 
uint8_t *dst);
 void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
const unsigned char *tt_buff, uint8_t tt_num_changes,
uint8_t ttvn, uint16_t tt_crc);
+bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr);
+
 
 #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
diff --git a/unicast.c b/unicast.c
index 2d61e54..63ab35b 100644
--- a/unicast.c
+++ b/unicast.c
@@ -392,6 +392,14 @@ find_router:
}
 
unicast_packet = (struct unicast_packet *)skb->data;
+
+   /* inform the destination ode that we are still missing a correct route
+* for this client. The destination will receive this packet and will
+* try to reroute it because the ttvn contained in the header is less
+* than the current one */
+   if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
+   unicast_packet->ttvn = unicast_packet->ttvn - 1;
+
/* fragmentation mechanism only works for UNICAST (now) */
if (packet_type == BAT_UNICAST &&
atomic_read(&bat_priv->fragmentation) &&
-- 
1.7.3.4



Re: [B.A.T.M.A.N.] Meshlinux Download Link - Error 404

2012-03-16 Thread Marek Lindner

Elektra,

> > I was about to grab a copy of meshlinux for my community's project
> > when I ran straight into 404. I also checked web.archive.org, but no
> > copies were stored. If you happen to have a copy, let me know: I
> > really could use it.
> 
> I'm sorry, the project hasn't been updated in a long time. It is unlikely
> that I will take up development on it again. I'd recommend to use OpenWrt
> for X86.

maybe you could update the wiki with that information ? It could help save 
some time for the next person.  :)

Cheers,
Marek
 


Re: [B.A.T.M.A.N.] Meshlinux Download Link - Error 404

2012-03-16 Thread Elektra
Hello Austin -
 
> I was about to grab a copy of meshlinux for my community's project
> when I ran straight into 404. I also checked web.archive.org, but no
> copies were stored. If you happen to have a copy, let me know: I
> really could use it.

I'm sorry, the project hasn't been updated in a long time. It is unlikely that 
I will take up development on it again. I'd recommend to use OpenWrt for X86.

Cheers,
Elektra
 


Re: [B.A.T.M.A.N.] Meshlinux Download Link - Error 404

2012-03-16 Thread Austin Williamson
Hello all,

I was about to grab a copy of meshlinux for my community's project
when I ran straight into 404. I also checked web.archive.org, but no
copies were stored. If you happen to have a copy, let me know: I
really could use it.
Thanks,
Austin


Re: [B.A.T.M.A.N.] [PATCH] batman-adv: improve unicast packet (re)routing

2012-03-16 Thread Marek Lindner
On Friday, March 16, 2012 22:58:20 Antonio Quartulli wrote:
> +/* returns true whether we know that the client has moved from its old
> + * originator to another one. This entry is kept is still kept for
> consistency + * purposes */
> +bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr)
> +{
> +   struct tt_global_entry *tt_global_entry =
> +   tt_global_hash_find(bat_priv, addr);

Unless you wish to feel David's wrath you should make this 2 lines.

Regards,
Marek


[B.A.T.M.A.N.] [PATCH] batman-adv: improve unicast packet (re)routing

2012-03-16 Thread Antonio Quartulli
In case of a client X roaming from a generic node A to another node B, it is
possible that a third node C gets A's OGM but not B's. At this point in time, if
C wants to send data to X it will send a unicast packet destined to A. The
packet header will contain A's last ttvn (C got A's OGM and so it knows it).

The packet will travel towards A without being intercepted because the ttvn
contained in its header is the newest for A.

Once A will receive the packet, A's state will not report to be in a "roaming
phase" (because, after a roaming, once A sends out its OGM, all the changes are
committed and the node is considered not to be in the roaming state anymore)
and it will match the ttvn carried by the packet. Therefore there is no reason
for A to try to alter the packet's route, thus dropping the packet because the
destination client is not there anymore.

However, C is well aware that it's routing information towards the client X is
outdated as it received an OGM from A saying that the client roamed away.
Thanks to this detail, this patch introduces a small change in behaviour: as
long as C is in the state of not knowing the new location of client X it will
forward the traffic to its last known location using ttvn-1 of the destination.
By using an older ttvn node A will be forced to re-route the packet.
Intermediate nodes are also allowed to update the packet's destination as long
as they have the information about the client's new location.

Signed-off-by: Antonio Quartulli 
---
 routing.c   |6 ++
 translation-table.c |   18 ++
 translation-table.h |2 ++
 unicast.c   |8 
 4 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/routing.c b/routing.c
index 576ffb1..0950c53 100644
--- a/routing.c
+++ b/routing.c
@@ -922,6 +922,12 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
 
ethhdr = (struct ethhdr *)(skb->data +
sizeof(struct unicast_packet));
+
+   /* we don't have an updated route for this client, so we should
+* not try to reroute the packet!! */
+   if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
+   return 1;
+
orig_node = transtable_search(bat_priv, NULL, ethhdr->h_dest);
 
if (!orig_node) {
diff --git a/translation-table.c b/translation-table.c
index b4a070f..dccf442 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -2113,3 +2113,21 @@ request_table:
}
}
 }
+
+/* returns true whether we know that the client has moved from its old
+ * originator to another one. This entry is kept is still kept for consistency
+ * purposes */
+bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr)
+{
+   struct tt_global_entry *tt_global_entry =
+   tt_global_hash_find(bat_priv, addr);
+   bool ret = false;
+
+   if (!tt_global_entry)
+   goto out;
+
+   ret = tt_global_entry->common.flags & TT_CLIENT_ROAM;
+   tt_global_entry_free_ref(tt_global_entry);
+out:
+   return ret;
+}
diff --git a/translation-table.h b/translation-table.h
index 593d1b3..c43374d 100644
--- a/translation-table.h
+++ b/translation-table.h
@@ -53,5 +53,7 @@ bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, 
uint8_t *dst);
 void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
const unsigned char *tt_buff, uint8_t tt_num_changes,
uint8_t ttvn, uint16_t tt_crc);
+bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr);
+
 
 #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
diff --git a/unicast.c b/unicast.c
index 2d61e54..63ab35b 100644
--- a/unicast.c
+++ b/unicast.c
@@ -392,6 +392,14 @@ find_router:
}
 
unicast_packet = (struct unicast_packet *)skb->data;
+
+   /* inform the destination ode that we are still missing a correct route
+* for this client. The destination will receive this packet and will
+* try to reroute it because the ttvn contained in the header is less
+* than the current one */
+   if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
+   unicast_packet->ttvn = unicast_packet->ttvn - 1;
+
/* fragmentation mechanism only works for UNICAST (now) */
if (packet_type == BAT_UNICAST &&
atomic_read(&bat_priv->fragmentation) &&
-- 
1.7.3.4



[B.A.T.M.A.N.] [PATCH] batman-adv: avoid skb_linearise() if not needed

2012-03-16 Thread Antonio Quartulli
Whenever we want to access headers only, we do not need to linearise the whole
packet. Instead we can use pskb_may_pull()

Signed-off-by: Antonio Quartulli 
---
 routing.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/routing.c b/routing.c
index 962a315..576ffb1 100644
--- a/routing.c
+++ b/routing.c
@@ -915,8 +915,9 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
 
/* Check whether I have to reroute the packet */
if (seq_before(unicast_packet->ttvn, curr_ttvn) || tt_poss_change) {
-   /* Linearize the skb before accessing it */
-   if (skb_linearize(skb) < 0)
+   /* check if there is enough data before accessing it */
+   if (pskb_may_pull(skb, sizeof(struct unicast_packet) +
+ ETH_HLEN) < 0)
return 0;
 
ethhdr = (struct ethhdr *)(skb->data +
-- 
1.7.3.4