32 if (peer->
timers[timer_id] != ~0)
35 peer->
timers[timer_id] = ~0;
44 if (peer->
timers[timer_id] == ~0)
48 timer_id, interval_ticks);
76 .interval_ticks = interval_ticks,
85 static const int32_t rounding = (int32_t) (
WHZ / 2);
89 return (ticks_remain > rounding) ? (
u32) ticks_remain : 0;
102 start_timer (peer, WG_TIMER_RETRANSMIT_HANDSHAKE, ticks);
132 start_timer (peer, WG_TIMER_SEND_KEEPALIVE, ticks);
159 start_timer (peer, WG_TIMER_PERSISTENT_KEEPALIVE, ticks);
204 WG_TIMER_PERSISTENT_KEEPALIVE,
251 if (peer->
timers[WG_TIMER_SEND_KEEPALIVE] == ~0)
291 for (i = 0; i <
vec_len (expired_timers); i++)
293 pool_index = expired_timers[
i] & 0x0FFFFFFF;
294 timer_id = expired_timers[
i] >> 28;
297 peer->
timers[timer_id] = ~0;
300 for (i = 0; i <
vec_len (expired_timers); i++)
302 pool_index = expired_timers[
i] & 0x0FFFFFFF;
303 timer_id = expired_timers[
i] >> 28;
308 case WG_TIMER_RETRANSMIT_HANDSHAKE:
311 case WG_TIMER_PERSISTENT_KEEPALIVE:
314 case WG_TIMER_SEND_KEEPALIVE:
317 case WG_TIMER_NEW_HANDSHAKE:
320 case WG_TIMER_KEY_ZEROING:
333 tw_timer_wheel_16t_2w_512sl_t *tw = &wmp->
timer_wheel;
334 tw_timer_wheel_init_16t_2w_512sl (tw,
350 tw_timer_expire_timers_16t_2w_512sl (&wmp->
timer_wheel,
363 stop_timer (peer, WG_TIMER_RETRANSMIT_HANDSHAKE);
364 stop_timer (peer, WG_TIMER_PERSISTENT_KEEPALIVE);
#define REJECT_AFTER_TIME
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
static void wg_expired_zero_key_material(vlib_main_t *vm, wg_peer_t *peer)
u16 persistent_keepalive_interval
static void stop_timer(wg_peer_t *peer, u32 timer_id)
static f64 vlib_time_now(vlib_main_t *vm)
tw_timer_wheel_16t_2w_512sl_t * timer_wheel
static void wg_expired_send_keepalive(vlib_main_t *vm, wg_peer_t *peer)
static u32 timer_ticks_left(vlib_main_t *vm, f64 init_time_sec, u32 interval_ticks)
void wg_timers_any_authenticated_packet_traversal(wg_peer_t *peer)
void wg_timers_stop(wg_peer_t *peer)
static void wg_expired_send_persistent_keepalive(vlib_main_t *vm, wg_peer_t *peer)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
static void start_timer(wg_peer_t *peer, u32 timer_id, u32 interval_ticks)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
void noise_remote_clear(vlib_main_t *vm, noise_remote_t *r)
tw_timer_wheel_16t_2w_512sl_t timer_wheel
static uword wg_timer_mngr_fn(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
void wg_timers_any_authenticated_packet_received(wg_peer_t *peer)
void wg_timers_data_sent(wg_peer_t *peer)
#define WHZ
WG tick frequency.
static vlib_node_registration_t wg_timer_mngr_node
(constructor) VLIB_REGISTER_NODE (wg_timer_mngr_node)
void wg_timers_data_received(wg_peer_t *peer)
#define WG_TICK
WG tick period (s)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
sll srl srl sll sra u16x4 i
static u32 get_random_u32_max(u32 max)
u32 new_handshake_interval_tick
void wg_timers_any_authenticated_packet_sent(wg_peer_t *peer)
void wg_timer_wheel_init()
bool timer_need_another_keepalive
static void wg_expired_retransmit_handshake(vlib_main_t *vm, wg_peer_t *peer)
static vlib_main_t * vlib_get_main(void)
u32 rehandshake_interval_tick
struct _vlib_node_registration vlib_node_registration_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void wg_expired_new_handshake(vlib_main_t *vm, wg_peer_t *peer)
void wg_timers_session_derived(wg_peer_t *peer)
static void start_timer_from_mt(u32 peer_idx, u32 timer_id, u32 interval_ticks)
static void * start_timer_thread_fn(void *arg)
static u32 random_u32(u32 *seed)
32-bit random number generator
bool wg_send_keepalive(vlib_main_t *vm, wg_peer_t *peer)
void wg_timers_handshake_initiated(wg_peer_t *peer)
static wg_peer_t * wg_peer_get(index_t peeri)
u32 timer_handshake_attempts
static void expired_timer_callback(u32 *expired_timers)
bool wg_send_handshake(vlib_main_t *vm, wg_peer_t *peer, bool is_retry)
void wg_timers_handshake_complete(wg_peer_t *peer)