batman-adv: Prefix main defines with BATADV_
[cascardo/linux.git] / net / batman-adv / bridge_loop_avoidance.c
index 5c1ac55..db20b68 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
+/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
  *
  * Simon Wunderlich
  *
@@ -16,7 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301, USA
- *
  */
 
 #include "main.h"
 #include <net/arp.h>
 #include <linux/if_vlan.h>
 
-static const uint8_t announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
+static const uint8_t batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
 
-static void bla_periodic_work(struct work_struct *work);
-static void bla_send_announce(struct bat_priv *bat_priv,
-                             struct backbone_gw *backbone_gw);
+static void batadv_bla_periodic_work(struct work_struct *work);
+static void batadv_bla_send_announce(struct bat_priv *bat_priv,
+                                    struct backbone_gw *backbone_gw);
 
 /* return the index of the claim */
-static inline uint32_t choose_claim(const void *data, uint32_t size)
+static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
 {
        const unsigned char *key = data;
        uint32_t hash = 0;
@@ -60,7 +58,8 @@ static inline uint32_t choose_claim(const void *data, uint32_t size)
 }
 
 /* return the index of the backbone gateway */
-static inline uint32_t choose_backbone_gw(const void *data, uint32_t size)
+static inline uint32_t batadv_choose_backbone_gw(const void *data,
+                                                uint32_t size)
 {
        const unsigned char *key = data;
        uint32_t hash = 0;
@@ -81,7 +80,8 @@ static inline uint32_t choose_backbone_gw(const void *data, uint32_t size)
 
 
 /* compares address and vid of two backbone gws */
-static int compare_backbone_gw(const struct hlist_node *node, const void *data2)
+static int batadv_compare_backbone_gw(const struct hlist_node *node,
+                                     const void *data2)
 {
        const void *data1 = container_of(node, struct backbone_gw,
                                         hash_entry);
@@ -90,7 +90,8 @@ static int compare_backbone_gw(const struct hlist_node *node, const void *data2)
 }
 
 /* compares address and vid of two claims */
-static int compare_claim(const struct hlist_node *node, const void *data2)
+static int batadv_compare_claim(const struct hlist_node *node,
+                               const void *data2)
 {
        const void *data1 = container_of(node, struct claim,
                                         hash_entry);
@@ -99,39 +100,38 @@ static int compare_claim(const struct hlist_node *node, const void *data2)
 }
 
 /* free a backbone gw */
-static void backbone_gw_free_ref(struct backbone_gw *backbone_gw)
+static void batadv_backbone_gw_free_ref(struct backbone_gw *backbone_gw)
 {
        if (atomic_dec_and_test(&backbone_gw->refcount))
                kfree_rcu(backbone_gw, rcu);
 }
 
 /* finally deinitialize the claim */
-static void claim_free_rcu(struct rcu_head *rcu)
+static void batadv_claim_free_rcu(struct rcu_head *rcu)
 {
        struct claim *claim;
 
        claim = container_of(rcu, struct claim, rcu);
 
-       backbone_gw_free_ref(claim->backbone_gw);
+       batadv_backbone_gw_free_ref(claim->backbone_gw);
        kfree(claim);
 }
 
 /* free a claim, call claim_free_rcu if its the last reference */
-static void claim_free_ref(struct claim *claim)
+static void batadv_claim_free_ref(struct claim *claim)
 {
        if (atomic_dec_and_test(&claim->refcount))
-               call_rcu(&claim->rcu, claim_free_rcu);
+               call_rcu(&claim->rcu, batadv_claim_free_rcu);
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @data: search data (may be local/static data)
  *
  * looks for a claim in the hash, and returns it if found
  * or NULL otherwise.
  */
-static struct claim *claim_hash_find(struct bat_priv *bat_priv,
-                                    struct claim *data)
+static struct claim *batadv_claim_hash_find(struct bat_priv *bat_priv,
+                                           struct claim *data)
 {
        struct hashtable_t *hash = bat_priv->claim_hash;
        struct hlist_head *head;
@@ -143,12 +143,12 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv,
        if (!hash)
                return NULL;
 
-       index = choose_claim(data, hash->size);
+       index = batadv_choose_claim(data, hash->size);
        head = &hash->table[index];
 
        rcu_read_lock();
        hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
-               if (!compare_claim(&claim->hash_entry, data))
+               if (!batadv_compare_claim(&claim->hash_entry, data))
                        continue;
 
                if (!atomic_inc_not_zero(&claim->refcount))
@@ -162,16 +162,15 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv,
        return claim_tmp;
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @addr: the address of the originator
  * @vid: the VLAN ID
  *
  * looks for a claim in the hash, and returns it if found
  * or NULL otherwise.
  */
-static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv,
-                                             uint8_t *addr, short vid)
+static struct backbone_gw *batadv_backbone_hash_find(struct bat_priv *bat_priv,
+                                                    uint8_t *addr, short vid)
 {
        struct hashtable_t *hash = bat_priv->backbone_hash;
        struct hlist_head *head;
@@ -186,13 +185,13 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv,
        memcpy(search_entry.orig, addr, ETH_ALEN);
        search_entry.vid = vid;
 
-       index = choose_backbone_gw(&search_entry, hash->size);
+       index = batadv_choose_backbone_gw(&search_entry, hash->size);
        head = &hash->table[index];
 
        rcu_read_lock();
        hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
-               if (!compare_backbone_gw(&backbone_gw->hash_entry,
-                                        &search_entry))
+               if (!batadv_compare_backbone_gw(&backbone_gw->hash_entry,
+                                               &search_entry))
                        continue;
 
                if (!atomic_inc_not_zero(&backbone_gw->refcount))
@@ -207,7 +206,7 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv,
 }
 
 /* delete all claims for a backbone */
-static void bla_del_backbone_claims(struct backbone_gw *backbone_gw)
+static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw)
 {
        struct hashtable_t *hash;
        struct hlist_node *node, *node_tmp;
@@ -231,26 +230,25 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw)
                        if (claim->backbone_gw != backbone_gw)
                                continue;
 
-                       claim_free_ref(claim);
+                       batadv_claim_free_ref(claim);
                        hlist_del_rcu(node);
                }
                spin_unlock_bh(list_lock);
        }
 
        /* all claims gone, intialize CRC */
-       backbone_gw->crc = BLA_CRC_INIT;
+       backbone_gw->crc = BATADV_BLA_CRC_INIT;
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @orig: the mac address to be announced within the claim
  * @vid: the VLAN ID
  * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...)
  *
  * sends a claim frame according to the provided info.
  */
