aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-12-08 12:06:39 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-12-09 21:31:11 +0100
commit9b6e9902708d30bda69e331249946371a2710553 (patch)
tree43544948921fbc5aa8257c2a5a7dd84fd9631f1d
parentmain: cleaner error teardown (diff)
downloadwireguard-monolithic-historical-9b6e9902708d30bda69e331249946371a2710553.tar.xz
wireguard-monolithic-historical-9b6e9902708d30bda69e331249946371a2710553.zip
device: make suspend code conditional on CONFIG_PM_SLEEP
This isn't actually neccessary, since there are no-op stubs for these functions, but the MIPS people don't want any unneccessary bloat.
-rw-r--r--src/device.c8
-rw-r--r--src/device.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 9590f92..efa2ee8 100644
--- a/src/device.c
+++ b/src/device.c
@@ -64,6 +64,7 @@ static int clear_noise_peer(struct wireguard_peer *peer, void *data)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
static int suspending_clear_noise_peers(struct notifier_block *nb, unsigned long action, void *data)
{
struct wireguard_device *wg = container_of(nb, struct wireguard_device, clear_peers_on_suspend);
@@ -75,6 +76,7 @@ static int suspending_clear_noise_peers(struct notifier_block *nb, unsigned long
}
return 0;
}
+#endif
static int stop_peer(struct wireguard_peer *peer, void *data)
{
@@ -236,7 +238,9 @@ static void destruct(struct net_device *dev)
skb_queue_purge(&wg->incoming_handshakes);
socket_uninit(wg);
cookie_checker_uninit(&wg->cookie_checker);
+#ifdef CONFIG_PM_SLEEP
unregister_pm_notifier(&wg->clear_peers_on_suspend);
+#endif
mutex_unlock(&wg->device_update_lock);
put_net(wg->creating_net);
@@ -318,10 +322,12 @@ static int newlink(struct net *src_net, struct net_device *dev, struct nlattr *t
if (err < 0)
goto error_5;
+#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)
goto error_6;
+#endif
err = register_netdevice(dev);
if (err < 0)
@@ -332,8 +338,10 @@ static int newlink(struct net *src_net, struct net_device *dev, struct nlattr *t
return 0;
error_7:
+#ifdef CONFIG_PM_SLEEP
unregister_pm_notifier(&wg->clear_peers_on_suspend);
error_6:
+#endif
cookie_checker_uninit(&wg->cookie_checker);
error_5:
#ifdef CONFIG_WIREGUARD_PARALLEL
diff --git a/src/device.h b/src/device.h
index f716242..cd62e9b 100644
--- a/src/device.h
+++ b/src/device.h
@@ -33,7 +33,9 @@ struct wireguard_device {
struct list_head peer_list;
struct mutex device_update_lock;
struct mutex socket_update_lock;
+#ifdef CONFIG_PM_SLEEP
struct notifier_block clear_peers_on_suspend;
+#endif
};
int device_init(void);