aboutsummaryrefslogtreecommitdiffstats
path: root/src/wg_cookie.h
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@noconroy.net>2021-04-21 11:48:58 +1000
committerMatt Dunwoodie <ncon@noconroy.net>2021-04-21 11:48:58 +1000
commit23dc8e4926e9af068b9e361e8390eda4c1d3c2f7 (patch)
treec8c7f435b82ab7d6ee7727a6a48d917f53cfbaa0 /src/wg_cookie.h
parentglobal: update timer-type comments (diff)
downloadwireguard-freebsd-23dc8e4926e9af068b9e361e8390eda4c1d3c2f7.tar.xz
wireguard-freebsd-23dc8e4926e9af068b9e361e8390eda4c1d3c2f7.zip
wg_cookie: ensure gc is called regularly
Previously we relied on gc being called when adding a new entry, which could leave us in a gc "blind spot". With this change, we schedule a callout to run gc whenever we have entries in the table. The callout will continue to run every ELEMENT_TIMEOUT seconds until the table is empty. Access to rl_gc is locked by rl_lock, so we will never have any threads racing to callout_{pending,stop,reset}. The alternative (which Linux does currently) is just to run the callout every ELEMENT_TIMEOUT (1) second even when no entries are in the table. However, the callout solution proposed here seems simple enough. Signed-off-by: Matt Dunwoodie <ncon@noconroy.net>
Diffstat (limited to 'src/wg_cookie.h')
-rw-r--r--src/wg_cookie.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wg_cookie.h b/src/wg_cookie.h
index 42271ca..690c650 100644
--- a/src/wg_cookie.h
+++ b/src/wg_cookie.h
@@ -62,10 +62,10 @@ struct ratelimit {
uma_zone_t rl_zone;
struct rwlock rl_lock;
+ struct callout rl_gc;
LIST_HEAD(, ratelimit_entry) *rl_table;
u_long rl_table_mask;
size_t rl_table_num;
- sbintime_t rl_last_gc; /* sbinuptime */
};
struct cookie_maker {