diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2011-12-20 06:30:40 -0500 |
---|---|---|
committer | Marek Lindner <lindner_marek@yahoo.de> | 2012-02-16 13:50:20 -0500 |
commit | 032b7969f8874d5ddc65691cd3d008beffd2a09e (patch) | |
tree | 73a0e8bdd4dcf0f1dc3407b17df0424106027f9d /net/batman-adv | |
parent | ea3d2fd1b11fb3ef8706a48ece0a49a61bcd08bc (diff) |
batman-adv: convert time_after instances to has_timed_out
To increase readability the has_timed_out() functions has been introduced.
This patch converts existing time_after() calls to use this wrapper
function (if applicable).
This patch also converts all timeouts to miliseconds to be consistent.
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/gateway_client.c | 2 | ||||
-rw-r--r-- | net/batman-adv/main.h | 13 | ||||
-rw-r--r-- | net/batman-adv/originator.c | 11 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 3 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 4 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 15 | ||||
-rw-r--r-- | net/batman-adv/vis.c | 3 | ||||
-rw-r--r-- | net/batman-adv/vis.h | 3 |
8 files changed, 24 insertions, 30 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 24403a7350f7..df5631e1f2a5 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -396,7 +396,7 @@ void gw_node_purge(struct bat_priv *bat_priv) | |||
396 | { | 396 | { |
397 | struct gw_node *gw_node, *curr_gw; | 397 | struct gw_node *gw_node, *curr_gw; |
398 | struct hlist_node *node, *node_tmp; | 398 | struct hlist_node *node, *node_tmp; |
399 | unsigned long timeout = 2 * PURGE_TIMEOUT * HZ; | 399 | unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT); |
400 | int do_deselect = 0; | 400 | int do_deselect = 0; |
401 | 401 | ||
402 | curr_gw = gw_get_selected_gw_node(bat_priv); | 402 | curr_gw = gw_get_selected_gw_node(bat_priv); |
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 586afafb1b67..ecfed88d0d43 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -41,13 +41,14 @@ | |||
41 | 41 | ||
42 | /* purge originators after time in seconds if no valid packet comes in | 42 | /* purge originators after time in seconds if no valid packet comes in |
43 | * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */ | 43 | * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */ |
44 | #define PURGE_TIMEOUT 200 | 44 | #define PURGE_TIMEOUT 200000 /* 200 seconds */ |
45 | #define TT_LOCAL_TIMEOUT 3600 /* in seconds */ | 45 | #define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */ |
46 | #define TT_CLIENT_ROAM_TIMEOUT 600 | 46 | #define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */ |
47 | /* sliding packet range of received originator messages in sequence numbers | 47 | /* sliding packet range of received originator messages in sequence numbers |
48 | * (should be a multiple of our word size) */ | 48 | * (should be a multiple of our word size) */ |
49 | #define TQ_LOCAL_WINDOW_SIZE 64 | 49 | #define TQ_LOCAL_WINDOW_SIZE 64 |
50 | #define TT_REQUEST_TIMEOUT 3 /* seconds we have to keep pending tt_req */ | 50 | #define TT_REQUEST_TIMEOUT 3000 /* miliseconds we have to keep |
51 | * pending tt_req */ | ||
51 | 52 | ||
52 | #define TQ_GLOBAL_WINDOW_SIZE 5 | 53 | #define TQ_GLOBAL_WINDOW_SIZE 5 |
53 | #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 | 54 | #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 |
@@ -56,8 +57,8 @@ | |||
56 | 57 | ||
57 | #define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ | 58 | #define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ |
58 | 59 | ||
59 | #define ROAMING_MAX_TIME 20 /* Time in which a client can roam at most | 60 | #define ROAMING_MAX_TIME 20000 /* Time in which a client can roam at most |
60 | * ROAMING_MAX_COUNT times */ | 61 | * ROAMING_MAX_COUNT times in miliseconds*/ |
61 | #define ROAMING_MAX_COUNT 5 | 62 | #define ROAMING_MAX_COUNT 5 |
62 | 63 | ||
63 | #define NO_FLAGS 0 | 64 | #define NO_FLAGS 0 |
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 847ff7e98a61..1161f27ad8cc 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -282,8 +282,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, | |||
282 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, | 282 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, |
283 | &orig_node->neigh_list, list) { | 283 | &orig_node->neigh_list, list) { |
284 | 284 | ||
285 | if ((time_after(jiffies, | 285 | if ((has_timed_out(neigh_node->last_valid, PURGE_TIMEOUT)) || |
286 | neigh_node->last_valid + PURGE_TIMEOUT * HZ)) || | ||
287 | (neigh_node->if_incoming->if_status == IF_INACTIVE) || | 286 | (neigh_node->if_incoming->if_status == IF_INACTIVE) || |
288 | (neigh_node->if_incoming->if_status == IF_NOT_IN_USE) || | 287 | (neigh_node->if_incoming->if_status == IF_NOT_IN_USE) || |
289 | (neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) { | 288 | (neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) { |
@@ -327,9 +326,7 @@ static bool purge_orig_node(struct bat_priv *bat_priv, | |||
327 | { | 326 | { |
328 | struct neigh_node *best_neigh_node; | 327 | struct neigh_node *best_neigh_node; |
329 | 328 | ||
330 | if (time_after(jiffies, | 329 | if (has_timed_out(orig_node->last_valid, 2 * PURGE_TIMEOUT)) { |
331 | orig_node->last_valid + 2 * PURGE_TIMEOUT * HZ)) { | ||
332 | |||
333 | bat_dbg(DBG_BATMAN, bat_priv, | 330 | bat_dbg(DBG_BATMAN, bat_priv, |
334 | "Originator timeout: originator %pM, last_valid %lu\n", | 331 | "Originator timeout: originator %pM, last_valid %lu\n", |
335 | orig_node->orig, (orig_node->last_valid / HZ)); | 332 | orig_node->orig, (orig_node->last_valid / HZ)); |
@@ -372,8 +369,8 @@ static void _purge_orig(struct bat_priv *bat_priv) | |||
372 | continue; | 369 | continue; |
373 | } | 370 | } |
374 | 371 | ||
375 | if (time_after(jiffies, orig_node->last_frag_packet + | 372 | if (has_timed_out(orig_node->last_frag_packet, |
376 | msecs_to_jiffies(FRAG_TIMEOUT))) | 373 | FRAG_TIMEOUT)) |
377 | frag_list_free(&orig_node->frag_list); | 374 | frag_list_free(&orig_node->frag_list); |
378 | } | 375 | } |
379 | spin_unlock_bh(list_lock); | 376 | spin_unlock_bh(list_lock); |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index b72d7f3b3c6a..c1e45c0bb186 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -231,8 +231,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, | |||
231 | { | 231 | { |
232 | if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) | 232 | if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) |
233 | || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { | 233 | || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { |
234 | if (time_after(jiffies, *last_reset + | 234 | if (has_timed_out(*last_reset, RESET_PROTECTION_MS)) { |
235 | msecs_to_jiffies(RESET_PROTECTION_MS))) { | ||
236 | 235 | ||
237 | *last_reset = jiffies; | 236 | *last_reset = jiffies; |
238 | bat_dbg(DBG_BATMAN, bat_priv, | 237 | bat_dbg(DBG_BATMAN, bat_priv, |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index b5aecd5e45cc..c41dac3bbf81 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -396,8 +396,8 @@ void softif_neigh_purge(struct bat_priv *bat_priv) | |||
396 | hlist_for_each_entry_safe(softif_neigh, node_tmp, node_tmp2, | 396 | hlist_for_each_entry_safe(softif_neigh, node_tmp, node_tmp2, |
397 | &softif_neigh_vid->softif_neigh_list, | 397 | &softif_neigh_vid->softif_neigh_list, |
398 | list) { | 398 | list) { |
399 | if ((!time_after(jiffies, softif_neigh->last_seen + | 399 | if ((!has_timed_out(softif_neigh->last_seen, |
400 | msecs_to_jiffies(SOFTIF_NEIGH_TIMEOUT))) && | 400 | SOFTIF_NEIGH_TIMEOUT)) && |
401 | (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE)) | 401 | (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE)) |
402 | continue; | 402 | continue; |
403 | 403 | ||
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index a84e80409f9b..ff9a1b33c136 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -413,7 +413,7 @@ static void tt_local_purge(struct bat_priv *bat_priv) | |||
413 | continue; | 413 | continue; |
414 | 414 | ||
415 | if (!has_timed_out(tt_local_entry->last_seen, | 415 | if (!has_timed_out(tt_local_entry->last_seen, |
416 | TT_LOCAL_TIMEOUT * 1000)) | 416 | TT_LOCAL_TIMEOUT)) |
417 | continue; | 417 | continue; |
418 | 418 | ||
419 | tt_local_set_pending(bat_priv, tt_local_entry, | 419 | tt_local_set_pending(bat_priv, tt_local_entry, |
@@ -751,7 +751,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) | |||
751 | if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) | 751 | if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) |
752 | continue; | 752 | continue; |
753 | if (!has_timed_out(tt_global_entry->roam_at, | 753 | if (!has_timed_out(tt_global_entry->roam_at, |
754 | TT_CLIENT_ROAM_TIMEOUT * 1000)) | 754 | TT_CLIENT_ROAM_TIMEOUT)) |
755 | continue; | 755 | continue; |
756 | 756 | ||
757 | bat_dbg(DBG_TT, bat_priv, "Deleting global " | 757 | bat_dbg(DBG_TT, bat_priv, "Deleting global " |
@@ -970,8 +970,7 @@ static void tt_req_purge(struct bat_priv *bat_priv) | |||
970 | 970 | ||
971 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 971 | spin_lock_bh(&bat_priv->tt_req_list_lock); |
972 | list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { | 972 | list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { |
973 | if (has_timed_out(node->issued_at, | 973 | if (has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { |
974 | TT_REQUEST_TIMEOUT * 1000)) { | ||
975 | list_del(&node->list); | 974 | list_del(&node->list); |
976 | kfree(node); | 975 | kfree(node); |
977 | } | 976 | } |
@@ -990,7 +989,7 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, | |||
990 | list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { | 989 | list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { |
991 | if (compare_eth(tt_req_node_tmp, orig_node) && | 990 | if (compare_eth(tt_req_node_tmp, orig_node) && |
992 | !has_timed_out(tt_req_node_tmp->issued_at, | 991 | !has_timed_out(tt_req_node_tmp->issued_at, |
993 | TT_REQUEST_TIMEOUT * 1000)) | 992 | TT_REQUEST_TIMEOUT)) |
994 | goto unlock; | 993 | goto unlock; |
995 | } | 994 | } |
996 | 995 | ||
@@ -1583,8 +1582,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv) | |||
1583 | 1582 | ||
1584 | spin_lock_bh(&bat_priv->tt_roam_list_lock); | 1583 | spin_lock_bh(&bat_priv->tt_roam_list_lock); |
1585 | list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { | 1584 | list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { |
1586 | if (!has_timed_out(node->first_time, | 1585 | if (!has_timed_out(node->first_time, ROAMING_MAX_TIME)) |
1587 | ROAMING_MAX_TIME * 1000)) | ||
1588 | continue; | 1586 | continue; |
1589 | 1587 | ||
1590 | list_del(&node->list); | 1588 | list_del(&node->list); |
@@ -1611,8 +1609,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv, | |||
1611 | if (!compare_eth(tt_roam_node->addr, client)) | 1609 | if (!compare_eth(tt_roam_node->addr, client)) |
1612 | continue; | 1610 | continue; |
1613 | 1611 | ||
1614 | if (has_timed_out(tt_roam_node->first_time, | 1612 | if (has_timed_out(tt_roam_node->first_time, ROAMING_MAX_TIME)) |
1615 | ROAMING_MAX_TIME * 1000)) | ||
1616 | continue; | 1613 | continue; |
1617 | 1614 | ||
1618 | if (!atomic_dec_not_zero(&tt_roam_node->counter)) | 1615 | if (!atomic_dec_not_zero(&tt_roam_node->counter)) |
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index ac7e66100590..4f4b2a0c2d7b 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -714,8 +714,7 @@ static void purge_vis_packets(struct bat_priv *bat_priv) | |||
714 | if (info == bat_priv->my_vis_info) | 714 | if (info == bat_priv->my_vis_info) |
715 | continue; | 715 | continue; |
716 | 716 | ||
717 | if (time_after(jiffies, | 717 | if (has_timed_out(info->first_seen, VIS_TIMEOUT)) { |
718 | info->first_seen + VIS_TIMEOUT * HZ)) { | ||
719 | hlist_del(node); | 718 | hlist_del(node); |
720 | send_list_del(info); | 719 | send_list_del(info); |
721 | kref_put(&info->refcount, free_info); | 720 | kref_put(&info->refcount, free_info); |
diff --git a/net/batman-adv/vis.h b/net/batman-adv/vis.h index 31b820d07f23..851bc4f1e358 100644 --- a/net/batman-adv/vis.h +++ b/net/batman-adv/vis.h | |||
@@ -22,7 +22,8 @@ | |||
22 | #ifndef _NET_BATMAN_ADV_VIS_H_ | 22 | #ifndef _NET_BATMAN_ADV_VIS_H_ |
23 | #define _NET_BATMAN_ADV_VIS_H_ | 23 | #define _NET_BATMAN_ADV_VIS_H_ |
24 | 24 | ||
25 | #define VIS_TIMEOUT 200 /* timeout of vis packets in seconds */ | 25 | #define VIS_TIMEOUT 200000 /* timeout of vis packets |
26 | * in miliseconds */ | ||
26 | 27 | ||
27 | int vis_seq_print_text(struct seq_file *seq, void *offset); | 28 | int vis_seq_print_text(struct seq_file *seq, void *offset); |
28 | void receive_server_sync_packet(struct bat_priv *bat_priv, | 29 | void receive_server_sync_packet(struct bat_priv *bat_priv, |