Re: [B.A.T.M.A.N.] linux-next: build failure after merge of the net-next tree

2013-04-19 Thread Antonio Quartulli
Hi Stephen,

On Fri, Apr 19, 2013 at 01:21:27PM +1000, Stephen Rothwell wrote:
 
 Caused by commits 612d2b4fe0a1 (batman-adv: network coding - save
 overheard and tx packets for decoding) and 2df5278b0267 (batman-adv:
 network coding - receive coded packets and decode them) from the
 net-next tree interacting with commit fe8a93b95145 (batman-adv: make
 is_my_mac() check for the current mesh only) from the net tree.
 
 I added the following merge fix patch and can carry it as necessary:


thank you very much for taking care of this.
However, as I wrote to David in the pull request which generated this noise
(http://patchwork.ozlabs.org/patch/237363/), I am now going to send a second
pull request which fixes this problem properly and adds the related kernel doc.

Your patch looks good, but I'd prefer to send my already prepared pull request.

Is it ok with you?

Cheers,




-- 
Antonio Quartulli

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


signature.asc
Description: Digital signature


[B.A.T.M.A.N.] batman-adv merge-conflict

2013-04-19 Thread Antonio Quartulli
Hi David,

here are the instructions to resolve the conflicts you will get while merging
net into net-next.


In net/batman-adv/routing.c

++ HEAD
 +static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size)
++===
+ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
+  struct sk_buff *skb, int hdr_size)
++ maint

Resolves as:
/**
 * batadv_check_unicast_packet - Check for malformed unicast packets
 * @skb: packet to check
 * @hdr_size: size of header to pull
 *
 * Check for short header and bad addresses in given packet. Returns negative
 * value when check fails and 0 otherwise. The negative value depends on the
 * reason: -ENODATA for bad header, -EBADR for broadcast destination or source,
 * and -EREMOTE for non-local (other host) destination.
 */
static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
   struct sk_buff *skb, int hdr_size)
===

++ HEAD
 +  if (!batadv_is_my_mac(ethhdr-h_dest))
 +  return -EREMOTE;
++===
+   if (!batadv_is_my_mac(bat_priv, ethhdr-h_dest))
+   return -1;
++ maint

Resolves as:
if (!batadv_is_my_mac(bat_priv, ethhdr-h_dest))
return -EREMOTE;
===

++ HEAD
 +  /* function returns -EREMOTE for promiscuous packets */
 +  check = batadv_check_unicast_packet(skb, hdr_size);
 +
 +  /* Even though the packet is not for us, we might save it to use for
 +   * decoding a later received coded packet
 +   */
 +  if (check == -EREMOTE)
 +  batadv_nc_skb_store_sniffed_unicast(bat_priv, skb);
 +
 +  if (check  0)
++===
+   if (batadv_check_unicast_packet(bat_priv, skb, hdr_size)  0)
++ maint

Resolves as:
/* function returns -EREMOTE for promiscuous packets */
check = batadv_check_unicast_packet(bat_priv, skb, hdr_size);

/* Even though the packet is not for us, we might save it to use for
 * decoding a later received coded packet
 */
if (check == -EREMOTE)
batadv_nc_skb_store_sniffed_unicast(bat_priv, skb);

if (check  0)
===


I'm now going to send a pull request to fix some compile issues generated by the
merge.


Cheers,


-- 
Antonio Quartulli

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


signature.asc
Description: Digital signature


Re: [B.A.T.M.A.N.] linux-next: build failure after merge of the net-next tree

2013-04-19 Thread Stephen Rothwell
Hi Antonio,

On Fri, 19 Apr 2013 09:34:09 +0200 Antonio Quartulli or...@autistici.org 
wrote:

 Your patch looks good, but I'd prefer to send my already prepared pull 
 request.
 
 Is it ok with you?

Its entirely up to Dave how/if he fixes this up.  He could just leave it
to Linus, though he would usually pull the net tree into the net-next
tree after Linus merges the net tree - in which case, this should be
fixed in that merge.

i.e. ask Dave :-)
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgphdizI93oI_.pgp
Description: PGP signature


[B.A.T.M.A.N.] [PATCH] batman-adv: remove useless newline

2013-04-19 Thread Antonio Quartulli
Signed-off-by: Antonio Quartulli or...@autistici.org
---
 network-coding.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/network-coding.c b/network-coding.c
index 4eb49fc..f7c5430 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -1504,8 +1504,7 @@ void batadv_nc_skb_store_sniffed_unicast(struct 
batadv_priv *bat_priv,
  * in case of an error.
  */
 static struct batadv_unicast_packet *
-batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv,
-   struct sk_buff *skb,
+batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
struct batadv_nc_packet *nc_packet)
 {
const int h_size = sizeof(struct batadv_unicast_packet);
-- 
1.8.1.5



[B.A.T.M.A.N.] [PATCH net-next 0/2] batman-adv: fixes for net-next

2013-04-19 Thread Antonio Quartulli
Hello David,

here you have two fixes for net-next. One is fixing the compile issues
introduced by the merge of net into net-next and one is fixing a bug in a
component existing in net-next only.


I'm not sending a pull request because I'm anticipating your merge of net into
net-next and so I don't have a base point.


I hope it is fine with you.

Thanks a lot,
Antonio


Antonio Quartulli (2):
  batman-adv: fix batadv_is_my_mac() usage
  batman-adv: fix global protection fault during soft_iface destruction

 net/batman-adv/main.c   |  6 ++
 net/batman-adv/network-coding.c | 18 ++
 net/batman-adv/routing.c|  1 +
 net/batman-adv/soft-interface.c |  7 +++
 4 files changed, 24 insertions(+), 8 deletions(-)

-- 
1.8.1.5



Re: [B.A.T.M.A.N.] [PATCH] batman-adv: remove useless newline

2013-04-19 Thread Marek Lindner
On Friday, April 19, 2013 16:56:25 Antonio Quartulli wrote:
 Signed-off-by: Antonio Quartulli or...@autistici.org
 ---
  network-coding.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

Applied in revision 7e0135e.

Thanks,
Marek


[B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary INIT_HLIST_NODE() calls

2013-04-19 Thread Linus Lüssing
There's no need to for an explicit hlist_node initialization if it is
added to a list right away, like it's the case with the
hlist_add_head()s here.

Signed-off-by: Linus Lüssing linus.luess...@web.de
---
Unmodified, reposted from: 
https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2013-March/009248.html

 bat_iv_ogm.c |2 --
 send.c   |2 --
 2 files changed, 4 deletions(-)

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 5b0a043..d07323b 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -464,8 +464,6 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char 
*packet_buff,
}
skb_reserve(forw_packet_aggr-skb, ETH_HLEN);
 
-   INIT_HLIST_NODE(forw_packet_aggr-list);
-
skb_buff = skb_put(forw_packet_aggr-skb, packet_len);
forw_packet_aggr-packet_len = packet_len;
memcpy(skb_buff, packet_buff, packet_len);
diff --git a/send.c b/send.c
index ed7072a..ce69f45 100644
--- a/send.c
+++ b/send.c
@@ -152,8 +152,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv 
*bat_priv,
 struct batadv_forw_packet *forw_packet,
 unsigned long send_time)
 {
-   INIT_HLIST_NODE(forw_packet-list);
-
/* add new packet to packet list */
spin_lock_bh(bat_priv-forw_bcast_list_lock);
hlist_add_head(forw_packet-list, bat_priv-forw_bcast_list);
-- 
1.7.10.4



Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: pass a 16bit long flag argument to tt_global_add()

2013-04-19 Thread Marek Lindner
On Thursday, April 18, 2013 21:13:01 Antonio Quartulli wrote:
 it may be the case that we want to store some local TT client flags in a
 global entry, therefore the tt_global_add needs to get a proper argument
 for this
 
 Signed-off-by: Antonio Quartulli or...@autistici.org
 ---
 
 v2:
 - add tt_global_add() kernel doc
 
  translation-table.c | 19 +--
  translation-table.h |  2 +-
  2 files changed, 18 insertions(+), 3 deletions(-)

Applied with minor rewording in revision 0ff0af1.

Cheers,
Marek


Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary INIT_HLIST_NODE() calls

2013-04-19 Thread Marek Lindner
On Friday, April 19, 2013 18:06:56 Linus Lüssing wrote:
 There's no need to for an explicit hlist_node initialization if it is
 added to a list right away, like it's the case with the
 hlist_add_head()s here.
 
 Signed-off-by: Linus Lüssing linus.luess...@web.de
 ---
 Unmodified, reposted from:
 https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2013-March/009248.html
 
  bat_iv_ogm.c |2 --
  send.c   |2 --
  2 files changed, 4 deletions(-)

Applied in revision 68a3373.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [PATCH repost] batman-adv: schedule global entry removal earlier

2013-04-19 Thread Marek Lindner
On Thursday, April 18, 2013 21:20:55 Antonio Quartulli wrote:
 Instead of scheduling the global entry removals in
 batadv_orig_node_free_rcu() (which would result in
 scheduling other RCU callbacks for the next RCU period),
 do it in batadv_orig_node_free_ref() directly.
 
 In this way all the callbacks get scheduled in one RCU
 period.
 
 CC: Linus Lüssing linus.luess...@web.de
 CC: Simon Wunderlich s...@hrz.tu-chemnitz.de
 CC: Marek Lindner lindner_ma...@yahoo.de
 Signed-off-by: Antonio Quartulli or...@autistici.org
 ---
  originator.c | 12 +---
  1 file changed, 9 insertions(+), 3 deletions(-)

I'd rather see a cleaner solution instead making the less than ideal 
situation worse.

Cheers,
Marek


Re: [B.A.T.M.A.N.] [PATCH] batman-adv: do not print orig nodes without nc neighbors on nc table print

2013-04-19 Thread Marek Lindner
On Thursday, April 18, 2013 04:56:03 Marek Lindner wrote:
 Signed-off-by: Marek Lindner lindner_ma...@yahoo.de
 ---
  network-coding.c |7 +++
  1 file changed, 7 insertions(+)

Applied in revision 7b6b29f.

Regards,
Marek


[B.A.T.M.A.N.] [PATCHv4] batman-adv: Move call to batadv_nc_skb_forward() from routing.c to send.c

2013-04-19 Thread Martin Hundebøll
The call to batadv_nc_skb_forward() fits better in
batadv_send_skb_to_orig(), as this is where the actual next hop is
looked up.

Signed-off-by: Martin Hundebøll mar...@hundeboll.net
---

v2: I should make random defines lowercase :)
v3: Do git add before committing and sending patches :|
v4: Don't count non-coded packets twice

