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/c4a0d898af79
branches:  trunk
changeset: 744287:c4a0d898af79
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jan 29 04:28:27 2020 +0000

description:
Adopt <net/if_stats.h>.

diffstat:

 sys/net/agr/ieee8023ad_lacp.c |   6 ++--
 sys/net/agr/if_agr.c          |  14 +++++----
 sys/net/if_ipsec.c            |  16 ++++------
 sys/net/if_ppp.c              |  23 +++++++---------
 sys/net/if_pppoe.c            |  12 ++++----
 sys/net/if_sl.c               |  47 +++++++++++++++++---------------
 sys/net/if_spppsubr.c         |  61 +++++++++++++++++++++---------------------
 sys/net/if_srt.c              |  10 +++---
 sys/net/if_stf.c              |  23 +++++++--------
 sys/net/if_tap.c              |  21 ++++++--------
 sys/net/if_tun.c              |  25 +++++-----------
 sys/net/if_vlan.c             |  31 +++++++++++----------
 sys/net/npf/npf_ext_log.c     |   5 +--
 sys/net/ppp_tty.c             |  10 +++---
 14 files changed, 145 insertions(+), 159 deletions(-)

diffs (truncated from 1138 to 300 lines):

diff -r c44359124f5b -r c4a0d898af79 sys/net/agr/ieee8023ad_lacp.c
--- a/sys/net/agr/ieee8023ad_lacp.c     Wed Jan 29 04:11:35 2020 +0000
+++ b/sys/net/agr/ieee8023ad_lacp.c     Wed Jan 29 04:28:27 2020 +0000
@@ -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,
@@ -27,7 +27,7 @@
  */
 
 #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/callout.h>
@@ -503,7 +503,7 @@
        if (__predict_false(lsc->lsc_suppress_distributing &&
            !AGR_ROUNDROBIN(sc))) {
                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;
        }
 
diff -r c44359124f5b -r c4a0d898af79 sys/net/agr/if_agr.c
--- a/sys/net/agr/if_agr.c      Wed Jan 29 04:11:35 2020 +0000
+++ b/sys/net/agr/if_agr.c      Wed Jan 29 04:28:27 2020 +0000
@@ -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,
@@ -27,7 +27,7 @@
  */
 
 #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
 #include "opt_inet.h"
@@ -156,7 +156,7 @@
        ifp = port->port_agrifp;
        if ((port->port_flags & AGRPORT_COLLECTING) == 0) {
                m_freem(m);
-               ifp->if_ierrors++;
+               if_statinc(ifp, if_ierrors);
                return;
        }
 
@@ -390,19 +390,21 @@
                }
                bpf_mtap(ifp, m, BPF_D_OUT);
                port = agr_select_tx_port(sc, m);
+               net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
                if (port) {
                        int error;
 
                        error = agr_xmit_frame(port->port_ifp, m);
                        if (error) {
-                               ifp->if_oerrors++;
+                               if_statinc_ref(nsr, if_oerrors);
                        } else {
-                               ifp->if_opackets++;
+                               if_statinc_ref(nsr, if_opackets);
                        }
                } else {
                        m_freem(m);
-                       ifp->if_oerrors++;
+                       if_statinc_ref(nsr, if_oerrors);
                }
+               IF_STAT_PUTREF(ifp);
        }
 
        AGR_UNLOCK(sc);
diff -r c44359124f5b -r c4a0d898af79 sys/net/if_ipsec.c
--- a/sys/net/if_ipsec.c        Wed Jan 29 04:11:35 2020 +0000
+++ b/sys/net/if_ipsec.c        Wed Jan 29 04:28:27 2020 +0000
@@ -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.
@@ -27,7 +27,7 @@
  */
 
 #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
 #include "opt_inet.h"
@@ -538,7 +538,7 @@
        curlwp_bindx(bound);
 noref_end:
        if (error)
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
 
        return error;
 }
@@ -566,8 +566,7 @@
        if (error)
                return error;
 
-       ifp->if_opackets++;
-       ifp->if_obytes += len;
+       if_statadd2(ifp, if_opackets, 1, if_obytes, len);
 
        return 0;
 }
@@ -609,7 +608,7 @@
                break;
 #endif
        default:
-               ifp->if_ierrors++;
+               if_statinc(ifp, if_ierrors);
                m_freem(m);
                return;
        }