-static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
-                          short vid, int claimtype)
+static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
+                                 short vid, int claimtype)
 {
        struct sk_buff *skb;
        struct ethhdr *ethhdr;
@@ -258,9 +256,9 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
        struct net_device *soft_iface;
        uint8_t *hw_src;
        struct bla_claim_dst local_claim_dest;
-       uint32_t zeroip = 0;
+       __be32 zeroip = 0;
 
-       primary_if = primary_if_get_selected(bat_priv);
+       primary_if = batadv_primary_if_get_selected(bat_priv);
        if (!primary_if)
                return;
 
@@ -299,25 +297,26 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
                 * set Ethernet SRC to the clients mac
                 */
                memcpy(ethhdr->h_source, mac, ETH_ALEN);
-               bat_dbg(DBG_BLA, bat_priv,
-                       "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid);
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid);
                break;
        case CLAIM_TYPE_DEL:
                /* unclaim frame
                 * set HW SRC to the clients mac
                 */
                memcpy(hw_src, mac, ETH_ALEN);
-               bat_dbg(DBG_BLA, bat_priv,
-                       "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, vid);
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac,
+                          vid);
                break;
        case CLAIM_TYPE_ANNOUNCE:
                /* announcement frame
                 * set HW SRC to the special mac containg the crc
                 */
                memcpy(hw_src, mac, ETH_ALEN);
-               bat_dbg(DBG_BLA, bat_priv,
-                       "bla_send_claim(): ANNOUNCE of %pM on vid %d\n",
-                       ethhdr->h_source, vid);
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "bla_send_claim(): ANNOUNCE of %pM on vid %d\n",
+                          ethhdr->h_source, vid);
                break;
        case CLAIM_TYPE_REQUEST:
                /* request frame
@@ -325,9 +324,9 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
                 */
                memcpy(hw_src, mac, ETH_ALEN);
                memcpy(ethhdr->h_dest, mac, ETH_ALEN);
-               bat_dbg(DBG_BLA, bat_priv,
-                       "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n",
-                       ethhdr->h_source, ethhdr->h_dest, vid);
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n",
+                          ethhdr->h_source, ethhdr->h_dest, vid);
                break;
 
        }
@@ -344,32 +343,31 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
        netif_rx(skb);
 out:
        if (primary_if)
-               hardif_free_ref(primary_if);
+               batadv_hardif_free_ref(primary_if);
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @orig: the mac address of the originator
  * @vid: the VLAN ID
  *
  * searches for the backbone gw or creates a new one if it could not
  * be found.
  */
-static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
-                                              uint8_t *orig, short vid)
+static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv,
+                                                     uint8_t *orig, short vid)
 {
        struct backbone_gw *entry;
        struct orig_node *orig_node;
        int hash_added;
 
-       entry = backbone_hash_find(bat_priv, orig, vid);
+       entry = batadv_backbone_hash_find(bat_priv, orig, vid);
 
        if (entry)
                return entry;
 
-       bat_dbg(DBG_BLA, bat_priv,
-               "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n",
-               orig, vid);
+       batadv_dbg(DBG_BLA, bat_priv,
+                  "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n",
+                  orig, vid);
 
        entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
        if (!entry)
@@ -377,7 +375,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
 
        entry->vid = vid;
        entry->lasttime = jiffies;
-       entry->crc = BLA_CRC_INIT;
+       entry->crc = BATADV_BLA_CRC_INIT;
        entry->bat_priv = bat_priv;
        atomic_set(&entry->request_sent, 0);
        memcpy(entry->orig, orig, ETH_ALEN);
@@ -385,8 +383,10 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
        /* one for the hash, one for returning */
        atomic_set(&entry->refcount, 2);
 
-       hash_added = hash_add(bat_priv->backbone_hash, compare_backbone_gw,
-                             choose_backbone_gw, entry, &entry->hash_entry);
+       hash_added = batadv_hash_add(bat_priv->backbone_hash,
+                                    batadv_compare_backbone_gw,
+                                    batadv_choose_backbone_gw, entry,
+                                    &entry->hash_entry);
 
        if (unlikely(hash_added != 0)) {
                /* hash failed, free the structure */
@@ -395,11 +395,11 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
        }
 
        /* this is a gateway now, remove any tt entries */
-       orig_node = orig_hash_find(bat_priv, orig);
+       orig_node = batadv_orig_hash_find(bat_priv, orig);
        if (orig_node) {
-               tt_global_del_orig(bat_priv, orig_node,
-                                  "became a backbone gateway");
-               orig_node_free_ref(orig_node);
+               batadv_tt_global_del_orig(bat_priv, orig_node,
+                                         "became a backbone gateway");
+               batadv_orig_node_free_ref(orig_node);
        }
        return entry;
 }
@@ -407,30 +407,30 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
 /* update or add the own backbone gw to make sure we announce
  * where we receive other backbone gws
  */
-static void bla_update_own_backbone_gw(struct bat_priv *bat_priv,
-                                      struct hard_iface *primary_if,
-                                      short vid)
+static void batadv_bla_update_own_backbone_gw(struct bat_priv *bat_priv,
+                                             struct hard_iface *primary_if,
+                                             short vid)
 {
        struct backbone_gw *backbone_gw;
 
-       backbone_gw = bla_get_backbone_gw(bat_priv,
-                                         primary_if->net_dev->dev_addr, vid);
+       backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
+                                                primary_if->net_dev->dev_addr,
+                                                vid);
        if (unlikely(!backbone_gw))
                return;
 
        backbone_gw->lasttime = jiffies;
-       backbone_gw_free_ref(backbone_gw);
+       batadv_backbone_gw_free_ref(backbone_gw);
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @vid: the vid where the request came on
  *
  * Repeat all of our own claims, and finally send an ANNOUNCE frame
  * to allow the requester another check if the CRC is correct now.
  */
-static void bla_answer_request(struct bat_priv *bat_priv,
-                              struct hard_iface *primary_if, short vid)
+static void batadv_bla_answer_request(struct bat_priv *bat_priv,
+                                     struct hard_iface *primary_if, short vid)
 {
        struct hlist_node *node;
        struct hlist_head *head;
@@ -439,11 +439,12 @@ static void bla_answer_request(struct bat_priv *bat_priv,
        struct backbone_gw *backbone_gw;
        int i;
 
-       bat_dbg(DBG_BLA, bat_priv,
-               "bla_answer_request(): received a claim request, send all of our own claims again\n");
+       batadv_dbg(DBG_BLA, bat_priv,
+                  "bla_answer_request(): received a claim request, send all of our own claims again\n");
 
-       backbone_gw = backbone_hash_find(bat_priv,
-                                        primary_if->net_dev->dev_addr, vid);
+       backbone_gw = batadv_backbone_hash_find(bat_priv,
+                                               primary_if->net_dev->dev_addr,
+                                               vid);
        if (!backbone_gw)
                return;
 
@@ -457,36 +458,34 @@ static void bla_answer_request(struct bat_priv *bat_priv,
                        if (claim->backbone_gw != backbone_gw)
                                continue;
 
-                       bla_send_claim(bat_priv, claim->addr, claim->vid,
-                                      CLAIM_TYPE_ADD);
+                       batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
+                                             CLAIM_TYPE_ADD);
                }
                rcu_read_unlock();
        }
 
        /* finally, send an announcement frame */
