summaryrefslogtreecommitdiffhomepage
path: root/src/netlink.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 04:20:14 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 06:08:37 +0200
commitf8b3991e881a64f47412082ae15c08285eb6880b (patch)
treec5308716de6dc4765ed466e73f5bf70829f9ecfd /src/netlink.c
parent66518b5ce61f74375c120a872a168585dc392ba7 (diff)
global: use ktime boottime instead of jiffies
Since this is a network protocol, expirations need to be accounted for, even across system suspend. On real systems, this isn't a problem, since we're clearing all keys before suspend. But on Android, where we don't do that, this is something of a problem. So, we switch to using boottime instead of jiffies. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/netlink.c')
-rw-r--r--src/netlink.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/netlink.c b/src/netlink.c
index 2f5157d..aef743f 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -110,7 +110,7 @@ static int get_peer(struct wireguard_peer *peer, unsigned int index, struct allo
if (fail)
goto err;
- if (nla_put(skb, WGPEER_A_LAST_HANDSHAKE_TIME, sizeof(struct timespec), &peer->walltime_last_handshake) || nla_put_u16(skb, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, peer->persistent_keepalive_interval / HZ) ||
+ if (nla_put(skb, WGPEER_A_LAST_HANDSHAKE_TIME, sizeof(struct timespec), &peer->walltime_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, WGPEER_A_UNSPEC) || nla_put_u64_64bit(skb, WGPEER_A_RX_BYTES, peer->rx_bytes, WGPEER_A_UNSPEC))
goto err;
@@ -376,7 +376,7 @@ static int set_peer(struct wireguard_device *wg, struct nlattr **attrs)
const u16 persistent_keepalive_interval = nla_get_u16(attrs[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL]);
const bool send_keepalive = !peer->persistent_keepalive_interval && persistent_keepalive_interval && netif_running(wg->dev);
- peer->persistent_keepalive_interval = (unsigned long)persistent_keepalive_interval * HZ;
+ peer->persistent_keepalive_interval = persistent_keepalive_interval;
if (send_keepalive)
packet_send_keepalive(peer);
}