device.c (d0034a7a4ac7fae708146ac0059b9c47a1543f0d) device.c (20ae1d6aa159eb91a9bf09ff92ccaa94dbea92c2)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4 */
5
6#include "queueing.h"
7#include "socket.h"
8#include "timers.h"

--- 384 unchanged lines hidden (view full) ---

393 .priv_size = sizeof(struct wg_device),
394 .setup = wg_setup,
395 .newlink = wg_newlink,
396};
397
398static void wg_netns_pre_exit(struct net *net)
399{
400 struct wg_device *wg;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4 */
5
6#include "queueing.h"
7#include "socket.h"
8#include "timers.h"

--- 384 unchanged lines hidden (view full) ---

393 .priv_size = sizeof(struct wg_device),
394 .setup = wg_setup,
395 .newlink = wg_newlink,
396};
397
398static void wg_netns_pre_exit(struct net *net)
399{
400 struct wg_device *wg;
401 struct wg_peer *peer;
401
402 rtnl_lock();
403 list_for_each_entry(wg, &device_list, device_list) {
404 if (rcu_access_pointer(wg->creating_net) == net) {
405 pr_debug("%s: Creating namespace exiting\n", wg->dev->name);
406 netif_carrier_off(wg->dev);
407 mutex_lock(&wg->device_update_lock);
408 rcu_assign_pointer(wg->creating_net, NULL);
409 wg_socket_reinit(wg, NULL, NULL);
402
403 rtnl_lock();
404 list_for_each_entry(wg, &device_list, device_list) {
405 if (rcu_access_pointer(wg->creating_net) == net) {
406 pr_debug("%s: Creating namespace exiting\n", wg->dev->name);
407 netif_carrier_off(wg->dev);
408 mutex_lock(&wg->device_update_lock);
409 rcu_assign_pointer(wg->creating_net, NULL);
410 wg_socket_reinit(wg, NULL, NULL);
411 list_for_each_entry(peer, &wg->peer_list, peer_list)
412 wg_socket_clear_peer_endpoint_src(peer);
410 mutex_unlock(&wg->device_update_lock);
411 }
412 }
413 rtnl_unlock();
414}
415
416static struct pernet_operations pernet_ops = {
417 .pre_exit = wg_netns_pre_exit

--- 40 unchanged lines hidden ---
413 mutex_unlock(&wg->device_update_lock);
414 }
415 }
416 rtnl_unlock();
417}
418
419static struct pernet_operations pernet_ops = {
420 .pre_exit = wg_netns_pre_exit

--- 40 unchanged lines hidden ---