]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
netlink: use __kernel_timespec for handshake time
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 22 Jan 2019 12:38:52 +0000 (13:38 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 23 Jan 2019 13:29:44 +0000 (14:29 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
contrib/embeddable-wg-library/wireguard.h
src/containers.h
src/ipc.c
src/show.c

index 9ebe47c719e9acd0f03bd63a9597e1693d07c341..e7a1bbf0d9e3566effc37c9860ffccf665d3bdca 100644 (file)
 typedef uint8_t wg_key[32];
 typedef char wg_key_b64_string[((sizeof(wg_key) + 2) / 3) * 4 + 1];
 
+/* Cross platform __kernel_timespec */
+struct timespec64 {
+       int64_t tv_sec;
+       int64_t tv_nsec;
+};
+
 typedef struct wg_allowedip {
        uint16_t family;
        union {
@@ -46,7 +52,7 @@ typedef struct wg_peer {
                struct sockaddr_in6 addr6;
        } endpoint;
 
-       struct timespec last_handshake_time;
+       struct timespec64 last_handshake_time;
        uint64_t rx_bytes, tx_bytes;
        uint16_t persistent_keepalive_interval;
 
index 2144052119f54b0815b73937ae0a3e8adc72786f..59a213e9f191fea35d40b1c0a5ec940a571756ff 100644 (file)
 
 #include "../uapi/wireguard.h"
 
+/* Cross platform __kernel_timespec */
+struct timespec64 {
+       int64_t tv_sec;
+       int64_t tv_nsec;
+};
+
 struct wgallowedip {
        uint16_t family;
        union {
@@ -45,7 +51,7 @@ struct wgpeer {
                struct sockaddr_in6 addr6;
        } endpoint;
 
-       struct timespec last_handshake_time;
+       struct timespec64 last_handshake_time;
        uint64_t rx_bytes, tx_bytes;
        uint16_t persistent_keepalive_interval;
 
index da31eff67db1367f847be75ec21e479ae54cd624..7ab3a6226c72acd92612f9b285ea7fbf6a0a2fd6 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -420,9 +420,9 @@ static int userspace_get_device(struct wgdevice **out, const char *interface)
                        if (*end || allowedip->family == AF_UNSPEC || (allowedip->family == AF_INET6 && allowedip->cidr > 128) || (allowedip->family == AF_INET && allowedip->cidr > 32))
                                break;
                } else if (peer && !strcmp(key, "last_handshake_time_sec"))
-                       peer->last_handshake_time.tv_sec = NUM(0xffffffffffffffffULL);
+                       peer->last_handshake_time.tv_sec = NUM(0x7fffffffffffffffULL);
                else if (peer && !strcmp(key, "last_handshake_time_nsec"))
-                       peer->last_handshake_time.tv_nsec = NUM(0xffffffffffffffffULL);
+                       peer->last_handshake_time.tv_nsec = NUM(0x7fffffffffffffffULL);
                else if (peer && !strcmp(key, "rx_bytes"))
                        peer->rx_bytes = NUM(0xffffffffffffffffULL);
                else if (peer && !strcmp(key, "tx_bytes"))
index ba6f115a658ea5f0966495bc40266ca4d4b5e8d5..4cc34ab1323bb9a7128d72e53e6da00427cdcd87 100644 (file)
@@ -155,7 +155,7 @@ static size_t pretty_time(char *buf, const size_t len, unsigned long long left)
        return offset;
 }
 
-static char *ago(const struct timespec *t)
+static char *ago(const struct timespec64 *t)
 {
        static char buf[1024];
        size_t offset;