Module Name: src Committed By: riastradh Date: Thu Aug 20 21:35:44 UTC 2020
Modified Files: src/sys/net: if_wg.c Log Message: Avoid callout_halt under lock. - We could pass the lock in, except we hold another lock too. - We could halt before taking the other lock, but it's not safe to sleep after getting the session pointer before taking its lock. - We could halt before getting the session pointer, but then there's no point in doing it under the lock. So just halt a little earlier instead. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.17 src/sys/net/if_wg.c:1.18 --- src/sys/net/if_wg.c:1.17 Thu Aug 20 21:35:33 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:35:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.17 2020/08/20 21:35:33 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.18 2020/08/20 21:35:44 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki <ozaki.ry...@gmail.com> @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.17 2020/08/20 21:35:33 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.18 2020/08/20 21:35:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1829,13 +1829,14 @@ wg_handle_msg_resp(struct wg_softc *wg, wg_clear_states(wgs); WG_TRACE("WGS_STATE_ESTABLISHED"); + wg_stop_handshake_timeout_timer(wgp); + mutex_enter(wgp->wgp_lock); wg_swap_sessions(wgp); wgs_prev = wgp->wgp_session_unstable; mutex_enter(wgs_prev->wgs_lock); getnanotime(&wgp->wgp_last_handshake_time); - wg_stop_handshake_timeout_timer(wgp); wgp->wgp_handshake_start_time = 0; wgp->wgp_last_sent_mac1_valid = false; wgp->wgp_last_sent_cookie_valid = false;