network-coding.c | 8 ++--
 network-coding.h | 6 ++
 routing.c| 9 +++--
 send.c   | 9 +++--
 4 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/network-coding.c b/network-coding.c
index c93df9e..3435729 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -542,9 +542,6 @@ static bool batadv_nc_fwd_flush(struct batadv_priv 
*bat_priv,
return false;
 
/* Send packet */
-   batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
-   batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
-  nc_packet-skb-len + ETH_HLEN);
list_del(nc_packet-list);
batadv_nc_send_packet(nc_packet);
 
@@ -1359,18 +1356,17 @@ static bool batadv_nc_skb_add_to_path(struct sk_buff 
*skb,
  *  buffer
  * @skb: data skb to forward
  * @neigh_node: next hop to forward packet to
- * @ethhdr: pointer to the ethernet header inside the skb
  *
  * Returns true if the skb was consumed (encoded packet sent) or false 
otherwise
  */
 bool batadv_nc_skb_forward(struct sk_buff *skb,
-  struct batadv_neigh_node *neigh_node,
-  struct ethhdr *ethhdr)
+  struct batadv_neigh_node *neigh_node)
 {
const struct net_device *netdev = neigh_node-if_incoming-soft_iface;
struct batadv_priv *bat_priv = netdev_priv(netdev);
struct batadv_unicast_packet *packet;
struct batadv_nc_path *nc_path;
+   struct ethhdr *ethhdr = eth_hdr(skb);
__be32 packet_id;
u8 *payload;
 
diff --git a/network-coding.h b/network-coding.h
index 4fa6d0c..85a4ec8 100644
--- a/network-coding.h
+++ b/network-coding.h
@@ -36,8 +36,7 @@ void batadv_nc_purge_orig(struct batadv_priv *bat_priv,
 void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv);
 void batadv_nc_init_orig(struct batadv_orig_node *orig_node);
 bool batadv_nc_skb_forward(struct sk_buff *skb,
-  struct batadv_neigh_node *neigh_node,
-  struct ethhdr *ethhdr);
+  struct batadv_neigh_node *neigh_node);
 void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
  struct sk_buff *skb);
 void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv,
@@ -87,8 +86,7 @@ static inline void batadv_nc_init_orig(struct 
batadv_orig_node *orig_node)
 }
 
 static inline bool batadv_nc_skb_forward(struct sk_buff *skb,
-struct batadv_neigh_node *neigh_node,
-struct ethhdr *ethhdr)
+struct batadv_neigh_node *neigh_node)
 {
return false;
 }
diff --git a/routing.c b/routing.c
index 0e10720..19cf8b6 100644
--- a/routing.c
+++ b/routing.c
@@ -835,16 +835,13 @@ static int batadv_route_unicast_packet(struct sk_buff 
*skb,
/* decrement ttl */
unicast_packet-header.ttl--;
 
-   /* network code packet if possible */
-   if (batadv_nc_skb_forward(skb, neigh_node, ethhdr)) {
-   ret = NET_RX_SUCCESS;
-   } else if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
-   ret = NET_RX_SUCCESS;
-
+   if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) {
/* Update stats counter */
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
   skb-len + ETH_HLEN);
+
+   ret = NET_RX_SUCCESS;
}
 
 out:
diff --git a/send.c b/send.c
index ed7072a..fa8077a 100644
--- a/send.c
+++ b/send.c
@@ -110,8 +110,13 @@ bool batadv_send_skb_to_orig(struct sk_buff *skb,
if (!neigh_node)
return false;
 
-   /* route it */
-   batadv_send_skb_packet(skb, neigh_node-if_incoming, neigh_node-addr);
+   /* try to network code the packet, if it is received on an interface
+* (i.e. being forwarded). If the packet originates from this node or if
+* network coding fails, then send the packet as usual.
+*/
+   if (!recv_if || !batadv_nc_skb_forward(skb, neigh_node))
+   batadv_send_skb_packet(skb, neigh_node-if_incoming, 
+  neigh_node-addr);
 
batadv_neigh_node_free_ref(neigh_node);
 
-- 
1.8.2.1



Re: [B.A.T.M.A.N.] [RFCv3] batman-adv: Modified DAT structures and functions in order to support both IPv4 and IPv6

2013-04-19 Thread Antonio Quartulli
Hi Mihail,

On Mon, Apr 15, 2013 at 12:37:33PM +0300, Mihail Costea wrote:

[...]

 
 +#ifdef CONFIG_BATMAN_ADV_DEBUG
 +
 +#if IS_ENABLED(CONFIG_IPV6)
 +
 +/* batadv_dat_dbg_ip - print similar debug message for IPv4 and IPv6.
 + * @bat_priv: the bat priv with all the soft interface information
 + * @ip_type: IPv4 / IPv6 address
 + * @format_prefix: format before IP field
 + * @format_suffix: format after IP field
 + *
 + * At list one variable parameter should be the IP itself, and it should
 + * be placed correctly based on format prefix and format suffix arguments.
 + */
 +#define batadv_dat_dbg_ip(bat_priv, ip_type, format_prefix, \
 +  format_suffix, ...) \
 + { \
 + switch (ip_type) { \
 + case BATADV_DAT_IPV4: \
 + batadv_dbg(BATADV_DBG_DAT, bat_priv, \
 +   format_prefix %pI4 format_suffix, \
 +   __VA_ARGS__); \
 + break; \
 + case BATADV_DAT_IPV6: \
 + batadv_dbg(BATADV_DBG_DAT, bat_priv, \
 +   format_prefix %pI6c format_suffix, \
 +   __VA_ARGS__); \
 + break; \
 + } \
 + }

I think this define is pretty overkill..What about creating a function which
only takes care of converting a generic DHT data in a string. Later you can
invoke this function when you want to print an IPv4/6 using batadv_dbg.

Here is an example:

char *batadv_dat_data_to_str(struct batadv_dat_entry *dat_entry,
 const char *buf, size_t buf_len)
{
/* do something and put the string representation of the entry in the
 * buf, without exceeding buf_len.
 * Remember to use IS_ENABLED(CONFIG_IPV6) inside
 */


return buf;
}

Then you can call it directly as parameter of a batdv_dbg function. E.g:

batadv_dbg(, %s\n, batadv_dat_data_to_str(entry, buf, buf_len));

I think this approach would be better and easy to extend for future data types.
If you like this approach, what do you think about sending a patch now to add
this function to the current code?

 +
  static void batadv_dat_purge(struct work_struct *work);
 
  /**
 @@ -45,6 +101,19 @@ static void batadv_dat_start_timer(struct
 batadv_priv *bat_priv)
  }
 
  /**
 + * batadv_dat_entry_free_ref_rcu - free a dat entry using its rcu
 + * @rcu: the dat entry rcu
 + */
 +static void batadv_dat_entry_free_ref_rcu(struct rcu_head *rcu)
 +{
 + struct batadv_dat_entry *dat_entry;
 +
 + dat_entry = container_of(rcu, struct batadv_dat_entry, rcu);
 + kfree(dat_entry-data);
 + kfree(dat_entry);
 +}
 +
 +/**
   * batadv_dat_entry_free_ref - decrement the dat_entry refcounter and 
 possibly
   * free it
   * @dat_entry: the entry to free
 @@ -52,7 +121,7 @@ static void batadv_dat_start_timer(struct
 batadv_priv *bat_priv)
  static void batadv_dat_entry_free_ref(struct batadv_dat_entry *dat_entry)
  {
   if (atomic_dec_and_test(dat_entry-refcount))
 - kfree_rcu(dat_entry, rcu);
 + call_rcu(dat_entry-rcu, batadv_dat_entry_free_ref_rcu);
  }
 
  /**
 @@ -130,6 +199,26 @@ static void batadv_dat_purge(struct work_struct *work)
  }
 
  /**
 + * batadv_sizeof_ip - get sizeof IP based on its type (IPv4 / IPv6)
 + * @ip_type: type of IP address
 + *
 + * Returns sizeof IP, or sizeof IPv4 if ip_type is invalid.
 + */
 +static size_t batadv_sizeof_ip(uint8_t ip_type)
 +{
 + switch (ip_type) {
 + case BATADV_DAT_IPV4:
 + return sizeof(__be32);
 +#if IS_ENABLED(CONFIG_IPV6)
 + case BATADV_DAT_IPV6:
 + return sizeof(struct in6_addr);
 +#endif
 + default:
 + return sizeof(__be32); /* fallback to IPv4 */
 + }
 +}

