summaryrefslogtreecommitdiffstats
path: root/net/atm
diff options
context:
space:
mode:
authorTina Ruchandani <ruchandani.tina@gmail.com>2017-11-27 09:02:17 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-30 09:26:32 -0500
commitd750dbdc071bf863112ea83c64cd7c44d4bad261 (patch)
tree6de5b06174f72a5cff623e5fb0c46fd05c6abcf2 /net/atm
parent59c036995c65606ae7d4ba3b93dfc01361618dce (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')
-rw-r--r--net/atm/common.c2
-rw-r--r--net/atm/mpc.c9
-rw-r--r--net/atm/mpoa_caches.c48
-rw-r--r--net/atm/mpoa_caches.h9
-rw-r--r--net/atm/mpoa_proc.c15
5 files changed, 43 insertions, 40 deletions
diff --git a/net/atm/common.c b/net/atm/common.c
index 8a4f99114cd2..5763fd241dc3 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -14,7 +14,7 @@
14#include <linux/capability.h> 14#include <linux/capability.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/sched/signal.h> 16#include <linux/sched/signal.h>
17#include <linux/time.h> /* struct timeval */ 17#include <linux/time64.h> /* 64-bit time for seconds */
18#include <linux/skbuff.h> 18#include <linux/skbuff.h>
19#include <linux/bitops.h> 19#include <linux/bitops.h>
20#include <linux/init.h> 20#include <linux/init.h>
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 7c6a1cc760a2..31e0dcb970f8 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -1089,7 +1089,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1089 msg->type = SND_MPOA_RES_RQST; 1089 msg->type = SND_MPOA_RES_RQST;
1090 msg->content.in_info = entry->ctrl_info; 1090 msg->content.in_info = entry->ctrl_info;
1091 msg_to_mpoad(msg, mpc); 1091 msg_to_mpoad(msg, mpc);
1092 do_gettimeofday(&(entry->reply_wait)); 1092 entry->reply_wait = ktime_get_seconds();
1093 mpc->in_ops->put(entry); 1093 mpc->in_ops->put(entry);
1094 return; 1094 return;
1095 } 1095 }
@@ -1099,7 +1099,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1099 msg->type = SND_MPOA_RES_RQST; 1099 msg->type = SND_MPOA_RES_RQST;
1100 msg->content.in_info = entry->ctrl_info; 1100 msg->content.in_info = entry->ctrl_info;
1101 msg_to_mpoad(msg, mpc); 1101 msg_to_mpoad(msg, mpc);
1102 do_gettimeofday(&(entry->reply_wait)); 1102 entry->reply_wait = ktime_get_seconds();
1103 mpc->in_ops->put(entry); 1103 mpc->in_ops->put(entry);
1104 return; 1104 return;
1105 } 1105 }
@@ -1175,8 +1175,9 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1175 } 1175 }
1176 1176
1177 entry->ctrl_info = msg->content.in_info; 1177 entry->ctrl_info = msg->content.in_info;
1178 do_gettimeofday(&(entry->tv)); 1178 entry->time = ktime_get_seconds();
1179 do_gettimeofday(&(entry->reply_wait)); /* Used in refreshing func from now on */ 1179 /* Used in refreshing func from now on */
1180 entry->reply_wait = ktime_get_seconds();
1180 entry->refresh_time = 0; 1181 entry->refresh_time = 0;
1181 ddprintk_cont("entry->shortcut = %p\n", entry->shortcut); 1182 ddprintk_cont("entry->shortcut = %p\n", entry->shortcut);
1182 1183
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,
227static void clear_count_and_expired(struct mpoa_client *client) 227static 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. */
301static void refresh_entries(struct mpoa_client *client) 300static 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
496static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) 495static 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)
503static void clear_expired(struct mpoa_client *client) 502static 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",
diff --git a/net/atm/mpoa_caches.h b/net/atm/mpoa_caches.h
index 6a266669ebf4..464c4c7f8d1f 100644
--- a/net/atm/mpoa_caches.h
+++ b/net/atm/mpoa_caches.h
@@ -2,6 +2,7 @@
2#ifndef MPOA_CACHES_H 2#ifndef MPOA_CACHES_H
3#define MPOA_CACHES_H 3#define MPOA_CACHES_H
4 4
5#include <linux/time64.h>
5#include <linux/netdevice.h> 6#include <linux/netdevice.h>
6#include <linux/types.h> 7#include <linux/types.h>
7#include <linux/atm.h> 8#include <linux/atm.h>
@@ -16,9 +17,9 @@ void atm_mpoa_init_cache(struct mpoa_client *mpc);
16typedef struct in_cache_entry { 17typedef struct in_cache_entry {
17 struct in_cache_entry *next; 18 struct in_cache_entry *next;
18 struct in_cache_entry *prev; 19 struct in_cache_entry *prev;
19 struct timeval tv; 20 time64_t time;
20 struct timeval reply_wait; 21 time64_t reply_wait;
21 struct timeval hold_down; 22 time64_t hold_down;
22 uint32_t packets_fwded; 23 uint32_t packets_fwded;
23 uint16_t entry_state; 24 uint16_t entry_state;
24 uint32_t retry_time; 25 uint32_t retry_time;
@@ -53,7 +54,7 @@ struct in_cache_ops{
53typedef struct eg_cache_entry{ 54typedef struct eg_cache_entry{
54 struct eg_cache_entry *next; 55 struct eg_cache_entry *next;
55 struct eg_cache_entry *prev; 56 struct eg_cache_entry *prev;
56 struct timeval tv; 57 time64_t time;
57 uint8_t MPS_ctrl_ATM_addr[ATM_ESA_LEN]; 58 uint8_t MPS_ctrl_ATM_addr[ATM_ESA_LEN];
58 struct atm_vcc *shortcut; 59 struct atm_vcc *shortcut;
59 uint32_t packets_rcvd; 60 uint32_t packets_rcvd;
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 8a0c17e1c203..2212da9c2da2 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -8,7 +8,7 @@
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/proc_fs.h> 10#include <linux/proc_fs.h>
11#include <linux/time.h> 11#include <linux/ktime.h>
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <linux/uaccess.h> 13#include <linux/uaccess.h>
14#include <linux/atmmpc.h> 14#include <linux/atmmpc.h>
@@ -138,7 +138,7 @@ static int mpc_show(struct seq_file *m, void *v)
138 int i; 138 int i;
139 in_cache_entry *in_entry; 139 in_cache_entry *in_entry;
140 eg_cache_entry *eg_entry; 140 eg_cache_entry *eg_entry;
141 struct timeval now; 141 time64_t now;
142 unsigned char ip_string[16]; 142 unsigned char ip_string[16];
143 143
144 if (v == SEQ_START_TOKEN) { 144 if (v == SEQ_START_TOKEN) {
@@ -148,15 +148,17 @@ static int mpc_show(struct seq_file *m, void *v)
148 148
149 seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num); 149 seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num);
150 seq_printf(m, "Ingress Entries:\nIP address State Holding time Packets fwded VPI VCI\n"); 150 seq_printf(m, "Ingress Entries:\nIP address State Holding time Packets fwded VPI VCI\n");
151 do_gettimeofday(&now); 151 now = ktime_get_seconds();
152 152
153 for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) { 153 for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) {
154 unsigned long seconds_delta = now - in_entry->time;
155
154 sprintf(ip_string, "%pI4", &in_entry->ctrl_info.in_dst_ip); 156 sprintf(ip_string, "%pI4", &in_entry->ctrl_info.in_dst_ip);
155 seq_printf(m, "%-16s%s%-14lu%-12u", 157 seq_printf(m, "%-16s%s%-14lu%-12u",
156 ip_string, 158 ip_string,
157 ingress_state_string(in_entry->entry_state), 159 ingress_state_string(in_entry->entry_state),
158 in_entry->ctrl_info.holding_time - 160 in_entry->ctrl_info.holding_time -
159 (now.tv_sec-in_entry->tv.tv_sec), 161 seconds_delta,
160 in_entry->packets_fwded); 162 in_entry->packets_fwded);
161 if (in_entry->shortcut) 163 if (in_entry->shortcut)
162 seq_printf(m, " %-3d %-3d", 164 seq_printf(m, " %-3d %-3d",
@@ -169,13 +171,14 @@ static int mpc_show(struct seq_file *m, void *v)
169 seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n"); 171 seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n");
170 for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) { 172 for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) {
171 unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr; 173 unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr;
174 unsigned long seconds_delta = now - eg_entry->time;
175
172 for (i = 0; i < ATM_ESA_LEN; i++) 176 for (i = 0; i < ATM_ESA_LEN; i++)
173 seq_printf(m, "%02x", p[i]); 177 seq_printf(m, "%02x", p[i]);
174 seq_printf(m, "\n%-16lu%s%-14lu%-15u", 178 seq_printf(m, "\n%-16lu%s%-14lu%-15u",
175 (unsigned long)ntohl(eg_entry->ctrl_info.cache_id), 179 (unsigned long)ntohl(eg_entry->ctrl_info.cache_id),
176 egress_state_string(eg_entry->entry_state), 180 egress_state_string(eg_entry->entry_state),
177 (eg_entry->ctrl_info.holding_time - 181 (eg_entry->ctrl_info.holding_time - seconds_delta),
178 (now.tv_sec-eg_entry->tv.tv_sec)),
179 eg_entry->packets_rcvd); 182 eg_entry->packets_rcvd);
180 183
181 /* latest IP address */ 184 /* latest IP address */