diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-31 07:03:07 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-31 07:19:52 +0200 |
commit | 488b7dcba7a5dcf5d65349992c7fc32b3d9c17d1 (patch) | |
tree | 847677cfc90dee98bfe86d64a991f3ff0d8f428d /src/peer.c | |
parent | ratelimiter: prevent init/uninit race (diff) | |
download | wireguard-linux-compat-488b7dcba7a5dcf5d65349992c7fc32b3d9c17d1.tar.xz wireguard-linux-compat-488b7dcba7a5dcf5d65349992c7fc32b3d9c17d1.zip |
peer: simplify rcu reference counts
Use RCU reference counts only when we must, and otherwise use a more
reasonably named function.
Reported-by: Jann Horn <jann@thejh.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 10 |
1 files changed, 1 insertions, 9 deletions
@@ -63,7 +63,7 @@ struct wireguard_peer *peer_create(struct wireguard_device *wg, const u8 public_ return peer; } -struct wireguard_peer *peer_get(struct wireguard_peer *peer) +struct wireguard_peer *peer_get_maybe_zero(struct wireguard_peer *peer) { RCU_LOCKDEP_WARN(!rcu_read_lock_bh_held(), "Taking peer reference without holding the RCU read lock"); if (unlikely(!peer || !kref_get_unless_zero(&peer->refcount))) @@ -71,14 +71,6 @@ struct wireguard_peer *peer_get(struct wireguard_peer *peer) return peer; } -struct wireguard_peer *peer_rcu_get(struct wireguard_peer *peer) -{ - rcu_read_lock_bh(); - peer = peer_get(peer); - rcu_read_unlock_bh(); - return peer; -} - /* We have a separate "remove" function to get rid of the final reference because * peer_list, clearing handshakes, and flushing all require mutexes which requires * sleeping, which must only be done from certain contexts. |