Module Name:    src
Committed By:   riastradh
Date:           Sun Jul 28 14:38:42 UTC 2024

Modified Files:
        src/sys/net: if_wg.c

Log Message:
wg(4): Use callout_halt, not callout_stop.

It's possible that callout_stop might work here, but let's simplify
reasoning about it -- the timers in question only take the peer intr
lock, so it's safe to wait for them while holding the peer lock in
the handshake worker thread.

We may have to undo the task bit but that will take a bit more
analysis to determine.

Prompted by (but probably won't fix anything in):

PR kern/55729: net/if_wg/t_misc:wg_rekey test case fails
PR kern/56252: wg(4) state machine has race conditions
PR kern/58463: if_wg does not work when idle.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 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.95 src/sys/net/if_wg.c:1.96
--- src/sys/net/if_wg.c:1.95	Sun Jul 28 14:38:19 2024
+++ src/sys/net/if_wg.c	Sun Jul 28 14:38:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wg.c,v 1.95 2024/07/28 14:38:19 riastradh Exp $	*/
+/*	$NetBSD: if_wg.c,v 1.96 2024/07/28 14:38:42 riastradh Exp $	*/
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ry...@gmail.com>
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.95 2024/07/28 14:38:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.96 2024/07/28 14:38:42 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq_enabled.h"
@@ -1651,7 +1651,7 @@ wg_handle_msg_init(struct wg_softc *wg, 
 		panic("unstable session can't be established");
 	case WGS_STATE_DESTROYING:	/* rekey initiated by peer */
 		WG_TRACE("Session destroying, but force to clear");
-		callout_stop(&wgp->wgp_session_dtor_timer);
+		callout_halt(&wgp->wgp_session_dtor_timer, NULL);
 		wg_put_session_index(wg, wgs);
 		KASSERTMSG(wgs->wgs_state == WGS_STATE_UNKNOWN, "state=%d",
 		    wgs->wgs_state);
@@ -2129,7 +2129,7 @@ wg_handle_msg_resp(struct wg_softc *wg, 
 	atomic_store_release(&wgs->wgs_state, WGS_STATE_ESTABLISHED);
 	WG_TRACE("WGS_STATE_ESTABLISHED");
 
-	callout_stop(&wgp->wgp_handshake_timeout_timer);
+	callout_halt(&wgp->wgp_handshake_timeout_timer, NULL);
 
 	/*
 	 * Session is ready to send data now that we have received the

Reply via email to