atm: mpoa: remove 32-bit timekeeping
Subsystems (3)
PATCH 1/1 atm: mpoa: remove 32-bit timekeeping
From: Tina Ruchandani <[email protected]>
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.
--- net/atm/common.c | 2 +- net/atm/mpc.c | 9 +++++---- net/atm/mpoa_caches.c | 48 +++++++++++++++++++++++------------------------- net/atm/mpoa_caches.h | 9 +++++---- net/atm/mpoa_proc.c | 15 +++++++++------ 5 files changed, 43 insertions(+), 40 deletions(-)
net/atm/common.c +1 -1
@@ -14,7 +14,7 @@#include <linux/capability.h> #include <linux/mm.h> #include <linux/sched/signal.h> -#include <linux/time.h> /* struct timeval */ +#include <linux/time64.h> /* 64-bit time for seconds */ #include <linux/skbuff.h> #include <linux/bitops.h> #include <linux/init.h>
net/atm/mpc.c +5 -4
@@ -1089,7 +1089,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) msg->type =SND_MPOA_RES_RQST ; msg->content.in_info = entry->ctrl_info;msg_to_mpoad (msg, mpc); -do_gettimeofday (&(entry->reply_wait)); + entry->reply_wait =ktime_get_seconds (); mpc->in_ops->put (entry);return ; }
@@ -1099,7 +1099,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) msg->type =SND_MPOA_RES_RQST ; msg->content.in_info = entry->ctrl_info;msg_to_mpoad (msg, mpc); -do_gettimeofday (&(entry->reply_wait)); + entry->reply_wait =ktime_get_seconds (); mpc->in_ops->put (entry);return ; }
@@ -1175,8 +1175,9 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) } entry->ctrl_info = msg->content.in_info; -do_gettimeofday (&(entry->tv)); -do_gettimeofday (&(entry->reply_wait));/* Used in refreshing func from now on */ + entry->time =ktime_get_seconds (); +/* Used in refreshing func from now on */ + entry->reply_wait =ktime_get_seconds (); entry->refresh_time =0 ;ddprintk_cont ("entry->shortcut = %p\n" , entry->shortcut);
net/atm/mpoa_caches.c +23 -25
152 lines not on this page · raw message
net/atm/mpoa_caches.h +5 -4
@@ -2,6 +2,7 @@#ifndef MPOA_CACHES_H #define MPOA_CACHES_H +#include <linux/time64.h> #include <linux/netdevice.h> #include <linux/types.h> #include <linux/atm.h>
@@ -16,9 +17,9 @@ void atm_mpoa_init_cache(struct mpoa_client *mpc); typedef struct in_cache_entry { struct in_cache_entry *next; struct in_cache_entry *prev; - struct timeval tv; - struct timeval reply_wait; - struct timeval hold_down; + time64_t time; + time64_t reply_wait; + time64_t hold_down; uint32_t packets_fwded; uint16_t entry_state; uint32_t retry_time;
@@ -53,7 +54,7 @@ struct in_cache_ops{ typedef struct eg_cache_entry{ struct eg_cache_entry *next; struct eg_cache_entry *prev; - struct timeval tv; + time64_t time; uint8_t MPS_ctrl_ATM_addr[ATM_ESA_LEN]; struct atm_vcc *shortcut; uint32_t packets_rcvd;
net/atm/mpoa_proc.c +9 -6
@@ -8,7 +8,7 @@#include <linux/mm.h> #include <linux/module.h> #include <linux/proc_fs.h> -#include <linux/time.h> +#include <linux/ktime.h> #include <linux/seq_file.h> #include <linux/uaccess.h> #include <linux/atmmpc.h>
@@ -138,7 +138,7 @@ static int mpc_show(struct seq_file *m, void *v)int i;in_cache_entry *in_entry;eg_cache_entry *eg_entry; -struct timeval now; +time64_t now;unsigned char ip_string[16 ];if (v ==SEQ_START_TOKEN ) {
@@ -148,15 +148,17 @@ static int mpc_show(struct seq_file *m, void *v)seq_printf (m,"\nInterface %d:\n\n" , mpc->dev_num);seq_printf (m,"Ingress Entries:\nIP address State Holding time Packets fwded VPI VCI\n" ); -do_gettimeofday (&now); + now =ktime_get_seconds ();for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) { +unsigned long seconds_delta = now - in_entry->time; +sprintf (ip_string,"%pI4" , &in_entry->ctrl_info.in_dst_ip);seq_printf (m,"%-16s%s%-14lu%-12u" , ip_string,ingress_state_string (in_entry->entry_state), in_entry->ctrl_info.holding_time - - (now.tv_sec-in_entry->tv.tv_sec), + seconds_delta, in_entry->packets_fwded);if (in_entry->shortcut) seq_printf(m, " %-3d %-3d",
@@ -169,13 +171,14 @@ static int mpc_show(struct seq_file *m, void *v)seq_printf (m,"Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n" );for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) {unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr; +unsigned long seconds_delta = now - eg_entry->time; +for (i =0 ; i <ATM_ESA_LEN ; i++)seq_printf (m,"%02x" , p[i]);seq_printf (m,"\n%-16lu%s%-14lu%-15u" , (unsigned long )ntohl (eg_entry->ctrl_info.cache_id),egress_state_string (eg_entry->entry_state), - (eg_entry->ctrl_info.holding_time - - (now.tv_sec-eg_entry->tv.tv_sec)), + (eg_entry->ctrl_info.holding_time - seconds_delta), eg_entry->packets_rcvd);/* latest IP address */
Signature · 1 line
2.9.0
From: Arnd Bergmann <[email protected]>
Date: Mon, 27 Nov 2017 15:02:17 +0100
Quoted 11 lines
From: Tina Ruchandani <[email protected]>
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 withtime64_tto store a 64-bit seconds field.Signed-off-by Tina Ruchandani <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>
Applied.