summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/data.c10
-rw-r--r--src/device.c16
-rw-r--r--src/main.c18
-rw-r--r--src/packets.h6
4 files changed, 26 insertions, 24 deletions
diff --git a/src/data.c b/src/data.c
index ae2515b..ff9fd66 100644
--- a/src/data.c
+++ b/src/data.c
@@ -26,7 +26,7 @@ struct encryption_skb_cb {
struct encryption_ctx {
struct padata_priv padata;
struct sk_buff_head queue;
- void (*callback)(struct sk_buff_head *, struct wireguard_peer *);
+ packet_create_data_callback_t callback;
struct wireguard_peer *peer;
struct noise_keypair *keypair;
};
@@ -34,12 +34,12 @@ struct encryption_ctx {
struct decryption_ctx {
struct padata_priv padata;
struct sk_buff *skb;
- void (*callback)(struct sk_buff *skb, struct wireguard_peer *, struct endpoint *, bool used_new_key, int err);
+ packet_consume_data_callback_t callback;
struct noise_keypair *keypair;
struct endpoint endpoint;
u64 nonce;
- u8 num_frags;
int ret;
+ u8 num_frags;
};
#ifdef CONFIG_WIREGUARD_PARALLEL
@@ -250,7 +250,7 @@ static inline unsigned int choose_cpu(__le32 key)
}
#endif
-int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer, void(*callback)(struct sk_buff_head *, struct wireguard_peer *))
+int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer, packet_create_data_callback_t callback)
{
int ret = -ENOKEY;
struct noise_keypair *keypair;
@@ -409,7 +409,7 @@ static inline int start_decryption(struct padata_instance *padata, struct padata
}
#endif
-void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, void(*callback)(struct sk_buff *skb, struct wireguard_peer *, struct endpoint *, bool used_new_key, int err))
+void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, packet_consume_data_callback_t callback)
{
int ret;
struct endpoint endpoint;
diff --git a/src/device.c b/src/device.c
index 0c9434a..38009bb 100644
--- a/src/device.c
+++ b/src/device.c
@@ -273,7 +273,7 @@ static void setup(struct net_device *dev)
static int newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[])
{
- int err = -ENOMEM;
+ int ret = -ENOMEM;
struct wireguard_device *wg = netdev_priv(dev);
wg->creating_net = get_net(src_net);
@@ -311,19 +311,19 @@ static int newlink(struct net *src_net, struct net_device *dev, struct nlattr *t
padata_start(wg->parallel_receive);
#endif
- err = cookie_checker_init(&wg->cookie_checker, wg);
- if (err < 0)
+ ret = cookie_checker_init(&wg->cookie_checker, wg);
+ if (ret < 0)
goto error_6;
#ifdef CONFIG_PM_SLEEP
wg->clear_peers_on_suspend.notifier_call = suspending_clear_noise_peers;
- err = register_pm_notifier(&wg->clear_peers_on_suspend);
- if (err < 0)
+ ret = register_pm_notifier(&wg->clear_peers_on_suspend);
+ if (ret < 0)
goto error_7;
#endif
- err = register_netdevice(dev);
- if (err < 0)
+ ret = register_netdevice(dev);
+ if (ret < 0)
goto error_8;
pr_debug("Device %s has been created\n", dev->name);
@@ -350,7 +350,7 @@ error_2:
free_percpu(dev->tstats);
error_1:
put_net(src_net);
- return err;
+ return ret;
}
static struct rtnl_link_ops link_ops __read_mostly = {
diff --git a/src/main.c b/src/main.c
index e27e619..e0e2bb0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -16,7 +16,7 @@
static int __init mod_init(void)
{
- int err;
+ int ret;
#ifdef DEBUG
if (!routing_table_selftest() || !packet_counter_selftest() || !curve25519_selftest() || !chacha20poly1305_selftest() || !blake2s_selftest() || !siphash24_selftest())
@@ -25,18 +25,18 @@ static int __init mod_init(void)
chacha20poly1305_init();
noise_init();
- err = ratelimiter_module_init();
- if (err < 0)
- return err;
+ ret = ratelimiter_module_init();
+ if (ret < 0)
+ return ret;
#ifdef CONFIG_WIREGUARD_PARALLEL
- err = packet_init_data_caches();
- if (err < 0)
+ ret = packet_init_data_caches();
+ if (ret < 0)
goto err_packet;
#endif
- err = device_init();
- if (err < 0)
+ ret = device_init();
+ if (ret < 0)
goto err_device;
pr_info("WireGuard " WIREGUARD_VERSION " loaded. See www.wireguard.io for information.\n");
@@ -50,7 +50,7 @@ err_device:
err_packet:
#endif
ratelimiter_module_deinit();
- return err;
+ return ret;
}
static void __exit mod_exit(void)
diff --git a/src/packets.h b/src/packets.h
index e36c12c..4d07adc 100644
--- a/src/packets.h
+++ b/src/packets.h
@@ -27,8 +27,10 @@ void packet_send_handshake_response(struct wireguard_peer *peer);
void packet_send_handshake_cookie(struct wireguard_device *wg, struct sk_buff *initiating_skb, void *data, size_t data_len, __le32 sender_index);
/* data.c */
-int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer, void(*callback)(struct sk_buff_head *, struct wireguard_peer *));
-void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, void(*callback)(struct sk_buff *, struct wireguard_peer *, struct endpoint *, bool, int));
+typedef void (*packet_create_data_callback_t)(struct sk_buff_head *, struct wireguard_peer *);
+typedef void (*packet_consume_data_callback_t)(struct sk_buff *skb, struct wireguard_peer *, struct endpoint *, bool used_new_key, int err);
+int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer, packet_create_data_callback_t callback);
+void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, packet_consume_data_callback_t callback);
#ifdef CONFIG_WIREGUARD_PARALLEL
int packet_init_data_caches(void);