diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-01-22 13:38:52 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-01-23 14:29:44 +0100 |
commit | 49c240044ca638128a35e4fc55d86c727d3b2b1f (patch) | |
tree | 4855020bd05898c165d7aa4300a4c7bb527f432f /src/netlink.c | |
parent | f43eabd5616d5dd114b1818867e4c51d3c24dbd3 (diff) |
netlink: use __kernel_timespec for handshake time
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/netlink.c')
-rw-r--r-- | src/netlink.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/netlink.c b/src/netlink.c index bdd3150..3458c81 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -33,7 +33,7 @@ static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] = { [WGPEER_A_FLAGS] = { .type = NLA_U32 }, [WGPEER_A_ENDPOINT] = { .len = sizeof(struct sockaddr) }, [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NLA_U16 }, - [WGPEER_A_LAST_HANDSHAKE_TIME] = { .len = sizeof(struct timespec) }, + [WGPEER_A_LAST_HANDSHAKE_TIME] = { .len = sizeof(struct __kernel_timespec) }, [WGPEER_A_RX_BYTES] = { .type = NLA_U64 }, [WGPEER_A_TX_BYTES] = { .type = NLA_U64 }, [WGPEER_A_ALLOWEDIPS] = { .type = NLA_NESTED }, @@ -107,6 +107,11 @@ static int get_peer(struct wg_peer *peer, struct allowedips_cursor *rt_cursor, goto err; if (!rt_cursor->seq) { + const struct __kernel_timespec last_handshake = { + .tv_sec = peer->walltime_last_handshake.tv_sec, + .tv_nsec = peer->walltime_last_handshake.tv_nsec + }; + down_read(&peer->handshake.lock); fail = nla_put(skb, WGPEER_A_PRESHARED_KEY, NOISE_SYMMETRIC_KEY_LEN, @@ -116,8 +121,7 @@ static int get_peer(struct wg_peer *peer, struct allowedips_cursor *rt_cursor, goto err; if (nla_put(skb, WGPEER_A_LAST_HANDSHAKE_TIME, - sizeof(peer->walltime_last_handshake), - &peer->walltime_last_handshake) || + sizeof(last_handshake), &last_handshake) || nla_put_u16(skb, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, peer->persistent_keepalive_interval) || nla_put_u64_64bit(skb, WGPEER_A_TX_BYTES, peer->tx_bytes, |