From patchwork Tue Dec 27 16:24:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 1457 Return-Path: Received: from cora.hrz.tu-chemnitz.de (cora.hrz.tu-chemnitz.de [134.109.228.40]) by open-mesh.org (Postfix) with ESMTPS id 166DB600760 for ; Tue, 27 Dec 2011 17:24:13 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@tu-chemnitz.de; dkim-adsp=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tu-chemnitz.de; s=dkim2010; h=Message-Id:Date:Subject:To:From; bh=Oo2L5kqvh716dC5EW82zrIW9iKqcTVGZ7WFEj+S2vkM=; b=mReFiR4eQf/BDc9zNirrQRASG+RFj846WXCijTn/nIQoS3a34vYAH8aEYeY1yzBHvSlxc/FlZREUeQBp6bVXtwk1AHKlUTfKbR+ILFJsW+InnPeSsg4DIiU70zlfywlVx7+pRx00fAKoQT0z4Ws0s4F/vBjOr/ck1bsxEFHVf+I=; Received: from p57aa0ef6.dip0.t-ipconnect.de ([87.170.14.246] helo=pandem0nium) by cora.hrz.tu-chemnitz.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1RfZoy-0004Nq-4d for b.a.t.m.a.n@lists.open-mesh.org; Tue, 27 Dec 2011 17:24:12 +0100 Received: from dotslash by pandem0nium with local (Exim 4.72) (envelope-from ) id 1RfZot-0004Jx-VW for b.a.t.m.a.n@lists.open-mesh.org; Tue, 27 Dec 2011 17:24:08 +0100 From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 27 Dec 2011 17:24:07 +0100 Message-Id: <1325003047-16582-1-git-send-email-siwu@hrz.tu-chemnitz.de> X-Mailer: git-send-email 1.7.2.5 X-RBL-Warning: 87.170.14.246 is listed at zen.spamhaus.org X-Scan-AV: cora.hrz.tu-chemnitz.de; 2011-12-27 17:24:12; a35081ff7bf0e6260dbe253552f63a48 X-Scan-SA: cora.hrz.tu-chemnitz.de; 2011-12-27 17:24:12; 1d5e0b03fdcdef0568f4bf61318454d2 X-Spam-Score: 1.5 (+) X-Spam-Report: --- Textanalyse SpamAssassin 3.3.1 (1.5 Punkte) Fragen an/questions to: Postmaster TU Chemnitz * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 2.5 TUC_RBL RBL: Mail von bekanntem Spam-Relay oder Dialup (TUC) --- Ende Textanalyse Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: convert all times to miliseconds X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 16:24:13 -0000 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 --- gateway_client.c | 2 +- main.h | 13 +++++++------ translation-table.c | 15 ++++++--------- vis.h | 3 ++- 4 files changed, 16 insertions(+), 17 deletions(-) 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,