Lines Matching +full:noise +full:- +full:sensitive
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
11 #include "noise.h"
26 int ret = -ENOMEM; in wg_peer_create()
28 lockdep_assert_held(&wg->device_update_lock); in wg_peer_create()
30 if (wg->num_peers >= MAX_PEERS_PER_DEVICE) in wg_peer_create()
36 if (unlikely(dst_cache_init(&peer->endpoint_cache, GFP_KERNEL))) in wg_peer_create()
39 peer->device = wg; in wg_peer_create()
40 wg_noise_handshake_init(&peer->handshake, &wg->static_identity, in wg_peer_create()
42 peer->internal_id = atomic64_inc_return(&peer_counter); in wg_peer_create()
43 peer->serial_work_cpu = nr_cpumask_bits; in wg_peer_create()
44 wg_cookie_init(&peer->latest_cookie); in wg_peer_create()
47 spin_lock_init(&peer->keypairs.keypair_update_lock); in wg_peer_create()
48 INIT_WORK(&peer->transmit_handshake_work, wg_packet_handshake_send_worker); in wg_peer_create()
49 INIT_WORK(&peer->transmit_packet_work, wg_packet_tx_worker); in wg_peer_create()
50 wg_prev_queue_init(&peer->tx_queue); in wg_peer_create()
51 wg_prev_queue_init(&peer->rx_queue); in wg_peer_create()
52 rwlock_init(&peer->endpoint_lock); in wg_peer_create()
53 kref_init(&peer->refcount); in wg_peer_create()
54 skb_queue_head_init(&peer->staged_packet_queue); in wg_peer_create()
55 wg_noise_reset_last_sent_handshake(&peer->last_sent_handshake); in wg_peer_create()
56 set_bit(NAPI_STATE_NO_BUSY_POLL, &peer->napi.state); in wg_peer_create()
57 netif_napi_add(wg->dev, &peer->napi, wg_packet_rx_poll); in wg_peer_create()
58 napi_enable(&peer->napi); in wg_peer_create()
59 list_add_tail(&peer->peer_list, &wg->peer_list); in wg_peer_create()
60 INIT_LIST_HEAD(&peer->allowedips_list); in wg_peer_create()
61 wg_pubkey_hashtable_add(wg->peer_hashtable, peer); in wg_peer_create()
62 ++wg->num_peers; in wg_peer_create()
63 pr_debug("%s: Peer %llu created\n", wg->dev->name, peer->internal_id); in wg_peer_create()
75 if (unlikely(!peer || !kref_get_unless_zero(&peer->refcount))) in wg_peer_get_maybe_zero()
82 /* Remove from configuration-time lookup structures. */ in peer_make_dead()
83 list_del_init(&peer->peer_list); in peer_make_dead()
84 wg_allowedips_remove_by_peer(&peer->device->peer_allowedips, peer, in peer_make_dead()
85 &peer->device->device_update_lock); in peer_make_dead()
86 wg_pubkey_hashtable_remove(peer->device->peer_hashtable, peer); in peer_make_dead()
89 WRITE_ONCE(peer->is_dead, true); in peer_make_dead()
96 WARN_ON(!peer->is_dead); in peer_remove_after_dead()
101 wg_noise_keypairs_clear(&peer->keypairs); in peer_remove_after_dead()
103 /* Destroy all ongoing timers that were in-flight at the beginning of in peer_remove_after_dead()
116 flush_workqueue(peer->device->packet_crypt_wq); in peer_remove_after_dead()
118 flush_workqueue(peer->device->packet_crypt_wq); in peer_remove_after_dead()
120 napi_disable(&peer->napi); in peer_remove_after_dead()
124 netif_napi_del(&peer->napi); in peer_remove_after_dead()
129 flush_workqueue(peer->device->handshake_send_wq); in peer_remove_after_dead()
143 * via the still-uncleared index hashtable entry, but not more than one, in peer_remove_after_dead()
148 --peer->device->num_peers; in peer_remove_after_dead()
160 lockdep_assert_held(&peer->device->device_update_lock); in wg_peer_remove()
172 lockdep_assert_held(&wg->device_update_lock); in wg_peer_remove_all()
175 wg_allowedips_free(&wg->peer_allowedips, &wg->device_update_lock); in wg_peer_remove_all()
177 list_for_each_entry_safe(peer, temp, &wg->peer_list, peer_list) { in wg_peer_remove_all()
179 list_add_tail(&peer->peer_list, &dead_peers); in wg_peer_remove_all()
190 dst_cache_destroy(&peer->endpoint_cache); in rcu_release()
191 WARN_ON(wg_prev_queue_peek(&peer->tx_queue) || wg_prev_queue_peek(&peer->rx_queue)); in rcu_release()
194 * material and other potentially sensitive information. in rcu_release()
205 peer->device->dev->name, peer->internal_id, in kref_release()
206 &peer->endpoint.addr); in kref_release()
211 wg_index_hashtable_remove(peer->device->index_hashtable, in kref_release()
212 &peer->handshake.entry); in kref_release()
220 call_rcu(&peer->rcu, rcu_release); in kref_release()
227 kref_put(&peer->refcount, kref_release); in wg_peer_put()
233 return peer_cache ? 0 : -ENOMEM; in wg_peer_init()