From patchwork Mon Nov 27 14:02:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 119713 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp311829qgn; Mon, 27 Nov 2017 06:04:44 -0800 (PST) X-Google-Smtp-Source: AGs4zMaVMbpDaRmu3Hcfl4ZX+aWpon/Hwdef5jRQVGA8uQ9Pv38rj8wL2v8C0HWm1FcLH4hXjRAh X-Received: by 10.98.7.149 with SMTP id 21mr37004475pfh.14.1511791484342; Mon, 27 Nov 2017 06:04:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511791484; cv=none; d=google.com; s=arc-20160816; b=A3iJpNhtnHLC/WcW2U2kDiA3tjg/KgiGYJTKbSqqdZmwX47/55E3Q1GOoR6fMHJNKI CSDY8Ql54fqhYMxAF1NzrpfSEYLZKbhwPKJ5IxdQfavTMSGbhsKEZUsUFaaG+pggT7Q6 kx9TCAXBljmffiO4FXn3M2wGqcGAfzk1Q9V/t3c0XF3QjrVoWV+i5S9qH03XnkbDPzkn Mu1/2KNLMEVjK6u0yYbOG09lzS5mnVzGjGAEnz9TX0voZNEdy5quuE8ooGg4GUQTgoHK Xz58ifYNbmkE167x7xjxXVKzp9RGC4x+Mg+ly6HjwUuQEG4vyjIfu5iLAe2cHms66TZB rGmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=N2iLMxP5cvcMJApOTSSagxyQotw/6kdvEmSJmsSKyTs=; b=CWQ6E8FSwrL9gL7MCwQUV3Zq8E0gxqFAQwVZIs/zI7U93jimD/NATRHRfeurpjQMrV ema1hxjIbjRwgW8v6bGDfyYmJIkUOi+J57pA1t2LZan+jlGVpFF2Mf6XedIV00JMS2eZ UDKzpBKMMFfuF2JNjlLg1e4hhxADVzwIBVtrMHDu2fZ2LS5xy+sIiKLS3pxBUTen4O7H tWzfJhjgH9IwVLWA4E4QyLnOv8XnEW+Em7Jo1f157AyfjaMjvPJSzBEBEJDWt6W207R2 kn0BGeYcNQ1COb60W+aXvzzKYkgkcHsQbulvvTgjeTdF3Ngc/1R4BYuylqiaOBzSmsOt LKag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si2199057pll.810.2017.11.27.06.04.44; Mon, 27 Nov 2017 06:04:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbdK0OEm (ORCPT + 28 others); Mon, 27 Nov 2017 09:04:42 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:51651 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752355AbdK0OEk (ORCPT ); Mon, 27 Nov 2017 09:04:40 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0La7G2-1eyjdd24mE-00m4KJ; Mon, 27 Nov 2017 15:04:19 +0100 From: Arnd Bergmann To: "David S. Miller" Cc: y2038@lists.linaro.org, Chas Williams <3chas3@gmail.com>, linux-atm-general@lists.sourceforge.net, Tina Ruchandani , Arnd Bergmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] atm: mpoa: remove 32-bit timekeeping Date: Mon, 27 Nov 2017 15:02:17 +0100 Message-Id: <20171127140337.3622068-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:BA3+FTmeVSX3GFNQJOdfOZh59S45+J0JySUXl2vzZpGeDZuEosr PPj2MklEQLFXEQjmuRrHzosn6IJx2LpcPgmHhp00gHrQd19+SSwNPP7tmpM0JY1zqLa+rCN YOyziWA1R1frFFvZMh8mSttMu6BYCHJw1a3bTE5jNi24BtbpnRd1/BeI5XkpAKsjyiNNZMx Z6pmfbcHKcEn/Dq7c48XQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:t0nlu7GoUOA=:uZCj8o14mkra4WGSrBWi7R Mq94Ug+2HptCNwSbJfWLN0fKZ53S09XocyA5xZSxiT3UFxBlV7durcoVoU6YJL026Ax3G+jI4 VsapiagcqxHfQqitNRuEn1b3Cpd+aO+HlhLcOIXuL+/naMDjiRMAs2vNSWlgX6ev7GF3r51KN 6ACqaXAZbpe65wpFt/kjdnQ77emSaZKuba+dr8kh4NEOD1ytMWCvC/65jdqoNjdEMzrlXSn+R 2GD/dVvGgQnpWHxBUs4lhIITvthrQ+cC+uzI2ZSVoXNQAGhisYm+IusKXcdpGmKh0mZP4ML2V j9NchoadzF61ocHOpqmaFa0yonRvjWpfNq2s+K0NnMcm3cCZ88JMaLGTmBAG+ZZITBA6LlZmV ouOIqSogw6Pkqcxqfya/a8pp0OcDn+eAphTQR58AlcMN/Of/CaBBZR+pqaQtXs4UHslObJRHz cbABUix1jjIoDWTPjHrlBRv9jIJ1UIwAr7b9+lfKF2ZWWQiQSQCuBZGVRoq1WJfkjbzzbsQM9 pU9HfWxDPus4GlL27XX/16noakBP+CTBmOKKDFzvPQxkkKMAJKuOkqMCoBuGhu/DtWOLEfShp ADIqY+eiKqsbo2n7RP8iYJy7Ou5dt3bhDRXM15v/MI1e+FNj4mJM3iMWJKAqglJNXpVpyzOKJ 05JmwMV7/yIGG4cgJvqt3xhOAaY9FILFbZ6WNHQEJu+PHsY4A16e5SeaXFce9R/8ApHtHw3lN MPRhH5pUr1iIl3eFf/W6jk8KuWdjrI++KPnubg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tina Ruchandani 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 Signed-off-by: Arnd Bergmann --- 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(-) -- 2.9.0 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 @@ #include #include #include -#include /* struct timeval */ +#include /* 64-bit time for seconds */ #include #include #include 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) 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); 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, memcpy(entry->MPS_ctrl_ATM_addr, client->mps_ctrl_addr, ATM_ESA_LEN); entry->ctrl_info.in_dst_ip = dst_ip; - do_gettimeofday(&(entry->tv)); + entry->time = ktime_get_seconds(); entry->retry_time = client->parameters.mpc_p4; entry->count = 1; entry->entry_state = INGRESS_INVALID; @@ -148,7 +148,7 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc) if (qos != NULL) msg.qos = qos->qos; msg_to_mpoad(&msg, mpc); - do_gettimeofday(&(entry->reply_wait)); + entry->reply_wait = ktime_get_seconds(); entry->entry_state = INGRESS_RESOLVING; } if (entry->shortcut != NULL) @@ -171,7 +171,7 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc) if (qos != NULL) msg.qos = qos->qos; msg_to_mpoad(&msg, mpc); - do_gettimeofday(&(entry->reply_wait)); + entry->reply_wait = ktime_get_seconds(); } return CLOSED; @@ -227,17 +227,16 @@ static void in_cache_remove_entry(in_cache_entry *entry, static void clear_count_and_expired(struct mpoa_client *client) { in_cache_entry *entry, *next_entry; - struct timeval now; + time64_t now; - do_gettimeofday(&now); + now = ktime_get_seconds(); write_lock_bh(&client->ingress_lock); entry = client->in_cache; while (entry != NULL) { entry->count = 0; next_entry = entry->next; - if ((now.tv_sec - entry->tv.tv_sec) - > entry->ctrl_info.holding_time) { + if ((now - entry->time) > entry->ctrl_info.holding_time) { dprintk("holding time expired, ip = %pI4\n", &entry->ctrl_info.in_dst_ip); client->in_ops->remove_entry(entry, client); @@ -253,35 +252,35 @@ static void check_resolving_entries(struct mpoa_client *client) struct atm_mpoa_qos *qos; in_cache_entry *entry; - struct timeval now; + time64_t now; struct k_message msg; - do_gettimeofday(&now); + now = ktime_get_seconds(); read_lock_bh(&client->ingress_lock); entry = client->in_cache; while (entry != NULL) { if (entry->entry_state == INGRESS_RESOLVING) { - if ((now.tv_sec - entry->hold_down.tv_sec) < - client->parameters.mpc_p6) { + + if ((now - entry->hold_down) + < client->parameters.mpc_p6) { entry = entry->next; /* Entry in hold down */ continue; } - if ((now.tv_sec - entry->reply_wait.tv_sec) > - entry->retry_time) { + if ((now - entry->reply_wait) > entry->retry_time) { entry->retry_time = MPC_C1 * (entry->retry_time); /* * Retry time maximum exceeded, * put entry in hold down. */ if (entry->retry_time > client->parameters.mpc_p5) { - do_gettimeofday(&(entry->hold_down)); + entry->hold_down = ktime_get_seconds(); entry->retry_time = client->parameters.mpc_p4; entry = entry->next; continue; } /* Ask daemon to send a resolution request. */ - memset(&(entry->hold_down), 0, sizeof(struct timeval)); + memset(&entry->hold_down, 0, sizeof(time64_t)); msg.type = SND_MPOA_RES_RTRY; memcpy(msg.MPS_ctrl, client->mps_ctrl_addr, ATM_ESA_LEN); msg.content.in_info = entry->ctrl_info; @@ -289,7 +288,7 @@ static void check_resolving_entries(struct mpoa_client *client) if (qos != NULL) msg.qos = qos->qos; msg_to_mpoad(&msg, client); - do_gettimeofday(&(entry->reply_wait)); + entry->reply_wait = ktime_get_seconds(); } } entry = entry->next; @@ -300,18 +299,18 @@ static void check_resolving_entries(struct mpoa_client *client) /* Call this every MPC-p5 seconds. */ static void refresh_entries(struct mpoa_client *client) { - struct timeval now; + time64_t now; struct in_cache_entry *entry = client->in_cache; ddprintk("refresh_entries\n"); - do_gettimeofday(&now); + now = ktime_get_seconds(); read_lock_bh(&client->ingress_lock); while (entry != NULL) { if (entry->entry_state == INGRESS_RESOLVED) { if (!(entry->refresh_time)) entry->refresh_time = (2 * (entry->ctrl_info.holding_time))/3; - if ((now.tv_sec - entry->reply_wait.tv_sec) > + if ((now - entry->reply_wait) > entry->refresh_time) { dprintk("refreshing an entry.\n"); entry->entry_state = INGRESS_REFRESHING; @@ -480,7 +479,7 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, memcpy(entry->MPS_ctrl_ATM_addr, client->mps_ctrl_addr, ATM_ESA_LEN); entry->ctrl_info = msg->content.eg_info; - do_gettimeofday(&(entry->tv)); + entry->time = ktime_get_seconds(); entry->entry_state = EGRESS_RESOLVED; dprintk("new_eg_cache_entry cache_id %u\n", ntohl(entry->ctrl_info.cache_id)); @@ -495,7 +494,7 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) { - do_gettimeofday(&(entry->tv)); + entry->time = ktime_get_seconds(); entry->entry_state = EGRESS_RESOLVED; entry->ctrl_info.holding_time = holding_time; } @@ -503,17 +502,16 @@ static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) static void clear_expired(struct mpoa_client *client) { eg_cache_entry *entry, *next_entry; - struct timeval now; + time64_t now; struct k_message msg; - do_gettimeofday(&now); + now = ktime_get_seconds(); write_lock_irq(&client->egress_lock); entry = client->eg_cache; while (entry != NULL) { next_entry = entry->next; - if ((now.tv_sec - entry->tv.tv_sec) - > entry->ctrl_info.holding_time) { + if ((now - entry->time) > entry->ctrl_info.holding_time) { msg.type = SND_EGRESS_PURGE; msg.content.eg_info = entry->ctrl_info; 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 @@ #ifndef MPOA_CACHES_H #define MPOA_CACHES_H +#include #include #include #include @@ -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; 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 @@ #include #include #include -#include +#include #include #include #include @@ -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 */