-       bla_send_announce(bat_priv, backbone_gw);
-       backbone_gw_free_ref(backbone_gw);
+       batadv_bla_send_announce(bat_priv, backbone_gw);
+       batadv_backbone_gw_free_ref(backbone_gw);
 }
 
-/**
- * @backbone_gw: the backbone gateway from whom we are out of sync
+/* @backbone_gw: the backbone gateway from whom we are out of sync
  *
  * When the crc is wrong, ask the backbone gateway for a full table update.
  * After the request, it will repeat all of his own claims and finally
  * send an announcement claim with which we can check again.
  */
-static void bla_send_request(struct backbone_gw *backbone_gw)
+static void batadv_bla_send_request(struct backbone_gw *backbone_gw)
 {
        /* first, remove all old entries */
-       bla_del_backbone_claims(backbone_gw);
+       batadv_bla_del_backbone_claims(backbone_gw);
 
-       bat_dbg(DBG_BLA, backbone_gw->bat_priv,
-               "Sending REQUEST to %pM\n",
-               backbone_gw->orig);
+       batadv_dbg(DBG_BLA, backbone_gw->bat_priv, "Sending REQUEST to %pM\n",
+                  backbone_gw->orig);
 
        /* send request */
-       bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig,
-                      backbone_gw->vid, CLAIM_TYPE_REQUEST);
+       batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig,
+                             backbone_gw->vid, CLAIM_TYPE_REQUEST);
 
        /* no local broadcasts should be sent or received, for now. */
        if (!atomic_read(&backbone_gw->request_sent)) {
@@ -495,37 +494,37 @@ static void bla_send_request(struct backbone_gw *backbone_gw)
        }
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @backbone_gw: our backbone gateway which should be announced
  *
  * This function sends an announcement. It is called from multiple
  * places.
  */
-static void bla_send_announce(struct bat_priv *bat_priv,
-                             struct backbone_gw *backbone_gw)
+static void batadv_bla_send_announce(struct bat_priv *bat_priv,
+                                    struct backbone_gw *backbone_gw)
 {
        uint8_t mac[ETH_ALEN];
-       uint16_t crc;
+       __be16 crc;
 
-       memcpy(mac, announce_mac, 4);
+       memcpy(mac, batadv_announce_mac, 4);
        crc = htons(backbone_gw->crc);
-       memcpy(&mac[4], (uint8_t *)&crc, 2);
+       memcpy(&mac[4], &crc, 2);
 
-       bla_send_claim(bat_priv, mac, backbone_gw->vid, CLAIM_TYPE_ANNOUNCE);
+       batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
+                             CLAIM_TYPE_ANNOUNCE);
 
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @mac: the mac address of the claim
  * @vid: the VLAN ID of the frame
  * @backbone_gw: the backbone gateway which claims it
  *
  * Adds a claim in the claim hash.
  */
-static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
-                         const short vid, struct backbone_gw *backbone_gw)
+static void batadv_bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
+                                const short vid,
+                                struct backbone_gw *backbone_gw)
 {
        struct claim *claim;
        struct claim search_claim;
@@ -533,7 +532,7 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
 
        memcpy(search_claim.addr, mac, ETH_ALEN);
        search_claim.vid = vid;
-       claim = claim_hash_find(bat_priv, &search_claim);
+       claim = batadv_claim_hash_find(bat_priv, &search_claim);
 
        /* create a new claim entry if it does not exist yet. */
        if (!claim) {
@@ -547,11 +546,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
                claim->backbone_gw = backbone_gw;
 
                atomic_set(&claim->refcount, 2);
-               bat_dbg(DBG_BLA, bat_priv,
-                       "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n",
-                       mac, vid);
-               hash_added = hash_add(bat_priv->claim_hash, compare_claim,
-                                     choose_claim, claim, &claim->hash_entry);
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n",
+                          mac, vid);
+               hash_added = batadv_hash_add(bat_priv->claim_hash,
+                                            batadv_compare_claim,
+                                            batadv_choose_claim, claim,
+                                            &claim->hash_entry);
 
                if (unlikely(hash_added != 0)) {
                        /* only local changes happened. */
@@ -564,13 +565,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
                        /* no need to register a new backbone */
                        goto claim_free_ref;
 
-               bat_dbg(DBG_BLA, bat_priv,
-                       "bla_add_claim(): changing ownership for %pM, vid %d\n",
-                       mac, vid);
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "bla_add_claim(): changing ownership for %pM, vid %d\n",
+                          mac, vid);
 
                claim->backbone_gw->crc ^=
                        crc16(0, claim->addr, ETH_ALEN);
-               backbone_gw_free_ref(claim->backbone_gw);
+               batadv_backbone_gw_free_ref(claim->backbone_gw);
 
        }
        /* set (new) backbone gw */
@@ -581,45 +582,48 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
        backbone_gw->lasttime = jiffies;
 
 claim_free_ref:
-       claim_free_ref(claim);
+       batadv_claim_free_ref(claim);
 }
 
 /* Delete a claim from the claim hash which has the
  * given mac address and vid.
  */
-static void bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac,
-                         const short vid)
+static void batadv_bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac,
+                                const short vid)
 {
        struct claim search_claim, *claim;
 
        memcpy(search_claim.addr, mac, ETH_ALEN);
        search_claim.vid = vid;
-       claim = claim_hash_find(bat_priv, &search_claim);
+       claim = batadv_claim_hash_find(bat_priv, &search_claim);
        if (!claim)
                return;
 
-       bat_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, vid);
+       batadv_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac,
+                  vid);
 
-       hash_remove(bat_priv->claim_hash, compare_claim, choose_claim, claim);
-       claim_free_ref(claim); /* reference from the hash is gone */
+       batadv_hash_remove(bat_priv->claim_hash, batadv_compare_claim,
+                          batadv_choose_claim, claim);
+       batadv_claim_free_ref(claim); /* reference from the hash is gone */
 
        claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
 
        /* don't need the reference from hash_find() anymore */
-       claim_free_ref(claim);
+       batadv_claim_free_ref(claim);
 }
 
 /* check for ANNOUNCE frame, return 1 if handled */
-static int handle_announce(struct bat_priv *bat_priv,
-                          uint8_t *an_addr, uint8_t *backbone_addr, short vid)
+static int batadv_handle_announce(struct bat_priv *bat_priv,
+                                 uint8_t *an_addr, uint8_t *backbone_addr,
+                                 short vid)
 {
        struct backbone_gw *backbone_gw;
        uint16_t crc;
 
-       if (memcmp(an_addr, announce_mac, 4) != 0)
+       if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
                return 0;
 
-       backbone_gw = bla_get_backbone_gw(bat_priv, backbone_addr, vid);
+       backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid);
 
        if (unlikely(!backbone_gw))
                return 1;
