-/* $OpenBSD: ip_ipsp.c,v 1.269 2022/03/10 15:21:08 bluhm Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.270 2022/04/30 13:28:53 mvs Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
found = RBT_INSERT(ipsec_ids_tree, &ipsec_ids_tree, ids);
if (found) {
/* if refcount was zero, then timeout is running */
- if (atomic_inc_int_nv(&found->id_refcount) == 1) {
+ if ((++found->id_refcount) == 1) {
LIST_REMOVE(found, id_gc_list);
if (LIST_EMPTY(&ipsp_ids_gc_list))
mtx_enter(&ipsec_flows_mtx);
ids = RBT_FIND(ipsec_ids_flows, &ipsec_ids_flows, &key);
- atomic_inc_int(&ids->id_refcount);
+ if (ids != NULL) {
+ if (ids->id_refcount != 0)
+ ids->id_refcount++;
+ else
+ ids = NULL;
+ }
mtx_leave(&ipsec_flows_mtx);
return ids;
if (ids == NULL)
return;
+ mtx_enter(&ipsec_flows_mtx);
+
/*
* If the refcount becomes zero, then a timeout is started. This
* timeout must be cancelled if refcount is increased from zero.
DPRINTF("ids %p count %d", ids, ids->id_refcount);
KASSERT(ids->id_refcount > 0);
- if (atomic_dec_int_nv(&ids->id_refcount) > 0)
+ if ((--ids->id_refcount) > 0) {
+ mtx_leave(&ipsec_flows_mtx);
return;
-
- mtx_enter(&ipsec_flows_mtx);
+ }
/*
* Add second for the case ipsp_ids_gc() is already running and
-/* $OpenBSD: ip_ipsp.h,v 1.238 2022/04/21 15:22:50 sashan Exp $ */
+/* $OpenBSD: ip_ipsp.h,v 1.239 2022/04/30 13:28:53 mvs Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
struct ipsec_id *id_local; /* [I] */
struct ipsec_id *id_remote; /* [I] */
u_int32_t id_flow; /* [I] */
- u_int id_refcount; /* [a] */
+ u_int id_refcount; /* [F] */
u_int id_gc_ttl; /* [F] */
};
RBT_HEAD(ipsec_ids_flows, ipsec_ids);