Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add and use a new function, mowner_init_owner(), that in...



details:   https://anonhg.NetBSD.org/src/rev/f480686ab0db
branches:  trunk
changeset: 970208:f480686ab0db
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Mar 15 23:14:41 2020 +0000

description:
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).

diffstat:

 sys/kern/uipc_mbuf.c   |  12 ++++++++++--
 sys/net/if_ethersubr.c |  14 ++++----------
 sys/sys/mbuf.h         |   4 +++-
 3 files changed, 17 insertions(+), 13 deletions(-)

diffs (93 lines):

diff -r 327e17148839 -r f480686ab0db sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Sun Mar 15 23:06:02 2020 +0000
+++ b/sys/kern/uipc_mbuf.c      Sun Mar 15 23:14:41 2020 +0000
@@ -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"
@@ -2054,6 +2054,14 @@
 
 #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)
 {
 
diff -r 327e17148839 -r f480686ab0db sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Sun Mar 15 23:06:02 2020 +0000
+++ b/sys/net/if_ethersubr.c    Sun Mar 15 23:14:41 2020 +0000
@@ -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 @@
        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;
diff -r 327e17148839 -r f480686ab0db sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Sun Mar 15 23:06:02 2020 +0000
+++ b/sys/sys/mbuf.h    Sun Mar 15 23:14:41 2020 +0000
@@ -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 @@
 
 #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_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



Home | Main Index | Thread Index | Old Index