aboutsummaryrefslogtreecommitdiffstats
path: root/src/wg_cookie.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-04-20 14:38:59 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2021-04-20 14:39:57 -0600
commitbbe309b68beb3f39ec5d87ae95ecaa16965090e5 (patch)
treeb100fbd9d69ca427cfb7a07dab6e363808cc4419 /src/wg_cookie.h
parentwg_noise: inline noise_timer_expired to make expensive multiplication go away (diff)
downloadwireguard-freebsd-bbe309b68beb3f39ec5d87ae95ecaa16965090e5.tar.xz
wireguard-freebsd-bbe309b68beb3f39ec5d87ae95ecaa16965090e5.zip
global: use sbintime_t consistently
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/wg_cookie.h')
-rw-r--r--src/wg_cookie.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/wg_cookie.h b/src/wg_cookie.h
index d24223f..c6e4604 100644
--- a/src/wg_cookie.h
+++ b/src/wg_cookie.h
@@ -32,10 +32,9 @@
/* Constants for initiation rate limiting */
#define RATELIMIT_SIZE (1 << 13)
#define RATELIMIT_SIZE_MAX (RATELIMIT_SIZE * 8)
-#define NSEC_PER_SEC 1000000000LL
#define INITIATIONS_PER_SECOND 20
#define INITIATIONS_BURSTABLE 5
-#define INITIATION_COST (NSEC_PER_SEC / INITIATIONS_PER_SECOND)
+#define INITIATION_COST (SBT_1S / INITIATIONS_PER_SECOND)
#define TOKEN_MAX (INITIATION_COST * INITIATIONS_BURSTABLE)
#define ELEMENT_TIMEOUT 1
#define IPV4_MASK_SIZE 4 /* Use all 4 bytes of IPv4 address */
@@ -55,7 +54,7 @@ struct ratelimit_entry {
struct in6_addr r_in6;
#endif
};
- struct timespec r_last_time; /* nanouptime */
+ sbintime_t r_last_time; /* nanouptime */
uint64_t r_tokens;
};
@@ -67,7 +66,7 @@ struct ratelimit {
LIST_HEAD(, ratelimit_entry) *rl_table;
u_long rl_table_mask;
size_t rl_table_num;
- struct timespec rl_last_gc; /* nanouptime */
+ sbintime_t rl_last_gc; /* nanouptime */
};
struct cookie_maker {
@@ -76,7 +75,7 @@ struct cookie_maker {
struct rwlock cp_lock;
uint8_t cp_cookie[COOKIE_COOKIE_SIZE];
- struct timespec cp_birthdate; /* nanouptime */
+ sbintime_t cp_birthdate; /* nanouptime */
bool cp_mac1_valid;
uint8_t cp_mac1_last[COOKIE_MAC_SIZE];
};
@@ -92,7 +91,7 @@ struct cookie_checker {
uint8_t cc_cookie_key[COOKIE_KEY_SIZE];
struct rwlock cc_secret_lock;
- struct timespec cc_secret_birthdate; /* nanouptime */
+ sbintime_t cc_secret_birthdate; /* nanouptime */
uint8_t cc_secret[COOKIE_SECRET_SIZE];
};