diff options
-rw-r--r-- | src/device.c | 8 | ||||
-rw-r--r-- | src/device.h | 2 |
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); |