Lines Matching refs:peer
30 static inline void mod_peer_timer(struct wg_peer *peer, in mod_peer_timer() argument
35 if (likely(netif_running(peer->device->dev) && in mod_peer_timer()
36 !READ_ONCE(peer->is_dead))) in mod_peer_timer()
43 struct wg_peer *peer = from_timer(peer, timer, in wg_expired_retransmit_handshake() local
46 if (peer->timer_handshake_attempts > MAX_TIMER_HANDSHAKES) { in wg_expired_retransmit_handshake()
48 peer->device->dev->name, peer->internal_id, in wg_expired_retransmit_handshake()
49 &peer->endpoint.addr, (int)MAX_TIMER_HANDSHAKES + 2); in wg_expired_retransmit_handshake()
51 del_timer(&peer->timer_send_keepalive); in wg_expired_retransmit_handshake()
55 wg_packet_purge_staged_packets(peer); in wg_expired_retransmit_handshake()
60 if (!timer_pending(&peer->timer_zero_key_material)) in wg_expired_retransmit_handshake()
61 mod_peer_timer(peer, &peer->timer_zero_key_material, in wg_expired_retransmit_handshake()
64 ++peer->timer_handshake_attempts; in wg_expired_retransmit_handshake()
66 peer->device->dev->name, peer->internal_id, in wg_expired_retransmit_handshake()
67 &peer->endpoint.addr, (int)REKEY_TIMEOUT, in wg_expired_retransmit_handshake()
68 peer->timer_handshake_attempts + 1); in wg_expired_retransmit_handshake()
73 wg_socket_clear_peer_endpoint_src(peer); in wg_expired_retransmit_handshake()
75 wg_packet_send_queued_handshake_initiation(peer, true); in wg_expired_retransmit_handshake()
81 struct wg_peer *peer = from_timer(peer, timer, timer_send_keepalive); in wg_expired_send_keepalive() local
83 wg_packet_send_keepalive(peer); in wg_expired_send_keepalive()
84 if (peer->timer_need_another_keepalive) { in wg_expired_send_keepalive()
85 peer->timer_need_another_keepalive = false; in wg_expired_send_keepalive()
86 mod_peer_timer(peer, &peer->timer_send_keepalive, in wg_expired_send_keepalive()
93 struct wg_peer *peer = from_timer(peer, timer, timer_new_handshake); in wg_expired_new_handshake() local
96 peer->device->dev->name, peer->internal_id, in wg_expired_new_handshake()
97 &peer->endpoint.addr, (int)(KEEPALIVE_TIMEOUT + REKEY_TIMEOUT)); in wg_expired_new_handshake()
101 wg_socket_clear_peer_endpoint_src(peer); in wg_expired_new_handshake()
102 wg_packet_send_queued_handshake_initiation(peer, false); in wg_expired_new_handshake()
107 struct wg_peer *peer = from_timer(peer, timer, timer_zero_key_material); in wg_expired_zero_key_material() local
110 if (!READ_ONCE(peer->is_dead)) { in wg_expired_zero_key_material()
111 wg_peer_get(peer); in wg_expired_zero_key_material()
112 if (!queue_work(peer->device->handshake_send_wq, in wg_expired_zero_key_material()
113 &peer->clear_peer_work)) in wg_expired_zero_key_material()
117 wg_peer_put(peer); in wg_expired_zero_key_material()
124 struct wg_peer *peer = container_of(work, struct wg_peer, in wg_queued_expired_zero_key_material() local
128 peer->device->dev->name, peer->internal_id, in wg_queued_expired_zero_key_material()
129 &peer->endpoint.addr, (int)REJECT_AFTER_TIME * 3); in wg_queued_expired_zero_key_material()
130 wg_noise_handshake_clear(&peer->handshake); in wg_queued_expired_zero_key_material()
131 wg_noise_keypairs_clear(&peer->keypairs); in wg_queued_expired_zero_key_material()
132 wg_peer_put(peer); in wg_queued_expired_zero_key_material()
137 struct wg_peer *peer = from_timer(peer, timer, in wg_expired_send_persistent_keepalive() local
140 if (likely(peer->persistent_keepalive_interval)) in wg_expired_send_persistent_keepalive()
141 wg_packet_send_keepalive(peer); in wg_expired_send_persistent_keepalive()
145 void wg_timers_data_sent(struct wg_peer *peer) in wg_timers_data_sent() argument
147 if (!timer_pending(&peer->timer_new_handshake)) in wg_timers_data_sent()
148 mod_peer_timer(peer, &peer->timer_new_handshake, in wg_timers_data_sent()
154 void wg_timers_data_received(struct wg_peer *peer) in wg_timers_data_received() argument
156 if (likely(netif_running(peer->device->dev))) { in wg_timers_data_received()
157 if (!timer_pending(&peer->timer_send_keepalive)) in wg_timers_data_received()
158 mod_peer_timer(peer, &peer->timer_send_keepalive, in wg_timers_data_received()
161 peer->timer_need_another_keepalive = true; in wg_timers_data_received()
168 void wg_timers_any_authenticated_packet_sent(struct wg_peer *peer) in wg_timers_any_authenticated_packet_sent() argument
170 del_timer(&peer->timer_send_keepalive); in wg_timers_any_authenticated_packet_sent()
176 void wg_timers_any_authenticated_packet_received(struct wg_peer *peer) in wg_timers_any_authenticated_packet_received() argument
178 del_timer(&peer->timer_new_handshake); in wg_timers_any_authenticated_packet_received()
182 void wg_timers_handshake_initiated(struct wg_peer *peer) in wg_timers_handshake_initiated() argument
184 mod_peer_timer(peer, &peer->timer_retransmit_handshake, in wg_timers_handshake_initiated()
192 void wg_timers_handshake_complete(struct wg_peer *peer) in wg_timers_handshake_complete() argument
194 del_timer(&peer->timer_retransmit_handshake); in wg_timers_handshake_complete()
195 peer->timer_handshake_attempts = 0; in wg_timers_handshake_complete()
196 peer->sent_lastminute_handshake = false; in wg_timers_handshake_complete()
197 ktime_get_real_ts64(&peer->walltime_last_handshake); in wg_timers_handshake_complete()
203 void wg_timers_session_derived(struct wg_peer *peer) in wg_timers_session_derived() argument
205 mod_peer_timer(peer, &peer->timer_zero_key_material, in wg_timers_session_derived()
212 void wg_timers_any_authenticated_packet_traversal(struct wg_peer *peer) in wg_timers_any_authenticated_packet_traversal() argument
214 if (peer->persistent_keepalive_interval) in wg_timers_any_authenticated_packet_traversal()
215 mod_peer_timer(peer, &peer->timer_persistent_keepalive, in wg_timers_any_authenticated_packet_traversal()
216 jiffies + peer->persistent_keepalive_interval * HZ); in wg_timers_any_authenticated_packet_traversal()
219 void wg_timers_init(struct wg_peer *peer) in wg_timers_init() argument
221 timer_setup(&peer->timer_retransmit_handshake, in wg_timers_init()
223 timer_setup(&peer->timer_send_keepalive, wg_expired_send_keepalive, 0); in wg_timers_init()
224 timer_setup(&peer->timer_new_handshake, wg_expired_new_handshake, 0); in wg_timers_init()
225 timer_setup(&peer->timer_zero_key_material, in wg_timers_init()
227 timer_setup(&peer->timer_persistent_keepalive, in wg_timers_init()
229 INIT_WORK(&peer->clear_peer_work, wg_queued_expired_zero_key_material); in wg_timers_init()
230 peer->timer_handshake_attempts = 0; in wg_timers_init()
231 peer->sent_lastminute_handshake = false; in wg_timers_init()
232 peer->timer_need_another_keepalive = false; in wg_timers_init()
235 void wg_timers_stop(struct wg_peer *peer) in wg_timers_stop() argument
237 timer_delete_sync(&peer->timer_retransmit_handshake); in wg_timers_stop()
238 timer_delete_sync(&peer->timer_send_keepalive); in wg_timers_stop()
239 timer_delete_sync(&peer->timer_new_handshake); in wg_timers_stop()
240 timer_delete_sync(&peer->timer_zero_key_material); in wg_timers_stop()
241 timer_delete_sync(&peer->timer_persistent_keepalive); in wg_timers_stop()
242 flush_work(&peer->clear_peer_work); in wg_timers_stop()