Lines Matching full:peer

8 #include "peer.h"
20 static void update_rx_stats(struct wg_peer *peer, size_t len) in update_rx_stats() argument
23 get_cpu_ptr(peer->device->dev->tstats); in update_rx_stats()
28 peer->rx_bytes += len; in update_rx_stats()
103 struct wg_peer *peer = NULL; in wg_receive_handshake_packet() local
151 peer = wg_noise_handshake_consume_initiation(message, wg); in wg_receive_handshake_packet()
152 if (unlikely(!peer)) { in wg_receive_handshake_packet()
157 wg_socket_set_peer_endpoint_from_skb(peer, skb); in wg_receive_handshake_packet()
158 net_dbg_ratelimited("%s: Receiving handshake initiation from peer %llu (%pISpfsc)\n", in wg_receive_handshake_packet()
159 wg->dev->name, peer->internal_id, in wg_receive_handshake_packet()
160 &peer->endpoint.addr); in wg_receive_handshake_packet()
161 wg_packet_send_handshake_response(peer); in wg_receive_handshake_packet()
173 peer = wg_noise_handshake_consume_response(message, wg); in wg_receive_handshake_packet()
174 if (unlikely(!peer)) { in wg_receive_handshake_packet()
179 wg_socket_set_peer_endpoint_from_skb(peer, skb); in wg_receive_handshake_packet()
180 net_dbg_ratelimited("%s: Receiving handshake response from peer %llu (%pISpfsc)\n", in wg_receive_handshake_packet()
181 wg->dev->name, peer->internal_id, in wg_receive_handshake_packet()
182 &peer->endpoint.addr); in wg_receive_handshake_packet()
183 if (wg_noise_handshake_begin_session(&peer->handshake, in wg_receive_handshake_packet()
184 &peer->keypairs)) { in wg_receive_handshake_packet()
185 wg_timers_session_derived(peer); in wg_receive_handshake_packet()
186 wg_timers_handshake_complete(peer); in wg_receive_handshake_packet()
193 wg_packet_send_keepalive(peer); in wg_receive_handshake_packet()
199 if (unlikely(!peer)) { in wg_receive_handshake_packet()
205 update_rx_stats(peer, skb->len); in wg_receive_handshake_packet()
208 wg_timers_any_authenticated_packet_received(peer); in wg_receive_handshake_packet()
209 wg_timers_any_authenticated_packet_traversal(peer); in wg_receive_handshake_packet()
210 wg_peer_put(peer); in wg_receive_handshake_packet()
226 static void keep_key_fresh(struct wg_peer *peer) in keep_key_fresh() argument
231 if (peer->sent_lastminute_handshake) in keep_key_fresh()
235 keypair = rcu_dereference_bh(peer->keypairs.current_keypair); in keep_key_fresh()
243 peer->sent_lastminute_handshake = true; in keep_key_fresh()
244 wg_packet_send_queued_handshake_initiation(peer, false); in keep_key_fresh()
341 static void wg_packet_consume_data_done(struct wg_peer *peer, in wg_packet_consume_data_done() argument
345 struct net_device *dev = peer->device->dev; in wg_packet_consume_data_done()
349 wg_socket_set_peer_endpoint(peer, endpoint); in wg_packet_consume_data_done()
351 if (unlikely(wg_noise_received_with_keypair(&peer->keypairs, in wg_packet_consume_data_done()
353 wg_timers_handshake_complete(peer); in wg_packet_consume_data_done()
354 wg_packet_send_staged_packets(peer); in wg_packet_consume_data_done()
357 keep_key_fresh(peer); in wg_packet_consume_data_done()
359 wg_timers_any_authenticated_packet_received(peer); in wg_packet_consume_data_done()
360 wg_timers_any_authenticated_packet_traversal(peer); in wg_packet_consume_data_done()
364 update_rx_stats(peer, message_data_len(0)); in wg_packet_consume_data_done()
365 net_dbg_ratelimited("%s: Receiving keepalive packet from peer %llu (%pISpfsc)\n", in wg_packet_consume_data_done()
366 dev->name, peer->internal_id, in wg_packet_consume_data_done()
367 &peer->endpoint.addr); in wg_packet_consume_data_done()
371 wg_timers_data_received(peer); in wg_packet_consume_data_done()
410 routed_peer = wg_allowedips_lookup_src(&peer->device->peer_allowedips, in wg_packet_consume_data_done()
414 if (unlikely(routed_peer != peer)) in wg_packet_consume_data_done()
417 napi_gro_receive(&peer->napi, skb); in wg_packet_consume_data_done()
418 update_rx_stats(peer, message_data_len(len_before_trim)); in wg_packet_consume_data_done()
422 net_dbg_skb_ratelimited("%s: Packet has unallowed src IP (%pISc) from peer %llu (%pISpfsc)\n", in wg_packet_consume_data_done()
423 dev->name, skb, peer->internal_id, in wg_packet_consume_data_done()
424 &peer->endpoint.addr); in wg_packet_consume_data_done()
429 net_dbg_ratelimited("%s: Packet is neither ipv4 nor ipv6 from peer %llu (%pISpfsc)\n", in wg_packet_consume_data_done()
430 dev->name, peer->internal_id, &peer->endpoint.addr); in wg_packet_consume_data_done()
435 net_dbg_ratelimited("%s: Packet has incorrect size from peer %llu (%pISpfsc)\n", in wg_packet_consume_data_done()
436 dev->name, peer->internal_id, &peer->endpoint.addr); in wg_packet_consume_data_done()
446 struct wg_peer *peer = container_of(napi, struct wg_peer, napi); in wg_packet_rx_poll() local
447 struct crypt_queue *queue = &peer->rx_queue; in wg_packet_rx_poll()
462 peer = PACKET_PEER(skb); in wg_packet_rx_poll()
472 peer->device->dev->name, in wg_packet_rx_poll()
482 wg_packet_consume_data_done(peer, skb, &endpoint); in wg_packet_rx_poll()
487 wg_peer_put(peer); in wg_packet_rx_poll()
520 struct wg_peer *peer = NULL; in wg_packet_consume_data() local
527 &peer); in wg_packet_consume_data()
531 if (unlikely(READ_ONCE(peer->is_dead))) in wg_packet_consume_data()
535 &peer->rx_queue, skb, in wg_packet_consume_data()
548 wg_peer_put(peer); in wg_packet_consume_data()