From 87430aa0c67a0fad7f5e9dbcc2975c0a524528ae Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Thu, 6 Jul 2023 19:46:54 +0000 Subject: use refcnt API for multicast addresses, add tracepoint:refcnt:ethmulti probe Replace hand-rolled reference counting with refcnt_init(9) and hook it up with a new dt(4) probe. OK mvs Feedback OK bluhm --- sys/net/if_ethersubr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/net') diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 4656fd8d2f8..20f7a9aee2e 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -931,7 +931,7 @@ ether_addmulti(struct ifreq *ifr, struct arpcom *ac) /* * Found it; just increment the reference count. */ - ++enm->enm_refcount; + refcnt_take(&enm->enm_refcnt); splx(s); return (0); } @@ -946,7 +946,7 @@ ether_addmulti(struct ifreq *ifr, struct arpcom *ac) } 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) @@ -984,7 +984,7 @@ ether_delmulti(struct ifreq *ifr, struct arpcom *ac) splx(s); return (ENXIO); } - if (--enm->enm_refcount != 0) { + if (refcnt_rele(&enm->enm_refcnt) == 0) { /* * Still some claims to this record. */ -- cgit v1.2.3