Module Name: src
Committed By: riastradh
Date: Sun Feb 13 19:20:23 UTC 2022
Modified Files:
src/sys/net/npf: npf_conn.c
Log Message:
npf(4): Use atomic_store_release and atomic_load_consume for conn_db.
...or atomic_load_relaxed, when npf->conn_lock is held, for the sake
of C11.
No need for store-before-load implied by membar_sync.
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/net/npf/npf_conn.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/npf/npf_conn.c
diff -u src/sys/net/npf/npf_conn.c:1.33 src/sys/net/npf/npf_conn.c:1.34
--- src/sys/net/npf/npf_conn.c:1.33 Mon Jan 25 17:18:55 2021
+++ src/sys/net/npf/npf_conn.c Sun Feb 13 19:20:23 2022
@@ -104,7 +104,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.33 2021/01/25 17:18:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.34 2022/02/13 19:20:23 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -221,8 +221,7 @@ npf_conn_load(npf_t *npf, npf_conndb_t *
KASSERT(atomic_load_relaxed(&npf->conn_tracking)
== CONN_TRACKING_OFF);
odb = atomic_load_relaxed(&npf->conn_db);
- membar_sync();
- atomic_store_relaxed(&npf->conn_db, ndb);
+ atomic_store_release(&npf->conn_db, ndb);
}
if (track) {
/* After this point lookups start flying in. */
@@ -492,7 +491,7 @@ npf_conn_establish(npf_cache_t *npc, con
* the connection later.
*/
mutex_enter(&con->c_lock);
- conn_db = atomic_load_relaxed(&npf->conn_db);
+ conn_db = atomic_load_consume(&npf->conn_db);
if (!npf_conndb_insert(conn_db, fw, con, NPF_FLOW_FORW)) {
error = EISCONN;
goto err;
@@ -597,7 +596,7 @@ npf_conn_setnat(const npf_cache_t *npc,
}
/* Remove the "backwards" key. */
- conn_db = atomic_load_relaxed(&npf->conn_db);
+ conn_db = atomic_load_consume(&npf->conn_db);
bk = npf_conn_getbackkey(con, con->c_alen);
ret = npf_conndb_remove(conn_db, bk);
KASSERT(ret == con);
@@ -762,7 +761,7 @@ npf_conn_remove(npf_conndb_t *cd, npf_co
void
npf_conn_worker(npf_t *npf)
{
- npf_conndb_t *conn_db = atomic_load_relaxed(&npf->conn_db);
+ npf_conndb_t *conn_db = atomic_load_consume(&npf->conn_db);
npf_conndb_gc(npf, conn_db, false, true);
}