From: Arnd Bergmann <a...@arndb.de>

Upstream commit:
    commit 311af51dcb5629f04976a8e451673f77e3301041
    Author: Arnd Bergmann <a...@arndb.de>
    Date:   Mon Nov 27 12:41:38 2017 +0100

    openvswitch: use ktime_get_ts64() instead of ktime_get_ts()

    timespec is deprecated because of the y2038 overflow, so let's convert
    this one to ktime_get_ts64(). The code is already safe even on 32-bit
    architectures, since it uses monotonic times. On 64-bit architectures,
    nothing changes, while on 32-bit architectures this avoids one
    type conversion.

    Signed-off-by: Arnd Bergmann <a...@arndb.de>
    Signed-off-by: David S. Miller <da...@davemloft.net>

Additional compatability check for ktime_get_ts64() exists or not.
If not, then just continue using ktime_get_ts().

Cc: Arnd Bergmann <a...@arndb.de>
Signed-off-by: Greg Rose <gvrose8...@gmail.com>
---
 datapath/flow.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/datapath/flow.c b/datapath/flow.c
index 5da7e3e..385e481 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -52,14 +52,19 @@
 #include "flow_netlink.h"
 #include "vport.h"
 
+#ifndef ktime_get_ts64
+#define ktime_get_ts64 ktime_get_ts
+#define timespec64 timespec
+#endif
+
 u64 ovs_flow_used_time(unsigned long flow_jiffies)
 {
-       struct timespec cur_ts;
+       struct timespec64 cur_ts;
        u64 cur_ms, idle_ms;
 
-       ktime_get_ts(&cur_ts);
+       ktime_get_ts64(&cur_ts);
        idle_ms = jiffies_to_msecs(jiffies - flow_jiffies);
-       cur_ms = (u64)cur_ts.tv_sec * MSEC_PER_SEC +
+       cur_ms = (u64)(u32)cur_ts.tv_sec * MSEC_PER_SEC +
                 cur_ts.tv_nsec / NSEC_PER_MSEC;
 
        return cur_ms - idle_ms;
-- 
1.8.3.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to