[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)
+ 

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