Module Name: src Committed By: thorpej Date: Wed Jan 29 04:18:34 UTC 2020
Modified Files: src/sys/net: if_bridge.c if_faith.c if_gif.c if_gre.c if_l2tp.c if_loop.c if_mpls.c Log Message: Adopt <net/if_stats.h>. To generate a diff of this commit: cvs rdiff -u -r1.165 -r1.166 src/sys/net/if_bridge.c cvs rdiff -u -r1.60 -r1.61 src/sys/net/if_faith.c cvs rdiff -u -r1.150 -r1.151 src/sys/net/if_gif.c cvs rdiff -u -r1.176 -r1.177 src/sys/net/if_gre.c cvs rdiff -u -r1.40 -r1.41 src/sys/net/if_l2tp.c cvs rdiff -u -r1.109 -r1.110 src/sys/net/if_loop.c cvs rdiff -u -r1.35 -r1.36 src/sys/net/if_mpls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_bridge.c diff -u src/sys/net/if_bridge.c:1.165 src/sys/net/if_bridge.c:1.166 --- src/sys/net/if_bridge.c:1.165 Mon Aug 5 13:30:21 2019 +++ src/sys/net/if_bridge.c Wed Jan 29 04:18:34 2020 @@ -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 @@ bridge_enqueue(struct bridge_softc *sc, 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 @@ bridge_output(struct ifnet *ifp, struct } 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 @@ bridge_output(struct ifnet *ifp, struct } 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 @@ bridge_forward(struct bridge_softc *sc, 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 @@ bridge_forward(struct bridge_softc *sc, } } 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 @@ bridge_broadcast(struct bridge_softc *sc 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 @@ bridge_broadcast(struct bridge_softc *sc 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; } Index: src/sys/net/if_faith.c diff -u src/sys/net/if_faith.c:1.60 src/sys/net/if_faith.c:1.61 --- src/sys/net/if_faith.c:1.60 Sat Apr 27 06:18:15 2019 +++ src/sys/net/if_faith.c Wed Jan 29 04:18:34 2020 @@ -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 @@ faithoutput(struct ifnet *ifp, struct mb 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 @@ faithoutput(struct ifnet *ifp, struct mb 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); Index: src/sys/net/if_gif.c diff -u src/sys/net/if_gif.c:1.150 src/sys/net/if_gif.c:1.151 --- src/sys/net/if_gif.c:1.150 Wed Oct 30 03:45:59 2019 +++ src/sys/net/if_gif.c Wed Jan 29 04:18:34 2020 @@ -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 @@ end: if (var != NULL) gif_putref_variant(var, &psref); if (error) - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); return error; } @@ -593,7 +593,7 @@ gif_start(struct ifnet *ifp) 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 @@ gif_start(struct ifnet *ifp) 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 @@ gif_transmit_direct(struct gif_variant * 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 @@ gif_transmit_direct(struct gif_variant * 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); return error; } @@ -717,8 +713,7 @@ gif_input(struct mbuf *m, int af, struct const uint32_t h = pktq_rps_hash(m); #endif if (__predict_true(pktq_enqueue(pktq, m, h))) { - ifp->if_ibytes += pktlen; - ifp->if_ipackets++; + if_statadd2(ifp, if_ibytes, pktlen, if_ipackets, 1); } else { m_freem(m); } Index: src/sys/net/if_gre.c diff -u src/sys/net/if_gre.c:1.176 src/sys/net/if_gre.c:1.177 --- src/sys/net/if_gre.c:1.176 Wed Oct 16 06:53:34 2019 +++ src/sys/net/if_gre.c Wed Jan 29 04:18:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_gre.c,v 1.176 2019/10/16 06:53:34 knakahara Exp $ */ +/* $NetBSD: if_gre.c,v 1.177 2020/01/29 04:18:34 thorpej Exp $ */ /* * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.176 2019/10/16 06:53:34 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.177 2020/01/29 04:18:34 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_atalk.h" @@ -791,8 +791,7 @@ gre_input(struct gre_softc *sc, struct m int isr = 0, s; int hlen; - 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); hlen = sizeof(struct gre_h); @@ -804,7 +803,7 @@ gre_input(struct gre_softc *sc, struct m hlen += 4; /* We don't support routing fields (variable length) */ if (flags & GRE_RP) { - sc->sc_if.if_ierrors++; + if_statinc(&sc->sc_if, if_ierrors); return 0; } if (flags & GRE_KP) @@ -842,13 +841,13 @@ gre_input(struct gre_softc *sc, struct m default: /* others not yet supported */ GRE_DPRINTF(sc, "unhandled ethertype 0x%04x\n", ntohs(gh->ptype)); - sc->sc_if.if_noproto++; + if_statinc(&sc->sc_if, if_noproto); return 0; } if (hlen > m->m_pkthdr.len) { m_freem(m); - sc->sc_if.if_ierrors++; + if_statinc(&sc->sc_if, if_ierrors); return 1; } m_adj(m, hlen); @@ -953,8 +952,7 @@ gre_output(struct ifnet *ifp, struct mbu gh->ptype = etype; /* XXX Need to handle IP ToS. Look at how I handle IP TTL. */ - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_statadd2(ifp, if_opackets, 1, if_obytes, m->m_pkthdr.len); /* Clear checksum-offload flags. */ m->m_pkthdr.csum_flags = 0; @@ -972,7 +970,7 @@ gre_output(struct ifnet *ifp, struct mbu end: if (error) - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); return error; } Index: src/sys/net/if_l2tp.c diff -u src/sys/net/if_l2tp.c:1.40 src/sys/net/if_l2tp.c:1.41 --- src/sys/net/if_l2tp.c:1.40 Wed Oct 16 06:53:34 2019 +++ src/sys/net/if_l2tp.c Wed Jan 29 04:18:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_l2tp.c,v 1.40 2019/10/16 06:53:34 knakahara Exp $ */ +/* $NetBSD: if_l2tp.c,v 1.41 2020/01/29 04:18:34 thorpej Exp $ */ /* * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.40 2019/10/16 06:53:34 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.41 2020/01/29 04:18:34 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -404,7 +404,7 @@ l2tp_tx_enqueue(struct l2tp_variant *var s = splsoftnet(); ifq = l2tp_ifq_percpu_getref(sc->l2tp_ifq_percpu); if (IF_QFULL(ifq)) { - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); l2tp_ifq_percpu_putref(sc->l2tp_ifq_percpu); splx(s); m_freem(m); @@ -465,7 +465,7 @@ l2tp_output(struct ifnet *ifp, struct mb end: l2tp_putref_variant(var, &psref); if (error) - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); return error; } @@ -504,10 +504,9 @@ l2tp_sendit(struct l2tp_variant *var, st break; } if (error) { - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); } else { - ifp->if_opackets++; - ifp->if_obytes += len; + if_statadd2(ifp, if_opackets, 1, if_obytes, len); } } Index: src/sys/net/if_loop.c diff -u src/sys/net/if_loop.c:1.109 src/sys/net/if_loop.c:1.110 --- src/sys/net/if_loop.c:1.109 Thu Nov 14 04:14:30 2019 +++ src/sys/net/if_loop.c Wed Jan 29 04:18:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_loop.c,v 1.109 2019/11/14 04:14:30 msaitoh Exp $ */ +/* $NetBSD: if_loop.c,v 1.110 2020/01/29 04:18:34 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.109 2019/11/14 04:14:30 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.110 2020/01/29 04:18:34 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -270,8 +270,8 @@ looutput(struct ifnet *ifp, struct mbuf } pktlen = m->m_pkthdr.len; - ifp->if_opackets++; - ifp->if_obytes += pktlen; + + if_statadd2(ifp, if_opackets, 1, if_obytes, pktlen); #ifdef ALTQ /* @@ -368,8 +368,7 @@ looutput(struct ifnet *ifp, struct mbuf error = 0; if (__predict_true(pktq_enqueue(pktq, m, 0))) { - ifp->if_ipackets++; - ifp->if_ibytes += pktlen; + if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen); } else { m_freem(m); error = ENOBUFS; @@ -384,8 +383,7 @@ looutput(struct ifnet *ifp, struct mbuf error = ENOBUFS; goto out; } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_statadd2(ifp, if_ipackets, 1, if_ibytes, m->m_pkthdr.len); IF_ENQUEUE(ifq, m); schednetisr(isr); splx(s); @@ -445,8 +443,7 @@ lostart(struct ifnet *ifp) splx(s); return; } - ifp->if_ipackets++; - ifp->if_ibytes += pktlen; + if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen); splx(s); continue; } @@ -458,8 +455,7 @@ lostart(struct ifnet *ifp) } IF_ENQUEUE(ifq, m); schednetisr(isr); - ifp->if_ipackets++; - ifp->if_ibytes += pktlen; + if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen); splx(s); } } Index: src/sys/net/if_mpls.c diff -u src/sys/net/if_mpls.c:1.35 src/sys/net/if_mpls.c:1.36 --- src/sys/net/if_mpls.c:1.35 Sat Apr 27 06:18:15 2019 +++ src/sys/net/if_mpls.c Wed Jan 29 04:18:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_mpls.c,v 1.35 2019/04/27 06:18:15 pgoyette Exp $ */ +/* $NetBSD: if_mpls.c,v 1.36 2020/01/29 04:18:34 thorpej Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.35 2019/04/27 06:18:15 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.36 2020/01/29 04:18:34 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -286,12 +286,11 @@ mpls_output(struct ifnet *ifp, struct mb if (m == NULL) { IF_DROP(&ifp->if_snd); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); return ENOBUFS; } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_statadd2(ifp, if_opackets, 1, if_obytes, m->m_pkthdr.len); if ((rt1 = rtalloc1(rt->rt_gateway, 1)) == NULL) { m_freem(m);