@@ -621,10 +620,9 @@
 #endif
        pktlen = m->m_pkthdr.len;
        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 {
-               ifp->if_iqdrops++;
+               if_statinc(ifp, if_iqdrops);
                m_freem(m);
        }
 
diff -r c44359124f5b -r c4a0d898af79 sys/net/if_ppp.c
--- a/sys/net/if_ppp.c  Wed Jan 29 04:11:35 2020 +0000
+++ b/sys/net/if_ppp.c  Wed Jan 29 04:28:27 2020 +0000
@@ -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       */
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #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
 #include "ppp.h"
@@ -1013,14 +1013,13 @@
                ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL;
                if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0)) != 0) {
                        splx(s);
-                       sc->sc_if.if_oerrors++;
+                       if_statinc(&sc->sc_if, if_oerrors);
                        sc->sc_stats.ppp_oerrors++;
                        return (error);
                }
                ppp_restart(sc);
        }
-       ifp->if_opackets++;
-       ifp->if_obytes += len;
+       if_statadd2(ifp, if_opackets, 1, if_obytes, len);
 
        splx(s);
        return (0);
@@ -1065,7 +1064,7 @@
                        m->m_nextpkt = NULL;
                        ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL;
                        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++;
                        }
                        break;
@@ -1715,11 +1714,10 @@
        if (__predict_true(pktq)) {
                if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
                        splx(s);
-                       ifp->if_iqdrops++;
+                       if_statinc(ifp, if_iqdrops);
                        goto bad;
                }
-               ifp->if_ipackets++;
-               ifp->if_ibytes += ilen;
+               if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen);
                splx(s);
                return;
        }
@@ -1734,13 +1732,12 @@
                splx(s);
                if (sc->sc_flags & SC_DEBUG)
                        printf("%s: input queue full\n", ifp->if_xname);
-               ifp->if_iqdrops++;
+               if_statinc(ifp, if_iqdrops);
                goto bad;
        }
        IF_ENQUEUE(inq, m);
        splx(s);
-       ifp->if_ipackets++;
-       ifp->if_ibytes += ilen;
+       if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen);
 
        (*sc->sc_ctlp)(sc);
 
@@ -1748,7 +1745,7 @@
 
 bad:
        m_freem(m);
-       sc->sc_if.if_ierrors++;
+       if_statinc(&sc->sc_if, if_ierrors);
        sc->sc_stats.ppp_ierrors++;
 }
 
diff -r c44359124f5b -r c4a0d898af79 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Wed Jan 29 04:11:35 2020 +0000
+++ b/sys/net/if_pppoe.c        Wed Jan 29 04:28:27 2020 +0000
@@ -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.
@@ -30,7 +30,7 @@
  */
 
 #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
 #include "pppoe.h"
@@ -1125,7 +1125,7 @@
        m_set_rcvif(m, &sc->sc_sppp.pp_if);
 
        /* 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);
        return;
 
@@ -1161,7 +1161,7 @@
 #endif
 
        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);
 }
 
@@ -1865,7 +1865,7 @@
                len = m->m_pkthdr.len;
                M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT);
                if (m == NULL) {
-                       ifp->if_oerrors++;
+                       if_statinc(ifp, if_oerrors);
                        continue;
                }
                p = mtod(m, uint8_t *);
@@ -1901,7 +1901,7 @@
        M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT);
        if (m == NULL) {
                PPPOE_UNLOCK(sc);
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
                return ENETDOWN;
        }
        p = mtod(m, uint8_t *);
diff -r c44359124f5b -r c4a0d898af79 sys/net/if_sl.c
--- a/sys/net/if_sl.c   Wed Jan 29 04:11:35 2020 +0000
+++ b/sys/net/if_sl.c   Wed Jan 29 04:28:27 2020 +0000
@@ -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
@@ -60,7 +60,7 @@
  */
 
 #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
 #include "opt_inet.h"
@@ -485,7 +485,7 @@
                printf("%s: af%d not supported\n", sc->sc_if.if_xname,
                    dst->sa_family);
                m_freem(m);
-               sc->sc_if.if_noproto++;
+               if_statinc(&sc->sc_if, if_noproto);
                return EAFNOSUPPORT;



Home | Main Index | Thread Index | Old Index