summaryrefslogtreecommitdiffhomepage
path: root/src/cookie.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 19:02:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 19:12:51 +0200
commit245f0bd331330c80e28e56e95c85ebacf7570ac2 (patch)
treed863021b9fe555e3d77a4d84baa553d94ea63c0c /src/cookie.c
parentf8b3991e881a64f47412082ae15c08285eb6880b (diff)
global: use fast boottime instead of normal boottime
Generally if we're inaccurate by a few nanoseconds, it doesn't matter. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/cookie.c')
-rw-r--r--src/cookie.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cookie.c b/src/cookie.c
index b7054fa..7981227 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -18,7 +18,7 @@
void cookie_checker_init(struct cookie_checker *checker, struct wireguard_device *wg)
{
init_rwsem(&checker->secret_lock);
- checker->secret_birthdate = ktime_get_boottime();
+ checker->secret_birthdate = ktime_get_boot_fast_ns();
get_random_bytes(checker->secret, NOISE_HASH_LEN);
checker->device = wg;
}
@@ -79,7 +79,7 @@ static void make_cookie(u8 cookie[COOKIE_LEN], struct sk_buff *skb, struct cooki
if (has_expired(checker->secret_birthdate, COOKIE_SECRET_MAX_AGE)) {
down_write(&checker->secret_lock);
- checker->secret_birthdate = ktime_get_boottime();
+ checker->secret_birthdate = ktime_get_boot_fast_ns();
get_random_bytes(checker->secret, NOISE_HASH_LEN);
up_write(&checker->secret_lock);
}
@@ -182,7 +182,7 @@ void cookie_message_consume(struct message_handshake_cookie *src, struct wiregua
if (ret) {
down_write(&entry->peer->latest_cookie.lock);
memcpy(entry->peer->latest_cookie.cookie, cookie, COOKIE_LEN);
- entry->peer->latest_cookie.birthdate = ktime_get_boottime();
+ entry->peer->latest_cookie.birthdate = ktime_get_boot_fast_ns();
entry->peer->latest_cookie.is_valid = true;
entry->peer->latest_cookie.have_sent_mac1 = false;
up_write(&entry->peer->latest_cookie.lock);