Debian Codegraph @

drivers/net/ovpn-dco/sock.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* OpenVPN data channel accelerator
3 *
4 * Copyright (C) 2020- OpenVPN, Inc.
5 *
6 * Author: James Yonan <[email protected]>
7 * Antonio Quartulli <[email protected]>
8 */
9
10 #ifndef _NET_OVPN_DCO_SOCK_H_
11 #define _NET_OVPN_DCO_SOCK_H_
12
13 #include <linux/net.h>
14 #include <linux/kref.h>
15 #include <linux/ptr_ring.h>
16 #include <net/sock.h>
17
18 #include "peer.h"
19
20 struct ovpn_struct;
21
22 /**
23 * struct ovpn_socket - a kernel socket referenced in the ovpn-dco code
24 */
25 struct ovpn_socket {
26 union {
27 /** @ovpn: the VPN session object owning this socket (UDP only) */
28 struct ovpn_struct *ovpn;
29
30 /* TCP only */
31 struct {
32 /** @peer: the unique peer transmitting over this socket (TCP only) */
33 struct ovpn_peer *peer;
34 struct ptr_ring recv_ring;
35 };
36 };
37
38 /** @sock: the kernel socket */
39 struct socket *sock;
40
41 /** @refcount: amount of contexts currently referencing this object */
42 struct kref refcount;
43
44 /** @rcu: member used to schedule RCU destructor callback */
45 struct rcu_head rcu;
46 };
47
48 struct ovpn_struct *ovpn_from_udp_sock(struct sock *sk);
49
50 void ovpn_socket_release_kref(struct kref *kref);
51
52 static inline void ovpn_socket_put(struct ovpn_socket *sock)
53 {
54 kref_put(&sock->refcount, ovpn_socket_release_kref);
55 }
56
57 struct ovpn_socket *ovpn_socket_new(struct socket *sock, struct ovpn_peer *peer);
58
59 #endif /* _NET_OVPN_DCO_SOCK_H_ */