Either you mail client killed the tabs or this switch is not indented properly.
Also, do you think it would be better to return 0 in case of unknown type? In
this way we prevent any further operation on the data buffer.

 +
 +/**
   * batadv_compare_dat - comparing function used in the local DAT hash table
   * @node: node in the local table
   * @data2: second object to compare the node to
 @@ -138,10 +227,18 @@ static void batadv_dat_purge(struct work_struct *work)
   */
  static int batadv_compare_dat(const struct hlist_node *node, const void 
 *data2)
  {
 - const void *data1 = container_of(node, struct batadv_dat_entry,
 - hash_entry);
 + struct batadv_dat_entry *dat_entry1 = container_of(node,
 + struct batadv_dat_entry, hash_entry);
 + struct batadv_dat_entry *dat_entry2 = container_of(data2,
 + struct batadv_dat_entry, data);
 + size_t ip_size;
 
 - return (memcmp(data1, data2, sizeof(__be32)) == 0 ? 1 : 0);
 + if (dat_entry1-type != dat_entry2-type)
 + return 0;
 +
 + ip_size = batadv_sizeof_ip(dat_entry1-type);
 + return (memcmp(dat_entry1-data, dat_entry2-data,
 +   ip_size) == 0 ? 1 : 0);
  }
 
  /**
 @@ -201,16 +298,19 @@ static __be32 batadv_arp_ip_dst(struct sk_buff
 *skb, int hdr_size)
   * batadv_hash_dat - compute the hash value for an IP address
   * @data: data to hash
   * @size: size of the hash table
 + * @ip_type: type of IP address
   *
   * Returns the selected index in the hash table for the given data.
   */
 -static uint32_t batadv_hash_dat(const void *data, uint32_t size)
 +static uint32_t 

[B.A.T.M.A.N.] [PATCHv3] batman-adv: use CRC32C instead of CRC16 in TT code

2013-04-19 Thread Antonio Quartulli
CRC32C has to be preferred to CRC16 because of its possible
HW native support and because of its less likely probability
of collision. With this change the Translation Table
component now uses CRC32C to compute the Local and Global
Table checksum.

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

v3:
- added kernel doc

 packet.h|  4 +--
 translation-table.c | 71 -
 types.h |  4 +--
 3 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/packet.h b/packet.h
index 27424e1..e24daa6 100644
--- a/packet.h
+++ b/packet.h
@@ -360,12 +360,12 @@ struct batadv_tvlv_long {
  * struct tvlv_tt_data - tt data propagated through the tt tvlv container
  * @flags: translation table flags (see batadv_tt_data_flags)
  * @ttvn: translation table version number
- * @crc: crc16 checksum of the local translation table
+ * @crc: crc32 checksum of the local translation table
  */
 struct batadv_tvlv_tt_data {
uint8_t flags;
uint8_t ttvn;
-   __be16  crc;
+   __be32  crc;
 };
 
 /**
diff --git a/translation-table.c b/translation-table.c
index 76aef1a..5545f55 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -27,7 +27,7 @@
 #include routing.h
 #include bridge_loop_avoidance.h
 
-#include linux/crc16.h
+#include linux/crc32c.h
 
 /* hash class keys */
 static struct lock_class_key batadv_tt_local_hash_lock_class_key;
@@ -409,7 +409,7 @@ static void batadv_tt_tvlv_container_update(struct 
batadv_priv *bat_priv)
 
tt_data-flags = BATADV_TT_OGM_DIFF;
tt_data-ttvn = atomic_read(bat_priv-tt.vn);
-   tt_data-crc = htons(bat_priv-tt.local_crc);
+   tt_data-crc = htonl(bat_priv-tt.local_crc);
 
if (tt_diff_len == 0)
goto container_register;
@@ -481,7 +481,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, 
void *offset)
goto out;
 
