diff options
author | Tina Ruchandani <ruchandani.tina@gmail.com> | 2017-11-27 09:02:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-30 09:26:32 -0500 |
commit | d750dbdc071bf863112ea83c64cd7c44d4bad261 (patch) | |
tree | 6de5b06174f72a5cff623e5fb0c46fd05c6abcf2 /net/atm/mpoa_caches.c | |
parent | 59c036995c65606ae7d4ba3b93dfc01361618dce (diff) |
atm: mpoa: remove 32-bit timekeeping
net/atm/mpoa_* files use 'struct timeval' to store event
timestamps. struct timeval uses a 32-bit seconds field which will
overflow in the year 2038 and beyond. Morever, the timestamps are being
compared only to get seconds elapsed, so struct timeval which stores
a seconds and microseconds field is an overkill. This patch replaces
the use of struct timeval with time64_t to store a 64-bit seconds field.
Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/atm/mpoa_caches.c')
-rw-r--r-- | net/atm/mpoa_caches.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c index e01450bb32d6..4bb418313720 100644 --- a/net/atm/mpoa_caches.c +++ b/net/atm/mpoa_caches.c | |||
@@ -117,7 +117,7 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip, | |||
117 | 117 | ||
118 | memcpy(entry->MPS_ctrl_ATM_addr, client->mps_ctrl_addr, ATM_ESA_LEN); | 118 | memcpy(entry->MPS_ctrl_ATM_addr, client->mps_ctrl_addr, ATM_ESA_LEN); |
119 | entry->ctrl_info.in_dst_ip = dst_ip; | 119 | entry->ctrl_info.in_dst_ip = dst_ip; |
120 | do_gettimeofday(&(entry->tv)); | 120 | entry->time = ktime_get_seconds(); |
121 | entry->retry_time = client->parameters.mpc_p4; | 121 | entry->retry_time = client->parameters.mpc_p4; |
122 | entry->count = 1; | 122 | entry->count = 1; |
123 | entry->entry_state = INGRESS_INVALID; | 123 | entry->entry_state = INGRESS_INVALID; |
@@ -148,7 +148,7 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc) | |||
148 | if (qos != NULL) | 148 | if (qos != NULL) |
149 | msg.qos = qos->qos; | 149 | msg.qos = qos->qos; |
150 | msg_to_mpoad(&msg, mpc); | 150 | msg_to_mpoad(&msg, mpc); |
151 | do_gettimeofday(&(entry->reply_wait)); | 151 | entry->reply_wait = ktime_get_seconds(); |
152 | entry->entry_state = INGRESS_RESOLVING; | 152 | entry->entry_state = INGRESS_RESOLVING; |
153 | } | 153 | } |
154 | if (entry->shortcut != NULL) | 154 | if (entry->shortcut != NULL) |
@@ -171,7 +171,7 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc) | |||
171 | if (qos != NULL) | 171 | if (qos != NULL) |
172 | msg.qos = qos->qos; | 172 | msg.qos = qos->qos; |
173 | msg_to_mpoad(&msg, mpc); | 173 | msg_to_mpoad(&msg, mpc); |
174 | do_gettimeofday(&(entry->reply_wait)); | 174 | entry->reply_wait = ktime_get_seconds(); |
175 | } | 175 | } |
176 | 176 | ||
177 | return CLOSED; | 177 | return CLOSED; |
@@ -227,17 +227,16 @@ static void in_cache_remove_entry(in_cache_entry *entry, | |||
227 | static void clear_count_and_expired(struct mpoa_client *client) | 227 | static void clear_count_and_expired(struct mpoa_client *client) |
228 | { | 228 | { |
229 | in_cache_entry *entry, *next_entry; | 229 | in_cache_entry *entry, *next_entry; |
230 | struct timeval now; | 230 | time64_t now; |
231 | 231 | ||
232 | do_gettimeofday(&now); | 232 | now = ktime_get_seconds(); |
233 | 233 | ||
234 | write_lock_bh(&client->ingress_lock); | 234 | write_lock_bh(&client->ingress_lock); |
235 | entry = client->in_cache; | 235 | entry = client->in_cache; |
236 | while (entry != NULL) { | 236 | while (entry != NULL) { |
237 | entry->count = 0; | 237 | entry->count = 0; |
238 | next_entry = entry->next; | 238 | next_entry = entry->next; |
239 | if ((now.tv_sec - entry->tv.tv_sec) | 239 | if ((now - entry->time) > entry->ctrl_info.holding_time) { |
240 | > entry->ctrl_info.holding_time) { | ||
241 | dprintk("holding time expired, ip = %pI4\n", | 240 | dprintk("holding time expired, ip = %pI4\n", |
242 | &entry->ctrl_info.in_dst_ip); | 241 | &entry->ctrl_info.in_dst_ip); |
243 | client->in_ops->remove_entry(entry, client); | 242 | client->in_ops->remove_entry(entry, client); |
@@ -253,35 +252,35 @@ static void check_resolving_entries(struct mpoa_client *client) | |||
253 | 252 | ||
254 | struct atm_mpoa_qos *qos; | 253 | struct atm_mpoa_qos *qos; |
255 | in_cache_entry *entry; | 254 | in_cache_entry *entry; |
256 | struct timeval now; | 255 | time64_t now; |
257 | struct k_message msg; | 256 | struct k_message msg; |
258 | 257 | ||
259 | do_gettimeofday(&now); | 258 | now = ktime_get_seconds(); |
260 | 259 | ||
261 | read_lock_bh(&client->ingress_lock); | 260 | read_lock_bh(&client->ingress_lock); |
262 | entry = client->in_cache; | 261 | entry = client->in_cache; |
263 | while (entry != NULL) { | 262 | while (entry != NULL) { |
264 | if (entry->entry_state == INGRESS_RESOLVING) { | 263 | if (entry->entry_state == INGRESS_RESOLVING) { |
265 | if ((now.tv_sec - entry->hold_down.tv_sec) < | 264 | |
266 | client->parameters.mpc_p6) { | 265 | if ((now - entry->hold_down) |
266 | < client->parameters.mpc_p6) { | ||
267 | entry = entry->next; /* Entry in hold down */ | 267 | entry = entry->next; /* Entry in hold down */ |
268 | continue; | 268 | continue; |
269 | } | 269 | } |
270 | if ((now.tv_sec - entry->reply_wait.tv_sec) > | 270 | if ((now - entry->reply_wait) > entry->retry_time) { |
271 | entry->retry_time) { | ||
272 | entry->retry_time = MPC_C1 * (entry->retry_time); | 271 | entry->retry_time = MPC_C1 * (entry->retry_time); |
273 | /* | 272 | /* |
274 | * Retry time maximum exceeded, | 273 | * Retry time maximum exceeded, |
275 | * put entry in hold down. | 274 | * put entry in hold down. |
276 | */ | 275 | */ |
277 | if (entry->retry_time > client->parameters.mpc_p5) { | 276 | if (entry->retry_time > client->parameters.mpc_p5) { |
278 | do_gettimeofday(&(entry->hold_down)); | 277 | entry->hold_down = ktime_get_seconds(); |
279 | entry->retry_time = client->parameters.mpc_p4; | 278 | entry->retry_time = client->parameters.mpc_p4; |
280 | entry = entry->next; | 279 | entry = entry->next; |
281 | continue; | 280 | continue; |
282 | } | 281 | } |
283 | /* Ask daemon to send a resolution request. */ | 282 | /* Ask daemon to send a resolution request. */ |
284 | memset(&(entry->hold_down), 0, sizeof(struct timeval)); | 283 | memset(&entry->hold_down, 0, sizeof(time64_t)); |
285 | msg.type = SND_MPOA_RES_RTRY; | 284 | msg.type = SND_MPOA_RES_RTRY; |
286 | memcpy(msg.MPS_ctrl, client->mps_ctrl_addr, ATM_ESA_LEN); | 285 | memcpy(msg.MPS_ctrl, client->mps_ctrl_addr, ATM_ESA_LEN); |
287 | msg.content.in_info = entry->ctrl_info; | 286 | msg.content.in_info = entry->ctrl_info; |
@@ -289,7 +288,7 @@ static void check_resolving_entries(struct mpoa_client *client) | |||
289 | if (qos != NULL) | 288 | if (qos != NULL) |
290 | msg.qos = qos->qos; | 289 | msg.qos = qos->qos; |
291 | msg_to_mpoad(&msg, client); | 290 | msg_to_mpoad(&msg, client); |
292 | do_gettimeofday(&(entry->reply_wait)); | 291 | entry->reply_wait = ktime_get_seconds(); |
293 | } | 292 | } |
294 | } | 293 | } |
295 | entry = entry->next; | 294 | entry = entry->next; |
@@ -300,18 +299,18 @@ static void check_resolving_entries(struct mpoa_client *client) | |||
300 | /* Call this every MPC-p5 seconds. */ | 299 | /* Call this every MPC-p5 seconds. */ |
301 | static void refresh_entries(struct mpoa_client *client) | 300 | static void refresh_entries(struct mpoa_client *client) |
302 | { | 301 | { |
303 | struct timeval now; | 302 | time64_t now; |
304 | struct in_cache_entry *entry = client->in_cache; | 303 | struct in_cache_entry *entry = client->in_cache; |
305 | 304 | ||
306 | ddprintk("refresh_entries\n"); | 305 | ddprintk("refresh_entries\n"); |
307 | do_gettimeofday(&now); | 306 | now = ktime_get_seconds(); |
308 | 307 | ||
309 | read_lock_bh(&client->ingress_lock); | 308 | read_lock_bh(&client->ingress_lock); |
310 | while (entry != NULL) { | 309 | while (entry != NULL) { |
311 | if (entry->entry_state == INGRESS_RESOLVED) { | 310 | if (entry->entry_state == INGRESS_RESOLVED) { |
312 | if (!(entry->refresh_time)) | 311 | if (!(entry->refresh_time)) |
313 | entry->refresh_time = (2 * (entry->ctrl_info.holding_time))/3; | 312 | entry->refresh_time = (2 * (entry->ctrl_info.holding_time))/3; |
314 | if ((now.tv_sec - entry->reply_wait.tv_sec) > | 313 | if ((now - entry->reply_wait) > |
315 | entry->refresh_time) { | 314 | entry->refresh_time) { |
316 | dprintk("refreshing an entry.\n"); | 315 | dprintk("refreshing an entry.\n"); |
317 | entry->entry_state = INGRESS_REFRESHING; | 316 | entry->entry_state = INGRESS_REFRESHING; |
@@ -480,7 +479,7 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, | |||
480 | 479 | ||
481 | memcpy(entry->MPS_ctrl_ATM_addr, client->mps_ctrl_addr, ATM_ESA_LEN); | 480 | memcpy(entry->MPS_ctrl_ATM_addr, client->mps_ctrl_addr, ATM_ESA_LEN); |
482 | entry->ctrl_info = msg->content.eg_info; | 481 | entry->ctrl_info = msg->content.eg_info; |
483 | do_gettimeofday(&(entry->tv)); | 482 | entry->time = ktime_get_seconds(); |
484 | entry->entry_state = EGRESS_RESOLVED; | 483 | entry->entry_state = EGRESS_RESOLVED; |
485 | dprintk("new_eg_cache_entry cache_id %u\n", | 484 | dprintk("new_eg_cache_entry cache_id %u\n", |
486 | ntohl(entry->ctrl_info.cache_id)); | 485 | ntohl(entry->ctrl_info.cache_id)); |
@@ -495,7 +494,7 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, | |||
495 | 494 | ||
496 | static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) | 495 | static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) |
497 | { | 496 | { |
498 | do_gettimeofday(&(entry->tv)); | 497 | entry->time = ktime_get_seconds(); |
499 | entry->entry_state = EGRESS_RESOLVED; | 498 | entry->entry_state = EGRESS_RESOLVED; |
500 | entry->ctrl_info.holding_time = holding_time; | 499 | entry->ctrl_info.holding_time = holding_time; |
501 | } | 500 | } |
@@ -503,17 +502,16 @@ static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) | |||
503 | static void clear_expired(struct mpoa_client *client) | 502 | static void clear_expired(struct mpoa_client *client) |
504 | { | 503 | { |
505 | eg_cache_entry *entry, *next_entry; | 504 | eg_cache_entry *entry, *next_entry; |
506 | struct timeval now; | 505 | time64_t now; |
507 | struct k_message msg; | 506 | struct k_message msg; |
508 | 507 | ||
509 | do_gettimeofday(&now); | 508 | now = ktime_get_seconds(); |
510 | 509 | ||
511 | write_lock_irq(&client->egress_lock); | 510 | write_lock_irq(&client->egress_lock); |
512 | entry = client->eg_cache; | 511 | entry = client->eg_cache; |
513 | while (entry != NULL) { | 512 | while (entry != NULL) { |
514 | next_entry = entry->next; | 513 | next_entry = entry->next; |
515 | if ((now.tv_sec - entry->tv.tv_sec) | 514 | if ((now - entry->time) > entry->ctrl_info.holding_time) { |
516 | > entry->ctrl_info.holding_time) { | ||
517 | msg.type = SND_EGRESS_PURGE; | 515 | msg.type = SND_EGRESS_PURGE; |
518 | msg.content.eg_info = entry->ctrl_info; | 516 | msg.content.eg_info = entry->ctrl_info; |
519 | dprintk("egress_cache: holding time expired, cache_id = %u.\n", | 517 | dprintk("egress_cache: holding time expired, cache_id = %u.\n", |