Re: [PATCH net-next v2 06/22] ovpn: introduce the ovpn_peer object
From: Antonio Quartulli <antonio@openvpn.net>
Date: 2024-03-08 11:00:37
On 08/03/2024 03:04, Andrew Lunn wrote:
quoted
+static inline bool ovpn_peer_hold(struct ovpn_peer *peer) +{ + return kref_get_unless_zero(&peer->refcount); +} + +static inline void ovpn_peer_put(struct ovpn_peer *peer) +{ + kref_put(&peer->refcount, ovpn_peer_release_kref); +}It is reasonably normal in the kernel to use _get() which takes a reference on something and _put() to release it.
I think I got inspired by dev_hold(), but I agree that _get() is more appropriate. Will change that.
quoted
+struct ovpn_peer *ovpn_peer_lookup_transp_addr(struct ovpn_struct *ovpn, struct sk_buff *skb); +struct ovpn_peer *ovpn_peer_lookup_by_dst(struct ovpn_struct *ovpn, struct sk_buff *skb); +struct ovpn_peer *ovpn_peer_lookup_by_src(struct ovpn_struct *ovpn, struct sk_buff *skb); +struct ovpn_peer *ovpn_peer_lookup_id(struct ovpn_struct *ovpn, u32 peer_id);All these look to take a reference on the peer. So maybe replace lookup by get? It should then be easier to check there is a matching put to every get.
Alright, will do! Regards, -- Antonio Quartulli OpenVPN Inc.