Author: simon Date: 2010-06-20 00:42:39 +0200 (Sun, 20 Jun 2010) New Revision: 1711
Modified: trunk/batman-adv-kernelland/gateway_client.c trunk/batman-adv-kernelland/main.h trunk/batman-adv-kernelland/originator.c trunk/batman-adv-kernelland/translation-table.c trunk/batman-adv-kernelland/vis.c trunk/batman-adv-kernelland/vis.h Log: batman-adv: Lower resolution for timeouts
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
Modified: trunk/batman-adv-kernelland/gateway_client.c =================================================================== --- trunk/batman-adv-kernelland/gateway_client.c 2010-06-19 22:23:29 UTC (rev 1710) +++ trunk/batman-adv-kernelland/gateway_client.c 2010-06-19 22:42:39 UTC (rev 1711) @@ -286,7 +286,7 @@ void gw_node_purge_deleted(void) { struct gw_node *gw_node, *gw_node_tmp; - unsigned long timeout = (2 * PURGE_TIMEOUT * HZ) / 1000; + unsigned long timeout = 2 * PURGE_TIMEOUT * HZ;
spin_lock(&gw_list_lock);
Modified: trunk/batman-adv-kernelland/main.h =================================================================== --- trunk/batman-adv-kernelland/main.h 2010-06-19 22:23:29 UTC (rev 1710) +++ trunk/batman-adv-kernelland/main.h 2010-06-19 22:42:39 UTC (rev 1711) @@ -36,10 +36,10 @@ #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
Modified: trunk/batman-adv-kernelland/originator.c =================================================================== --- trunk/batman-adv-kernelland/originator.c 2010-06-19 22:23:29 UTC (rev 1710) +++ trunk/batman-adv-kernelland/originator.c 2010-06-19 22:42:39 UTC (rev 1711) @@ -195,8 +195,7 @@ 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)) {
@@ -233,8 +232,7 @@ 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",
Modified: trunk/batman-adv-kernelland/translation-table.c =================================================================== --- trunk/batman-adv-kernelland/translation-table.c 2010-06-19 22:23:29 UTC (rev 1710) +++ trunk/batman-adv-kernelland/translation-table.c 2010-06-19 22:42:39 UTC (rev 1711) @@ -258,8 +258,7 @@ 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");
Modified: trunk/batman-adv-kernelland/vis.c =================================================================== --- trunk/batman-adv-kernelland/vis.c 2010-06-19 22:23:29 UTC (rev 1710) +++ trunk/batman-adv-kernelland/vis.c 2010-06-19 22:42:39 UTC (rev 1711) @@ -598,7 +598,7 @@ 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);
Modified: trunk/batman-adv-kernelland/vis.h =================================================================== --- trunk/batman-adv-kernelland/vis.h 2010-06-19 22:23:29 UTC (rev 1710) +++ trunk/batman-adv-kernelland/vis.h 2010-06-19 22:42:39 UTC (rev 1711) @@ -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;