The following commit has been merged in the master branch:
commit d2c993d1532362a5c6e14e4bc9f0b2dfad64ed24
Author: Simon Wunderlich <simon.wunderlich(a)s2003.tu-chemnitz.de>
Date: Tue Dec 27 17:24:07 2011 +0100
batman-adv: convert all times to miliseconds
has_timed_out() takes the second argument in miliseconds. The commit
"batman-adv: convert time_after instances to has_timed_out" introduced
some bugs by confusing seconds and miliseconds.
This patch converts all timeouts to miliseconds to be consistent, and
also fixes the previously introduced bugs.
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
diff --git a/gateway_client.c b/gateway_client.c
index 24403a7..df5631e 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -396,7 +396,7 @@ void gw_node_purge(struct bat_priv *bat_priv)
{
struct gw_node *gw_node, *curr_gw;
struct hlist_node *node, *node_tmp;
- unsigned long timeout = 2 * PURGE_TIMEOUT * HZ;
+ unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT);
int do_deselect = 0;
curr_gw = gw_get_selected_gw_node(bat_priv);
diff --git a/main.h b/main.h
index 222c120..d124c28 100644
--- a/main.h
+++ b/main.h
@@ -41,13 +41,14 @@
/* purge originators after time in seconds if no valid packet comes in
* -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */
-#define PURGE_TIMEOUT 200
-#define TT_LOCAL_TIMEOUT 3600 /* in seconds */
-#define TT_CLIENT_ROAM_TIMEOUT 600
+#define PURGE_TIMEOUT 200000 /* 200 seconds */
+#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */
+#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */
/* sliding packet range of received originator messages in sequence numbers
* (should be a multiple of our word size) */
#define TQ_LOCAL_WINDOW_SIZE 64
-#define TT_REQUEST_TIMEOUT 3 /* seconds we have to keep pending tt_req */
+#define TT_REQUEST_TIMEOUT 3000 /* miliseconds we have to keep
+ * pending tt_req */
#define TQ_GLOBAL_WINDOW_SIZE 5
#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
@@ -56,8 +57,8 @@
#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */
-#define ROAMING_MAX_TIME 20 /* Time in which a client can roam at most
- * ROAMING_MAX_COUNT times */
+#define ROAMING_MAX_TIME 20000 /* Time in which a client can roam at most
+ * ROAMING_MAX_COUNT times in miliseconds*/
#define ROAMING_MAX_COUNT 5
#define NO_FLAGS 0
diff --git a/translation-table.c b/translation-table.c
index a1be7ef..9fe38c1 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -413,7 +413,7 @@ static void tt_local_purge(struct bat_priv *bat_priv)
continue;
if (!has_timed_out(tt_local_entry->last_seen,
- TT_LOCAL_TIMEOUT * 1000))
+ TT_LOCAL_TIMEOUT))
continue;
tt_local_set_pending(bat_priv, tt_local_entry,
@@ -753,7 +753,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM))
continue;
if (!has_timed_out(tt_global_entry->roam_at,
- TT_CLIENT_ROAM_TIMEOUT * 1000))
+ TT_CLIENT_ROAM_TIMEOUT))
continue;
bat_dbg(DBG_TT, bat_priv, "Deleting global "
@@ -972,8 +972,7 @@ static void tt_req_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_req_list_lock);
list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) {
- if (has_timed_out(node->issued_at,
- TT_REQUEST_TIMEOUT * 1000)) {
+ if (has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) {
list_del(&node->list);
kfree(node);
}
@@ -992,7 +991,7 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) {
if (compare_eth(tt_req_node_tmp, orig_node) &&
!has_timed_out(tt_req_node_tmp->issued_at,
- TT_REQUEST_TIMEOUT * 1000))
+ TT_REQUEST_TIMEOUT))
goto unlock;
}
@@ -1585,8 +1584,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_roam_list_lock);
list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) {
- if (!has_timed_out(node->first_time,
- ROAMING_MAX_TIME * 1000))
+ if (!has_timed_out(node->first_time, ROAMING_MAX_TIME))
continue;
list_del(&node->list);
@@ -1613,8 +1611,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
if (!compare_eth(tt_roam_node->addr, client))
continue;
- if (has_timed_out(tt_roam_node->first_time,
- ROAMING_MAX_TIME * 1000))
+ if (has_timed_out(tt_roam_node->first_time, ROAMING_MAX_TIME))
continue;
if (!atomic_dec_not_zero(&tt_roam_node->counter))
diff --git a/vis.h b/vis.h
index 31b820d..851bc4f 100644
--- a/vis.h
+++ b/vis.h
@@ -22,7 +22,8 @@
#ifndef _NET_BATMAN_ADV_VIS_H_
#define _NET_BATMAN_ADV_VIS_H_
-#define VIS_TIMEOUT 200 /* timeout of vis packets in seconds */
+#define VIS_TIMEOUT 200000 /* timeout of vis packets
+ * in miliseconds */
int vis_seq_print_text(struct seq_file *seq, void *offset);
void receive_server_sync_packet(struct bat_priv *bat_priv,
--
batman-adv