Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
0004  */
0005 
0006 #ifndef _WG_DEVICE_H
0007 #define _WG_DEVICE_H
0008 
0009 #include "noise.h"
0010 #include "allowedips.h"
0011 #include "peerlookup.h"
0012 #include "cookie.h"
0013 
0014 #include <linux/types.h>
0015 #include <linux/netdevice.h>
0016 #include <linux/workqueue.h>
0017 #include <linux/mutex.h>
0018 #include <linux/net.h>
0019 #include <linux/ptr_ring.h>
0020 
0021 struct wg_device;
0022 
0023 struct multicore_worker {
0024     void *ptr;
0025     struct work_struct work;
0026 };
0027 
0028 struct crypt_queue {
0029     struct ptr_ring ring;
0030     struct multicore_worker __percpu *worker;
0031     int last_cpu;
0032 };
0033 
0034 struct prev_queue {
0035     struct sk_buff *head, *tail, *peeked;
0036     struct { struct sk_buff *next, *prev; } empty; // Match first 2 members of struct sk_buff.
0037     atomic_t count;
0038 };
0039 
0040 struct wg_device {
0041     struct net_device *dev;
0042     struct crypt_queue encrypt_queue, decrypt_queue, handshake_queue;
0043     struct sock __rcu *sock4, *sock6;
0044     struct net __rcu *creating_net;
0045     struct noise_static_identity static_identity;
0046     struct workqueue_struct *packet_crypt_wq,*handshake_receive_wq, *handshake_send_wq;
0047     struct cookie_checker cookie_checker;
0048     struct pubkey_hashtable *peer_hashtable;
0049     struct index_hashtable *index_hashtable;
0050     struct allowedips peer_allowedips;
0051     struct mutex device_update_lock, socket_update_lock;
0052     struct list_head device_list, peer_list;
0053     atomic_t handshake_queue_len;
0054     unsigned int num_peers, device_update_gen;
0055     u32 fwmark;
0056     u16 incoming_port;
0057 };
0058 
0059 int wg_device_init(void);
0060 void wg_device_uninit(void);
0061 
0062 #endif /* _WG_DEVICE_H */