seq_printf(seq,
-  Locally retrieved addresses (from %s) announced via TT 
(TTVN: %u CRC: %#.4x):\n,
+  Locally retrieved addresses (from %s) announced via TT 
(TTVN: %u CRC: %#.8x):\n,
   net_dev-name, (uint8_t)atomic_read(bat_priv-tt.vn),
   bat_priv-tt.local_crc);
seq_printf(seq,%-13s %-7s %-10s\n, Client, Flags,
@@ -978,7 +978,7 @@ batadv_tt_global_print_entry(struct batadv_tt_global_entry 
*tt_global_entry,
if (best_entry) {
last_ttvn = atomic_read(best_entry-orig_node-last_ttvn);
seq_printf(seq,
-   %c %pM  (%3u) via %pM (%3u)   (%#.4x) 
[%c%c%c]\n,
+   %c %pM  (%3u) via %pM (%3u)   (%#.8x) 
[%c%c%c]\n,
   '*', tt_global_entry-common.addr,
   best_entry-ttvn, best_entry-orig_node-orig,
   last_ttvn, best_entry-orig_node-tt_crc,
@@ -1022,7 +1022,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, 
void *offset)
seq_printf(seq,
   Globally announced TT entries received via the mesh %s\n,
   net_dev-name);
-   seq_printf(seq,%-13s %s   %-15s %s (%-6s) %s\n,
+   seq_printf(seq,%-13s %s   %-15s %s (%-10s) %s\n,
   Client, (TTVN), Originator, (Curr TTVN), CRC,
   Flags);
 
@@ -1379,17 +1379,19 @@ out:
return orig_node;
 }
 
-/* Calculates the checksum of the local table of a given orig_node */
-static uint16_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
+/**
+ * batadv_tt_global_crc - calculates the checksum of the local table of a
+ * given orig_node
+ * @bat_priv: the bat priv with all the soft interface information
+ */
+static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 struct batadv_orig_node *orig_node)
 {
-   uint16_t total = 0, total_one;
struct batadv_hashtable *hash = bat_priv-tt.global_hash;
struct batadv_tt_common_entry *tt_common;
struct batadv_tt_global_entry *tt_global;
struct hlist_head *head;
-   uint32_t i;
-   int j;
+   uint32_t i, crc = 0;
 
for (i = 0; i  hash-size; i++) {
head = hash-table[i];
@@ -1420,27 +1422,24 @@ static uint16_t batadv_tt_global_crc(struct batadv_priv 
*bat_priv,
 orig_node))
continue;
 
-   total_one = 0;
-   for (j = 0; j  ETH_ALEN; j++)
-   total_one = crc16_byte(total_one,
-  tt_common-addr[j]);
-   total ^= total_one;
+   crc ^= crc32c(0, tt_common-addr, ETH_ALEN);
}
rcu_read_unlock();
}
 
-   return total;
+   return crc;
 }
 
-/* Calculates the checksum of the 

Re: [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: print the VID properly

2013-04-19 Thread Simon Wunderlich
On Thu, Apr 18, 2013 at 03:43:47PM +0200, Antonio Quartulli wrote:
 From: Antonio Quartulli anto...@open-mesh.com
 
 Since the MSB bits of any vid variable are now used for
 storing flags, print the vid properly by taking the flags
 away and printing -1 in case of VID representing no real
 VLAN.
 
 Signed-off-by: Antonio Quartulli anto...@open-mesh.com
 ---
  bridge_loop_avoidance.c | 57 
 ++---
  main.h  |  2 ++
  2 files changed, 32 insertions(+), 27 deletions(-)
 
 diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
 index 16f9239..24a62ac 100644
 --- a/bridge_loop_avoidance.c
 +++ b/bridge_loop_avoidance.c
 @@ -307,7 +307,8 @@ static void batadv_bla_send_claim(struct batadv_priv 
 *bat_priv, uint8_t *mac,
*/
   memcpy(ethhdr-h_source, mac, ETH_ALEN);
   batadv_dbg(BATADV_DBG_BLA, bat_priv,
 -bla_send_claim(): CLAIM %pM on vid %hu\n, mac, 
 vid);
 +bla_send_claim(): CLAIM %pM on vid %hd\n, mac,
 +BATADV_PRINT_VID(vid));

You've changed all these strings from %d into %hu and now back to %hd? Why not 
just leave everything
at %d and reduce the bloat of these patches? It should not hurt anyone - yes, 
printing -1 is not pretty
but this is developer debug info anyway. And keeping %d instead of %hd should 
not be a problem as far
as I understand.

Apart from that, using the BATADV_PRINT_VID macro is a good idea IMHO.

Cheers,
Simon


signature.asc
Description: Digital signature


Re: [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: print the VID properly

2013-04-19 Thread Antonio Quartulli
On Fri, Apr 19, 2013 at 03:12:47PM +0200, Simon Wunderlich wrote:
 On Thu, Apr 18, 2013 at 03:43:47PM +0200, Antonio Quartulli wrote:
  From: Antonio Quartulli anto...@open-mesh.com
  
  Since the MSB bits of any vid variable are now used for
  storing flags, print the vid properly by taking the flags
  away and printing -1 in case of VID representing no real
  VLAN.
  
  Signed-off-by: Antonio Quartulli anto...@open-mesh.com
  ---
   bridge_loop_avoidance.c | 57 
  ++---
   main.h  |  2 ++
   2 files changed, 32 insertions(+), 27 deletions(-)
  
  diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
  index 16f9239..24a62ac 100644
  --- a/bridge_loop_avoidance.c
  +++ b/bridge_loop_avoidance.c
  @@ -307,7 +307,8 @@ static void batadv_bla_send_claim(struct batadv_priv 
  *bat_priv, uint8_t *mac,
   */
  memcpy(ethhdr-h_source, mac, ETH_ALEN);
  batadv_dbg(BATADV_DBG_BLA, bat_priv,
  -  bla_send_claim(): CLAIM %pM on vid %hu\n, mac, 
  vid);
  +  bla_send_claim(): CLAIM %pM on vid %hd\n, mac,
  +  BATADV_PRINT_VID(vid));
 
 You've changed all these strings from %d into %hu and now back to %hd? Why 
 not just leave everything
 at %d and reduce the bloat of these patches? It should not hurt anyone - yes, 
 printing -1 is not pretty
 but this is developer debug info anyway. And keeping %d instead of %hd should 
 not be a problem as far
 as I understand.
 
 Apart from that, using the BATADV_PRINT_VID macro is a good idea IMHO.

Ok, I'll remove all the format changes and keep the %d :)

Cheers,


-- 
Antonio Quartulli

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


signature.asc
Description: Digital signature


[B.A.T.M.A.N.] [PATCHv3 1/2] batman-adv: change VID semantic in the BLA code

2013-04-19 Thread Antonio Quartulli
From: Antonio Quartulli anto...@open-mesh.com

In order to make batman-adv fully vlan aware later, the
semantic used for variables storing the VLAN ID values has
to be changed in order to be adapted to the new one which
will be used batman-adv wide.

In particular, the VID has to be an _unsigned_ short int
and its 4 MSB will be used as a flag bitfield, while the
remaining 12 bits are used to store the real VID value

Cc: Simon Wunderlich s...@hrz.tu-chemnitz.de
Signed-off-by: Antonio Quartulli anto...@open-mesh.com
---

v3:
- don't change the print format (keep %d)
- added a couple of fixes to debug messages

 bridge_loop_avoidance.c | 50 +
 bridge_loop_avoidance.h | 12 +++-
 main.h  | 11 +++
 soft-interface.c|  4 ++--
 types.h |  4 ++--
 5 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
index 0cc0c3e..d75fb80 100644
--- a/bridge_loop_avoidance.c
+++ b/bridge_loop_avoidance.c
@@ -180,7 +180,7 @@ static struct batadv_bla_claim
  */
 static struct batadv_bla_backbone_gw *
 batadv_backbone_hash_find(struct batadv_priv *bat_priv,
- uint8_t *addr, short vid)
+ uint8_t *addr, unsigned short vid)
 {
struct batadv_hashtable *hash = bat_priv-bla.backbone_hash;
struct hlist_head *head;
@@ -257,7 +257,7 @@ batadv_bla_del_backbone_claims(struct 
batadv_bla_backbone_gw *backbone_gw)
  * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...)
  */
 static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
- short vid, int claimtype)
+ unsigned short vid, int claimtype)
 {
struct sk_buff *skb;
struct ethhdr *ethhdr;
@@ -335,13 +335,13 @@ static void batadv_bla_send_claim(struct batadv_priv 
*bat_priv, uint8_t *mac,
memcpy(hw_src, mac, ETH_ALEN);
memcpy(ethhdr-h_dest, mac, ETH_ALEN);
batadv_dbg(BATADV_DBG_BLA, bat_priv,
-  bla_send_claim(): REQUEST of %pM to %pMon vid %d\n,
+  bla_send_claim(): REQUEST of %pM to %pM on vid 
%d\n,
   ethhdr-h_source, ethhdr-h_dest, vid);
break;
}
 
-   if (vid != -1)
-   skb = vlan_insert_tag(skb, vid);
+   if (vid  BATADV_VLAN_HAS_TAG)
+   skb = vlan_insert_tag(skb, vid  BATADV_VID_MASK);
 
skb_reset_mac_header(skb);
skb-protocol = eth_type_trans(skb, soft_iface);
@@ -367,7 +367,7 @@ out:
  */
 static struct batadv_bla_backbone_gw *
 batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig,
-  short vid, bool own_backbone)
+  unsigned short vid, bool own_backbone)
 {
struct batadv_bla_backbone_gw *entry;
struct batadv_orig_node *orig_node;
@@ -434,7 +434,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, 
uint8_t *orig,
 static void
 batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
  struct batadv_hard_iface *primary_if,
- short vid)
+ unsigned short vid)
 {
struct batadv_bla_backbone_gw *backbone_gw;
 
@@ -456,7 +456,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv 
*bat_priv,
  */
 static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
  struct batadv_hard_iface *primary_if,
- short vid)
+ unsigned short vid)
 {
struct hlist_head *head;
struct batadv_hashtable *hash;
@@ -547,7 +547,7 @@ static void batadv_bla_send_announce(struct batadv_priv 
*bat_priv,
  * @backbone_gw: the backbone gateway which claims it
  */
 static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
-const uint8_t *mac, const short vid,
+const uint8_t *mac, const unsigned short vid,
 struct batadv_bla_backbone_gw *backbone_gw)
 {
struct batadv_bla_claim *claim;
@@ -611,7 +611,7 @@ claim_free_ref:
  * given mac address and vid.
  */
 static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
-const uint8_t *mac, const short vid)
+const uint8_t *mac, const unsigned short vid)
 {
struct batadv_bla_claim search_claim, *claim;
 
@@ -637,7 +637,7 @@ static void batadv_bla_del_claim(struct batadv_priv 
*bat_priv,
 /* check for ANNOUNCE frame, return 1 if handled */
 static int batadv_handle_announce(struct batadv_priv *bat_priv,
  uint8_t *an_addr, uint8_t *backbone_addr,
- short vid)
+ 

[B.A.T.M.A.N.] [PATCHv3 2/2] batman-adv: print the VID properly

2013-04-19 Thread Antonio Quartulli
From: Antonio Quartulli anto...@open-mesh.com

Since the MSB bits of any vid variable are now used for
storing flags, print the vid properly by taking the flags
away and printing -1 in case of VID representing no real
VLAN.

Signed-off-by: Antonio Quartulli anto...@open-mesh.com
---
 bridge_loop_avoidance.c | 36 
 main.h  |  2 ++
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
index d75fb80..fc0f29c 100644
--- a/bridge_loop_avoidance.c
+++ b/bridge_loop_avoidance.c
@@ -307,7 +307,8 @@ static void batadv_bla_send_claim(struct batadv_priv 
*bat_priv, uint8_t *mac,
 */
memcpy(ethhdr-h_source, mac, ETH_ALEN);
batadv_dbg(BATADV_DBG_BLA, bat_priv,
-  bla_send_claim(): CLAIM %pM on vid %d\n, mac, vid);
+  bla_send_claim(): CLAIM %pM on vid %d\n, mac,
+  BATADV_PRINT_VID(vid));
break;
case BATADV_CLAIM_TYPE_UNCLAIM:
/* unclaim frame
@@ -316,7 +317,7 @@ static void batadv_bla_send_claim(struct batadv_priv 
*bat_priv, uint8_t *mac,
memcpy(hw_src, mac, ETH_ALEN);
batadv_dbg(BATADV_DBG_BLA, bat_priv,
   bla_send_claim(): UNCLAIM %pM on vid %d\n, mac,
-  vid);
+  BATADV_PRINT_VID(vid));
break;
case BATADV_CLAIM_TYPE_ANNOUNCE:
/* announcement frame
@@ -325,7 +326,7 @@ static void batadv_bla_send_claim(struct batadv_priv 
*bat_priv, uint8_t *mac,
memcpy(hw_src, mac, ETH_ALEN);
batadv_dbg(BATADV_DBG_BLA, bat_priv,
   bla_send_claim(): ANNOUNCE of %pM on vid %d\n,
-  ethhdr-h_source, vid);
+  ethhdr-h_source, BATADV_PRINT_VID(vid));
break;
case BATADV_CLAIM_TYPE_REQUEST:
/* request frame
@@ -336,7 +337,8 @@ static void batadv_bla_send_claim(struct batadv_priv 
*bat_priv, uint8_t *mac,
memcpy(ethhdr-h_dest, mac, ETH_ALEN);
batadv_dbg(BATADV_DBG_BLA, bat_priv,
   bla_send_claim(): REQUEST of %pM to %pM on vid 
%d\n,
-  ethhdr-h_source, ethhdr-h_dest, vid);
+  ethhdr-h_source, ethhdr-h_dest,
+  BATADV_PRINT_VID(vid));
break;
}
 
@@ -380,7 +382,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, 
uint8_t *orig,
 
batadv_dbg(BATADV_DBG_BLA, bat_priv,
   bla_get_backbone_gw(): not found (%pM, %d), creating new 
entry\n,
-  orig, vid);
+  orig, BATADV_PRINT_VID(vid));
 
entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry)
@@ -572,7 +574,7 @@ static void batadv_bla_add_claim(struct batadv_priv 
*bat_priv,
atomic_set(claim-refcount, 2);
batadv_dbg(BATADV_DBG_BLA, bat_priv,
   bla_add_claim(): adding new entry %pM, vid %d to 
hash ...\n,
-  mac, vid);
+  mac, BATADV_PRINT_VID(vid));
hash_added = batadv_hash_add(bat_priv-bla.claim_hash,
 batadv_compare_claim,
 batadv_choose_claim, claim,
@@ -591,7 +593,7 @@ static void batadv_bla_add_claim(struct batadv_priv 
*bat_priv,
 
batadv_dbg(BATADV_DBG_BLA, bat_priv,
   bla_add_claim(): changing ownership for %pM, vid 
%d\n,
-  mac, vid);
+  mac, BATADV_PRINT_VID(vid));
 
claim-backbone_gw-crc ^= crc16(0, claim-addr, ETH_ALEN);
batadv_backbone_gw_free_ref(claim-backbone_gw);
@@ -622,7 +624,7 @@ static void batadv_bla_del_claim(struct batadv_priv 
*bat_priv,
return;
 
batadv_dbg(BATADV_DBG_BLA, bat_priv, bla_del_claim(): %pM, vid %d\n,
-  mac, vid);
+  mac, BATADV_PRINT_VID(vid));
 
batadv_hash_remove(bat_priv-bla.claim_hash, batadv_compare_claim,
   batadv_choose_claim, claim);
@@ -658,12 +660,12 @@ static int batadv_handle_announce(struct batadv_priv 
*bat_priv,
 
batadv_dbg(BATADV_DBG_BLA, bat_priv,
   handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = 
%#.4x\n,
-  vid, backbone_gw-orig, crc);
+  BATADV_PRINT_VID(vid), backbone_gw-orig, crc);
 
if (backbone_gw-crc != crc) {
batadv_dbg(BATADV_DBG_BLA, backbone_gw-bat_priv,
   handle_announce(): CRC FAILED for %pM/%d (my = 
%#.4x, sent = %#.4x)\n,
-  backbone_gw-orig, backbone_gw-vid,
+  

Re: [B.A.T.M.A.N.] [PATCHv3 1/2] batman-adv: change VID semantic in the BLA code

2013-04-19 Thread Simon Wunderlich

On Fri, Apr 19, 2013 at 06:07:00PM +0200, Antonio Quartulli wrote:
 From: Antonio Quartulli anto...@open-mesh.com
 
 In order to make batman-adv fully vlan aware later, the
 semantic used for variables storing the VLAN ID values has
 to be changed in order to be adapted to the new one which
 will be used batman-adv wide.
 
 In particular, the VID has to be an _unsigned_ short int
 and its 4 MSB will be used as a flag bitfield, while the
 remaining 12 bits are used to store the real VID value
 
 Cc: Simon Wunderlich s...@hrz.tu-chemnitz.de
 Signed-off-by: Antonio Quartulli anto...@open-mesh.com

Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de


signature.asc
Description: Digital signature


Re: [B.A.T.M.A.N.] [PATCHv3 1/2] batman-adv: change VID semantic in the BLA code

2013-04-19 Thread Marek Lindner
On Saturday, April 20, 2013 00:07:00 Antonio Quartulli wrote:
 From: Antonio Quartulli anto...@open-mesh.com
 
 In order to make batman-adv fully vlan aware later, the
 semantic used for variables storing the VLAN ID values has
 to be changed in order to be adapted to the new one which
 will be used batman-adv wide.
 
 In particular, the VID has to be an _unsigned_ short int
 and its 4 MSB will be used as a flag bitfield, while the
 remaining 12 bits are used to store the real VID value
 
 Cc: Simon Wunderlich s...@hrz.tu-chemnitz.de
 Signed-off-by: Antonio Quartulli anto...@open-mesh.com
 ---
 
 v3:
 - don't change the print format (keep %d)
 - added a couple of fixes to debug messages
 
  bridge_loop_avoidance.c | 50
 + bridge_loop_avoidance.h
 | 12 +++-
  main.h  | 11 +++
  soft-interface.c|  4 ++--
  types.h |  4 ++--
  5 files changed, 48 insertions(+), 33 deletions(-)

Applied in revision 0b1da17.

Thanks,
Marek


Re: [B.A.T.M.A.N.] [RFCv3] batman-adv: Modified DAT structures and functions in order to support both IPv4 and IPv6

2013-04-19 Thread Mihail Costea
On 19 April 2013 15:38, Antonio Quartulli or...@autistici.org wrote:

 Hi Mihail,

 On Mon, Apr 15, 2013 at 12:37:33PM +0300, Mihail Costea wrote:

 [...]

 
  +#ifdef CONFIG_BATMAN_ADV_DEBUG
  +
  +#if IS_ENABLED(CONFIG_IPV6)
  +
  +/* batadv_dat_dbg_ip - print similar debug message for IPv4 and IPv6.
  + * @bat_priv: the bat priv with all the soft interface information
  + * @ip_type: IPv4 / IPv6 address
  + * @format_prefix: format before IP field
  + * @format_suffix: format after IP field
  + *
  + * At list one variable parameter should be the IP itself, and it should
  + * be placed correctly based on format prefix and format suffix arguments.
  + */
  +#define batadv_dat_dbg_ip(bat_priv, ip_type, format_prefix, \
  +  format_suffix, ...) \
  + { \
  + switch (ip_type) { \
  + case BATADV_DAT_IPV4: \
  + batadv_dbg(BATADV_DBG_DAT, bat_priv, \
  +   format_prefix %pI4 format_suffix, \
  +   __VA_ARGS__); \
  + break; \
  + case BATADV_DAT_IPV6: \
  + batadv_dbg(BATADV_DBG_DAT, bat_priv, \
  +   format_prefix %pI6c format_suffix, \
  +   __VA_ARGS__); \
  + break; \
  + } \
  + }

 I think this define is pretty overkill..What about creating a function which
 only takes care of converting a generic DHT data in a string. Later you can
 invoke this function when you want to print an IPv4/6 using batadv_dbg.

 Here is an example:

 char *batadv_dat_data_to_str(struct batadv_dat_entry *dat_entry,
  const char *buf, size_t buf_len)
 {
 /* do something and put the string representation of the entry in the
  * buf, without exceeding buf_len.
  * Remember to use IS_ENABLED(CONFIG_IPV6) inside
  */


 return buf;
 }

 Then you can call it directly as parameter of a batdv_dbg function. E.g:

 batadv_dbg(, %s\n, batadv_dat_data_to_str(entry, buf, buf_len));

 I think this approach would be better and easy to extend for future data 
 types.
 If you like this approach, what do you think about sending a patch now to add
 this function to the current code?


This could work. buf could be a string with a given pattern inside
(let's say %data, or something similar) that would be automatically
converted to the right type (like %pI4, or %pI6c.

  +
   static void batadv_dat_purge(struct work_struct *work);
 
   /**
  @@ -45,6 +101,19 @@ static void batadv_dat_start_timer(struct
  batadv_priv *bat_priv)
   }
 
   /**
  + * batadv_dat_entry_free_ref_rcu - free a dat entry using its rcu
  + * @rcu: the dat entry rcu
  + */
  +static void batadv_dat_entry_free_ref_rcu(struct rcu_head *rcu)
  +{
  + struct batadv_dat_entry *dat_entry;
  +
  + dat_entry = container_of(rcu, struct batadv_dat_entry, rcu);
  + kfree(dat_entry-data);
  + kfree(dat_entry);
  +}
  +
  +/**
* batadv_dat_entry_free_ref - decrement the dat_entry refcounter and 
  possibly
* free it
* @dat_entry: the entry to free
  @@ -52,7 +121,7 @@ static void batadv_dat_start_timer(struct
  batadv_priv *bat_priv)
   static void batadv_dat_entry_free_ref(struct batadv_dat_entry *dat_entry)
   {
if (atomic_dec_and_test(dat_entry-refcount))
  - kfree_rcu(dat_entry, rcu);
  + call_rcu(dat_entry-rcu, batadv_dat_entry_free_ref_rcu);
   }
 
   /**
  @@ -130,6 +199,26 @@ static void batadv_dat_purge(struct work_struct *work)
   }
 
   /**
  + * batadv_sizeof_ip - get sizeof IP based on its type (IPv4 / IPv6)
  + * @ip_type: type of IP address
  + *
  + * Returns sizeof IP, or sizeof IPv4 if ip_type is invalid.
  + */
  +static size_t batadv_sizeof_ip(uint8_t ip_type)
  +{
  + switch (ip_type) {
  + case BATADV_DAT_IPV4:
  + return sizeof(__be32);
  +#if IS_ENABLED(CONFIG_IPV6)
  + case BATADV_DAT_IPV6:
  + return sizeof(struct in6_addr);
  +#endif
  + default:
  + return sizeof(__be32); /* fallback to IPv4 */
  + }
  +}

 Either you mail client killed the tabs or this switch is not indented 
 properly.
 Also, do you think it would be better to return 0 in case of unknown type? In
 this way we prevent any further operation on the data buffer.


It might be from my gmail. Next time I will send it with git send-email. Thanks.

  +
  +/**
* batadv_compare_dat - comparing function used in the local DAT hash table
* @node: node in the local table
* @data2: second object to compare the node to
  @@ -138,10 +227,18 @@ static void batadv_dat_purge(struct work_struct *work)
*/
   static int batadv_compare_dat(const struct hlist_node *node, const void 
  *data2)
   {
  - const void *data1 = container_of(node, struct batadv_dat_entry,
  - hash_entry);
  + struct batadv_dat_entry *dat_entry1 = container_of(node,
  + struct batadv_dat_entry, hash_entry);
  + struct batadv_dat_entry *dat_entry2 = container_of(data2,
  + struct batadv_dat_entry, data);
  + size_t ip_size;
 
  - return (memcmp(data1, data2, sizeof(__be32)) == 0 ? 1 : 0);
  + if (dat_entry1-type != dat_entry2-type)
  + return 0;
  +
  + ip_size = batadv_sizeof_ip(dat_entry1-type);
  + return (memcmp(dat_entry1-data, 

Re: [B.A.T.M.A.N.] [PATCHv3 2/2] batman-adv: print the VID properly

2013-04-19 Thread Marek Lindner
On Saturday, April 20, 2013 00:07:01 Antonio Quartulli wrote:
 From: Antonio Quartulli anto...@open-mesh.com
 
 Since the MSB bits of any vid variable are now used for
 storing flags, print the vid properly by taking the flags
 away and printing -1 in case of VID representing no real
 VLAN.
 
 Signed-off-by: Antonio Quartulli anto...@open-mesh.com
 ---
  bridge_loop_avoidance.c | 36 
  main.h  |  2 ++
  2 files changed, 22 insertions(+), 16 deletions(-)

Applied in revision 454b849 after making it checkpatch clean.

Cheers,
Marek


[B.A.T.M.A.N.] [PATCH 3/3] batman-adv: remove packed from batadv_ogm_packet

2013-04-19 Thread Simon Wunderlich
As we decreased the struct size from 26 to 24 byte, we can remove
__packed as the compile will not add any more padding.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 packet.h |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/packet.h b/packet.h
index c90856d..be390ea 100644
--- a/packet.h
+++ b/packet.h
@@ -178,7 +178,10 @@ struct batadv_ogm_packet {
uint8_t  reserved;
uint8_t  tq;
__be16   tvlv_len;
-} __packed;
+   /* __packed is not needed as the struct is divisible by 4.
+* Add it again if this is ever changed again.
+*/
+};
 
 #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
 
-- 
1.7.10.4



[B.A.T.M.A.N.] [PATCH 2/3] batman-adv: reorder packet types

2013-04-19 Thread Simon Wunderlich
Reordering the packet type numbers allows us to handle unicast
packets in a general way - even if we don't know the specific packet
type, we can still forward it. There was already code handling
this for a couple of unicast packets, and this is the more
generalized version to do that.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 main.c|   28 +++-
 packet.h  |   34 +-
 routing.c |   19 +++
 routing.h |2 ++
 4 files changed, 69 insertions(+), 14 deletions(-)

diff --git a/main.c b/main.c
index a003067..5c0a8db 100644
--- a/main.c
+++ b/main.c
@@ -328,18 +328,31 @@ static void batadv_recv_handler_init(void)
for (i = 0; i  ARRAY_SIZE(batadv_rx_handler); i++)
batadv_rx_handler[i] = batadv_recv_unhandled_packet;
 
-   /* batman icmp packet */
-   batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
+   for (i = BATADV_UNICAST_MIN; i = BATADV_UNICAST_MAX; i++)
+   batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet;
+
+   /* compile time checks for struct member offsets */
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10);
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_frag_packet, dest) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
+
+   /* broadcast packet */
+   batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
+
+   /* unicast packets ... */
/* unicast with 4 addresses packet */
batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet;
/* unicast packet */
batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet;
/* fragmented unicast packet */
batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
-   /* broadcast packet */
-   batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
/* unicast tvlv packet */
batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv;
+   /* batman icmp packet */
+   batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
 }
 
 int
@@ -347,7 +360,12 @@ batadv_recv_handler_register(uint8_t packet_type,
 int (*recv_handler)(struct sk_buff *,
 struct batadv_hard_iface *))
 {
-   if (batadv_rx_handler[packet_type] != batadv_recv_unhandled_packet)
+   int (*curr)(struct sk_buff *,
+   struct batadv_hard_iface *);
+   curr = batadv_rx_handler[packet_type];
+
+   if ((curr != batadv_recv_unhandled_packet) 
+   (curr != batadv_recv_unhandled_unicast_packet))
return -EBUSY;
 
batadv_rx_handler[packet_type] = recv_handler;
diff --git a/packet.h b/packet.h
index 8ec9cf7..c90856d 100644
--- a/packet.h
+++ b/packet.h
@@ -22,18 +22,34 @@
 
 /**
  * enum batadv_packettype - types for batman-adv encapsulated packets
+ * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
+ * @BATADV_BCAST: broadcast packets carrying broadcast payload
+ * @BATADV_CODED: network coded packets
+ *
+ * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
+ * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
+ * payload packet
+ * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
+ * the sender
+ * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
  * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
+ *
  */
+
 enum batadv_packettype {
-   BATADV_IV_OGM   = 0x01,
-   BATADV_ICMP = 0x02,
-   BATADV_UNICAST  = 0x03,
-   BATADV_BCAST= 0x04,
-   BATADV_VIS  = 0x05,
-   BATADV_UNICAST_FRAG = 0x06,
-   BATADV_UNICAST_4ADDR= 0x09,
-   BATADV_CODED= 0x0a,
-   BATADV_UNICAST_TVLV = 0x0b,
+   /* 0x00 - 0x3f: local packets or special rules for handling */
+   BATADV_IV_OGM   = 0x00,
+   BATADV_BCAST= 0x01,
+   BATADV_CODED= 0x02,
+   /* 0x40 - 0x7f: unicast */
+#define BATADV_UNICAST_MIN 0x40
+   BATADV_UNICAST  = 0x40,
+   BATADV_UNICAST_FRAG = 0x41,
+   BATADV_UNICAST_4ADDR= 0x42,
+   BATADV_ICMP = 0x43,
+   BATADV_UNICAST_TVLV = 0x44,
+#define BATADV_UNICAST_MAX 0x7f
+   /* 0x80 - 0xff: reserved */
 };
 
 /**
diff --git a/routing.c b/routing.c
index d48f9f9..b63a002 100644
--- a/routing.c
+++ b/routing.c
@@ -892,6 +892,25 @@ static int batadv_check_unicast_ttvn(struct batadv_priv 
*bat_priv,
return 1;
 }
 
+int batadv_recv_unhandled_unicast_packet(struct sk_buff 

[B.A.T.M.A.N.] [PATCH 0/3] compat bump work

2013-04-19 Thread Simon Wunderlich
These are some patches for inclusion for the next compat bump:
 * remove vis server - this functionality will be provided by alfred
   and associated programs in the future and does not really belong
   to kernel space
 * reorder packet types - this allows to route future unicast packets
   even if not yet implemented
 * remove __packed from ogm packets to allow better access in compiled code 

This is based on ordex/compat_bump.

Simon Wunderlich (3):
  batman-adv: remove vis functionality
  batman-adv: reorder packet types
  batman-adv: remove packed from batadv_ogm_packet

 Makefile.kbuild  |1 -
 bat_iv_ogm.c |7 -
 debugfs.c|9 -
 hard-interface.c |9 -
 main.c   |   39 ++-
 packet.h |   56 ++--
 routing.c|   70 ++--
 routing.h|2 +
 send.c   |1 -
 soft-interface.c |1 -
 sysfs.c  |   72 -
 types.h  |   82 -
 vis.c|  935 --
 vis.h|   36 ---
 14 files changed, 73 insertions(+), 1247 deletions(-)
 delete mode 100644 vis.c
 delete mode 100644 vis.h

-- 
1.7.10.4



[B.A.T.M.A.N.] [PATCH 1/3] batman-adv: remove vis functionality

2013-04-19 Thread Simon Wunderlich
This is replaced by a userspace program, we don't need this
functionality to bloat the kernel.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 Makefile.kbuild  |1 -
 bat_iv_ogm.c |7 -
 debugfs.c|9 -
 hard-interface.c |9 -
 main.c   |   11 -
 packet.h |   17 -
 routing.c|   51 ---
 send.c   |1 -
 soft-interface.c |1 -
 sysfs.c  |   72 -
 types.h  |   82 -
 vis.c|  935 --
 vis.h|   36 ---
 13 files changed, 1232 deletions(-)
 delete mode 100644 vis.c
 delete mode 100644 vis.h

diff --git a/Makefile.kbuild b/Makefile.kbuild
index 489bb36..8ddbfe6 100644
--- a/Makefile.kbuild
+++ b/Makefile.kbuild
@@ -38,4 +38,3 @@ batman-adv-y += soft-interface.o
 batman-adv-y += sysfs.o
 batman-adv-y += translation-table.o
 batman-adv-y += unicast.o
-batman-adv-y += vis.o
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 2acebad..d6f31ec 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -671,11 +671,9 @@ static void batadv_iv_ogm_schedule(struct 
batadv_hard_iface *hard_iface)
struct batadv_ogm_packet *batadv_ogm_packet;
struct batadv_hard_iface *primary_if;
int *ogm_buff_len = hard_iface-bat_iv.ogm_buff_len;
-   int vis_server;
uint32_t seqno;
uint16_t tvlv_len = 0;
 
-   vis_server = atomic_read(bat_priv-vis_mode);
primary_if = batadv_primary_if_get_selected(bat_priv);
 
if (hard_iface == primary_if) {
@@ -696,11 +694,6 @@ static void batadv_iv_ogm_schedule(struct 
batadv_hard_iface *hard_iface)
batadv_ogm_packet-seqno = htonl(seqno);
atomic_inc(hard_iface-bat_iv.ogm_seqno);
 
-   if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC)
-   batadv_ogm_packet-flags |= BATADV_VIS_SERVER;
-   else
-   batadv_ogm_packet-flags = ~BATADV_VIS_SERVER;
-
batadv_iv_ogm_slide_own_bcast_window(hard_iface);
batadv_iv_ogm_queue_add(bat_priv, hard_iface-bat_iv.ogm_buff,
hard_iface-bat_iv.ogm_buff_len, hard_iface, 1,
diff --git a/debugfs.c b/debugfs.c
index f186a55..049a7a2 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -28,7 +28,6 @@
 #include gateway_common.h
 #include gateway_client.h
 #include soft-interface.h
-#include vis.h
 #include icmp_socket.h
 #include bridge_loop_avoidance.h
 #include distributed-arp-table.h
@@ -300,12 +299,6 @@ static int batadv_transtable_local_open(struct inode 
*inode, struct file *file)
return single_open(file, batadv_tt_local_seq_print_text, net_dev);
 }
 
-static int batadv_vis_data_open(struct inode *inode, struct file *file)
-{
-   struct net_device *net_dev = (struct net_device *)inode-i_private;
-   return single_open(file, batadv_vis_seq_print_text, net_dev);
-}
-
 struct batadv_debuginfo {
struct attribute attr;
const struct file_operations fops;
@@ -356,7 +349,6 @@ static BATADV_DEBUGINFO(dat_cache, S_IRUGO, 
batadv_dat_cache_open);
 #endif
 static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
batadv_transtable_local_open);
-static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
 #ifdef CONFIG_BATMAN_ADV_NC
 static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open);
 #endif
@@ -373,7 +365,6 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
batadv_debuginfo_dat_cache,
 #endif
batadv_debuginfo_transtable_local,
-   batadv_debuginfo_vis_data,
 #ifdef CONFIG_BATMAN_ADV_NC
batadv_debuginfo_nc_nodes,
 #endif
diff --git a/hard-interface.c b/hard-interface.c
index dc4ac29..9746600 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -194,22 +194,13 @@ out:
 static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv,
  struct batadv_hard_iface *oldif)
 {
-   struct batadv_vis_packet *vis_packet;
struct batadv_hard_iface *primary_if;
-   struct sk_buff *skb;
 
primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;
 
batadv_dat_init_own_addr(bat_priv, primary_if);
-
-   skb = bat_priv-vis.my_info-skb_packet;
-   vis_packet = (struct batadv_vis_packet *)skb-data;
-   memcpy(vis_packet-vis_orig, primary_if-net_dev-dev_addr, ETH_ALEN);
-   memcpy(vis_packet-sender_orig,
-  primary_if-net_dev-dev_addr, ETH_ALEN);
-
batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
 out:
if (primary_if)
diff --git a/main.c b/main.c
index 2bf3f4e..a003067 100644
--- a/main.c
+++ b/main.c
@@ -34,7 +34,6 @@
 #include distributed-arp-table.h
 #include unicast.h
 #include gateway_common.h
-#include vis.h
 #include hash.h
 #include bat_algo.h
 #include network-coding.h
@@ -107,8 +106,6 @@ int batadv_mesh_init(struct net_device *soft_iface)
spin_lock_init(bat_priv-tt.roam_list_lock);

[B.A.T.M.A.N.] [PATCHv2 0/6] compat bump work

2013-04-19 Thread Simon Wunderlich
Changes to v1:
 * move the build check macros in a separate flag
 * reorder batadv_iv_flags and remove VIS stuff
 * add check for adding record route info for icmp request/replies

This is based on ordex/compat_bump.

Simon Wunderlich (6):
  batman-adv: remove vis functionality
  batman-adv: add build check macros for packet member offset
  batman-adv: reorder packet types
  batman-adv: remove packed from batadv_ogm_packet
  batman-adv: reorder batadv_iv_flags
  batman-adv: only add recordroute information to icmp request/reply

 Makefile.kbuild  |1 -
 bat_iv_ogm.c |7 -
 debugfs.c|9 -
 hard-interface.c |9 -
 main.c   |   39 ++-
 packet.h |   66 ++--
 routing.c|   74 ++---
 routing.h|2 +
 send.c   |1 -
 soft-interface.c |1 -
 sysfs.c  |   72 -
 types.h  |   82 -
 vis.c|  935 --
 vis.h|   36 ---
 14 files changed, 81 insertions(+), 1253 deletions(-)
 delete mode 100644 vis.c
 delete mode 100644 vis.h

-- 
1.7.10.4



[B.A.T.M.A.N.] [PATCHv2 2/6] batman-adv: add build check macros for packet member offset

2013-04-19 Thread Simon Wunderlich
Since we removed the __packed from most of the packets, we should
make sure that the offset generated by the compile are correct for
sent/received data.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 main.c |8 
 1 file changed, 8 insertions(+)

diff --git a/main.c b/main.c
index a003067..5c76d6f 100644
--- a/main.c
+++ b/main.c
@@ -328,6 +328,14 @@ static void batadv_recv_handler_init(void)
for (i = 0; i  ARRAY_SIZE(batadv_rx_handler); i++)
batadv_rx_handler[i] = batadv_recv_unhandled_packet;
 
+   /* compile time checks for struct member offsets */
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10);
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_frag_packet, dest) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
+   BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
+
/* batman icmp packet */
batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
/* unicast with 4 addresses packet */
-- 
1.7.10.4



[B.A.T.M.A.N.] [PATCHv2 6/6] batman-adv: only add recordroute information to icmp request/reply

2013-04-19 Thread Simon Wunderlich
Adding host information for record route is only required for ICMP
requests and replys, and should not be added to just any (future?)
packet type.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 routing.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/routing.c b/routing.c
index b63a002..eca5ae4 100644
--- a/routing.c
+++ b/routing.c
@@ -379,7 +379,9 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
icmp_packet = (struct batadv_icmp_packet_rr *)skb-data;
 
/* add record route information if not full */
-   if ((hdr_size == sizeof(struct batadv_icmp_packet_rr)) 
+   if ((icmp_packet-msg_type == BATADV_ECHO_REPLY ||
+icmp_packet-msg_type == BATADV_ECHO_REQUEST) 
+   (hdr_size == sizeof(struct batadv_icmp_packet_rr)) 
(icmp_packet-rr_cur  BATADV_RR_LEN)) {
memcpy((icmp_packet-rr[icmp_packet-rr_cur]),
   ethhdr-h_dest, ETH_ALEN);
-- 
1.7.10.4



[B.A.T.M.A.N.] [PATCHv2 3/6] batman-adv: reorder packet types

2013-04-19 Thread Simon Wunderlich
Reordering the packet type numbers allows us to handle unicast
packets in a general way - even if we don't know the specific packet
type, we can still forward it. There was already code handling
this for a couple of unicast packets, and this is the more
generalized version to do that.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 main.c|   20 +++-
 packet.h  |   34 +-
 routing.c |   19 +++
 routing.h |2 ++
 4 files changed, 61 insertions(+), 14 deletions(-)

diff --git a/main.c b/main.c
index 5c76d6f..5c0a8db 100644
--- a/main.c
+++ b/main.c
@@ -328,6 +328,9 @@ static void batadv_recv_handler_init(void)
for (i = 0; i  ARRAY_SIZE(batadv_rx_handler); i++)
batadv_rx_handler[i] = batadv_recv_unhandled_packet;
 
+   for (i = BATADV_UNICAST_MIN; i = BATADV_UNICAST_MAX; i++)
+   batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet;
+
/* compile time checks for struct member offsets */
BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10);
BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
@@ -336,18 +339,20 @@ static void batadv_recv_handler_init(void)
BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
 
-   /* batman icmp packet */
-   batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
+   /* broadcast packet */
+   batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
+
+   /* unicast packets ... */
/* unicast with 4 addresses packet */
batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet;
/* unicast packet */
batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet;
/* fragmented unicast packet */
batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
-   /* broadcast packet */
-   batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
/* unicast tvlv packet */
batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv;
+   /* batman icmp packet */
+   batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
 }
 
 int
@@ -355,7 +360,12 @@ batadv_recv_handler_register(uint8_t packet_type,
 int (*recv_handler)(struct sk_buff *,
 struct batadv_hard_iface *))
 {
-   if (batadv_rx_handler[packet_type] != batadv_recv_unhandled_packet)
+   int (*curr)(struct sk_buff *,
+   struct batadv_hard_iface *);
+   curr = batadv_rx_handler[packet_type];
+
+   if ((curr != batadv_recv_unhandled_packet) 
+   (curr != batadv_recv_unhandled_unicast_packet))
return -EBUSY;
 
batadv_rx_handler[packet_type] = recv_handler;
diff --git a/packet.h b/packet.h
index 8ec9cf7..c90856d 100644
--- a/packet.h
+++ b/packet.h
@@ -22,18 +22,34 @@
 
 /**
  * enum batadv_packettype - types for batman-adv encapsulated packets
+ * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
+ * @BATADV_BCAST: broadcast packets carrying broadcast payload
+ * @BATADV_CODED: network coded packets
+ *
+ * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
+ * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
+ * payload packet
+ * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
+ * the sender
+ * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
  * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
+ *
  */
+
 enum batadv_packettype {
-   BATADV_IV_OGM   = 0x01,
-   BATADV_ICMP = 0x02,
-   BATADV_UNICAST  = 0x03,
-   BATADV_BCAST= 0x04,
-   BATADV_VIS  = 0x05,
-   BATADV_UNICAST_FRAG = 0x06,
-   BATADV_UNICAST_4ADDR= 0x09,
-   BATADV_CODED= 0x0a,
-   BATADV_UNICAST_TVLV = 0x0b,
+   /* 0x00 - 0x3f: local packets or special rules for handling */
+   BATADV_IV_OGM   = 0x00,
+   BATADV_BCAST= 0x01,
+   BATADV_CODED= 0x02,
+   /* 0x40 - 0x7f: unicast */
+#define BATADV_UNICAST_MIN 0x40
+   BATADV_UNICAST  = 0x40,
+   BATADV_UNICAST_FRAG = 0x41,
+   BATADV_UNICAST_4ADDR= 0x42,
+   BATADV_ICMP = 0x43,
+   BATADV_UNICAST_TVLV = 0x44,
+#define BATADV_UNICAST_MAX 0x7f
+   /* 0x80 - 0xff: reserved */
 };
 
 /**
diff --git a/routing.c b/routing.c
index d48f9f9..b63a002 100644
--- a/routing.c
+++ b/routing.c
@@ -892,6 +892,25 @@ static int batadv_check_unicast_ttvn(struct batadv_priv 
*bat_priv,
return 1;
 }
 
+int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb,
+struct batadv_hard_iface *recv_if)
+{
+   struct 

[B.A.T.M.A.N.] [PATCHv2 4/6] batman-adv: remove packed from batadv_ogm_packet

2013-04-19 Thread Simon Wunderlich
As we decreased the struct size from 26 to 24 byte, we can remove
__packed as the compile will not add any more padding.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 packet.h |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/packet.h b/packet.h
index c90856d..88d3aa6 100644
--- a/packet.h
+++ b/packet.h
@@ -178,7 +178,10 @@ struct batadv_ogm_packet {
uint8_t  reserved;
uint8_t  tq;
__be16   tvlv_len;
-} __packed;
+   /* __packed is not needed as the struct size is divisible by 4,
+* and the largest data type in this struct has a size of 4.
+*/
+};
 
 #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
 
-- 
1.7.10.4



[B.A.T.M.A.N.] [PATCHv2 5/6] batman-adv: reorder batadv_iv_flags

2013-04-19 Thread Simon Wunderlich
The vis flag is not needed anymore, and since we do a compat bump we
can start with the first bit again
Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 packet.h |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/packet.h b/packet.h
index 88d3aa6..cda3236 100644
--- a/packet.h
+++ b/packet.h
@@ -70,10 +70,9 @@ enum batadv_subtype {
 #define BATADV_COMPAT_VERSION 14
 
 enum batadv_iv_flags {
-   BATADV_NOT_BEST_NEXT_HOP   = BIT(3),
-   BATADV_PRIMARIES_FIRST_HOP = BIT(4),
-   BATADV_VIS_SERVER  = BIT(5),
-   BATADV_DIRECTLINK  = BIT(6),
+   BATADV_NOT_BEST_NEXT_HOP   = BIT(0),
+   BATADV_PRIMARIES_FIRST_HOP = BIT(1),
+   BATADV_DIRECTLINK  = BIT(2),
 };
 
 /* ICMP message types */
@@ -167,11 +166,12 @@ struct batadv_header {
 /**
  * struct batadv_ogm_packet - ogm (routing protocol) packet
  * @header: common batman packet header
+ * @flags: contains routing relevant flags - see enum batadv_iv_flags
  * @tvlv_len: length of tvlv data following the ogm header
  */
 struct batadv_ogm_packet {
struct batadv_header header;
-   uint8_t  flags;/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
+   uint8_t  flags;
__be32   seqno;
uint8_t  orig[ETH_ALEN];
uint8_t  prev_sender[ETH_ALEN];
-- 
1.7.10.4



[B.A.T.M.A.N.] [PATCHv2 1/6] batman-adv: remove vis functionality

2013-04-19 Thread Simon Wunderlich
This is replaced by a userspace program, we don't need this
functionality to bloat the kernel.

Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de
---
 Makefile.kbuild  |1 -
 bat_iv_ogm.c |7 -
 debugfs.c|9 -
 hard-interface.c |9 -
 main.c   |   11 -
 packet.h |   17 -
 routing.c|   51 ---
 send.c   |1 -
 soft-interface.c |1 -
 sysfs.c  |   72 -
 types.h  |   82 -
 vis.c|  935 --
 vis.h|   36 ---
 13 files changed, 1232 deletions(-)
 delete mode 100644 vis.c
 delete mode 100644 vis.h

diff --git a/Makefile.kbuild b/Makefile.kbuild
index 489bb36..8ddbfe6 100644
--- a/Makefile.kbuild
+++ b/Makefile.kbuild
@@ -38,4 +38,3 @@ batman-adv-y += soft-interface.o
 batman-adv-y += sysfs.o
 batman-adv-y += translation-table.o
 batman-adv-y += unicast.o
-batman-adv-y += vis.o
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 2acebad..d6f31ec 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -671,11 +671,9 @@ static void batadv_iv_ogm_schedule(struct 
batadv_hard_iface *hard_iface)
struct batadv_ogm_packet *batadv_ogm_packet;
struct batadv_hard_iface *primary_if;
int *ogm_buff_len = hard_iface-bat_iv.ogm_buff_len;
-   int vis_server;
uint32_t seqno;
uint16_t tvlv_len = 0;
 
-   vis_server = atomic_read(bat_priv-vis_mode);
primary_if = batadv_primary_if_get_selected(bat_priv);
 
if (hard_iface == primary_if) {
@@ -696,11 +694,6 @@ static void batadv_iv_ogm_schedule(struct 
batadv_hard_iface *hard_iface)
batadv_ogm_packet-seqno = htonl(seqno);
atomic_inc(hard_iface-bat_iv.ogm_seqno);
 
-   if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC)
-   batadv_ogm_packet-flags |= BATADV_VIS_SERVER;
-   else
-   batadv_ogm_packet-flags = ~BATADV_VIS_SERVER;
-
batadv_iv_ogm_slide_own_bcast_window(hard_iface);
batadv_iv_ogm_queue_add(bat_priv, hard_iface-bat_iv.ogm_buff,
hard_iface-bat_iv.ogm_buff_len, hard_iface, 1,
diff --git a/debugfs.c b/debugfs.c
index f186a55..049a7a2 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -28,7 +28,6 @@
 #include gateway_common.h
 #include gateway_client.h
 #include soft-interface.h
-#include vis.h
 #include icmp_socket.h
 #include bridge_loop_avoidance.h
 #include distributed-arp-table.h
@@ -300,12 +299,6 @@ static int batadv_transtable_local_open(struct inode 
*inode, struct file *file)
return single_open(file, batadv_tt_local_seq_print_text, net_dev);
 }
 
-static int batadv_vis_data_open(struct inode *inode, struct file *file)
-{
-   struct net_device *net_dev = (struct net_device *)inode-i_private;
-   return single_open(file, batadv_vis_seq_print_text, net_dev);
-}
-
 struct batadv_debuginfo {
struct attribute attr;
const struct file_operations fops;
@@ -356,7 +349,6 @@ static BATADV_DEBUGINFO(dat_cache, S_IRUGO, 
batadv_dat_cache_open);
 #endif
 static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
batadv_transtable_local_open);
-static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
 #ifdef CONFIG_BATMAN_ADV_NC
 static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open);
 #endif
@@ -373,7 +365,6 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
batadv_debuginfo_dat_cache,
 #endif
batadv_debuginfo_transtable_local,
-   batadv_debuginfo_vis_data,
 #ifdef CONFIG_BATMAN_ADV_NC
batadv_debuginfo_nc_nodes,
 #endif
diff --git a/hard-interface.c b/hard-interface.c
index dc4ac29..9746600 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -194,22 +194,13 @@ out:
 static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv,
  struct batadv_hard_iface *oldif)
 {
-   struct batadv_vis_packet *vis_packet;
struct batadv_hard_iface *primary_if;
-   struct sk_buff *skb;
 
primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;
 
batadv_dat_init_own_addr(bat_priv, primary_if);
-
-   skb = bat_priv-vis.my_info-skb_packet;
-   vis_packet = (struct batadv_vis_packet *)skb-data;
-   memcpy(vis_packet-vis_orig, primary_if-net_dev-dev_addr, ETH_ALEN);
-   memcpy(vis_packet-sender_orig,
-  primary_if-net_dev-dev_addr, ETH_ALEN);
-
batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
 out:
if (primary_if)
diff --git a/main.c b/main.c
index 2bf3f4e..a003067 100644
--- a/main.c
+++ b/main.c
@@ -34,7 +34,6 @@
 #include distributed-arp-table.h
 #include unicast.h
 #include gateway_common.h
-#include vis.h
 #include hash.h
 #include bat_algo.h
 #include network-coding.h
@@ -107,8 +106,6 @@ int batadv_mesh_init(struct net_device *soft_iface)
spin_lock_init(bat_priv-tt.roam_list_lock);