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.
This commit is contained in:
parent
579b43d0be
commit
cdafe9a8a9
|
@ -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 *ndb, bool track)
|
|||
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, const unsigned di, bool global)
|
|||
* 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, npf_conn_t *con,
|
|||
}
|
||||
|
||||
/* 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_conn_t *con)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue