Add and use a new function, mowner_init_owner(), that initializes an
MBUFTRACE mowner structure (so that providers of it don't have to grovel the internals).
This commit is contained in:
parent
89dc2fdefd
commit
83ce4c20bb
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uipc_mbuf.c,v 1.236 2019/12/06 07:27:07 maxv Exp $ */
|
||||
/* $NetBSD: uipc_mbuf.c,v 1.237 2020/03/15 23:14:41 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.236 2019/12/06 07:27:07 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.237 2020/03/15 23:14:41 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_mbuftrace.h"
|
||||
@ -2053,6 +2053,14 @@ nextchain:
|
||||
#endif /* defined(DDB) */
|
||||
|
||||
#if defined(MBUFTRACE)
|
||||
void
|
||||
mowner_init_owner(struct mowner *mo, const char *name, const char *descr)
|
||||
{
|
||||
memset(mo, 0, sizeof(*mo));
|
||||
strlcpy(mo->mo_name, name, sizeof(mo->mo_name));
|
||||
strlcpy(mo->mo_descr, descr, sizeof(mo->mo_descr));
|
||||
}
|
||||
|
||||
void
|
||||
mowner_attach(struct mowner *mo)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_ethersubr.c,v 1.282 2020/01/29 04:11:35 thorpej Exp $ */
|
||||
/* $NetBSD: if_ethersubr.c,v 1.283 2020/03/15 23:14:41 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.282 2020/01/29 04:11:35 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.283 2020/03/15 23:14:41 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
@ -1007,14 +1007,8 @@ ether_ifattach(struct ifnet *ifp, const uint8_t *lla)
|
||||
ifp->if_broadcastaddr = etherbroadcastaddr;
|
||||
bpf_attach(ifp, DLT_EN10MB, sizeof(struct ether_header));
|
||||
#ifdef MBUFTRACE
|
||||
strlcpy(ec->ec_tx_mowner.mo_name, ifp->if_xname,
|
||||
sizeof(ec->ec_tx_mowner.mo_name));
|
||||
strlcpy(ec->ec_tx_mowner.mo_descr, "tx",
|
||||
sizeof(ec->ec_tx_mowner.mo_descr));
|
||||
strlcpy(ec->ec_rx_mowner.mo_name, ifp->if_xname,
|
||||
sizeof(ec->ec_rx_mowner.mo_name));
|
||||
strlcpy(ec->ec_rx_mowner.mo_descr, "rx",
|
||||
sizeof(ec->ec_rx_mowner.mo_descr));
|
||||
mowner_init_owner(&ec->ec_tx_mowner, ifp->if_xname, "tx");
|
||||
mowner_init_owner(&ec->ec_rx_mowner, ifp->if_xname, "rx");
|
||||
MOWNER_ATTACH(&ec->ec_tx_mowner);
|
||||
MOWNER_ATTACH(&ec->ec_rx_mowner);
|
||||
ifp->if_mowner = &ec->ec_tx_mowner;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mbuf.h,v 1.225 2020/03/05 15:18:55 riastradh Exp $ */
|
||||
/* $NetBSD: mbuf.h,v 1.226 2020/03/15 23:14:41 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
|
||||
@ -412,6 +412,7 @@ extern const char * const mbuftypes[];
|
||||
|
||||
#ifdef MBUFTRACE
|
||||
/* Mbuf allocation tracing. */
|
||||
void mowner_init_owner(struct mowner *, const char *, const char *);
|
||||
void mowner_init(struct mbuf *, int);
|
||||
void mowner_ref(struct mbuf *, int);
|
||||
void m_claim(struct mbuf *, struct mowner *);
|
||||
@ -420,6 +421,7 @@ void mowner_attach(struct mowner *);
|
||||
void mowner_detach(struct mowner *);
|
||||
void m_claimm(struct mbuf *, struct mowner *);
|
||||
#else
|
||||
#define mowner_init_owner(mo, n, d) __nothing
|
||||
#define mowner_init(m, type) __nothing
|
||||
#define mowner_ref(m, flags) __nothing
|
||||
#define mowner_revoke(m, all, flags) __nothing
|
||||
|
Loading…
Reference in New Issue
Block a user