]> Pileus Git - ~andy/linux/blobdiff - net/batman-adv/vis.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[~andy/linux] / net / batman-adv / vis.c
index f81a6b668b0c524d33f4f3b7794e2181a1897a9b..c4a5b8cafadae068582e44b213b0e09422443b28 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2011 B.A.T.M.A.N. contributors:
+ * Copyright (C) 2008-2012 B.A.T.M.A.N. contributors:
  *
  * Simon Wunderlich
  *
@@ -66,7 +66,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2)
 
 /* hash function to choose an entry in a hash table of given size */
 /* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */
-static int vis_info_choose(const void *data, int size)
+static uint32_t vis_info_choose(const void *data, uint32_t size)
 {
        const struct vis_info *vis_info = data;
        const struct vis_packet *packet;
@@ -96,7 +96,7 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv,
        struct hlist_head *head;
        struct hlist_node *node;
        struct vis_info *vis_info, *vis_info_tmp = NULL;
-       int index;
+       uint32_t index;
 
        if (!hash)
                return NULL;
@@ -202,7 +202,8 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
        HLIST_HEAD(vis_if_list);
        struct if_list_entry *entry;
        struct hlist_node *pos, *n;
-       int i, j, ret = 0;
+       uint32_t i;
+       int j, ret = 0;
        int vis_server = atomic_read(&bat_priv->vis_mode);
        size_t buff_pos, buf_size;
        char *buff;
@@ -556,7 +557,8 @@ static int find_best_vis_server(struct bat_priv *bat_priv,
        struct hlist_head *head;
        struct orig_node *orig_node;
        struct vis_packet *packet;
-       int best_tq = -1, i;
+       int best_tq = -1;
+       uint32_t i;
 
        packet = (struct vis_packet *)info->skb_packet->data;
 
@@ -607,14 +609,15 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
        struct vis_info *info = bat_priv->my_vis_info;
        struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data;
        struct vis_info_entry *entry;
-       struct tt_local_entry *tt_local_entry;
-       int best_tq = -1, i;
+       struct tt_common_entry *tt_common_entry;
+       int best_tq = -1;
+       uint32_t i;
 
        info->first_seen = jiffies;
        packet->vis_type = atomic_read(&bat_priv->vis_mode);
 
        memcpy(packet->target_orig, broadcast_addr, ETH_ALEN);
-       packet->ttl = TTL;
+       packet->header.ttl = TTL;
        packet->seqno = htonl(ntohl(packet->seqno) + 1);
        packet->entries = 0;
        skb_trim(info->skb_packet, sizeof(*packet));
@@ -669,13 +672,13 @@ next:
                head = &hash->table[i];
 
                rcu_read_lock();
-               hlist_for_each_entry_rcu(tt_local_entry, node, head,
+               hlist_for_each_entry_rcu(tt_common_entry, node, head,
                                         hash_entry) {
                        entry = (struct vis_info_entry *)
                                        skb_put(info->skb_packet,
                                                sizeof(*entry));
                        memset(entry->src, 0, ETH_ALEN);
-                       memcpy(entry->dest, tt_local_entry->addr, ETH_ALEN);
+                       memcpy(entry->dest, tt_common_entry->addr, ETH_ALEN);
                        entry->quality = 0; /* 0 means TT */
                        packet->entries++;
 
@@ -696,7 +699,7 @@ unlock:
  * held */
 static void purge_vis_packets(struct bat_priv *bat_priv)
 {
-       int i;
+       uint32_t i;
        struct hashtable_t *hash = bat_priv->vis_hash;
        struct hlist_node *node, *node_tmp;
        struct hlist_head *head;
@@ -711,8 +714,7 @@ static void purge_vis_packets(struct bat_priv *bat_priv)
                        if (info == bat_priv->my_vis_info)
                                continue;
 
-                       if (time_after(jiffies,
-                                      info->first_seen + VIS_TIMEOUT * HZ)) {
+                       if (has_timed_out(info->first_seen, VIS_TIMEOUT)) {
                                hlist_del(node);
                                send_list_del(info);
                                kref_put(&info->refcount, free_info);
@@ -733,7 +735,7 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,
        struct sk_buff *skb;
        struct hard_iface *hard_iface;
        uint8_t dstaddr[ETH_ALEN];
-       int i;
+       uint32_t i;
 
 
        packet = (struct vis_packet *)info->skb_packet->data;
@@ -815,19 +817,19 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
                goto out;
 
        packet = (struct vis_packet *)info->skb_packet->data;
-       if (packet->ttl < 2) {
+       if (packet->header.ttl < 2) {
                pr_debug("Error - can't send vis packet: ttl exceeded\n");
                goto out;
        }
 
        memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
-       packet->ttl--;
+       packet->header.ttl--;
 
        if (is_broadcast_ether_addr(packet->target_orig))
                broadcast_vis_packet(bat_priv, info);
        else
                unicast_vis_packet(bat_priv, info);
-       packet->ttl++; /* restore TTL */
+       packet->header.ttl++; /* restore TTL */
 
 out:
        if (primary_if)
@@ -907,9 +909,9 @@ int vis_init(struct bat_priv *bat_priv)
        INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list);
        kref_init(&bat_priv->my_vis_info->refcount);
        bat_priv->my_vis_info->bat_priv = bat_priv;
-       packet->version = COMPAT_VERSION;
-       packet->packet_type = BAT_VIS;
-       packet->ttl = TTL;
+       packet->header.version = COMPAT_VERSION;
+       packet->header.packet_type = BAT_VIS;
+       packet->header.ttl = TTL;
        packet->seqno = 0;
        packet->entries = 0;