@@ -627,19 +631,19 @@ static int handle_announce(struct bat_priv *bat_priv,
 
        /* handle as ANNOUNCE frame */
        backbone_gw->lasttime = jiffies;
-       crc = ntohs(*((uint16_t *)(&an_addr[4])));
+       crc = ntohs(*((__be16 *)(&an_addr[4])));
 
-       bat_dbg(DBG_BLA, bat_priv,
-               "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n",
-               vid, backbone_gw->orig, crc);
+       batadv_dbg(DBG_BLA, bat_priv,
+                  "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n",
+                  vid, backbone_gw->orig, crc);
 
        if (backbone_gw->crc != crc) {
-               bat_dbg(DBG_BLA, backbone_gw->bat_priv,
-                       "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n",
-                       backbone_gw->orig, backbone_gw->vid, backbone_gw->crc,
-                       crc);
+               batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
+                          "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n",
+                          backbone_gw->orig, backbone_gw->vid,
+                          backbone_gw->crc, crc);
 
-               bla_send_request(backbone_gw);
+               batadv_bla_send_request(backbone_gw);
        } else {
                /* if we have sent a request and the crc was OK,
                 * we can allow traffic again.
@@ -650,89 +654,91 @@ static int handle_announce(struct bat_priv *bat_priv,
                }
        }
 
-       backbone_gw_free_ref(backbone_gw);
+       batadv_backbone_gw_free_ref(backbone_gw);
        return 1;
 }
 
 /* check for REQUEST frame, return 1 if handled */
-static int handle_request(struct bat_priv *bat_priv,
-                         struct hard_iface *primary_if,
-                         uint8_t *backbone_addr,
-                         struct ethhdr *ethhdr, short vid)
+static int batadv_handle_request(struct bat_priv *bat_priv,
+                                struct hard_iface *primary_if,
+                                uint8_t *backbone_addr,
+                                struct ethhdr *ethhdr, short vid)
 {
        /* check for REQUEST frame */
-       if (!compare_eth(backbone_addr, ethhdr->h_dest))
+       if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest))
                return 0;
 
        /* sanity check, this should not happen on a normal switch,
         * we ignore it in this case.
         */
-       if (!compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr))
+       if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr))
                return 1;
 
-       bat_dbg(DBG_BLA, bat_priv,
-               "handle_request(): REQUEST vid %d (sent by %pM)...\n",
-               vid, ethhdr->h_source);
+       batadv_dbg(DBG_BLA, bat_priv,
+                  "handle_request(): REQUEST vid %d (sent by %pM)...\n",
+                  vid, ethhdr->h_source);
 
-       bla_answer_request(bat_priv, primary_if, vid);
+       batadv_bla_answer_request(bat_priv, primary_if, vid);
        return 1;
 }
 
 /* check for UNCLAIM frame, return 1 if handled */
-static int handle_unclaim(struct bat_priv *bat_priv,
-                         struct hard_iface *primary_if,
-                         uint8_t *backbone_addr,
-                         uint8_t *claim_addr, short vid)
+static int batadv_handle_unclaim(struct bat_priv *bat_priv,
+                                struct hard_iface *primary_if,
+                                uint8_t *backbone_addr,
+                                uint8_t *claim_addr, short vid)
 {
        struct backbone_gw *backbone_gw;
 
        /* unclaim in any case if it is our own */
-       if (primary_if && compare_eth(backbone_addr,
-                                     primary_if->net_dev->dev_addr))
-               bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_DEL);
+       if (primary_if && batadv_compare_eth(backbone_addr,
+                                            primary_if->net_dev->dev_addr))
+               batadv_bla_send_claim(bat_priv, claim_addr, vid,
+                                     CLAIM_TYPE_DEL);
 
-       backbone_gw = backbone_hash_find(bat_priv, backbone_addr, vid);
+       backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
 
        if (!backbone_gw)
                return 1;
 
        /* this must be an UNCLAIM frame */
-       bat_dbg(DBG_BLA, bat_priv,
-               "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n",
-               claim_addr, vid, backbone_gw->orig);
+       batadv_dbg(DBG_BLA, bat_priv,
+                  "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n",
+                  claim_addr, vid, backbone_gw->orig);
 
-       bla_del_claim(bat_priv, claim_addr, vid);
-       backbone_gw_free_ref(backbone_gw);
+       batadv_bla_del_claim(bat_priv, claim_addr, vid);
+       batadv_backbone_gw_free_ref(backbone_gw);
        return 1;
 }
 
 /* check for CLAIM frame, return 1 if handled */
-static int handle_claim(struct bat_priv *bat_priv,
-                       struct hard_iface *primary_if, uint8_t *backbone_addr,
-                       uint8_t *claim_addr, short vid)
+static int batadv_handle_claim(struct bat_priv *bat_priv,
+                              struct hard_iface *primary_if,
+                              uint8_t *backbone_addr, uint8_t *claim_addr,
+                              short vid)
 {
        struct backbone_gw *backbone_gw;
 
        /* register the gateway if not yet available, and add the claim. */
 
-       backbone_gw = bla_get_backbone_gw(bat_priv, backbone_addr, vid);
+       backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid);
 
        if (unlikely(!backbone_gw))
                return 1;
 
        /* this must be a CLAIM frame */
-       bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
-       if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
-               bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_ADD);
+       batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
+       if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
+               batadv_bla_send_claim(bat_priv, claim_addr, vid,
+                                     CLAIM_TYPE_ADD);
 
        /* TODO: we could call something like tt_local_del() here. */
 
-       backbone_gw_free_ref(backbone_gw);
+       batadv_backbone_gw_free_ref(backbone_gw);
        return 1;
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @hw_src: the Hardware source in the ARP Header
  * @hw_dst: the Hardware destination in the ARP Header
  * @ethhdr: pointer to the Ethernet header of the claim frame
@@ -746,10 +752,10 @@ static int handle_claim(struct bat_priv *bat_priv,
  *     1  - if is a claim packet from another group
  *     0  - if it is not a claim packet
  */
-static int check_claim_group(struct bat_priv *bat_priv,
-                            struct hard_iface *primary_if,
-                            uint8_t *hw_src, uint8_t *hw_dst,
-                            struct ethhdr *ethhdr)
+static int batadv_check_claim_group(struct bat_priv *bat_priv,
+                                   struct hard_iface *primary_if,
+                                   uint8_t *hw_src, uint8_t *hw_dst,
+                                   struct ethhdr *ethhdr)
 {
        uint8_t *backbone_addr;
        struct orig_node *orig_node;
@@ -780,7 +786,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
        }
 
        /* don't accept claim frames from ourselves */
-       if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
+       if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
                return 0;
 
        /* if its already the same group, it is fine. */
@@ -788,7 +794,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
                return 2;
 
        /* lets see if this originator is in our mesh */
-       orig_node = orig_hash_find(bat_priv, backbone_addr);
+       orig_node = batadv_orig_hash_find(bat_priv, backbone_addr);
 
        /* dont accept claims from gateways which are not in
         * the same mesh or group.
@@ -798,20 +804,19 @@ static int check_claim_group(struct bat_priv *bat_priv,
 
        /* if our mesh friends mac is bigger, use it for ourselves. */
        if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) {
-               bat_dbg(DBG_BLA, bat_priv,
-                       "taking other backbones claim group: %04x\n",
-                       ntohs(bla_dst->group));
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "taking other backbones claim group: %04x\n",
+                          ntohs(bla_dst->group));
                bla_dst_own->group = bla_dst->group;
        }
 
