Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Fix order in rollback case; switch if_ipsec to atomi...
details: https://anonhg.NetBSD.org/src/rev/53ccb02f9af8
branches: trunk
changeset: 1006943:53ccb02f9af8
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Feb 01 02:57:55 2020 +0000
description:
Fix order in rollback case; switch if_ipsec to atomic_load/store_*.
diffstat:
sys/net/if_ipsec.c | 14 ++++++--------
sys/net/if_ipsec.h | 5 ++---
2 files changed, 8 insertions(+), 11 deletions(-)
diffs (89 lines):
diff -r 5fc1b24a1c44 -r 53ccb02f9af8 sys/net/if_ipsec.c
--- a/sys/net/if_ipsec.c Sat Feb 01 02:57:45 2020 +0000
+++ b/sys/net/if_ipsec.c Sat Feb 01 02:57:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ipsec.c,v 1.26 2020/01/29 04:34:10 thorpej Exp $ */
+/* $NetBSD: if_ipsec.c,v 1.27 2020/02/01 02:57:55 riastradh Exp $ */
/*
* Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,13 +27,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.26 2020/01/29 04:34:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.27 2020/02/01 02:57:55 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
#endif
#include <sys/param.h>
+#include <sys/atomic.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/mbuf.h>
@@ -1130,7 +1131,6 @@
if_ipsec_copy_variant(nullvar, ovar);
if_ipsec_clear_config(nullvar);
psref_target_init(&nullvar->iv_psref, iv_psref_class);
- membar_producer();
/*
* (2-3) Swap variant include its SPs.
*/
@@ -1236,7 +1236,6 @@
if_ipsec_copy_variant(nullvar, ovar);
if_ipsec_clear_config(nullvar);
psref_target_init(&nullvar->iv_psref, iv_psref_class);
- membar_producer();
/*
* (2-3) Swap variant include its SPs.
*/
@@ -1323,7 +1322,6 @@
if_ipsec_copy_variant(nullvar, ovar);
if_ipsec_clear_config(nullvar);
psref_target_init(&nullvar->iv_psref, iv_psref_class);
- membar_producer();
/*
* (2-3) Swap variant include its SPs.
*/
@@ -1894,16 +1892,16 @@
* we stop packet processing while replacing SPs, that is, we set
* "null" config variant to sc->ipsec_var.
*/
- sc->ipsec_var = nullvar;
+ atomic_store_release(&sc->ipsec_var, nullvar);
pserialize_perform(sc->ipsec_psz);
psref_target_destroy(&ovar->iv_psref, iv_psref_class);
error = if_ipsec_replace_sp(sc, ovar, nvar);
if (!error)
- sc->ipsec_var = nvar;
+ atomic_store_release(&sc->ipsec_var, nvar);
else {
- sc->ipsec_var = ovar; /* rollback */
psref_target_init(&ovar->iv_psref, iv_psref_class);
+ atomic_store_release(&sc->ipsec_var, ovar); /* rollback */
}
pserialize_perform(sc->ipsec_psz);
diff -r 5fc1b24a1c44 -r 53ccb02f9af8 sys/net/if_ipsec.h
--- a/sys/net/if_ipsec.h Sat Feb 01 02:57:45 2020 +0000
+++ b/sys/net/if_ipsec.h Sat Feb 01 02:57:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ipsec.h,v 1.6 2019/11/01 04:28:14 knakahara Exp $ */
+/* $NetBSD: if_ipsec.h,v 1.7 2020/02/01 02:57:55 riastradh Exp $ */
/*
* Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -165,9 +165,8 @@
int s;
s = pserialize_read_enter();
- var = sc->ipsec_var;
+ var = atomic_load_consume(&sc->ipsec_var);
KASSERT(var != NULL);
- membar_datadep_consumer();
psref_acquire(psref, &var->iv_psref, iv_psref_class);
pserialize_read_exit(s);
Home |
Main Index |
Thread Index |
Old Index