Module Name:    src
Committed By:   thorpej
Date:           Wed Jan 29 04:37:24 UTC 2020

Modified Files:
        src/sys/netinet: in_l2tp.c ip_carp.c

Log Message:
Adopt <net/if_stats.h>.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.107 -r1.108 src/sys/netinet/ip_carp.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/netinet/in_l2tp.c
diff -u src/sys/netinet/in_l2tp.c:1.17 src/sys/netinet/in_l2tp.c:1.18
--- src/sys/netinet/in_l2tp.c:1.17	Thu Sep 19 06:07:25 2019
+++ src/sys/netinet/in_l2tp.c	Wed Jan 29 04:37:24 2020
@@ -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 @@ in_l2tp_output(struct l2tp_variant *var,
 
 looped:
 	if (error)
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 
 out:
 	return error;

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.107 src/sys/netinet/ip_carp.c:1.108
--- src/sys/netinet/ip_carp.c:1.107	Mon Jan 20 18:38:22 2020
+++ src/sys/netinet/ip_carp.c	Wed Jan 29 04:37:24 2020
@@ -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 @@ carp_proto_input_c(struct mbuf *m, struc
 	}
 
 	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 @@ carp_proto_input_c(struct mbuf *m, struc
 #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 @@ carp_send_ad(void *v)
 
 	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 @@ carp_send_ad(void *v)
 
 		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 @@ carp_send_ad(void *v)
 		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_send_ad(void *v)
 				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 @@ carp_send_ad(void *v)
 
 		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 @@ carp_send_ad(void *v)
 		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 @@ carp_send_ad(void *v)
 		    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_send_ad(void *v)
 				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 @@ carp_input(struct mbuf *m, u_int8_t *sho
 	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);
 }

Reply via email to