Lines Matching refs:peer
20 static void update_rx_stats(struct wg_peer *peer, size_t len) in update_rx_stats() argument
22 dev_sw_netstats_rx_add(peer->device->dev, len); in update_rx_stats()
23 peer->rx_bytes += len; in update_rx_stats()
96 struct wg_peer *peer = NULL; in wg_receive_handshake_packet() local
144 peer = wg_noise_handshake_consume_initiation(message, wg); in wg_receive_handshake_packet()
145 if (unlikely(!peer)) { in wg_receive_handshake_packet()
150 wg_socket_set_peer_endpoint_from_skb(peer, skb); in wg_receive_handshake_packet()
152 wg->dev->name, peer->internal_id, in wg_receive_handshake_packet()
153 &peer->endpoint.addr); in wg_receive_handshake_packet()
154 wg_packet_send_handshake_response(peer); in wg_receive_handshake_packet()
166 peer = wg_noise_handshake_consume_response(message, wg); in wg_receive_handshake_packet()
167 if (unlikely(!peer)) { in wg_receive_handshake_packet()
172 wg_socket_set_peer_endpoint_from_skb(peer, skb); in wg_receive_handshake_packet()
174 wg->dev->name, peer->internal_id, in wg_receive_handshake_packet()
175 &peer->endpoint.addr); in wg_receive_handshake_packet()
176 if (wg_noise_handshake_begin_session(&peer->handshake, in wg_receive_handshake_packet()
177 &peer->keypairs)) { in wg_receive_handshake_packet()
178 wg_timers_session_derived(peer); in wg_receive_handshake_packet()
179 wg_timers_handshake_complete(peer); in wg_receive_handshake_packet()
186 wg_packet_send_keepalive(peer); in wg_receive_handshake_packet()
192 if (unlikely(!peer)) { in wg_receive_handshake_packet()
198 update_rx_stats(peer, skb->len); in wg_receive_handshake_packet()
201 wg_timers_any_authenticated_packet_received(peer); in wg_receive_handshake_packet()
202 wg_timers_any_authenticated_packet_traversal(peer); in wg_receive_handshake_packet()
203 wg_peer_put(peer); in wg_receive_handshake_packet()
220 static void keep_key_fresh(struct wg_peer *peer) in keep_key_fresh() argument
225 if (peer->sent_lastminute_handshake) in keep_key_fresh()
229 keypair = rcu_dereference_bh(peer->keypairs.current_keypair); in keep_key_fresh()
237 peer->sent_lastminute_handshake = true; in keep_key_fresh()
238 wg_packet_send_queued_handshake_initiation(peer, false); in keep_key_fresh()
335 static void wg_packet_consume_data_done(struct wg_peer *peer, in wg_packet_consume_data_done() argument
339 struct net_device *dev = peer->device->dev; in wg_packet_consume_data_done()
343 wg_socket_set_peer_endpoint(peer, endpoint); in wg_packet_consume_data_done()
345 if (unlikely(wg_noise_received_with_keypair(&peer->keypairs, in wg_packet_consume_data_done()
347 wg_timers_handshake_complete(peer); in wg_packet_consume_data_done()
348 wg_packet_send_staged_packets(peer); in wg_packet_consume_data_done()
351 keep_key_fresh(peer); in wg_packet_consume_data_done()
353 wg_timers_any_authenticated_packet_received(peer); in wg_packet_consume_data_done()
354 wg_timers_any_authenticated_packet_traversal(peer); in wg_packet_consume_data_done()
358 update_rx_stats(peer, message_data_len(0)); in wg_packet_consume_data_done()
360 dev->name, peer->internal_id, in wg_packet_consume_data_done()
361 &peer->endpoint.addr); in wg_packet_consume_data_done()
365 wg_timers_data_received(peer); in wg_packet_consume_data_done()
404 routed_peer = wg_allowedips_lookup_src(&peer->device->peer_allowedips, in wg_packet_consume_data_done()
408 if (unlikely(routed_peer != peer)) in wg_packet_consume_data_done()
411 napi_gro_receive(&peer->napi, skb); in wg_packet_consume_data_done()
412 update_rx_stats(peer, message_data_len(len_before_trim)); in wg_packet_consume_data_done()
417 dev->name, skb, peer->internal_id, in wg_packet_consume_data_done()
418 &peer->endpoint.addr); in wg_packet_consume_data_done()
424 dev->name, peer->internal_id, &peer->endpoint.addr); in wg_packet_consume_data_done()
430 dev->name, peer->internal_id, &peer->endpoint.addr); in wg_packet_consume_data_done()
440 struct wg_peer *peer = container_of(napi, struct wg_peer, napi); in wg_packet_rx_poll() local
451 while ((skb = wg_prev_queue_peek(&peer->rx_queue)) != NULL && in wg_packet_rx_poll()
454 wg_prev_queue_drop_peeked(&peer->rx_queue); in wg_packet_rx_poll()
464 peer->device->dev->name, in wg_packet_rx_poll()
474 wg_packet_consume_data_done(peer, skb, &endpoint); in wg_packet_rx_poll()
479 wg_peer_put(peer); in wg_packet_rx_poll()
512 struct wg_peer *peer = NULL; in wg_packet_consume_data() local
519 &peer); in wg_packet_consume_data()
523 if (unlikely(READ_ONCE(peer->is_dead))) in wg_packet_consume_data()
526 ret = wg_queue_enqueue_per_device_and_peer(&wg->decrypt_queue, &peer->rx_queue, skb, in wg_packet_consume_data()
538 wg_peer_put(peer); in wg_packet_consume_data()