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 struct workqueue_struct; 19 20 extern struct workqueue_struct *ovpn_wq; 21 22 /** 23 * struct ovpn_peer_collection - container of peers for MultiPeer mode 24 * @by_id: table of peers index by ID 25 * @by_vpn_addr4: table of peers indexed by VPN IPv4 address (items can be 26 * rehashed on the fly due to peer IP change) 27 * @by_vpn_addr6: table of peers indexed by VPN IPv6 address (items can be 28 * rehashed on the fly due to peer IP change) 29 * @by_transp_addr: table of peers indexed by transport address (items can be 30 * rehashed on the fly due to peer IP change) 31 */ 32 struct ovpn_peer_collection { 33 DECLARE_HASHTABLE(by_id, 12); 34 struct hlist_nulls_head by_vpn_addr4[1 << 12]; 35 struct hlist_nulls_head by_vpn_addr6[1 << 12]; 36 struct hlist_nulls_head by_transp_addr[1 << 12]; 37 }; 38 39 /** 40 * struct ovpn_priv - per ovpn interface state 41 * @dev: the actual netdev representing the tunnel 42 * @mode: device operation mode (i.e. p2p, mp, ..) 43 * @lock: protect this object 44 * @peers: data structures holding multi-peer references 45 * @peer: in P2P mode, this is the only remote peer 46 * @gro_cells: pointer to the Generic Receive Offload cell 47 * @keepalive_work: struct used to schedule keepalive periodic job 48 */ 49 struct ovpn_priv { 50 struct net_device *dev; 51 enum ovpn_mode mode; 52 spinlock_t lock; /* protect writing to the ovpn_priv object */ 53 struct ovpn_peer_collection *peers; 54 struct ovpn_peer __rcu *peer; 55 struct gro_cells gro_cells; 56 struct delayed_work keepalive_work; 57 }; 58 59 #endif /* _NET_OVPN_OVPNSTRUCT_H_ */ 60