Skip to content

Commit f74da2c

Browse files
zx2c4gregkh
authored andcommitted
wireguard: use synchronize_net rather than synchronize_rcu
commit 24b70ee upstream. 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. Fixes: e7096c1 ("net: WireGuard secure network tunnel") Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d427588 commit f74da2c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎drivers/net/wireguard/peer.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static void peer_make_dead(struct wg_peer *peer)
8989
/* Mark as dead, so that we don't allow jumping contexts after. */
9090
WRITE_ONCE(peer->is_dead, true);
9191

92-
/* The caller must now synchronize_rcu() for this to take effect. */
92+
/* The caller must now synchronize_net() for this to take effect. */
9393
}
9494

9595
static void peer_remove_after_dead(struct wg_peer *peer)
@@ -161,7 +161,7 @@ void wg_peer_remove(struct wg_peer *peer)
161161
lockdep_assert_held(&peer->device->device_update_lock);
162162

163163
peer_make_dead(peer);
164-
synchronize_rcu();
164+
synchronize_net();
165165
peer_remove_after_dead(peer);
166166
}
167167

@@ -179,7 +179,7 @@ void wg_peer_remove_all(struct wg_device *wg)
179179
peer_make_dead(peer);
180180
list_add_tail(&peer->peer_list, &dead_peers);
181181
}
182-
synchronize_rcu();
182+
synchronize_net();
183183
list_for_each_entry_safe(peer, temp, &dead_peers, peer_list)
184184
peer_remove_after_dead(peer);
185185
}

‎drivers/net/wireguard/socket.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ void wg_socket_reinit(struct wg_device *wg, struct sock *new4,
430430
if (new4)
431431
wg->incoming_port = ntohs(inet_sk(new4)->inet_sport);
432432
mutex_unlock(&wg->socket_update_lock);
433-
synchronize_rcu();
433+
synchronize_net();
434434
sock_free(old4);
435435
sock_free(old6);
436436
}

0 commit comments

Comments
 (0)