xref: /linux/drivers/net/ovpn/ovpnpriv.h (revision bca5cfbb694d66a1c482d0c347eee80f6afbc870)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*  OpenVPN data channel offload
3  *
4  *  Copyright (C) 2019-2025 OpenVPN, Inc.
5  *
6  *  Author:	James Yonan <james@openvpn.net>
7  *		Antonio Quartulli <antonio@openvpn.net>
8  */
9 
10 #ifndef _NET_OVPN_OVPNSTRUCT_H_
11 #define _NET_OVPN_OVPNSTRUCT_H_
12 
13 #include <linux/workqueue.h>
14 #include <net/gro_cells.h>
15 #include <uapi/linux/if_link.h>
16 #include <uapi/linux/ovpn.h>
17 
18 /**
19  * struct ovpn_peer_collection - container of peers for MultiPeer mode
20  * @by_id: table of peers index by ID
21  * @by_vpn_addr4: table of peers indexed by VPN IPv4 address (items can be
22  *		  rehashed on the fly due to peer IP change)
23  * @by_vpn_addr6: table of peers indexed by VPN IPv6 address (items can be
24  *		  rehashed on the fly due to peer IP change)
25  * @by_transp_addr: table of peers indexed by transport address (items can be
26  *		    rehashed on the fly due to peer IP change)
27  */
28 struct ovpn_peer_collection {
29 	DECLARE_HASHTABLE(by_id, 12);
30 	struct hlist_nulls_head by_vpn_addr4[1 << 12];
31 	struct hlist_nulls_head by_vpn_addr6[1 << 12];
32 	struct hlist_nulls_head by_transp_addr[1 << 12];
33 };
34 
35 /**
36  * struct ovpn_priv - per ovpn interface state
37  * @dev: the actual netdev representing the tunnel
38  * @mode: device operation mode (i.e. p2p, mp, ..)
39  * @lock: protect this object
40  * @peers: data structures holding multi-peer references
41  * @peer: in P2P mode, this is the only remote peer
42  * @gro_cells: pointer to the Generic Receive Offload cell
43  * @keepalive_work: struct used to schedule keepalive periodic job
44  */
45 struct ovpn_priv {
46 	struct net_device *dev;
47 	enum ovpn_mode mode;
48 	spinlock_t lock; /* protect writing to the ovpn_priv object */
49 	struct ovpn_peer_collection *peers;
50 	struct ovpn_peer __rcu *peer;
51 	struct gro_cells gro_cells;
52 	struct delayed_work keepalive_work;
53 };
54 
55 #endif /* _NET_OVPN_OVPNSTRUCT_H_ */
56