-       orig_node_free_ref(orig_node);
+       batadv_orig_node_free_ref(orig_node);
 
        return 2;
 }
 
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @skb: the frame to be checked
  *
  * Check if this is a claim frame, and process it accordingly.
@@ -819,9 +824,9 @@ static int check_claim_group(struct bat_priv *bat_priv,
  * returns 1 if it was a claim frame, otherwise return 0 to
  * tell the callee that it can use the frame on its own.
  */
-static int bla_process_claim(struct bat_priv *bat_priv,
-                            struct hard_iface *primary_if,
-                            struct sk_buff *skb)
+static int batadv_bla_process_claim(struct bat_priv *bat_priv,
+                                   struct hard_iface *primary_if,
+                                   struct sk_buff *skb)
 {
        struct ethhdr *ethhdr;
        struct vlan_ethhdr *vhdr;
@@ -860,7 +865,6 @@ static int bla_process_claim(struct bat_priv *bat_priv,
        /* Check whether the ARP frame carries a valid
         * IP information
         */
-
        if (arphdr->ar_hrd != htons(ARPHRD_ETHER))
                return 0;
        if (arphdr->ar_pro != htons(ETH_P_IP))
@@ -875,51 +879,54 @@ static int bla_process_claim(struct bat_priv *bat_priv,
        bla_dst = (struct bla_claim_dst *)hw_dst;
 
        /* check if it is a claim frame. */
-       ret = check_claim_group(bat_priv, primary_if, hw_src, hw_dst, ethhdr);
+       ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
+                                      ethhdr);
        if (ret == 1)
-               bat_dbg(DBG_BLA, bat_priv,
-                       "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
-                       ethhdr->h_source, vid, hw_src, hw_dst);
+               batadv_dbg(DBG_BLA, bat_priv,
+                          "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
+                          ethhdr->h_source, vid, hw_src, hw_dst);
 
        if (ret < 2)
                return ret;
 
        /* become a backbone gw ourselves on this vlan if not happened yet */
-       bla_update_own_backbone_gw(bat_priv, primary_if, vid);
+       batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
 
        /* check for the different types of claim frames ... */
        switch (bla_dst->type) {
        case CLAIM_TYPE_ADD:
-               if (handle_claim(bat_priv, primary_if, hw_src,
-                                ethhdr->h_source, vid))
+               if (batadv_handle_claim(bat_priv, primary_if, hw_src,
+                                       ethhdr->h_source, vid))
                        return 1;
                break;
        case CLAIM_TYPE_DEL:
-               if (handle_unclaim(bat_priv, primary_if,
-                                  ethhdr->h_source, hw_src, vid))
+               if (batadv_handle_unclaim(bat_priv, primary_if,
+                                         ethhdr->h_source, hw_src, vid))
                        return 1;
                break;
 
        case CLAIM_TYPE_ANNOUNCE:
-               if (handle_announce(bat_priv, hw_src, ethhdr->h_source, vid))
+               if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source,
+                                          vid))
                        return 1;
                break;
        case CLAIM_TYPE_REQUEST:
-               if (handle_request(bat_priv, primary_if, hw_src, ethhdr, vid))
+               if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr,
+                                         vid))
                        return 1;
                break;
        }
 
-       bat_dbg(DBG_BLA, bat_priv,
-               "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
-               ethhdr->h_source, vid, hw_src, hw_dst);
+       batadv_dbg(DBG_BLA, bat_priv,
+                  "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
+                  ethhdr->h_source, vid, hw_src, hw_dst);
        return 1;
 }
 
 /* Check when we last heard from other nodes, and remove them in case of
  * a time out, or clean all backbone gws if now is set.
  */
-static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
+static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
 {
        struct backbone_gw *backbone_gw;
        struct hlist_node *node, *node_tmp;
@@ -941,38 +948,37 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
                                          head, hash_entry) {
                        if (now)
                                goto purge_now;
-                       if (!has_timed_out(backbone_gw->lasttime,
-                                          BLA_BACKBONE_TIMEOUT))
+                       if (!batadv_has_timed_out(backbone_gw->lasttime,
+                                                 BATADV_BLA_BACKBONE_TIMEOUT))
                                continue;
 
-                       bat_dbg(DBG_BLA, backbone_gw->bat_priv,
-                               "bla_purge_backbone_gw(): backbone gw %pM timed out\n",
-                               backbone_gw->orig);
+                       batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
+                                  "bla_purge_backbone_gw(): backbone gw %pM timed out\n",
+                                  backbone_gw->orig);
 
 purge_now:
                        /* don't wait for the pending request anymore */
                        if (atomic_read(&backbone_gw->request_sent))
                                atomic_dec(&bat_priv->bla_num_requests);
 
-                       bla_del_backbone_claims(backbone_gw);
+                       batadv_bla_del_backbone_claims(backbone_gw);
 
                        hlist_del_rcu(node);
-                       backbone_gw_free_ref(backbone_gw);
+                       batadv_backbone_gw_free_ref(backbone_gw);
                }
                spin_unlock_bh(list_lock);
        }
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @primary_if: the selected primary interface, may be NULL if now is set
  * @now: whether the whole hash shall be wiped now
  *
  * Check when we heard last time from our own claims, and remove them in case of
  * a time out, or clean all claims if now is set
  */
-static void bla_purge_claims(struct bat_priv *bat_priv,
-                            struct hard_iface *primary_if, int now)
+static void batadv_bla_purge_claims(struct bat_priv *bat_priv,
+                                   struct hard_iface *primary_if, int now)
 {
        struct claim *claim;
        struct hlist_node *node;
@@ -991,37 +997,35 @@ static void bla_purge_claims(struct bat_priv *bat_priv,
                hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
                        if (now)
                                goto purge_now;
-                       if (!compare_eth(claim->backbone_gw->orig,
-                                        primary_if->net_dev->dev_addr))
+                       if (!batadv_compare_eth(claim->backbone_gw->orig,
+                                               primary_if->net_dev->dev_addr))
                                continue;
-                       if (!has_timed_out(claim->lasttime,
-                                          BLA_CLAIM_TIMEOUT))
+                       if (!batadv_has_timed_out(claim->lasttime,
+                                                 BATADV_BLA_CLAIM_TIMEOUT))
                                continue;
 
-                       bat_dbg(DBG_BLA, bat_priv,
-                               "bla_purge_claims(): %pM, vid %d, time out\n",
-                               claim->addr, claim->vid);
+                       batadv_dbg(DBG_BLA, bat_priv,
+                                  "bla_purge_claims(): %pM, vid %d, time out\n",
+                                  claim->addr, claim->vid);
 
 purge_now:
-                       handle_unclaim(bat_priv, primary_if,
-                                      claim->backbone_gw->orig,
-                                      claim->addr, claim->vid);
+                       batadv_handle_unclaim(bat_priv, primary_if,
+                                             claim->backbone_gw->orig,
+                                             claim->addr, claim->vid);
                }
                rcu_read_unlock();
        }
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @primary_if: the new selected primary_if
  * @oldif: the old primary interface, may be NULL
  *
  * Update the backbone gateways when the own orig address changes.
