Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net wg: Drop wgp_lock while waiting for endpoint psref t...
details: https://anonhg.NetBSD.org/src/rev/7ecb2c91b187
branches: trunk
changeset: 1013952:7ecb2c91b187
user: riastradh <riastradh%NetBSD.org@localhost>
date: Tue Sep 08 16:39:57 2020 +0000
description:
wg: Drop wgp_lock while waiting for endpoint psref to drain.
- This is safe because wgp_endpoint_changing locks out any attempts
to change the endpoint until the draining is complete.
- This is necessary to avoid a deadlock where the handshake thread
holds a psref and awaits mutex_enter(wgp->wgp_lock).
XXX The same deadlock may occur in wg_destroy_session. Not clear
that it's safe to just release wgp_lock there; may need to create a
new session state, say WGS_STATE_DRAINING, while we wait for
psref_target_destroy. But this needs a little more thought; a new
state may not be necessary, and would be nice to avoid if not
necessary.
diffstat:
sys/net/if_wg.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (31 lines):
diff -r e27810af7499 -r 7ecb2c91b187 sys/net/if_wg.c
--- a/sys/net/if_wg.c Tue Sep 08 16:39:36 2020 +0000
+++ b/sys/net/if_wg.c Tue Sep 08 16:39:57 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wg.c,v 1.55 2020/09/07 01:15:25 riastradh Exp $ */
+/* $NetBSD: if_wg.c,v 1.56 2020/09/08 16:39:57 riastradh Exp $ */
/*
* Copyright (C) Ryota Ozaki <ozaki.ryota%gmail.com@localhost>
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.55 2020/09/07 01:15:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.56 2020/09/08 16:39:57 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -2965,10 +2965,12 @@
if (atomic_load_relaxed(&wgp->wgp_endpoint_changing)) {
pserialize_perform(wgp->wgp_psz);
+ mutex_exit(wgp->wgp_lock);
psref_target_destroy(&wgp->wgp_endpoint0->wgsa_psref,
wg_psref_class);
psref_target_init(&wgp->wgp_endpoint0->wgsa_psref,
wg_psref_class);
+ mutex_enter(wgp->wgp_lock);
atomic_store_release(&wgp->wgp_endpoint_changing, 0);
}
}
Home |
Main Index |
Thread Index |
Old Index