aboutsummaryrefslogtreecommitdiffstatshomepage
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
commitd0bd6dc67d81236f66cb763c3d47dd6b5d7581a6 (patch)
tree6b3669f075d28267e50bda153a32e9b7ea9ff30b /src/netlink.c
parenttools: fix misspelling of strchrnul in comment (diff)
downloadwireguard-monolithic-historical-d0bd6dc67d81236f66cb763c3d47dd6b5d7581a6.tar.xz
wireguard-monolithic-historical-d0bd6dc67d81236f66cb763c3d47dd6b5d7581a6.zip
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.
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);
}