summaryrefslogtreecommitdiffhomepage
path: root/src/peer.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-07-31 07:03:07 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-07-31 07:19:52 +0200
commit488b7dcba7a5dcf5d65349992c7fc32b3d9c17d1 (patch)
tree847677cfc90dee98bfe86d64a991f3ff0d8f428d /src/peer.h
parent0c942d003c4291fe05d0de296ac040c7b0d0503c (diff)
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.h')
-rw-r--r--src/peer.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/peer.h b/src/peer.h
index 088a6ee..70120ee 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -62,9 +62,11 @@ struct wireguard_peer {
struct wireguard_peer *peer_create(struct wireguard_device *wg, const u8 public_key[NOISE_PUBLIC_KEY_LEN], const u8 preshared_key[NOISE_SYMMETRIC_KEY_LEN]);
-struct wireguard_peer *peer_get(struct wireguard_peer *peer);
-struct wireguard_peer *peer_rcu_get(struct wireguard_peer *peer);
-
+struct wireguard_peer * __must_check peer_get_maybe_zero(struct wireguard_peer *peer);
+static inline void peer_get(struct wireguard_peer *peer)
+{
+ kref_get(&peer->refcount);
+}
void peer_put(struct wireguard_peer *peer);
void peer_remove(struct wireguard_peer *peer);
void peer_remove_all(struct wireguard_device *wg);