From f0e0eb88b7e85be1b86f2e7ded47921afc6b1efe Mon Sep 17 00:00:00 2001 From: riastradh Date: Mon, 31 Aug 2020 20:26:21 +0000 Subject: [PATCH] wg: Switch to callout_stop for session destructor timer. Can't release the lock here, and can't sleep waiting for the callout while we hold it without risking deadlock. But not waiting is fine; after we transition out of WGS_STATE_UNKNOWN the timer has no effect. --- sys/net/if_wg.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/net/if_wg.c b/sys/net/if_wg.c index 12834df09151..fa2d83de1099 100644 --- a/sys/net/if_wg.c +++ b/sys/net/if_wg.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.41 2020/08/31 20:25:33 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.42 2020/08/31 20:26:21 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.41 2020/08/31 20:25:33 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.42 2020/08/31 20:26:21 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1389,11 +1389,13 @@ wg_handle_msg_init(struct wg_softc *wg, const struct wg_msg_init *wgmi, wgs = wg_lock_unstable_session(wgp); if (wgs->wgs_state == WGS_STATE_DESTROYING) { /* - * We can assume that the peer doesn't have an established - * session, so clear it now. + * We can assume that the peer doesn't have an + * established session, so clear it now. If the timer + * fired, tough -- it won't have any effect unless we + * manage to transition back to WGS_STATE_DESTROYING. */ WG_TRACE("Session destroying, but force to clear"); - callout_halt(&wgp->wgp_session_dtor_timer, NULL); + callout_stop(&wgp->wgp_session_dtor_timer); wg_clear_states(wgs); wgs->wgs_state = WGS_STATE_UNKNOWN; }