Source-Changes-HG archive

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

[src/trunk]: src/sys Adopt <net/if_stats.h>.



details:   https://anonhg.NetBSD.org/src/rev/0007e4957a78
branches:  trunk
changeset: 1006837:0007e4957a78
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jan 29 04:37:24 2020 +0000

description:
Adopt <net/if_stats.h>.

diffstat:

 sys/netinet/in_l2tp.c   |   6 +++---
 sys/netinet/ip_carp.c   |  31 ++++++++++++++-----------------
 sys/netinet6/in6_l2tp.c |   6 +++---
 3 files changed, 20 insertions(+), 23 deletions(-)

diffs (180 lines):

diff -r 923a27dc9f28 -r 0007e4957a78 sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c     Wed Jan 29 04:35:13 2020 +0000
+++ b/sys/netinet/in_l2tp.c     Wed Jan 29 04:37:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_l2tp.c,v 1.17 2019/09/19 06:07:25 knakahara Exp $   */
+/*     $NetBSD: in_l2tp.c,v 1.18 2020/01/29 04:37:24 thorpej Exp $     */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.17 2019/09/19 06:07:25 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.18 2020/01/29 04:37:24 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -239,7 +239,7 @@
 
 looped:
        if (error)
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
 
 out:
        return error;
diff -r 923a27dc9f28 -r 0007e4957a78 sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c     Wed Jan 29 04:35:13 2020 +0000
+++ b/sys/netinet/ip_carp.c     Wed Jan 29 04:37:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_carp.c,v 1.107 2020/01/20 18:38:22 thorpej Exp $    */
+/*     $NetBSD: ip_carp.c,v 1.108 2020/01/29 04:37:24 thorpej Exp $    */
 /*     $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $   */
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.107 2020/01/20 18:38:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.108 2020/01/29 04:37:24 thorpej Exp $");
 
 /*
  * TODO:
@@ -712,13 +712,12 @@
        }
 
        nanotime(&sc->sc_if.if_lastchange);
-       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);
 
        /* verify the CARP version. */
        if (ch->carp_version != CARP_VERSION) {
                CARP_STATINC(CARP_STAT_BADVER);
-               sc->sc_if.if_ierrors++;
+               if_statinc(&sc->sc_if, if_ierrors);
                CARP_LOG(sc, ("invalid version %d != %d",
                    ch->carp_version, CARP_VERSION));
                m_freem(m);
@@ -735,7 +734,7 @@
 #endif
 
                CARP_STATINC(CARP_STAT_BADAUTH);
-               sc->sc_if.if_ierrors++;
+               if_statinc(&sc->sc_if, if_ierrors);
 
                switch(af) {
                case AF_INET:
@@ -1038,7 +1037,7 @@
 
        advbase = advskew = 0; /* Sssssh compiler */
        if (sc->sc_carpdev == NULL) {
-               sc->sc_if.if_oerrors++;
+               if_statinc(&sc->sc_if, if_oerrors);
                goto retry_later;
        }
 
@@ -1075,7 +1074,7 @@
 
                MGETHDR(m, M_DONTWAIT, MT_HEADER);
                if (m == NULL) {
-                       sc->sc_if.if_oerrors++;
+                       if_statinc(&sc->sc_if, if_oerrors);
                        CARP_STATINC(CARP_STAT_ONOMEM);
                        /* XXX maybe less ? */
                        goto retry_later;
@@ -1119,8 +1118,7 @@
                m->m_data -= sizeof(*ip);
 
                nanotime(&sc->sc_if.if_lastchange);
-               sc->sc_if.if_opackets++;
-               sc->sc_if.if_obytes += len;
+               if_statadd2(&sc->sc_if, if_opackets, 1, if_obytes, len);
                CARP_STATINC(CARP_STAT_OPACKETS);
 
                error = ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo,
@@ -1130,7 +1128,7 @@
                                CARP_STATINC(CARP_STAT_ONOMEM);
                        else
                                CARP_LOG(sc, ("ip_output failed: %d", error));
-                       sc->sc_if.if_oerrors++;
+                       if_statinc(&sc->sc_if, if_oerrors);
                        if (sc->sc_sendad_errors < INT_MAX)
                                sc->sc_sendad_errors++;
                        if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) {
@@ -1159,7 +1157,7 @@
 
                MGETHDR(m, M_DONTWAIT, MT_HEADER);
                if (m == NULL) {
-                       sc->sc_if.if_oerrors++;
+                       if_statinc(&sc->sc_if, if_oerrors);
                        CARP_STATINC(CARP_STAT_ONOMEM);
                        /* XXX maybe less ? */
                        goto retry_later;
@@ -1193,7 +1191,7 @@
                ip6->ip6_dst.s6_addr16[0] = htons(0xff02);
                ip6->ip6_dst.s6_addr8[15] = 0x12;
                if (in6_setscope(&ip6->ip6_dst, &sc->sc_if, NULL) != 0) {
-                       sc->sc_if.if_oerrors++;
+                       if_statinc(&sc->sc_if, if_oerrors);
                        m_freem(m);
                        CARP_LOG(sc, ("in6_setscope failed"));
                        goto retry_later;
@@ -1207,8 +1205,7 @@
                    len - sizeof(*ip6));
 
                nanotime(&sc->sc_if.if_lastchange);
-               sc->sc_if.if_opackets++;
-               sc->sc_if.if_obytes += len;
+               if_statadd2(&sc->sc_if, if_opackets, 1, if_obytes, len);
                CARP_STATINC(CARP_STAT_OPACKETS6);
 
                error = ip6_output(m, NULL, NULL, 0, &sc->sc_im6o, NULL, NULL);
@@ -1217,7 +1214,7 @@
                                CARP_STATINC(CARP_STAT_ONOMEM);
                        else
                                CARP_LOG(sc, ("ip6_output failed: %d", error));
-                       sc->sc_if.if_oerrors++;
+                       if_statinc(&sc->sc_if, if_oerrors);
                        if (sc->sc_sendad_errors < INT_MAX)
                                sc->sc_sendad_errors++;
                        if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) {
@@ -1509,7 +1506,7 @@
        m_set_rcvif(m, ifp);
 
        bpf_mtap(ifp, m, BPF_D_IN);
-       ifp->if_ipackets++;
+       if_statinc(ifp, if_ipackets);
        ether_input(ifp, m);
        return (0);
 }
diff -r 923a27dc9f28 -r 0007e4957a78 sys/netinet6/in6_l2tp.c
--- a/sys/netinet6/in6_l2tp.c   Wed Jan 29 04:35:13 2020 +0000
+++ b/sys/netinet6/in6_l2tp.c   Wed Jan 29 04:37:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_l2tp.c,v 1.18 2019/09/19 06:07:25 knakahara Exp $  */
+/*     $NetBSD: in6_l2tp.c,v 1.19 2020/01/29 04:38:06 thorpej Exp $    */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.18 2019/09/19 06:07:25 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.19 2020/01/29 04:38:06 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -231,7 +231,7 @@
 
 looped:
        if (error)
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
 
        return error;
 }



Home | Main Index | Thread Index | Old Index