-/* $OpenBSD: dt_prov_static.c,v 1.19 2023/06/28 11:49:49 kn Exp $ */
+/* $OpenBSD: dt_prov_static.c,v 1.20 2023/07/06 19:46:53 kn Exp $ */
/*
* Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org>
* reference counting, keep in sync with sys/refcnt.h
*/
DT_STATIC_PROBE0(refcnt, none);
+DT_STATIC_PROBE3(refcnt, ethmulti, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, ifaddr, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, ifmaddr, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, inpcb, "void *", "int", "int");
&_DT_STATIC_P(smr, thread),
/* refcnt */
&_DT_STATIC_P(refcnt, none),
+ &_DT_STATIC_P(refcnt, ethmulti),
&_DT_STATIC_P(refcnt, ifaddr),
&_DT_STATIC_P(refcnt, ifmaddr),
&_DT_STATIC_P(refcnt, inpcb),
-/* $OpenBSD: if_ethersubr.c,v 1.289 2023/07/03 15:52:51 kn Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.290 2023/07/06 19:46:53 kn Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
/*
* Found it; just increment the reference count.
*/
- ++enm->enm_refcount;
+ refcnt_take(&enm->enm_refcnt);
splx(s);
return (0);
}
}
memcpy(enm->enm_addrlo, addrlo, ETHER_ADDR_LEN);
memcpy(enm->enm_addrhi, addrhi, ETHER_ADDR_LEN);
- enm->enm_refcount = 1;
+ refcnt_init_trace(&enm->enm_refcnt, DT_REFCNT_IDX_ETHMULTI);
LIST_INSERT_HEAD(&ac->ac_multiaddrs, enm, enm_list);
ac->ac_multicnt++;
if (memcmp(addrlo, addrhi, ETHER_ADDR_LEN) != 0)
splx(s);
return (ENXIO);
}
- if (--enm->enm_refcount != 0) {
+ if (refcnt_rele(&enm->enm_refcnt) == 0) {
/*
* Still some claims to this record.
*/
-/* $OpenBSD: if_ether.h,v 1.88 2023/02/07 16:14:55 bluhm Exp $ */
+/* $OpenBSD: if_ether.h,v 1.89 2023/07/06 19:46:53 kn Exp $ */
/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
/*
#define RTF_PERMANENT_ARP RTF_PROTO3 /* only manual overwrite of entry */
#ifdef _KERNEL
+
+#include <sys/refcnt.h>
+
/*
* Macro to map an IP multicast address to an Ethernet multicast address.
* The high-order 25 bits of the Ethernet address are statically assigned,
struct ether_multi {
u_int8_t enm_addrlo[ETHER_ADDR_LEN]; /* low or only address of range */
u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
- u_int enm_refcount; /* no. claims to this addr/range */
+ struct refcnt enm_refcnt; /* no. claims to this addr/range */
LIST_ENTRY(ether_multi) enm_list;
};
-/* $OpenBSD: refcnt.h,v 1.10 2023/06/28 11:49:49 kn Exp $ */
+/* $OpenBSD: refcnt.h,v 1.11 2023/07/06 19:46:53 kn Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
unsigned int refcnt_read(struct refcnt *);
/* sorted alphabetically, keep in sync with dev/dt/dt_prov_static.c */
-#define DT_REFCNT_IDX_IFADDR 1
-#define DT_REFCNT_IDX_IFMADDR 2
-#define DT_REFCNT_IDX_INPCB 3
-#define DT_REFCNT_IDX_RTENTRY 4
-#define DT_REFCNT_IDX_TDB 5
+#define DT_REFCNT_IDX_ETHMULTI 1
+#define DT_REFCNT_IDX_IFADDR 2
+#define DT_REFCNT_IDX_IFMADDR 3
+#define DT_REFCNT_IDX_INPCB 4
+#define DT_REFCNT_IDX_RTENTRY 5
+#define DT_REFCNT_IDX_TDB 6
#endif /* _KERNEL */