--- src/device.c | 5 +++-- src/device.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/device.c b/src/device.c index 92aefc4..cb54ae1 100644 --- a/src/device.c +++ b/src/device.c @@ -396,10 +396,11 @@ static int netdevice_notification(struct notifier_block *nb, if (action != NETDEV_REGISTER || dev->netdev_ops != &netdev_ops) return 0; - if (dev_net(dev) == wg->transit_net && wg->have_transit_net_ref) { + wg->dev_net = dev_net(dev); + if (wg->dev_net == wg->transit_net && wg->have_transit_net_ref) { put_net(wg->transit_net); wg->have_transit_net_ref = false; - } else if (dev_net(dev) != wg->transit_net && + } else if (wg->dev_net != wg->transit_net && !wg->have_transit_net_ref) { wg->have_transit_net_ref = true; get_net(wg->transit_net); diff --git a/src/device.h b/src/device.h index 4b7552c..0bd25f2 100644 --- a/src/device.h +++ b/src/device.h @@ -41,6 +41,7 @@ struct wireguard_device { struct crypt_queue encrypt_queue, decrypt_queue; struct sock __rcu *sock4, *sock6; struct net *transit_net; + struct net *dev_net; struct noise_static_identity static_identity; struct workqueue_struct *handshake_receive_wq, *handshake_send_wq; struct workqueue_struct *packet_crypt_wq; -- 2.18.0 _______________________________________________ WireGuard mailing list WireGuard@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/wireguard