- *
  */
-void bla_update_orig_address(struct bat_priv *bat_priv,
-                            struct hard_iface *primary_if,
-                            struct hard_iface *oldif)
+void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
+                                   struct hard_iface *primary_if,
+                                   struct hard_iface *oldif)
 {
        struct backbone_gw *backbone_gw;
        struct hlist_node *node;
@@ -1034,8 +1038,8 @@ void bla_update_orig_address(struct bat_priv *bat_priv,
                htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
 
        if (!oldif) {
-               bla_purge_claims(bat_priv, NULL, 1);
-               bla_purge_backbone_gw(bat_priv, 1);
+               batadv_bla_purge_claims(bat_priv, NULL, 1);
+               batadv_bla_purge_backbone_gw(bat_priv, 1);
                return;
        }
 
@@ -1049,8 +1053,8 @@ void bla_update_orig_address(struct bat_priv *bat_priv,
                rcu_read_lock();
                hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
                        /* own orig still holds the old value. */
-                       if (!compare_eth(backbone_gw->orig,
-                                        oldif->net_dev->dev_addr))
+                       if (!batadv_compare_eth(backbone_gw->orig,
+                                               oldif->net_dev->dev_addr))
                                continue;
 
                        memcpy(backbone_gw->orig,
@@ -1058,7 +1062,7 @@ void bla_update_orig_address(struct bat_priv *bat_priv,
                        /* send an announce frame so others will ask for our
                         * claims and update their tables.
                         */
-                       bla_send_announce(bat_priv, backbone_gw);
+                       batadv_bla_send_announce(bat_priv, backbone_gw);
                }
                rcu_read_unlock();
        }
@@ -1067,18 +1071,18 @@ void bla_update_orig_address(struct bat_priv *bat_priv,
 
 
 /* (re)start the timer */
-static void bla_start_timer(struct bat_priv *bat_priv)
+static void batadv_bla_start_timer(struct bat_priv *bat_priv)
 {
-       INIT_DELAYED_WORK(&bat_priv->bla_work, bla_periodic_work);
-       queue_delayed_work(bat_event_workqueue, &bat_priv->bla_work,
-                          msecs_to_jiffies(BLA_PERIOD_LENGTH));
+       INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work);
+       queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
+                          msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
 }
 
 /* periodic work to do:
  *  * purge structures when they are too old
  *  * send announcements
  */
-static void bla_periodic_work(struct work_struct *work)
+static void batadv_bla_periodic_work(struct work_struct *work)
 {
        struct delayed_work *delayed_work =
                container_of(work, struct delayed_work, work);
@@ -1091,12 +1095,12 @@ static void bla_periodic_work(struct work_struct *work)
        struct hard_iface *primary_if;
        int i;
 
-       primary_if = primary_if_get_selected(bat_priv);
+       primary_if = batadv_primary_if_get_selected(bat_priv);
        if (!primary_if)
                goto out;
 
-       bla_purge_claims(bat_priv, primary_if, 0);
-       bla_purge_backbone_gw(bat_priv, 0);
+       batadv_bla_purge_claims(bat_priv, primary_if, 0);
+       batadv_bla_purge_backbone_gw(bat_priv, 0);
 
        if (!atomic_read(&bat_priv->bridge_loop_avoidance))
                goto out;
@@ -1110,21 +1114,21 @@ static void bla_periodic_work(struct work_struct *work)
 
                rcu_read_lock();
                hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
-                       if (!compare_eth(backbone_gw->orig,
-                                        primary_if->net_dev->dev_addr))
+                       if (!batadv_compare_eth(backbone_gw->orig,
+                                               primary_if->net_dev->dev_addr))
                                continue;
 
                        backbone_gw->lasttime = jiffies;
 
-                       bla_send_announce(bat_priv, backbone_gw);
+                       batadv_bla_send_announce(bat_priv, backbone_gw);
                }
                rcu_read_unlock();
        }
 out:
        if (primary_if)
-               hardif_free_ref(primary_if);
+               batadv_hardif_free_ref(primary_if);
 
-       bla_start_timer(bat_priv);
+       batadv_bla_start_timer(bat_priv);
 }
 
 /* The hash for claim and backbone hash receive the same key because they
@@ -1132,59 +1136,58 @@ out:
  * them with to different keys to allow nested locking without generating
  * lockdep warnings
  */
-static struct lock_class_key claim_hash_lock_class_key;
-static struct lock_class_key backbone_hash_lock_class_key;
+static struct lock_class_key batadv_claim_hash_lock_class_key;
+static struct lock_class_key batadv_backbone_hash_lock_class_key;
 
 /* initialize all bla structures */
-int bla_init(struct bat_priv *bat_priv)
+int batadv_bla_init(struct bat_priv *bat_priv)
 {
        int i;
        uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00};
        struct hard_iface *primary_if;
 
-       bat_dbg(DBG_BLA, bat_priv, "bla hash registering\n");
+       batadv_dbg(DBG_BLA, bat_priv, "bla hash registering\n");
 
        /* setting claim destination address */
        memcpy(&bat_priv->claim_dest.magic, claim_dest, 3);
        bat_priv->claim_dest.type = 0;
-       primary_if = primary_if_get_selected(bat_priv);
+       primary_if = batadv_primary_if_get_selected(bat_priv);
        if (primary_if) {
                bat_priv->claim_dest.group =
                        htons(crc16(0, primary_if->net_dev->dev_addr,
                                    ETH_ALEN));
-               hardif_free_ref(primary_if);
+               batadv_hardif_free_ref(primary_if);
        } else {
                bat_priv->claim_dest.group = 0; /* will be set later */
        }
 
        /* initialize the duplicate list */
-       for (i = 0; i < DUPLIST_SIZE; i++)
+       for (i = 0; i < BATADV_DUPLIST_SIZE; i++)
                bat_priv->bcast_duplist[i].entrytime =
-                       jiffies - msecs_to_jiffies(DUPLIST_TIMEOUT);
+                       jiffies - msecs_to_jiffies(BATADV_DUPLIST_TIMEOUT);
        bat_priv->bcast_duplist_curr = 0;
 
        if (bat_priv->claim_hash)
-               return 1;
+               return 0;
 
-       bat_priv->claim_hash = hash_new(128);
-       bat_priv->backbone_hash = hash_new(32);
+       bat_priv->claim_hash = batadv_hash_new(128);
+       bat_priv->backbone_hash = batadv_hash_new(32);
 
        if (!bat_priv->claim_hash || !bat_priv->backbone_hash)
-               return -1;
+               return -ENOMEM;
 
        batadv_hash_set_lock_class(bat_priv->claim_hash,
-                                  &claim_hash_lock_class_key);
+                                  &batadv_claim_hash_lock_class_key);
        batadv_hash_set_lock_class(bat_priv->backbone_hash,
-                                  &backbone_hash_lock_class_key);
+                                  &batadv_backbone_hash_lock_class_key);
 
