summaryrefslogtreecommitdiffhomepage
path: root/src/peer.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-05-19 17:55:51 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-06-02 18:31:09 +0200
commit6fbc0e62842cefac784a817cd70e90d5e29fe816 (patch)
treede8e7777bd2216b1c93110180389eee876958ee2 /src/peer.c
parent405caf01e9b234bc512ec93ac055d57336ce18d9 (diff)
global: use synchronize_net rather than synchronize_rcu
Many of the synchronization points are sometimes called under the rtnl lock, which means we should use synchronize_net rather than synchronize_rcu. Under the hood, this expands to using the expedited flavor of function in the event that rtnl is held, in order to not stall other concurrent changes. This fixes some very, very long delays when removing multiple peers at once, which would cause some operations to take several minutes. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/peer.c b/src/peer.c
index cd5cb02..3a042d2 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -88,7 +88,7 @@ static void peer_make_dead(struct wg_peer *peer)
/* Mark as dead, so that we don't allow jumping contexts after. */
WRITE_ONCE(peer->is_dead, true);
- /* The caller must now synchronize_rcu() for this to take effect. */
+ /* The caller must now synchronize_net() for this to take effect. */
}
static void peer_remove_after_dead(struct wg_peer *peer)
@@ -160,7 +160,7 @@ void wg_peer_remove(struct wg_peer *peer)
lockdep_assert_held(&peer->device->device_update_lock);
peer_make_dead(peer);
- synchronize_rcu();
+ synchronize_net();
peer_remove_after_dead(peer);
}
@@ -178,7 +178,7 @@ void wg_peer_remove_all(struct wg_device *wg)
peer_make_dead(peer);
list_add_tail(&peer->peer_list, &dead_peers);
}
- synchronize_rcu();
+ synchronize_net();
list_for_each_entry_safe(peer, temp, &dead_peers, peer_list)
peer_remove_after_dead(peer);
}