Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Adopt <net/if_stats.h>.
details: https://anonhg.NetBSD.org/src/rev/c44359124f5b
branches: trunk
changeset: 744286:c44359124f5b
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Jan 29 04:11:35 2020 +0000
description:
Adopt <net/if_stats.h>.
diffstat:
sys/net/if_arcsubr.c | 12 ++++++------
sys/net/if_bridge.c | 28 +++++++++++++++-------------
sys/net/if_ethersubr.c | 12 ++++++------
sys/net/if_faith.c | 10 ++++------
sys/net/if_gif.c | 29 ++++++++++++-----------------
sys/net/if_gre.c | 18 ++++++++----------
sys/net/if_l2tp.c | 13 ++++++-------
sys/net/if_loop.c | 20 ++++++++------------
sys/net/if_mpls.c | 9 ++++-----
9 files changed, 69 insertions(+), 82 deletions(-)
diffs (truncated from 545 to 300 lines):
diff -r 84618fc9203c -r c44359124f5b sys/net/if_arcsubr.c
--- a/sys/net/if_arcsubr.c Wed Jan 29 03:51:56 2020 +0000
+++ b/sys/net/if_arcsubr.c Wed Jan 29 04:11:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arcsubr.c,v 1.80 2018/05/09 06:35:10 maxv Exp $ */
+/* $NetBSD: if_arcsubr.c,v 1.81 2020/01/29 04:11:35 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.80 2018/05/09 06:35:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.81 2020/01/29 04:11:35 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -358,7 +358,7 @@
if (m->m_len < ARC_HDRNEWLEN) {
m = m_pullup(m, ARC_HDRNEWLEN);
if (m == NULL) {
- ++ifp->if_ierrors;
+ if_statinc(ifp, if_ierrors);
return NULL;
}
}
@@ -378,7 +378,7 @@
if (m->m_len < ARC_HDRNEWLEN) {
m = m_pullup(m, ARC_HDRNEWLEN);
if (m == NULL) {
- ++ifp->if_ierrors;
+ if_statinc(ifp, if_ierrors);
return NULL;
}
}
@@ -524,11 +524,11 @@
ah = mtod(m, struct arc_header *);
- ifp->if_ibytes += m->m_pkthdr.len;
+ if_statadd(ifp, if_ibytes, m->m_pkthdr.len);
if (arcbroadcastaddr == ah->arc_dhost) {
m->m_flags |= M_BCAST|M_MCAST;
- ifp->if_imcasts++;
+ if_statinc(ifp, if_imcasts);
}
atype = ah->arc_type;
diff -r 84618fc9203c -r c44359124f5b sys/net/if_bridge.c
--- a/sys/net/if_bridge.c Wed Jan 29 03:51:56 2020 +0000
+++ b/sys/net/if_bridge.c Wed Jan 29 04:11:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.165 2019/08/05 13:30:21 msaitoh Exp $ */
+/* $NetBSD: if_bridge.c,v 1.166 2020/01/29 04:18:34 thorpej Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.165 2019/08/05 13:30:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.166 2020/01/29 04:18:34 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_bridge_ipf.h"
@@ -1461,14 +1461,16 @@
error = if_transmit_lock(dst_ifp, m);
if (error) {
/* mbuf is already freed */
- sc->sc_if.if_oerrors++;
+ if_statinc(&sc->sc_if, if_oerrors);
return;
}
- sc->sc_if.if_opackets++;
- sc->sc_if.if_obytes += len;
+ net_stat_ref_t nsr = IF_STAT_GETREF(&sc->sc_if);
+ if_statinc_ref(nsr, if_opackets);
+ if_statadd_ref(nsr, if_obytes, len);
if (mflags & M_MCAST)
- sc->sc_if.if_omcasts++;
+ if_statinc_ref(nsr, if_omcasts);
+ IF_STAT_PUTREF(&sc->sc_if);
}
/*
@@ -1649,7 +1651,7 @@
} else {
mc = m_copypacket(m, M_DONTWAIT);
if (mc == NULL) {
- sc->sc_if.if_oerrors++;
+ if_statinc(&sc->sc_if, if_oerrors);
goto next;
}
}
@@ -1667,7 +1669,8 @@
} else {
mc = m_copypacket(m, M_DONTWAIT);
if (mc == NULL) {
- sc->sc_if.if_oerrors++;
+ if_statinc(&sc->sc_if,
+ if_oerrors);
goto next;
}
}
@@ -1750,8 +1753,7 @@
goto out;
}
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += m->m_pkthdr.len;
+ if_statadd2(&sc->sc_if, if_ipackets, 1, if_ibytes, m->m_pkthdr.len);
/*
* Look up the bridge_iflist.
@@ -1819,7 +1821,7 @@
}
} else {
/* ...forward it to all interfaces. */
- sc->sc_if.if_imcasts++;
+ if_statinc(&sc->sc_if, if_imcasts);
dst_if = NULL;
}
@@ -2081,7 +2083,7 @@
if (dst_if != src_if) {
mc = m_copypacket(m, M_DONTWAIT);
if (mc == NULL) {
- sc->sc_if.if_oerrors++;
+ if_statinc(&sc->sc_if, if_oerrors);
goto next;
}
/*
@@ -2099,7 +2101,7 @@
if (bmcast) {
mc = m_copypacket(m, M_DONTWAIT);
if (mc == NULL) {
- sc->sc_if.if_oerrors++;
+ if_statinc(&sc->sc_if, if_oerrors);
goto next;
}
diff -r 84618fc9203c -r c44359124f5b sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c Wed Jan 29 03:51:56 2020 +0000
+++ b/sys/net/if_ethersubr.c Wed Jan 29 04:11:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.281 2020/01/16 13:16:59 kardel Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.282 2020/01/29 04:11:35 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.281 2020/01/16 13:16:59 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.282 2020/01/29 04:11:35 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -438,7 +438,7 @@
#if NCARP > 0
if (ifp != ifp0)
- ifp0->if_obytes += m->m_pkthdr.len + ETHER_HDR_LEN;
+ if_statadd(ifp0, if_obytes, m->m_pkthdr.len + ETHER_HDR_LEN);
#endif
#ifdef ALTQ
@@ -623,7 +623,7 @@
}
mutex_exit(&bigpktpps_lock);
#endif
- ifp->if_iqdrops++;
+ if_statinc(ifp, if_iqdrops);
m_freem(m);
return;
}
@@ -645,7 +645,7 @@
m->m_flags |= M_BCAST;
else
m->m_flags |= M_MCAST;
- ifp->if_imcasts++;
+ if_statinc(ifp, if_imcasts);
}
/* If the CRC is still on the packet, trim it off. */
@@ -654,7 +654,7 @@
m->m_flags &= ~M_HASFCS;
}
- ifp->if_ibytes += m->m_pkthdr.len;
+ if_statadd(ifp, if_ibytes, m->m_pkthdr.len);
#if NCARP > 0
if (__predict_false(ifp->if_carp && ifp->if_type != IFT_CARP)) {
diff -r 84618fc9203c -r c44359124f5b sys/net/if_faith.c
--- a/sys/net/if_faith.c Wed Jan 29 03:51:56 2020 +0000
+++ b/sys/net/if_faith.c Wed Jan 29 04:11:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_faith.c,v 1.60 2019/04/27 06:18:15 pgoyette Exp $ */
+/* $NetBSD: if_faith.c,v 1.61 2020/01/29 04:18:34 thorpej Exp $ */
/* $KAME: if_faith.c,v 1.21 2001/02/20 07:59:26 itojun Exp $ */
/*
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.60 2019/04/27 06:18:15 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.61 2020/01/29 04:18:34 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -201,8 +201,7 @@
rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
}
pktlen = m->m_pkthdr.len;
- ifp->if_opackets++;
- ifp->if_obytes += pktlen;
+ if_statadd2(ifp, if_opackets, 1, if_obytes, pktlen);
switch (af) {
#ifdef INET
case AF_INET:
@@ -225,8 +224,7 @@
s = splnet();
if (__predict_true(pktq_enqueue(pktq, m, 0))) {
- ifp->if_ipackets++;
- ifp->if_ibytes += pktlen;
+ if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
error = 0;
} else {
m_freem(m);
diff -r 84618fc9203c -r c44359124f5b sys/net/if_gif.c
--- a/sys/net/if_gif.c Wed Jan 29 03:51:56 2020 +0000
+++ b/sys/net/if_gif.c Wed Jan 29 04:11:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gif.c,v 1.150 2019/10/30 03:45:59 knakahara Exp $ */
+/* $NetBSD: if_gif.c,v 1.151 2020/01/29 04:18:34 thorpej Exp $ */
/* $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.150 2019/10/30 03:45:59 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.151 2020/01/29 04:18:34 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -563,7 +563,7 @@
if (var != NULL)
gif_putref_variant(var, &psref);
if (error)
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
return error;
}
@@ -593,7 +593,7 @@
if (sizeof(int) > m->m_len) {
m = m_pullup(m, sizeof(int));
if (!m) {
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
continue;
}
}
@@ -605,11 +605,9 @@
error = var->gv_output(var, family, m);
if (error)
- ifp->if_oerrors++;
- else {
- ifp->if_opackets++;
- ifp->if_obytes += len;
- }
+ if_statinc(ifp, if_oerrors);
+ else
+ if_statadd2(ifp, if_opackets, 1, if_obytes, len);
}
gif_putref_variant(var, &psref);
@@ -651,7 +649,7 @@
if (sizeof(int) > m->m_len) {
m = m_pullup(m, sizeof(int));
if (!m) {
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
return ENOBUFS;
}
}
@@ -663,11 +661,9 @@
error = var->gv_output(var, family, m);
Home |
Main Index |
Thread Index |
Old Index