Module Name: src
Committed By: thorpej
Date: Wed Jan 29 04:34:10 UTC 2020
Modified Files:
src/sys/net: if_ipsec.c if_tun.c
Log Message:
Adopt <net/if_stats.h>.
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/net/if_ipsec.c
cvs rdiff -u -r1.157 -r1.158 src/sys/net/if_tun.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_ipsec.c
diff -u src/sys/net/if_ipsec.c:1.25 src/sys/net/if_ipsec.c:1.26
--- src/sys/net/if_ipsec.c:1.25 Fri Nov 1 04:28:14 2019
+++ src/sys/net/if_ipsec.c Wed Jan 29 04:34:10 2020
@@ -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 @@ end:
curlwp_bindx(bound);
noref_end:
if (error)
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
return error;
}
@@ -566,8 +566,7 @@ if_ipsec_out_direct(struct ipsec_variant
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 @@ if_ipsec_in_enqueue(struct mbuf *m, int
break;
#endif
default:
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
m_freem(m);
return;
}
@@ -621,10 +620,9 @@ if_ipsec_in_enqueue(struct mbuf *m, int
#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);
}
Index: src/sys/net/if_tun.c
diff -u src/sys/net/if_tun.c:1.157 src/sys/net/if_tun.c:1.158
--- src/sys/net/if_tun.c:1.157 Fri Dec 13 14:13:55 2019
+++ src/sys/net/if_tun.c Wed Jan 29 04:34:10 2020
@@ -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 <[email protected]>
@@ -19,7 +19,7 @@
*/
#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
#include "opt_inet.h"
@@ -259,13 +259,6 @@ tunattach0(struct tun_softc *tp)
ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE;
ifp->if_type = IFT_TUNNEL;
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;
IFQ_SET_READY(&ifp->if_snd);
if_attach(ifp);
@@ -612,13 +605,12 @@ tun_output(struct ifnet *ifp, struct mbu
mlen = m0->m_pkthdr.len;
IFQ_ENQUEUE(&ifp->if_snd, m0, error);
if (error) {
- ifp->if_collisions++;
+ if_statinc(ifp, if_collisions);
error = EAFNOSUPPORT;
m0 = NULL;
goto out;
}
- ifp->if_opackets++;
- ifp->if_obytes += mlen;
+ if_statadd2(ifp, if_opackets, 1, if_obytes, mlen);
break;
#endif
default:
@@ -828,7 +820,7 @@ tunread(dev_t dev, struct uio *uio, int
m_freem(m0);
}
if (error)
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
return error;
@@ -946,7 +938,7 @@ tunwrite(dev_t dev, struct uio *uio, int
if (error) {
if (top != NULL)
m_freem(top);
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
goto out0;
}
@@ -967,14 +959,13 @@ tunwrite(dev_t dev, struct uio *uio, int
goto out;
}
if (__predict_false(!pktq_enqueue(pktq, top, 0))) {
- ifp->if_collisions++;
+ if_statinc(ifp, if_collisions);
mutex_exit(&tp->tun_lock);
error = ENOBUFS;
m_freem(top);
goto out0;
}
- ifp->if_ipackets++;
- ifp->if_ibytes += tlen;
+ if_statadd2(ifp, if_ipackets, 1, if_ibytes, tlen);
out:
mutex_exit(&tp->tun_lock);
out0: