Adopt <net/if_stats.h>.

This commit is contained in:
thorpej 2020-01-29 04:28:27 +00:00
parent 70b554e641
commit d99f8f369a
14 changed files with 145 additions and 159 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee8023ad_lacp.c,v 1.10 2011/07/01 02:46:24 joerg Exp $ */ /* $NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $ */
/*- /*-
* Copyright (c)2005 YAMAMOTO Takashi, * Copyright (c)2005 YAMAMOTO Takashi,
@ -27,7 +27,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.10 2011/07/01 02:46:24 joerg Exp $"); __KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/callout.h> #include <sys/callout.h>
@ -503,7 +503,7 @@ ieee8023ad_select_tx_port(struct agr_softc *sc, struct mbuf *m)
if (__predict_false(lsc->lsc_suppress_distributing && if (__predict_false(lsc->lsc_suppress_distributing &&
!AGR_ROUNDROBIN(sc))) { !AGR_ROUNDROBIN(sc))) {
LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__)); LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__));
sc->sc_if.if_collisions++; /* XXX abuse */ if_statinc(&sc->sc_if, if_collisions); /* XXX abuse */
return NULL; return NULL;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_agr.c,v 1.50 2019/10/06 15:11:17 uwe Exp $ */ /* $NetBSD: if_agr.c,v 1.51 2020/01/29 04:30:41 thorpej Exp $ */
/*- /*-
* Copyright (c)2005 YAMAMOTO Takashi, * Copyright (c)2005 YAMAMOTO Takashi,
@ -27,7 +27,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.50 2019/10/06 15:11:17 uwe Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.51 2020/01/29 04:30:41 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -156,7 +156,7 @@ agr_input(struct ifnet *ifp_port, struct mbuf *m)
ifp = port->port_agrifp; ifp = port->port_agrifp;
if ((port->port_flags & AGRPORT_COLLECTING) == 0) { if ((port->port_flags & AGRPORT_COLLECTING) == 0) {
m_freem(m); m_freem(m);
ifp->if_ierrors++; if_statinc(ifp, if_ierrors);
return; return;
} }
@ -390,19 +390,21 @@ agr_start(struct ifnet *ifp)
} }
bpf_mtap(ifp, m, BPF_D_OUT); bpf_mtap(ifp, m, BPF_D_OUT);
port = agr_select_tx_port(sc, m); port = agr_select_tx_port(sc, m);
net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
if (port) { if (port) {
int error; int error;
error = agr_xmit_frame(port->port_ifp, m); error = agr_xmit_frame(port->port_ifp, m);
if (error) { if (error) {
ifp->if_oerrors++; if_statinc_ref(nsr, if_oerrors);
} else { } else {
ifp->if_opackets++; if_statinc_ref(nsr, if_opackets);
} }
} else { } else {
m_freem(m); m_freem(m);
ifp->if_oerrors++; if_statinc_ref(nsr, if_oerrors);
} }
IF_STAT_PUTREF(ifp);
} }
AGR_UNLOCK(sc); AGR_UNLOCK(sc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ipsec.c,v 1.25 2019/11/01 04:28:14 knakahara Exp $ */ /* $NetBSD: if_ipsec.c,v 1.26 2020/01/29 04:34:10 thorpej Exp $ */
/* /*
* Copyright (c) 2017 Internet Initiative Japan Inc. * Copyright (c) 2017 Internet Initiative Japan Inc.
@ -27,7 +27,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.25 2019/11/01 04:28:14 knakahara Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.26 2020/01/29 04:34:10 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -538,7 +538,7 @@ end:
curlwp_bindx(bound); curlwp_bindx(bound);
noref_end: noref_end:
if (error) if (error)
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return error; return error;
} }
@ -566,8 +566,7 @@ if_ipsec_out_direct(struct ipsec_variant *var, struct mbuf *m, int family)
if (error) if (error)
return error; return error;
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1, if_obytes, len);
ifp->if_obytes += len;
return 0; return 0;
} }
@ -609,7 +608,7 @@ if_ipsec_in_enqueue(struct mbuf *m, int af, struct ifnet *ifp)
break; break;
#endif #endif
default: default:
ifp->if_ierrors++; if_statinc(ifp, if_ierrors);
m_freem(m); m_freem(m);
return; return;
} }
@ -621,10 +620,9 @@ if_ipsec_in_enqueue(struct mbuf *m, int af, struct ifnet *ifp)
#endif #endif
pktlen = m->m_pkthdr.len; pktlen = m->m_pkthdr.len;
if (__predict_true(pktq_enqueue(pktq, m, h))) { if (__predict_true(pktq_enqueue(pktq, m, h))) {
ifp->if_ibytes += pktlen; if_statadd2(ifp, if_ibytes, pktlen, if_ipackets, 1);
ifp->if_ipackets++;
} else { } else {
ifp->if_iqdrops++; if_statinc(ifp, if_iqdrops);
m_freem(m); m_freem(m);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ppp.c,v 1.166 2019/09/20 08:45:29 maxv Exp $ */ /* $NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $ */
/* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */ /* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */
/* /*
@ -102,7 +102,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.166 2019/09/20 08:45:29 maxv Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "ppp.h" #include "ppp.h"
@ -1013,14 +1013,13 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL;
if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0)) != 0) { if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0)) != 0) {
splx(s); splx(s);
sc->sc_if.if_oerrors++; if_statinc(&sc->sc_if, if_oerrors);
sc->sc_stats.ppp_oerrors++; sc->sc_stats.ppp_oerrors++;
return (error); return (error);
} }
ppp_restart(sc); ppp_restart(sc);
} }
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1, if_obytes, len);
ifp->if_obytes += len;
splx(s); splx(s);
return (0); return (0);
@ -1065,7 +1064,7 @@ ppp_requeue(struct ppp_softc *sc)
m->m_nextpkt = NULL; m->m_nextpkt = NULL;
ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL;
if ((error = ifq_enqueue2(&sc->sc_if, ifq, m)) != 0) { if ((error = ifq_enqueue2(&sc->sc_if, ifq, m)) != 0) {
sc->sc_if.if_oerrors++; if_statinc(&sc->sc_if, if_oerrors);
sc->sc_stats.ppp_oerrors++; sc->sc_stats.ppp_oerrors++;
} }
break; break;
@ -1715,11 +1714,10 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
if (__predict_true(pktq)) { if (__predict_true(pktq)) {
if (__predict_false(!pktq_enqueue(pktq, m, 0))) { if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
splx(s); splx(s);
ifp->if_iqdrops++; if_statinc(ifp, if_iqdrops);
goto bad; goto bad;
} }
ifp->if_ipackets++; if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen);
ifp->if_ibytes += ilen;
splx(s); splx(s);
return; return;
} }
@ -1734,13 +1732,12 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
splx(s); splx(s);
if (sc->sc_flags & SC_DEBUG) if (sc->sc_flags & SC_DEBUG)
printf("%s: input queue full\n", ifp->if_xname); printf("%s: input queue full\n", ifp->if_xname);
ifp->if_iqdrops++; if_statinc(ifp, if_iqdrops);
goto bad; goto bad;
} }
IF_ENQUEUE(inq, m); IF_ENQUEUE(inq, m);
splx(s); splx(s);
ifp->if_ipackets++; if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen);
ifp->if_ibytes += ilen;
(*sc->sc_ctlp)(sc); (*sc->sc_ctlp)(sc);
@ -1748,7 +1745,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
bad: bad:
m_freem(m); m_freem(m);
sc->sc_if.if_ierrors++; if_statinc(&sc->sc_if, if_ierrors);
sc->sc_stats.ppp_ierrors++; sc->sc_stats.ppp_ierrors++;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_pppoe.c,v 1.147 2019/03/18 11:38:03 msaitoh Exp $ */ /* $NetBSD: if_pppoe.c,v 1.148 2020/01/29 04:28:27 thorpej Exp $ */
/* /*
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.147 2019/03/18 11:38:03 msaitoh Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.148 2020/01/29 04:28:27 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "pppoe.h" #include "pppoe.h"
@ -1125,7 +1125,7 @@ pppoe_data_input(struct mbuf *m)
m_set_rcvif(m, &sc->sc_sppp.pp_if); m_set_rcvif(m, &sc->sc_sppp.pp_if);
/* pass packet up and account for it */ /* pass packet up and account for it */
sc->sc_sppp.pp_if.if_ipackets++; if_statinc(&sc->sc_sppp.pp_if, if_ipackets);
sppp_input(&sc->sc_sppp.pp_if, m); sppp_input(&sc->sc_sppp.pp_if, m);
return; return;
@ -1161,7 +1161,7 @@ pppoe_output(struct pppoe_softc *sc, struct mbuf *m)
#endif #endif
m->m_flags &= ~(M_BCAST|M_MCAST); m->m_flags &= ~(M_BCAST|M_MCAST);
sc->sc_sppp.pp_if.if_opackets++; if_statinc(&sc->sc_sppp.pp_if, if_opackets);
return if_output_lock(sc->sc_eth_if, sc->sc_eth_if, m, &dst, NULL); return if_output_lock(sc->sc_eth_if, sc->sc_eth_if, m, &dst, NULL);
} }
@ -1865,7 +1865,7 @@ pppoe_start(struct ifnet *ifp)
len = m->m_pkthdr.len; len = m->m_pkthdr.len;
M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT); M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT);
if (m == NULL) { if (m == NULL) {
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
continue; continue;
} }
p = mtod(m, uint8_t *); p = mtod(m, uint8_t *);
@ -1901,7 +1901,7 @@ pppoe_transmit(struct ifnet *ifp, struct mbuf *m)
M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT); M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT);
if (m == NULL) { if (m == NULL) {
PPPOE_UNLOCK(sc); PPPOE_UNLOCK(sc);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return ENETDOWN; return ENETDOWN;
} }
p = mtod(m, uint8_t *); p = mtod(m, uint8_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sl.c,v 1.131 2019/01/24 09:33:03 knakahara Exp $ */ /* $NetBSD: if_sl.c,v 1.132 2020/01/29 04:28:27 thorpej Exp $ */
/* /*
* Copyright (c) 1987, 1989, 1992, 1993 * Copyright (c) 1987, 1989, 1992, 1993
@ -60,7 +60,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.131 2019/01/24 09:33:03 knakahara Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.132 2020/01/29 04:28:27 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -485,7 +485,7 @@ sloutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
printf("%s: af%d not supported\n", sc->sc_if.if_xname, printf("%s: af%d not supported\n", sc->sc_if.if_xname,
dst->sa_family); dst->sa_family);
m_freem(m); m_freem(m);
sc->sc_if.if_noproto++; if_statinc(&sc->sc_if, if_noproto);
return EAFNOSUPPORT; return EAFNOSUPPORT;
} }
@ -625,7 +625,7 @@ slinput(int c, struct tty *tp)
} }
c &= TTY_CHARMASK; c &= TTY_CHARMASK;
++sc->sc_if.if_ibytes; if_statinc(&sc->sc_if, if_ibytes);
if (sc->sc_if.if_flags & IFF_DEBUG) { if (sc->sc_if.if_flags & IFF_DEBUG) {
if (c == ABT_ESC) { if (c == ABT_ESC) {
@ -697,7 +697,7 @@ slinput(int c, struct tty *tp)
sc->sc_flags |= SC_ERROR; sc->sc_flags |= SC_ERROR;
error: error:
sc->sc_if.if_ierrors++; if_statinc(&sc->sc_if, if_ierrors);
newpack: newpack:
sc->sc_mp = sc->sc_pktstart = (u_char *)sc->sc_mbuf->m_ext.ext_buf + sc->sc_mp = sc->sc_pktstart = (u_char *)sc->sc_mbuf->m_ext.ext_buf +
BUFOFFSET; BUFOFFSET;
@ -746,7 +746,7 @@ slintr(void *arg)
s = splnet(); s = splnet();
IF_DEQUEUE(&sc->sc_fastq, m); IF_DEQUEUE(&sc->sc_fastq, m);
if (m) if (m)
sc->sc_if.if_omcasts++; /* XXX */ if_statinc(&sc->sc_if, if_omcasts); /* XXX */
else else
IFQ_DEQUEUE(&sc->sc_if.if_snd, m); IFQ_DEQUEUE(&sc->sc_if.if_snd, m);
splx(s); splx(s);
@ -794,7 +794,7 @@ slintr(void *arg)
* some time. * some time.
*/ */
if (tp->t_outq.c_cc == 0) { if (tp->t_outq.c_cc == 0) {
sc->sc_if.if_obytes++; if_statinc(&sc->sc_if, if_obytes);
(void)putc(FRAME_END, &tp->t_outq); (void)putc(FRAME_END, &tp->t_outq);
} }
@ -825,7 +825,8 @@ slintr(void *arg)
*/ */
if (b_to_q(bp, cp - bp, &tp->t_outq)) if (b_to_q(bp, cp - bp, &tp->t_outq))
break; break;
sc->sc_if.if_obytes += cp - bp; if_statadd(&sc->sc_if, if_obytes,
cp - bp);
} }
/* /*
* If there are characters left in * If there are characters left in
@ -843,7 +844,7 @@ slintr(void *arg)
(void)unputc(&tp->t_outq); (void)unputc(&tp->t_outq);
break; break;
} }
sc->sc_if.if_obytes += 2; if_statadd(&sc->sc_if, if_obytes, 2);
} }
bp = cp; bp = cp;
} }
@ -861,10 +862,9 @@ slintr(void *arg)
*/ */
(void)unputc(&tp->t_outq); (void)unputc(&tp->t_outq);
(void)putc(FRAME_END, &tp->t_outq); (void)putc(FRAME_END, &tp->t_outq);
sc->sc_if.if_collisions++; if_statinc(&sc->sc_if, if_collisions);
} else { } else {
sc->sc_if.if_obytes++; if_statadd2(&sc->sc_if, if_obytes, 1, if_opackets, 1);
sc->sc_if.if_opackets++;
} }
/* /*
@ -959,14 +959,13 @@ slintr(void *arg)
m = n; m = n;
} }
sc->sc_if.if_ipackets++; if_statinc(&sc->sc_if, if_ipackets);
getbinuptime(&sc->sc_lastpacket); getbinuptime(&sc->sc_lastpacket);
#ifdef INET #ifdef INET
s = splnet(); s = splnet();
if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) { if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) {
sc->sc_if.if_ierrors++; if_statadd2(&sc->sc_if, if_ierrors, 1, if_iqdrops, 1);
sc->sc_if.if_iqdrops++;
m_freem(m); m_freem(m);
} }
splx(s); splx(s);
@ -1032,15 +1031,18 @@ slioctl(struct ifnet *ifp, u_long cmd, void *data)
} }
break; break;
case SIOCGPPPSTATS: case SIOCGPPPSTATS: {
struct if_data ifi;
if_export_if_data(&sc->sc_if, &ifi, false);
psp = &((struct ifpppstatsreq *) data)->stats; psp = &((struct ifpppstatsreq *) data)->stats;
(void)memset(psp, 0, sizeof(*psp)); (void)memset(psp, 0, sizeof(*psp));
psp->p.ppp_ibytes = sc->sc_if.if_ibytes; psp->p.ppp_ibytes = ifi.ifi_ibytes;
psp->p.ppp_ipackets = sc->sc_if.if_ipackets; psp->p.ppp_ipackets = ifi.ifi_ipackets;
psp->p.ppp_ierrors = sc->sc_if.if_ierrors; psp->p.ppp_ierrors = ifi.ifi_ierrors;
psp->p.ppp_obytes = sc->sc_if.if_obytes; psp->p.ppp_obytes = ifi.ifi_obytes;
psp->p.ppp_opackets = sc->sc_if.if_opackets; psp->p.ppp_opackets = ifi.ifi_opackets;
psp->p.ppp_oerrors = sc->sc_if.if_oerrors; psp->p.ppp_oerrors = ifi.ifi_oerrors;
#ifdef INET #ifdef INET
psp->vj.vjs_packets = sc->sc_comp.sls_packets; psp->vj.vjs_packets = sc->sc_comp.sls_packets;
psp->vj.vjs_compressed = sc->sc_comp.sls_compressed; psp->vj.vjs_compressed = sc->sc_comp.sls_compressed;
@ -1051,6 +1053,7 @@ slioctl(struct ifnet *ifp, u_long cmd, void *data)
psp->vj.vjs_errorin = sc->sc_comp.sls_errorin; psp->vj.vjs_errorin = sc->sc_comp.sls_errorin;
psp->vj.vjs_tossed = sc->sc_comp.sls_tossed; psp->vj.vjs_tossed = sc->sc_comp.sls_tossed;
#endif #endif
}
break; break;
case SIOCGPPPCSTATS: case SIOCGPPPCSTATS:

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_spppsubr.c,v 1.184 2019/09/13 07:55:07 msaitoh Exp $ */ /* $NetBSD: if_spppsubr.c,v 1.185 2020/01/29 04:28:27 thorpej Exp $ */
/* /*
* Synchronous PPP/Cisco link level subroutines. * Synchronous PPP/Cisco link level subroutines.
@ -41,7 +41,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.184 2019/09/13 07:55:07 msaitoh Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.185 2020/01/29 04:28:27 thorpej Exp $");
#if defined(_KERNEL_OPT) #if defined(_KERNEL_OPT)
#include "opt_inet.h" #include "opt_inet.h"
@ -532,7 +532,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_UP) {
/* Count received bytes, add hardware framing */ /* Count received bytes, add hardware framing */
ifp->if_ibytes += m->m_pkthdr.len + sp->pp_framebytes; if_statadd(ifp, if_ibytes, m->m_pkthdr.len + sp->pp_framebytes);
/* Note time of last receive */ /* Note time of last receive */
sp->pp_last_receive = time_uptime; sp->pp_last_receive = time_uptime;
} }
@ -544,8 +544,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
"%s: input packet is too small, %d bytes\n", "%s: input packet is too small, %d bytes\n",
ifp->if_xname, m->m_pkthdr.len); ifp->if_xname, m->m_pkthdr.len);
drop: drop:
++ifp->if_ierrors; if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1);
++ifp->if_iqdrops;
m_freem(m); m_freem(m);
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
return; return;
@ -589,7 +588,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
} }
switch (ntohs(h->protocol)) { switch (ntohs(h->protocol)) {
default: default:
++ifp->if_noproto; if_statinc(ifp, if_noproto);
goto invalid; goto invalid;
case CISCO_KEEPALIVE: case CISCO_KEEPALIVE:
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
@ -636,7 +635,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
log(LOG_DEBUG, log(LOG_DEBUG,
"%s: invalid input protocol " "%s: invalid input protocol "
"<proto=0x%x>\n", ifp->if_xname, ntohs(protocol)); "<proto=0x%x>\n", ifp->if_xname, ntohs(protocol));
++ifp->if_noproto; if_statinc(ifp, if_noproto);
goto drop; goto drop;
case PPP_LCP: case PPP_LCP:
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
@ -850,7 +849,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
if (ifp->if_flags & IFF_DEBUG) if (ifp->if_flags & IFF_DEBUG)
log(LOG_DEBUG, "%s: no memory for transmit header\n", log(LOG_DEBUG, "%s: no memory for transmit header\n",
ifp->if_xname); ifp->if_xname);
++ifp->if_oerrors; if_statinc(ifp, if_oerrors);
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
splx(s); splx(s);
return (ENOBUFS); return (ENOBUFS);
@ -912,7 +911,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
#endif #endif
default: default:
m_freem(m); m_freem(m);
++ifp->if_oerrors; if_statinc(ifp, if_oerrors);
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
splx(s); splx(s);
return (EAFNOSUPPORT); return (EAFNOSUPPORT);
@ -924,7 +923,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
if (ifp->if_flags & IFF_DEBUG) if (ifp->if_flags & IFF_DEBUG)
log(LOG_DEBUG, "%s: no memory for transmit header\n", log(LOG_DEBUG, "%s: no memory for transmit header\n",
ifp->if_xname); ifp->if_xname);
++ifp->if_oerrors; if_statinc(ifp, if_oerrors);
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
splx(s); splx(s);
return (ENOBUFS); return (ENOBUFS);
@ -940,7 +939,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
error = if_transmit_lock(ifp, m); error = if_transmit_lock(ifp, m);
SPPP_LOCK(sp, RW_READER); SPPP_LOCK(sp, RW_READER);
if (error == 0) if (error == 0)
ifp->if_obytes += pktlen + sp->pp_framebytes; if_statadd(ifp, if_obytes, pktlen + sp->pp_framebytes);
#else /* !SPPPSUBR_MPSAFE */ #else /* !SPPPSUBR_MPSAFE */
error = ifq_enqueue2(ifp, ifq, m); error = ifq_enqueue2(ifp, ifq, m);
@ -955,7 +954,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
if_start_lock(ifp); if_start_lock(ifp);
SPPP_LOCK(sp, RW_READER); SPPP_LOCK(sp, RW_READER);
} }
ifp->if_obytes += pktlen + sp->pp_framebytes; if_statadd(ifp, if_obytes, pktlen + sp->pp_framebytes);
} }
#endif /* !SPPPSUBR_MPSAFE */ #endif /* !SPPPSUBR_MPSAFE */
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
@ -1419,11 +1418,11 @@ sppp_cisco_send(struct sppp *sp, int type, int32_t par1, int32_t par2)
IF_DROP(&sp->pp_fastq); IF_DROP(&sp->pp_fastq);
IF_DROP(&ifp->if_snd); IF_DROP(&ifp->if_snd);
m_freem(m); m_freem(m);
++ifp->if_oerrors; if_statinc(ifp, if_oerrors);
return; return;
} }
ifp->if_obytes += m->m_pkthdr.len + sp->pp_framebytes; if_statadd(ifp, if_obytes, m->m_pkthdr.len + sp->pp_framebytes);
IF_ENQUEUE(&sp->pp_cpq, m); IF_ENQUEUE(&sp->pp_cpq, m);
if (! (ifp->if_flags & IFF_OACTIVE)) { if (! (ifp->if_flags & IFF_OACTIVE)) {
@ -1492,11 +1491,11 @@ sppp_cp_send(struct sppp *sp, u_short proto, u_char type,
IF_DROP(&sp->pp_fastq); IF_DROP(&sp->pp_fastq);
IF_DROP(&ifp->if_snd); IF_DROP(&ifp->if_snd);
m_freem(m); m_freem(m);
++ifp->if_oerrors; if_statinc(ifp, if_oerrors);
return; return;
} }
ifp->if_obytes += m->m_pkthdr.len + sp->pp_framebytes; if_statadd(ifp, if_obytes, m->m_pkthdr.len + sp->pp_framebytes);
IF_ENQUEUE(&sp->pp_cpq, m); IF_ENQUEUE(&sp->pp_cpq, m);
@ -1554,7 +1553,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
addlog("%s: %s invalid conf-req length %d\n", addlog("%s: %s invalid conf-req length %d\n",
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
len); len);
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
break; break;
} }
/* handle states where RCR doesn't get a SCA/SCN */ /* handle states where RCR doesn't get a SCA/SCN */
@ -1609,7 +1608,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
sppp_cp_type_name(h->type), sppp_cp_type_name(h->type),
sppp_state_name(sp->state[cp->protoidx])); sppp_state_name(sp->state[cp->protoidx]));
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
break; break;
case CONF_ACK: case CONF_ACK:
@ -1618,7 +1617,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
addlog("%s: %s id mismatch 0x%x != 0x%x\n", addlog("%s: %s id mismatch 0x%x != 0x%x\n",
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
h->ident, sp->confid[cp->protoidx]); h->ident, sp->confid[cp->protoidx]);
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
break; break;
} }
switch (sp->state[cp->protoidx]) { switch (sp->state[cp->protoidx]) {
@ -1653,7 +1652,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
sppp_cp_type_name(h->type), sppp_cp_type_name(h->type),
sppp_state_name(sp->state[cp->protoidx])); sppp_state_name(sp->state[cp->protoidx]));
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
break; break;
case CONF_NAK: case CONF_NAK:
@ -1663,7 +1662,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
addlog("%s: %s id mismatch 0x%x != 0x%x\n", addlog("%s: %s id mismatch 0x%x != 0x%x\n",
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
h->ident, sp->confid[cp->protoidx]); h->ident, sp->confid[cp->protoidx]);
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
break; break;
} }
if (h->type == CONF_NAK) if (h->type == CONF_NAK)
@ -1696,7 +1695,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
sppp_cp_type_name(h->type), sppp_cp_type_name(h->type),
sppp_state_name(sp->state[cp->protoidx])); sppp_state_name(sp->state[cp->protoidx]));
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
break; break;
@ -1728,7 +1727,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
sppp_cp_type_name(h->type), sppp_cp_type_name(h->type),
sppp_state_name(sp->state[cp->protoidx])); sppp_state_name(sp->state[cp->protoidx]));
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
break; break;
case TERM_ACK: case TERM_ACK:
@ -1761,7 +1760,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
sppp_cp_type_name(h->type), sppp_cp_type_name(h->type),
sppp_state_name(sp->state[cp->protoidx])); sppp_state_name(sp->state[cp->protoidx]));
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
break; break;
case CODE_REJ: case CODE_REJ:
@ -1788,7 +1787,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
sppp_cp_type_name(h->type), sppp_cp_type_name(h->type),
sppp_state_name(sp->state[cp->protoidx])); sppp_state_name(sp->state[cp->protoidx]));
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
break; break;
case PROTO_REJ: case PROTO_REJ:
@ -1847,7 +1846,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, ifp->if_xname, cp->name,
sppp_cp_type_name(h->type), sppp_cp_type_name(h->type),
sppp_state_name(sp->state[cp->protoidx])); sppp_state_name(sp->state[cp->protoidx]));
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
break; break;
} }
@ -1863,7 +1862,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
if (debug) if (debug)
addlog("%s: lcp echo req but lcp closed\n", addlog("%s: lcp echo req but lcp closed\n",
ifp->if_xname); ifp->if_xname);
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
break; break;
} }
if (len < 8) { if (len < 8) {
@ -1901,7 +1900,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
if (cp->proto != PPP_LCP) if (cp->proto != PPP_LCP)
goto illegal; goto illegal;
if (h->ident != sp->lcp.echoid) { if (h->ident != sp->lcp.echoid) {
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
break; break;
} }
if (len < 8) { if (len < 8) {
@ -1926,7 +1925,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
ifp->if_xname, cp->name, h->type); ifp->if_xname, cp->name, h->type);
sppp_cp_send(sp, cp->proto, CODE_REJ, sppp_cp_send(sp, cp->proto, CODE_REJ,
++sp->pp_seq[cp->protoidx], m->m_pkthdr.len, h); ++sp->pp_seq[cp->protoidx], m->m_pkthdr.len, h);
++ifp->if_ierrors; if_statinc(ifp, if_ierrors);
} }
SPPP_UNLOCK(sp); SPPP_UNLOCK(sp);
@ -5094,11 +5093,11 @@ sppp_auth_send(const struct cp *cp, struct sppp *sp,
IF_DROP(&sp->pp_fastq); IF_DROP(&sp->pp_fastq);
IF_DROP(&ifp->if_snd); IF_DROP(&ifp->if_snd);
m_freem(m); m_freem(m);
++ifp->if_oerrors; if_statinc(ifp, if_oerrors);
return; return;
} }
ifp->if_obytes += m->m_pkthdr.len + sp->pp_framebytes; if_statadd(ifp, if_obytes, m->m_pkthdr.len + sp->pp_framebytes);
IF_ENQUEUE(&sp->pp_cpq, m); IF_ENQUEUE(&sp->pp_cpq, m);
if (! (ifp->if_flags & IFF_OACTIVE)) { if (! (ifp->if_flags & IFF_OACTIVE)) {

View File

@ -1,8 +1,8 @@
/* $NetBSD: if_srt.c,v 1.30 2019/04/27 06:18:15 pgoyette Exp $ */ /* $NetBSD: if_srt.c,v 1.31 2020/01/29 04:28:27 thorpej Exp $ */
/* This file is in the public domain. */ /* This file is in the public domain. */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.30 2019/04/27 06:18:15 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.31 2020/01/29 04:28:27 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -246,9 +246,9 @@ srt_if_output(
} }
/* XXX Do we need to bpf_tap? Or do higher layers now handle that? */ /* XXX Do we need to bpf_tap? Or do higher layers now handle that? */
/* if_gif.c seems to imply the latter. */ /* if_gif.c seems to imply the latter. */
ifp->if_opackets ++; if_statinc(ifp, if_opackets);
if (! r) { if (! r) {
ifp->if_oerrors ++; if_statinc(ifp, if_oerrors);
m_freem(m); m_freem(m);
return 0; return 0;
} }
@ -257,7 +257,7 @@ srt_if_output(
m_freem(m); m_freem(m);
return 0; return 0;
} }
ifp->if_obytes += m->m_pkthdr.len; if_statadd(ifp, if_obytes, m->m_pkthdr.len);
if (! (r->u.dstifp->if_flags & IFF_UP)) { if (! (r->u.dstifp->if_flags & IFF_UP)) {
m_freem(m); m_freem(m);
return 0; /* XXX ENETDOWN? */ return 0; /* XXX ENETDOWN? */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_stf.c,v 1.106 2019/04/26 11:51:56 pgoyette Exp $ */ /* $NetBSD: if_stf.c,v 1.107 2020/01/29 04:28:27 thorpej Exp $ */
/* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */ /* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
/* /*
@ -75,7 +75,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.106 2019/04/26 11:51:56 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.107 2020/01/29 04:28:27 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -392,14 +392,14 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
ia6 = stf_getsrcifa6(ifp); ia6 = stf_getsrcifa6(ifp);
if (ia6 == NULL) { if (ia6 == NULL) {
m_freem(m); m_freem(m);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return ENETDOWN; return ENETDOWN;
} }
if (m->m_len < sizeof(*ip6)) { if (m->m_len < sizeof(*ip6)) {
m = m_pullup(m, sizeof(*ip6)); m = m_pullup(m, sizeof(*ip6));
if (m == NULL) { if (m == NULL) {
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return ENOBUFS; return ENOBUFS;
} }
} }
@ -416,7 +416,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
in4 = GET_V4(&dst6->sin6_addr); in4 = GET_V4(&dst6->sin6_addr);
else { else {
m_freem(m); m_freem(m);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return ENETUNREACH; return ENETUNREACH;
} }
@ -426,7 +426,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if (m && m->m_len < sizeof(struct ip)) if (m && m->m_len < sizeof(struct ip))
m = m_pullup(m, sizeof(struct ip)); m = m_pullup(m, sizeof(struct ip));
if (m == NULL) { if (m == NULL) {
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return ENOBUFS; return ENOBUFS;
} }
ip = mtod(m, struct ip *); ip = mtod(m, struct ip *);
@ -447,7 +447,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0); sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
if ((rt = rtcache_lookup(&sc->sc_ro, &u.dst)) == NULL) { if ((rt = rtcache_lookup(&sc->sc_ro, &u.dst)) == NULL) {
m_freem(m); m_freem(m);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return ENETUNREACH; return ENETUNREACH;
} }
@ -456,13 +456,13 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
rtcache_unref(rt, &sc->sc_ro); rtcache_unref(rt, &sc->sc_ro);
rtcache_free(&sc->sc_ro); rtcache_free(&sc->sc_ro);
m_freem(m); m_freem(m);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
return ENETUNREACH; return ENETUNREACH;
} }
rtcache_unref(rt, &sc->sc_ro); rtcache_unref(rt, &sc->sc_ro);
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1,
ifp->if_obytes += m->m_pkthdr.len - sizeof(struct ip); if_obytes, m->m_pkthdr.len - sizeof(struct ip));
return ip_output(m, NULL, &sc->sc_ro, 0, NULL, NULL); return ip_output(m, NULL, &sc->sc_ro, 0, NULL, NULL);
} }
@ -667,8 +667,7 @@ in_stf_input(struct mbuf *m, int off, int proto, void *eparg)
s = splnet(); s = splnet();
if (__predict_true(pktq_enqueue(ip6_pktq, m, 0))) { if (__predict_true(pktq_enqueue(ip6_pktq, m, 0))) {
ifp->if_ipackets++; if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
ifp->if_ibytes += pktlen;
} else { } else {
m_freem(m); m_freem(m);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tap.c,v 1.115 2020/01/06 20:31:35 christos Exp $ */ /* $NetBSD: if_tap.c,v 1.116 2020/01/29 04:28:27 thorpej Exp $ */
/* /*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@ -33,7 +33,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.115 2020/01/06 20:31:35 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.116 2020/01/29 04:28:27 thorpej Exp $");
#if defined(_KERNEL_OPT) #if defined(_KERNEL_OPT)
@ -524,8 +524,7 @@ tap_start(struct ifnet *ifp)
if (m0 == NULL) if (m0 == NULL)
goto done; goto done;
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1, if_obytes, m0->m_len);
ifp->if_obytes += m0->m_len;
bpf_mtap(ifp, m0, BPF_D_OUT); bpf_mtap(ifp, m0, BPF_D_OUT);
m_freem(m0); m_freem(m0);
@ -893,8 +892,7 @@ tap_dev_close(struct tap_softc *sc)
if (m == NULL) if (m == NULL)
break; break;
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1, if_obytes, m->m_len);
ifp->if_obytes += m->m_len;
bpf_mtap(ifp, m, BPF_D_OUT); bpf_mtap(ifp, m, BPF_D_OUT);
m_freem(m); m_freem(m);
} }
@ -980,8 +978,8 @@ tap_dev_read(int unit, struct uio *uio, int flags)
goto out; goto out;
} }
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1,
ifp->if_obytes += m->m_len; // XXX: only first in chain if_obytes, m->m_len); /* XXX only first in chain */
bpf_mtap(ifp, m, BPF_D_OUT); bpf_mtap(ifp, m, BPF_D_OUT);
if ((error = pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_OUT)) != 0) if ((error = pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_OUT)) != 0)
goto out; goto out;
@ -1069,7 +1067,7 @@ tap_dev_write(int unit, struct uio *uio, int flags)
/* One write, one packet, that's the rule */ /* One write, one packet, that's the rule */
MGETHDR(m, M_DONTWAIT, MT_DATA); MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) { if (m == NULL) {
ifp->if_ierrors++; if_statinc(ifp, if_ierrors);
return ENOBUFS; return ENOBUFS;
} }
m->m_pkthdr.len = uio->uio_resid; m->m_pkthdr.len = uio->uio_resid;
@ -1089,15 +1087,14 @@ tap_dev_write(int unit, struct uio *uio, int flags)
mp = &(*mp)->m_next; mp = &(*mp)->m_next;
} }
if (error) { if (error) {
ifp->if_ierrors++; if_statinc(ifp, if_ierrors);
m_freem(m); m_freem(m);
return error; return error;
} }
m_set_rcvif(m, ifp); m_set_rcvif(m, ifp);
ifp->if_ipackets++; if_statadd2(ifp, if_ipackets, 1, if_ibytes, len);
ifp->if_ibytes += len;
bpf_mtap(ifp, m, BPF_D_IN); bpf_mtap(ifp, m, BPF_D_IN);
if ((error = pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_IN)) != 0) if ((error = pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_IN)) != 0)
return error; return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tun.c,v 1.157 2019/12/13 14:13:55 maxv Exp $ */ /* $NetBSD: if_tun.c,v 1.158 2020/01/29 04:34:10 thorpej Exp $ */
/* /*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
@ -19,7 +19,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.157 2019/12/13 14:13:55 maxv Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.158 2020/01/29 04:34:10 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -259,13 +259,6 @@ tunattach0(struct tun_softc *tp)
ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE; ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE;
ifp->if_type = IFT_TUNNEL; ifp->if_type = IFT_TUNNEL;
ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_collisions = 0;
ifp->if_ierrors = 0;
ifp->if_oerrors = 0;
ifp->if_ipackets = 0;
ifp->if_opackets = 0;
ifp->if_ibytes = 0;
ifp->if_obytes = 0;
ifp->if_dlt = DLT_NULL; ifp->if_dlt = DLT_NULL;
IFQ_SET_READY(&ifp->if_snd); IFQ_SET_READY(&ifp->if_snd);
if_attach(ifp); if_attach(ifp);
@ -612,13 +605,12 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
mlen = m0->m_pkthdr.len; mlen = m0->m_pkthdr.len;
IFQ_ENQUEUE(&ifp->if_snd, m0, error); IFQ_ENQUEUE(&ifp->if_snd, m0, error);
if (error) { if (error) {
ifp->if_collisions++; if_statinc(ifp, if_collisions);
error = EAFNOSUPPORT; error = EAFNOSUPPORT;
m0 = NULL; m0 = NULL;
goto out; goto out;
} }
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1, if_obytes, mlen);
ifp->if_obytes += mlen;
break; break;
#endif #endif
default: default:
@ -828,7 +820,7 @@ tunread(dev_t dev, struct uio *uio, int ioflag)
m_freem(m0); m_freem(m0);
} }
if (error) if (error)
ifp->if_ierrors++; if_statinc(ifp, if_ierrors);
return error; return error;
@ -946,7 +938,7 @@ tunwrite(dev_t dev, struct uio *uio, int ioflag)
if (error) { if (error) {
if (top != NULL) if (top != NULL)
m_freem(top); m_freem(top);
ifp->if_ierrors++; if_statinc(ifp, if_ierrors);
goto out0; goto out0;
} }
@ -967,14 +959,13 @@ tunwrite(dev_t dev, struct uio *uio, int ioflag)
goto out; goto out;
} }
if (__predict_false(!pktq_enqueue(pktq, top, 0))) { if (__predict_false(!pktq_enqueue(pktq, top, 0))) {
ifp->if_collisions++; if_statinc(ifp, if_collisions);
mutex_exit(&tp->tun_lock); mutex_exit(&tp->tun_lock);
error = ENOBUFS; error = ENOBUFS;
m_freem(top); m_freem(top);
goto out0; goto out0;
} }
ifp->if_ipackets++; if_statadd2(ifp, if_ipackets, 1, if_ibytes, tlen);
ifp->if_ibytes += tlen;
out: out:
mutex_exit(&tp->tun_lock); mutex_exit(&tp->tun_lock);
out0: out0:

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_vlan.c,v 1.149 2019/12/12 02:15:43 pgoyette Exp $ */ /* $NetBSD: if_vlan.c,v 1.150 2020/01/29 04:28:27 thorpej Exp $ */
/* /*
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.149 2019/12/12 02:15:43 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.150 2020/01/29 04:28:27 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -1391,7 +1391,7 @@ vlan_start(struct ifnet *ifp)
if (m == NULL) { if (m == NULL) {
printf("%s: unable to prepend encap header", printf("%s: unable to prepend encap header",
p->if_xname); p->if_xname);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
continue; continue;
} }
@ -1406,7 +1406,7 @@ vlan_start(struct ifnet *ifp)
if (m == NULL) { if (m == NULL) {
printf("%s: unable to pullup encap " printf("%s: unable to pullup encap "
"header", p->if_xname); "header", p->if_xname);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
continue; continue;
} }
@ -1455,10 +1455,10 @@ vlan_start(struct ifnet *ifp)
error = if_transmit_lock(p, m); error = if_transmit_lock(p, m);
if (error) { if (error) {
/* mbuf is already freed */ /* mbuf is already freed */
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
continue; continue;
} }
ifp->if_opackets++; if_statinc(ifp, if_opackets);
} }
ifp->if_flags &= ~IFF_OACTIVE; ifp->if_flags &= ~IFF_OACTIVE;
@ -1509,7 +1509,7 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m)
if (m == NULL) { if (m == NULL) {
printf("%s: unable to prepend encap header", printf("%s: unable to prepend encap header",
p->if_xname); p->if_xname);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
error = ENOBUFS; error = ENOBUFS;
goto out; goto out;
} }
@ -1525,7 +1525,7 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m)
if (m == NULL) { if (m == NULL) {
printf("%s: unable to pullup encap " printf("%s: unable to pullup encap "
"header", p->if_xname); "header", p->if_xname);
ifp->if_oerrors++; if_statinc(ifp, if_oerrors);
error = ENOBUFS; error = ENOBUFS;
goto out; goto out;
} }
@ -1574,16 +1574,17 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m)
} }
error = if_transmit_lock(p, m); error = if_transmit_lock(p, m);
net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
if (error) { if (error) {
/* mbuf is already freed */ /* mbuf is already freed */
ifp->if_oerrors++; if_statinc_ref(nsr, if_oerrors);
} else { } else {
if_statinc_ref(nsr, if_opackets);
ifp->if_opackets++; if_statadd_ref(nsr, if_obytes, pktlen);
ifp->if_obytes += pktlen;
if (mcast) if (mcast)
ifp->if_omcasts++; if_statinc_ref(nsr, if_omcasts);
} }
IF_STAT_PUTREF(ifp);
out: out:
/* Remove reference to mib before release */ /* Remove reference to mib before release */
@ -1639,7 +1640,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m)
mib = vlan_lookup_tag_psref(ifp, vid, &psref); mib = vlan_lookup_tag_psref(ifp, vid, &psref);
if (mib == NULL) { if (mib == NULL) {
m_freem(m); m_freem(m);
ifp->if_noproto++; if_statinc(ifp, if_noproto);
return; return;
} }
KASSERT(mib->ifvm_encaplen == ETHER_VLAN_ENCAP_LEN); KASSERT(mib->ifvm_encaplen == ETHER_VLAN_ENCAP_LEN);
@ -1648,7 +1649,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m)
if ((ifv->ifv_if.if_flags & (IFF_UP | IFF_RUNNING)) != if ((ifv->ifv_if.if_flags & (IFF_UP | IFF_RUNNING)) !=
(IFF_UP | IFF_RUNNING)) { (IFF_UP | IFF_RUNNING)) {
m_freem(m); m_freem(m);
ifp->if_noproto++; if_statinc(ifp, if_noproto);
goto out; goto out;
} }

