mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 16:42:56 -08:00
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
This commit is contained in:
parent
4994896c09
commit
69761fb125
@ -1,4 +1,4 @@
|
||||
/* $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>
|
||||
@ -92,6 +92,7 @@ DT_STATIC_PROBE2(smr, thread, "uint64_t", "uint64_t");
|
||||
* 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");
|
||||
@ -140,6 +141,7 @@ struct dt_probe *const dtps_static[] = {
|
||||
&_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),
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*
|
||||
@ -181,6 +181,9 @@ struct sockaddr_inarp {
|
||||
#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,
|
||||
@ -318,7 +321,7 @@ void ether_extract_headers(struct mbuf *, struct ether_extracted *);
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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>
|
||||
@ -44,11 +44,12 @@ int refcnt_shared(struct refcnt *);
|
||||
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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user