Staging: batman-adv: Lower resolution for timeouts
authorSimon Wunderlich <siwu@hrz.tu-chemnitz.de>
Fri, 25 Jun 2010 22:28:20 +0000 (00:28 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 8 Jul 2010 19:17:32 +0000 (12:17 -0700)
It is enough for our timeouts to keep them in seconds instead of miliseconds.
With a too high resolution, we might even risk an integer overflow, so this
patch should make things more safe.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/batman-adv/main.h
drivers/staging/batman-adv/originator.c
drivers/staging/batman-adv/translation-table.c
drivers/staging/batman-adv/vis.c
drivers/staging/batman-adv/vis.h

index ab4c9e73abe940c85ef51bfa48c02d4b2665f421..49aaec56b769d95d583c3402e4f6af23a15afd89 100644 (file)
 #define JITTER 20
 #define TTL 50                   /* Time To Live of broadcast messages */
 
-#define PURGE_TIMEOUT 200000     /* purge originators after time in ms if no
+#define PURGE_TIMEOUT 200      /* purge originators after time in seconds if no
                                   * valid packet comes in -> TODO: check
                                   * influence on TQ_LOCAL_WINDOW_SIZE */
-#define LOCAL_HNA_TIMEOUT 3600000
+#define LOCAL_HNA_TIMEOUT 3600 /* in seconds */
 
 #define TQ_LOCAL_WINDOW_SIZE 64          /* sliding packet range of received originator
                                   * messages in squence numbers (should be a
index 195c1ee0198a3338afe6a00efe4ba690ba9e687f..26bbf2d8cc3e6633fc48a5d360eebe27beb24110 100644 (file)
@@ -193,8 +193,7 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,
                neigh_node = list_entry(list_pos, struct neigh_node, list);
 
                if ((time_after(jiffies,
-                              (neigh_node->last_valid +
-                               ((PURGE_TIMEOUT * HZ) / 1000)))) ||
+                       neigh_node->last_valid + PURGE_TIMEOUT * HZ)) ||
                    (neigh_node->if_incoming->if_status ==
                                                IF_TO_BE_REMOVED)) {
 
@@ -231,8 +230,7 @@ static bool purge_orig_node(struct orig_node *orig_node)
        struct neigh_node *best_neigh_node;
 
        if (time_after(jiffies,
-                      (orig_node->last_valid +
-                       ((2 * PURGE_TIMEOUT * HZ) / 1000)))) {
+               orig_node->last_valid + 2 * PURGE_TIMEOUT * HZ)) {
 
                bat_dbg(DBG_BATMAN,
                        "Originator timeout: originator %pM, last_valid %lu\n",
index fdd902d25c7e12badd0ff165ec79c72576caa1a3..9e3c845e202797472fa03285a20b0a1bfb688fc8 100644 (file)
@@ -257,8 +257,7 @@ static void hna_local_purge(struct work_struct *work)
        while (hash_iterate(hna_local_hash, &hashit)) {
                hna_local_entry = hashit.bucket->data;
 
-               timeout = hna_local_entry->last_seen +
-                       ((LOCAL_HNA_TIMEOUT * HZ) / 1000);
+               timeout = hna_local_entry->last_seen + LOCAL_HNA_TIMEOUT * HZ;
                if ((!hna_local_entry->never_purge) &&
                    time_after(jiffies, timeout))
                        hna_local_del(hna_local_entry, "address timed out");
index ed2c1f9eec4c6e6f8fe05e8d6d0c666b2cc0c672..ddee0f2f6c8e3214074070634223c5b6963570dc 100644 (file)
@@ -597,7 +597,7 @@ static void purge_vis_packets(void)
                if (info == my_vis_info)        /* never purge own data. */
                        continue;
                if (time_after(jiffies,
-                              info->first_seen + (VIS_TIMEOUT*HZ)/1000)) {
+                              info->first_seen + VIS_TIMEOUT * HZ)) {
                        hash_remove_bucket(vis_hash, &hashit);
                        send_list_del(info);
                        kref_put(&info->refcount, free_info);
index 1cfadce5932597ad44f6736598b740cf45f4066c..e152cd7a46c66f60049362b31e1a9d680658ab65 100644 (file)
@@ -19,7 +19,7 @@
  *
  */
 
-#define VIS_TIMEOUT            200000
+#define VIS_TIMEOUT            200     /* timeout of vis packets in seconds */
 
 struct vis_info {
        unsigned long       first_seen;