-       bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n");
+       batadv_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n");
 
-       bla_start_timer(bat_priv);
-       return 1;
+       batadv_bla_start_timer(bat_priv);
+       return 0;
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @bcast_packet: originator mac address
  * @hdr_size: maximum length of the frame
  *
@@ -1196,12 +1199,10 @@ int bla_init(struct bat_priv *bat_priv)
  * with a good chance that it is the same packet. If it is furthermore
  * sent by another host, drop it. We allow equal packets from
  * the same host however as this might be intended.
- *
- **/
-
-int bla_check_bcast_duplist(struct bat_priv *bat_priv,
-                           struct bcast_packet *bcast_packet,
-                           int hdr_size)
+ */
+int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
+                                  struct bcast_packet *bcast_packet,
+                                  int hdr_size)
 {
        int i, length, curr;
        uint8_t *content;
@@ -1215,20 +1216,21 @@ int bla_check_bcast_duplist(struct bat_priv *bat_priv,
        /* calculate the crc ... */
        crc = crc16(0, content, length);
 
-       for (i = 0 ; i < DUPLIST_SIZE; i++) {
-               curr = (bat_priv->bcast_duplist_curr + i) % DUPLIST_SIZE;
+       for (i = 0; i < BATADV_DUPLIST_SIZE; i++) {
+               curr = (bat_priv->bcast_duplist_curr + i) % BATADV_DUPLIST_SIZE;
                entry = &bat_priv->bcast_duplist[curr];
 
                /* we can stop searching if the entry is too old ;
                 * later entries will be even older
                 */
-               if (has_timed_out(entry->entrytime, DUPLIST_TIMEOUT))
+               if (batadv_has_timed_out(entry->entrytime,
+                                        BATADV_DUPLIST_TIMEOUT))
                        break;
 
                if (entry->crc != crc)
                        continue;
 
-               if (compare_eth(entry->orig, bcast_packet->orig))
+               if (batadv_compare_eth(entry->orig, bcast_packet->orig))
                        continue;
 
                /* this entry seems to match: same crc, not too old,
@@ -1237,7 +1239,8 @@ int bla_check_bcast_duplist(struct bat_priv *bat_priv,
                return 1;
        }
        /* not found, add a new entry (overwrite the oldest entry) */
-       curr = (bat_priv->bcast_duplist_curr + DUPLIST_SIZE - 1) % DUPLIST_SIZE;
+       curr = (bat_priv->bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
+       curr %= BATADV_DUPLIST_SIZE;
        entry = &bat_priv->bcast_duplist[curr];
        entry->crc = crc;
        entry->entrytime = jiffies;
@@ -1250,17 +1253,14 @@ int bla_check_bcast_duplist(struct bat_priv *bat_priv,
 
 
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @orig: originator mac address
  *
  * check if the originator is a gateway for any VLAN ID.
  *
  * returns 1 if it is found, 0 otherwise
- *
  */
-
-int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
+int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
 {
        struct hashtable_t *hash = bat_priv->backbone_hash;
        struct hlist_head *head;
@@ -1279,7 +1279,7 @@ int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
 
                rcu_read_lock();
                hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
-                       if (compare_eth(backbone_gw->orig, orig)) {
+                       if (batadv_compare_eth(backbone_gw->orig, orig)) {
                                rcu_read_unlock();
                                return 1;
                        }
@@ -1291,18 +1291,16 @@ int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
 }
 
 
-/**
- * @skb: the frame to be checked
+/* @skb: the frame to be checked
  * @orig_node: the orig_node of the frame
  * @hdr_size: maximum length of the frame
  *
  * bla_is_backbone_gw inspects the skb for the VLAN ID and returns 1
  * if the orig_node is also a gateway on the soft interface, otherwise it
  * returns 0.
- *
  */
-int bla_is_backbone_gw(struct sk_buff *skb,
-                      struct orig_node *orig_node, int hdr_size)
+int batadv_bla_is_backbone_gw(struct sk_buff *skb,
+                             struct orig_node *orig_node, int hdr_size)
 {
        struct ethhdr *ethhdr;
        struct vlan_ethhdr *vhdr;
@@ -1328,40 +1326,38 @@ int bla_is_backbone_gw(struct sk_buff *skb,
        }
 
        /* see if this originator is a backbone gw for this VLAN */
-
-       backbone_gw = backbone_hash_find(orig_node->bat_priv,
-                                        orig_node->orig, vid);
+       backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
+                                               orig_node->orig, vid);
        if (!backbone_gw)
                return 0;
 
-       backbone_gw_free_ref(backbone_gw);
+       batadv_backbone_gw_free_ref(backbone_gw);
        return 1;
 }
 
 /* free all bla structures (for softinterface free or module unload) */
-void bla_free(struct bat_priv *bat_priv)
+void batadv_bla_free(struct bat_priv *bat_priv)
 {
        struct hard_iface *primary_if;
 
        cancel_delayed_work_sync(&bat_priv->bla_work);
-       primary_if = primary_if_get_selected(bat_priv);
+       primary_if = batadv_primary_if_get_selected(bat_priv);
 
        if (bat_priv->claim_hash) {
-               bla_purge_claims(bat_priv, primary_if, 1);
-               hash_destroy(bat_priv->claim_hash);
+               batadv_bla_purge_claims(bat_priv, primary_if, 1);
+               batadv_hash_destroy(bat_priv->claim_hash);
                bat_priv->claim_hash = NULL;
        }
        if (bat_priv->backbone_hash) {
-               bla_purge_backbone_gw(bat_priv, 1);
-               hash_destroy(bat_priv->backbone_hash);
+               batadv_bla_purge_backbone_gw(bat_priv, 1);
+               batadv_hash_destroy(bat_priv->backbone_hash);
                bat_priv->backbone_hash = NULL;
        }
        if (primary_if)
-               hardif_free_ref(primary_if);
+               batadv_hardif_free_ref(primary_if);
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @skb: the frame to be checked
  * @vid: the VLAN ID of the frame
  *
@@ -1372,9 +1368,8 @@ void bla_free(struct bat_priv *bat_priv)
  * in these cases, the skb is further handled by this function and
  * returns 1, otherwise it returns 0 and the caller shall further
  * process the skb.
- *
  */
-int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
+int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
 {
        struct ethhdr *ethhdr;
        struct claim search_claim, *claim = NULL;
@@ -1383,7 +1378,7 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
 
        ethhdr = (struct ethhdr *)skb_mac_header(skb);
 
-       primary_if = primary_if_get_selected(bat_priv);
+       primary_if = batadv_primary_if_get_selected(bat_priv);
        if (!primary_if)
                goto handled;
 
@@ -1398,21 +1393,21 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
 
        memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN);
        search_claim.vid = vid;
-       claim = claim_hash_find(bat_priv, &search_claim);
+       claim = batadv_claim_hash_find(bat_priv, &search_claim);
 
        if (!claim) {
                /* possible optimization: race for a claim */
                /* No claim exists yet, claim it for us!
                 */
-               handle_claim(bat_priv, primary_if,
-                            primary_if->net_dev->dev_addr,
-                            ethhdr->h_source, vid);
+               batadv_handle_claim(bat_priv, primary_if,
+                                   primary_if->net_dev->dev_addr,
+                                   ethhdr->h_source, vid);
                goto allow;
        }
 
        /* if it is our own claim ... */
-       if (compare_eth(claim->backbone_gw->orig,
-                       primary_if->net_dev->dev_addr)) {
+       if (batadv_compare_eth(claim->backbone_gw->orig,
+                              primary_if->net_dev->dev_addr)) {
                /* ... allow it in any case */
                claim->lasttime = jiffies;
                goto allow;
@@ -1427,13 +1422,13 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
                 * send a claim and update the claim table
                 * immediately.
                 */
-               handle_claim(bat_priv, primary_if,
-                            primary_if->net_dev->dev_addr,
-                            ethhdr->h_source, vid);
+               batadv_handle_claim(bat_priv, primary_if,
+                                   primary_if->net_dev->dev_addr,
+                                   ethhdr->h_source, vid);
                goto allow;
        }
 allow:
-       bla_update_own_backbone_gw(bat_priv, primary_if, vid);
+       batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
        ret = 0;
        goto out;
 
@@ -1443,14 +1438,13 @@ handled:
 
 out:
        if (primary_if)
-               hardif_free_ref(primary_if);
+               batadv_hardif_free_ref(primary_if);
        if (claim)
-               claim_free_ref(claim);
+               batadv_claim_free_ref(claim);
        return ret;
 }
 
-/**
- * @bat_priv: the bat priv with all the soft interface information
+/* @bat_priv: the bat priv with all the soft interface information
  * @skb: the frame to be checked
  * @vid: the VLAN ID of the frame
  *
@@ -1461,16 +1455,15 @@ out:
  * in these cases, the skb is further handled by this function and
  * returns 1, otherwise it returns 0 and the caller shall further
  * process the skb.
- *
  */
-int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
+int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
 {
        struct ethhdr *ethhdr;
        struct claim search_claim, *claim = NULL;
        struct hard_iface *primary_if;
        int ret = 0;
 
-       primary_if = primary_if_get_selected(bat_priv);
+       primary_if = batadv_primary_if_get_selected(bat_priv);
        if (!primary_if)
                goto out;
 
@@ -1480,7 +1473,7 @@ int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
        /* in VLAN case, the mac header might not be set. */
        skb_reset_mac_header(skb);
 
-       if (bla_process_claim(bat_priv, primary_if, skb))
+       if (batadv_bla_process_claim(bat_priv, primary_if, skb))
                goto handled;
 
        ethhdr = (struct ethhdr *)skb_mac_header(skb);
@@ -1493,21 +1486,21 @@ int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
        memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN);
        search_claim.vid = vid;
 
-       claim = claim_hash_find(bat_priv, &search_claim);
+       claim = batadv_claim_hash_find(bat_priv, &search_claim);
 
        /* if no claim exists, allow it. */
        if (!claim)
                goto allow;
 
        /* check if we are responsible. */
-       if (compare_eth(claim->backbone_gw->orig,
-                       primary_if->net_dev->dev_addr)) {
+       if (batadv_compare_eth(claim->backbone_gw->orig,
+                              primary_if->net_dev->dev_addr)) {
                /* if yes, the client has roamed and we have
                 * to unclaim it.
                 */
-               handle_unclaim(bat_priv, primary_if,
-                              primary_if->net_dev->dev_addr,
-                              ethhdr->h_source, vid);
+               batadv_handle_unclaim(bat_priv, primary_if,
+                                     primary_if->net_dev->dev_addr,
+                                     ethhdr->h_source, vid);
                goto allow;
        }
 
@@ -1524,20 +1517,20 @@ int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
                goto allow;
        }
 allow:
-       bla_update_own_backbone_gw(bat_priv, primary_if, vid);
+       batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
        ret = 0;
        goto out;
 handled:
        ret = 1;
 out:
        if (primary_if)
-               hardif_free_ref(primary_if);
+               batadv_hardif_free_ref(primary_if);
        if (claim)
-               claim_free_ref(claim);
+               batadv_claim_free_ref(claim);
        return ret;
 }
 
-int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
+int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
 {
        struct net_device *net_dev = (struct net_device *)seq->private;
        struct bat_priv *bat_priv = netdev_priv(net_dev);
@@ -1549,8 +1542,9 @@ int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
        uint32_t i;
        bool is_own;
        int ret = 0;
+       uint8_t *primary_addr;
 
-       primary_if = primary_if_get_selected(bat_priv);
+       primary_if = batadv_primary_if_get_selected(bat_priv);
        if (!primary_if) {
                ret = seq_printf(seq,
                                 "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -1565,9 +1559,10 @@ int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
                goto out;
        }
 
+       primary_addr = primary_if->net_dev->dev_addr;
        seq_printf(seq,
                   "Claims announced for the mesh %s (orig %pM, group id %04x)\n",
-                  net_dev->name, primary_if->net_dev->dev_addr,
+                  net_dev->name, primary_addr,
                   ntohs(bat_priv->claim_dest.group));
        seq_printf(seq, "   %-17s    %-5s    %-17s [o] (%-4s)\n",
                   "Client", "VID", "Originator", "CRC");
@@ -1576,8 +1571,8 @@ int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
 
                rcu_read_lock();
                hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
-                       is_own = compare_eth(claim->backbone_gw->orig,
-                                            primary_if->net_dev->dev_addr);
+                       is_own = batadv_compare_eth(claim->backbone_gw->orig,
+                                                   primary_addr);
                        seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n",
                                   claim->addr, claim->vid,
                                   claim->backbone_gw->orig,
@@ -1588,6 +1583,6 @@ int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
        }
 out:
        if (primary_if)
-               hardif_free_ref(primary_if);
+               batadv_hardif_free_ref(primary_if);
        return ret;
 }