Lines Matching refs:peer

106 get_peer(struct wg_peer *peer, struct sk_buff *skb, struct dump_ctx *ctx)  in get_peer()  argument
116 down_read(&peer->handshake.lock); in get_peer()
118 peer->handshake.remote_static); in get_peer()
119 up_read(&peer->handshake.lock); in get_peer()
125 .tv_sec = peer->walltime_last_handshake.tv_sec, in get_peer()
126 .tv_nsec = peer->walltime_last_handshake.tv_nsec in get_peer()
129 down_read(&peer->handshake.lock); in get_peer()
132 peer->handshake.preshared_key); in get_peer()
133 up_read(&peer->handshake.lock); in get_peer()
140 peer->persistent_keepalive_interval) || in get_peer()
141 nla_put_u64_64bit(skb, WGPEER_A_TX_BYTES, peer->tx_bytes, in get_peer()
143 nla_put_u64_64bit(skb, WGPEER_A_RX_BYTES, peer->rx_bytes, in get_peer()
148 read_lock_bh(&peer->endpoint_lock); in get_peer()
149 if (peer->endpoint.addr.sa_family == AF_INET) in get_peer()
151 sizeof(peer->endpoint.addr4), in get_peer()
152 &peer->endpoint.addr4); in get_peer()
153 else if (peer->endpoint.addr.sa_family == AF_INET6) in get_peer()
155 sizeof(peer->endpoint.addr6), in get_peer()
156 &peer->endpoint.addr6); in get_peer()
157 read_unlock_bh(&peer->endpoint_lock); in get_peer()
161 list_first_entry_or_null(&peer->allowedips_list, in get_peer()
175 list_for_each_entry_from(allowedips_node, &peer->allowedips_list, in get_peer()
212 struct wg_peer *peer, *next_peer_cursor; in wg_get_device_dump() local
269 peer = list_prepare_entry(ctx->next_peer, &wg->peer_list, peer_list); in wg_get_device_dump()
270 list_for_each_entry_continue(peer, &wg->peer_list, peer_list) { in wg_get_device_dump()
271 if (get_peer(peer, skb, ctx)) { in wg_get_device_dump()
275 next_peer_cursor = peer; in wg_get_device_dump()
316 struct wg_peer *peer; in set_port() local
320 list_for_each_entry(peer, &wg->peer_list, peer_list) in set_port()
321 wg_socket_clear_peer_endpoint_src(peer); in set_port()
329 static int set_allowedip(struct wg_peer *peer, struct nlattr **attrs) in set_allowedip() argument
344 &peer->device->peer_allowedips, in set_allowedip()
345 nla_data(attrs[WGALLOWEDIP_A_IPADDR]), cidr, peer, in set_allowedip()
346 &peer->device->device_update_lock); in set_allowedip()
350 &peer->device->peer_allowedips, in set_allowedip()
351 nla_data(attrs[WGALLOWEDIP_A_IPADDR]), cidr, peer, in set_allowedip()
352 &peer->device->device_update_lock); in set_allowedip()
360 struct wg_peer *peer = NULL; in set_peer() local
386 peer = wg_pubkey_hashtable_lookup(wg->peer_hashtable, in set_peer()
389 if (!peer) { /* Peer doesn't exist yet. Add a new one. */ in set_peer()
412 peer = wg_peer_create(wg, public_key, preshared_key); in set_peer()
413 if (IS_ERR(peer)) { in set_peer()
414 ret = PTR_ERR(peer); in set_peer()
415 peer = NULL; in set_peer()
421 wg_peer_get(peer); in set_peer()
425 wg_peer_remove(peer); in set_peer()
430 down_write(&peer->handshake.lock); in set_peer()
431 memcpy(&peer->handshake.preshared_key, preshared_key, in set_peer()
433 up_write(&peer->handshake.lock); in set_peer()
443 wg_socket_set_peer_endpoint(peer, &endpoint); in set_peer()
446 wg_socket_set_peer_endpoint(peer, &endpoint); in set_peer()
451 wg_allowedips_remove_by_peer(&wg->peer_allowedips, peer, in set_peer()
463 ret = set_allowedip(peer, allowedip); in set_peer()
473 !peer->persistent_keepalive_interval && in set_peer()
477 peer->persistent_keepalive_interval = persistent_keepalive_interval; in set_peer()
479 wg_packet_send_keepalive(peer); in set_peer()
483 wg_packet_send_staged_packets(peer); in set_peer()
486 wg_peer_put(peer); in set_peer()
526 struct wg_peer *peer; in wg_set_device() local
529 list_for_each_entry(peer, &wg->peer_list, peer_list) in wg_set_device()
530 wg_socket_clear_peer_endpoint_src(peer); in wg_set_device()
548 struct wg_peer *peer, *temp; in wg_set_device() local
559 peer = wg_pubkey_hashtable_lookup(wg->peer_hashtable, in wg_set_device()
561 if (peer) { in wg_set_device()
562 wg_peer_put(peer); in wg_set_device()
563 wg_peer_remove(peer); in wg_set_device()
573 list_for_each_entry_safe(peer, temp, &wg->peer_list, peer_list) { in wg_set_device()
574 wg_noise_precompute_static_static(peer); in wg_set_device()
575 wg_noise_expire_current_peer_keypairs(peer); in wg_set_device()
577 wg_packet_send_staged_packets(peer); in wg_set_device()
584 struct nlattr *attr, *peer[WGPEER_A_MAX + 1]; in wg_set_device() local
588 ret = nla_parse_nested(peer, WGPEER_A_MAX, attr, in wg_set_device()
592 ret = set_peer(wg, peer); in wg_set_device()