View File

@ -33,7 +33,7 @@
#ifdef _KERNEL #ifdef _KERNEL
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: npf_ext_log.c,v 1.15 2018/09/29 14:41:36 rmind Exp $"); __KERNEL_RCSID(0, "$NetBSD: npf_ext_log.c,v 1.16 2020/01/29 04:30:41 thorpej Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/module.h> #include <sys/module.h>
@ -140,8 +140,7 @@ npf_log(npf_cache_t *npc, void *meta, const npf_match_info_t *mi, int *decision)
} }
/* Pass through BPF. */ /* Pass through BPF. */
ifp->if_opackets++; if_statadd2(ifp, if_opackets, 1, if_obytes, m->m_pkthdr.len);
ifp->if_obytes += m->m_pkthdr.len;
if (ifp->if_bpf) { if (ifp->if_bpf) {
bpf_mtap2(ifp->if_bpf, &hdr, NPFLOG_HDRLEN, m, BPF_D_OUT); bpf_mtap2(ifp->if_bpf, &hdr, NPFLOG_HDRLEN, m, BPF_D_OUT);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: ppp_tty.c,v 1.66 2019/09/20 08:45:29 maxv Exp $ */ /* $NetBSD: ppp_tty.c,v 1.67 2020/01/29 04:28:27 thorpej Exp $ */
/* Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp */ /* Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp */
/* /*
@ -93,7 +93,7 @@
/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.66 2019/09/20 08:45:29 maxv Exp $"); __KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.67 2020/01/29 04:28:27 thorpej Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "ppp.h" #include "ppp.h"
@ -1035,7 +1035,7 @@ pppinput(int c, struct tty *tp)
if (sc->sc_flags & SC_DEBUG) if (sc->sc_flags & SC_DEBUG)
printf("%s: bad fcs %x\n", sc->sc_if.if_xname, printf("%s: bad fcs %x\n", sc->sc_if.if_xname,
sc->sc_fcs); sc->sc_fcs);
sc->sc_if.if_ierrors++; if_statinc(&sc->sc_if, if_ierrors);
sc->sc_stats.ppp_ierrors++; sc->sc_stats.ppp_ierrors++;
} else } else
sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED); sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
@ -1048,7 +1048,7 @@ pppinput(int c, struct tty *tp)
if (sc->sc_flags & SC_DEBUG) if (sc->sc_flags & SC_DEBUG)
printf("%s: too short (%d)\n", sc->sc_if.if_xname, ilen); printf("%s: too short (%d)\n", sc->sc_if.if_xname, ilen);
s = spltty(); s = spltty();
sc->sc_if.if_ierrors++; if_statinc(&sc->sc_if, if_ierrors);
sc->sc_stats.ppp_ierrors++; sc->sc_stats.ppp_ierrors++;
sc->sc_flags |= SC_PKTLOST; sc->sc_flags |= SC_PKTLOST;
splx(s); splx(s);
@ -1192,7 +1192,7 @@ pppinput(int c, struct tty *tp)
flush: flush:
if (!(sc->sc_flags & SC_FLUSH)) { if (!(sc->sc_flags & SC_FLUSH)) {
s = spltty(); s = spltty();
sc->sc_if.if_ierrors++; if_statinc(&sc->sc_if, if_ierrors);
sc->sc_stats.ppp_ierrors++; sc->sc_stats.ppp_ierrors++;
sc->sc_flags |= SC_FLUSH; sc->sc_flags |= SC_FLUSH;
splx(s); splx(s);