From 3751dddb3e546d8c31867e491790da2b9d9215e0 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Fri, 19 Sep 2014 10:39:58 +0000 Subject: [PATCH] Mechanically convert to if_inc_counter(). --- sys/net/if_arcsubr.c | 8 +++---- sys/net/if_atmsubr.c | 2 +- sys/net/if_bridge.c | 32 +++++++++++++------------- sys/net/if_disc.c | 4 ++-- sys/net/if_edsc.c | 4 ++-- sys/net/if_epair.c | 26 ++++++++++----------- sys/net/if_ethersubr.c | 16 ++++++------- sys/net/if_faith.c | 8 +++---- sys/net/if_fddisubr.c | 26 ++++++++++----------- sys/net/if_fwsubr.c | 6 ++--- sys/net/if_gif.c | 20 ++++++++-------- sys/net/if_gre.c | 18 +++++++-------- sys/net/if_iso88025subr.c | 30 ++++++++++++------------ sys/net/if_loop.c | 8 +++---- sys/net/if_spppfr.c | 10 ++++---- sys/net/if_spppsubr.c | 48 +++++++++++++++++++-------------------- sys/net/if_stf.c | 18 +++++++-------- sys/net/if_tap.c | 8 +++---- sys/net/if_tun.c | 16 ++++++------- sys/net/if_vlan.c | 4 ++-- 20 files changed, 156 insertions(+), 156 deletions(-) diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index f59315040abb..617f9ee13d88 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -357,7 +357,7 @@ arc_defrag(struct ifnet *ifp, struct mbuf *m) if (m->m_len < ARC_HDRNEWLEN) { m = m_pullup(m, ARC_HDRNEWLEN); if (m == NULL) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return NULL; } } @@ -377,7 +377,7 @@ arc_defrag(struct ifnet *ifp, struct mbuf *m) if (m->m_len < ARC_HDRNEWLEN) { m = m_pullup(m, ARC_HDRNEWLEN); if (m == NULL) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return NULL; } } @@ -530,11 +530,11 @@ arc_input(struct ifnet *ifp, struct mbuf *m) return; } - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); if (ah->arc_dhost == arcbroadcastaddr) { m->m_flags |= M_BCAST|M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } atype = ah->arc_type; diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 8bf8534bc851..e1c4a6753973 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -252,7 +252,7 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m, #ifdef MAC mac_ifnet_create_mbuf(ifp, m); #endif - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); if (ng_atm_input_p != NULL) { (*ng_atm_input_p)(ifp, &m, ah, rxhand); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 59d63ee4f227..252404f328e6 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1848,7 +1848,7 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m) if (m == NULL) { if_printf(dst_ifp, "unable to prepend VLAN header\n"); - dst_ifp->if_oerrors++; + if_inc_counter(dst_ifp, IFCOUNTER_OERRORS, 1); continue; } m->m_flags &= ~M_VLANTAG; @@ -1856,14 +1856,14 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m) if ((err = dst_ifp->if_transmit(dst_ifp, m))) { m_freem(m0); - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); break; } - sc->sc_ifp->if_opackets++; - sc->sc_ifp->if_obytes += len; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(sc->sc_ifp, IFCOUNTER_OBYTES, len); if (mflags & M_MCAST) - sc->sc_ifp->if_omcasts++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OMCASTS, 1); } return (err); @@ -1994,7 +1994,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, } else { mc = m_copypacket(m, M_NOWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -2084,8 +2084,8 @@ bridge_forward(struct bridge_softc *sc, struct bridge_iflist *sbif, src_if = m->m_pkthdr.rcvif; ifp = sc->sc_ifp; - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); vlan = VLANTAGOF(m); if ((sbif->bif_flags & IFBIF_STP) && @@ -2137,7 +2137,7 @@ bridge_forward(struct bridge_softc *sc, struct bridge_iflist *sbif, goto drop; /* ...forward it to all interfaces. */ - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); dst_if = NULL; } @@ -2245,8 +2245,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) if ((bifp->if_flags & IFF_MONITOR) != 0) { m->m_pkthdr.rcvif = bifp; ETHER_BPF_MTAP(bifp, m); - bifp->if_ipackets++; - bifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(bifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(bifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); m_freem(m); return (NULL); } @@ -2347,8 +2347,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) ) { \ if ((iface)->if_type == IFT_BRIDGE) { \ ETHER_BPF_MTAP(iface, m); \ - iface->if_ipackets++; \ - iface->if_ibytes += m->m_pkthdr.len; \ + if_inc_counter(iface, IFCOUNTER_IPACKETS, 1); \ + if_inc_counter(iface, IFCOUNTER_IBYTES, m->m_pkthdr.len); \ /* Filter on the physical interface. */ \ if (pfil_local_phys && \ (PFIL_HOOKED(&V_inet_pfil_hook) \ @@ -2478,7 +2478,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *src_if, } else { mc = m_dup(m, M_NOWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -2498,7 +2498,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *src_if, i = min(mc->m_pkthdr.len, max_protohdr); mc = m_copyup(mc, i, ETHER_ALIGN); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -2541,7 +2541,7 @@ bridge_span(struct bridge_softc *sc, struct mbuf *m) mc = m_copypacket(m, M_NOWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index 370cce822e5b..4cce4847d02b 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -174,8 +174,8 @@ discoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, m->m_pkthdr.rcvif = ifp; - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); m_freem(m); return (0); diff --git a/sys/net/if_edsc.c b/sys/net/if_edsc.c index 3ee1c6d864af..b75f134c9bc6 100644 --- a/sys/net/if_edsc.c +++ b/sys/net/if_edsc.c @@ -291,8 +291,8 @@ edsc_start(struct ifnet *ifp) /* * Update the interface counters. */ - ifp->if_obytes += m->m_pkthdr.len; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * Finally, just drop the packet. diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index fd1120c41ff0..13d7e0b30d1a 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -418,7 +418,7 @@ epair_start_locked(struct ifnet *ifp) */ if ((oifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || (oifp->if_flags & IFF_UP) ==0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); continue; } @@ -434,15 +434,15 @@ epair_start_locked(struct ifnet *ifp) error = netisr_queue(NETISR_EPAIR, m); CURVNET_RESTORE(); if (!error) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* Someone else received the packet. */ - oifp->if_ipackets++; + if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); } else { /* The packet was freed already. */ epair_dpcpu->epair_drv_flags |= IFF_DRV_OACTIVE; ifp->if_drv_flags |= IFF_DRV_OACTIVE; (void) epair_add_ifp_for_draining(ifp); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); EPAIR_REFCOUNT_RELEASE(&sc->refcount); EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, ("%s: ifp=%p sc->refcount not >= 1: %d", @@ -503,7 +503,7 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) oifp = sc->oifp; if ((oifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || (oifp->if_flags & IFF_UP) ==0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); return (0); } @@ -517,12 +517,12 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) if (ALTQ_IS_ENABLED(&ifp->if_snd)) { ALTQ_ENQUEUE(&ifp->if_snd, m, NULL, error); if (error) - ifp->if_oqdrops++; + if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); IF_UNLOCK(&ifp->if_snd); if (!error) { - ifp->if_obytes += len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); if (mflags & (M_BCAST|M_MCAST)) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); if ((ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) epair_start_locked(ifp); @@ -556,22 +556,22 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) error = netisr_queue(NETISR_EPAIR, m); CURVNET_RESTORE(); if (!error) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * IFQ_HANDOFF_ADJ/ip_handoff() update statistics, * but as we bypass all this we have to duplicate * the logic another time. */ - ifp->if_obytes += len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); if (mflags & (M_BCAST|M_MCAST)) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); /* Someone else received the packet. */ - oifp->if_ipackets++; + if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); } else { /* The packet was freed already. */ epair_dpcpu->epair_drv_flags |= IFF_DRV_OACTIVE; ifp->if_drv_flags |= IFF_DRV_OACTIVE; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); EPAIR_REFCOUNT_RELEASE(&sc->refcount); EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, ("%s: ifp=%p sc->refcount not >= 1: %d", diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 4c2bd4ecb70b..5f315ec02cb8 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -306,7 +306,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m, update_mbuf_csumflags(m, n); (void)if_simloop(ifp, n, dst->sa_family, hlen); } else - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); } else if (bcmp(eh->ether_dhost, eh->ether_shost, ETHER_ADDR_LEN) == 0) { update_mbuf_csumflags(m, m); @@ -404,7 +404,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) */ if ((m->m_flags & M_PKTHDR) == 0) { if_printf(ifp, "discard frame w/o packet header\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -413,7 +413,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) if_printf(ifp, "discard frame w/o leading ethernet " "header (len %u pkt len %u)\n", m->m_len, m->m_pkthdr.len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -421,7 +421,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) etype = ntohs(eh->ether_type); if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -439,7 +439,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } #ifdef MAC @@ -466,7 +466,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) } if (!(ifp->if_capenable & IFCAP_HWSTATS)) - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* Allow monitor mode to claim this frame, after stats are updated. */ if (ifp->if_flags & IFF_MONITOR) { @@ -502,7 +502,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) #ifdef DIAGNOSTIC if_printf(ifp, "cannot pullup VLAN header\n"); #endif - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); CURVNET_RESTORE(); return; @@ -715,7 +715,7 @@ ether_demux(struct ifnet *ifp, struct mbuf *m) if ((m->m_flags & M_VLANTAG) && EVL_VLANOFTAG(m->m_pkthdr.ether_vtag) != 0) { if (ifp->if_vlantrunk == NULL) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); m_freem(m); return; } diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index 5d22a4a9dbe0..2aeb14adfdbb 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -211,8 +211,8 @@ faithoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, return (rt->rt_flags & RTF_BLACKHOLE ? 0 : rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); switch (af) { #ifdef INET case AF_INET: @@ -232,8 +232,8 @@ faithoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, /* XXX do we need more sanity checks? */ m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); netisr_dispatch(isr, m); return (0); } diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 1680dcac1dd8..4056396b6a68 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -288,12 +288,12 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, error = (ifp->if_transmit)(ifp, m); if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (m) m_freem(m); return (error); @@ -317,20 +317,20 @@ fddi_input(ifp, m) */ if ((m->m_flags & M_PKTHDR) == 0) { if_printf(ifp, "discard frame w/o packet header\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } m = m_pullup(m, FDDI_HDR_LEN); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } fh = mtod(m, struct fddi_header *); @@ -362,7 +362,7 @@ fddi_input(ifp, m) /* * Update interface statistics. */ - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); getmicrotime(&ifp->if_lastchange); /* @@ -383,7 +383,7 @@ fddi_input(ifp, m) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } #ifdef M_LINK0 @@ -401,7 +401,7 @@ fddi_input(ifp, m) m = m_pullup(m, LLC_SNAPFRAMELEN); if (m == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } l = mtod(m, struct llc *); @@ -412,13 +412,13 @@ fddi_input(ifp, m) u_int16_t type; if ((l->llc_control != LLC_UI) || (l->llc_ssap != LLC_SNAP_LSAP)) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } if (l->llc_snap.org_code[0] != 0 || l->llc_snap.org_code[1] != 0 || l->llc_snap.org_code[2] != 0) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } @@ -451,7 +451,7 @@ fddi_input(ifp, m) #endif default: /* printf("fddi_input: unknown protocol 0x%x\n", type); */ - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } break; @@ -459,7 +459,7 @@ fddi_input(ifp, m) default: /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */ - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } M_SETFIB(m, ifp->if_fib); @@ -467,7 +467,7 @@ fddi_input(ifp, m) return; dropanyway: - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (m) m_freem(m); return; diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index 5f0f9238794c..39e9cf9fd867 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -537,7 +537,7 @@ firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src) if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -582,7 +582,7 @@ firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src) return; } - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* Discard packet if interface is not up */ if ((ifp->if_flags & IFF_UP) == 0) { @@ -591,7 +591,7 @@ firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src) } if (m->m_flags & (M_BCAST|M_MCAST)) - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); switch (type) { #ifdef INET diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 6cf04373a4d8..7071fef45c90 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -377,10 +377,10 @@ gif_start(struct ifnet *ifp) af = AF_LINK; BPF_MTAP2(ifp, &af, sizeof(af), m); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* Done by IFQ_HANDOFF */ -/* ifp->if_obytes += m->m_pkthdr.len;*/ +/* if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);*/ /* override to IPPROTO_ETHERIP for bridged traffic */ M_SETFIB(m, sc->gif_fibnum); @@ -403,7 +403,7 @@ gif_start(struct ifnet *ifp) error = ENETDOWN; } if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -513,7 +513,7 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, IFQ_HANDOFF(ifp, m, error); end: if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); } @@ -544,8 +544,8 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) } if ((ifp->if_flags & IFF_MONITOR) != 0) { - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); m_freem(m); return; } @@ -583,7 +583,7 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) if (n > m->m_len) { m = m_pullup(m, n); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } } @@ -622,7 +622,7 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } BRIDGE_INPUT(ifp, m); @@ -647,8 +647,8 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) return; } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); } diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index fe648eafe493..65b3029b7d90 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -361,7 +361,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * be encapsulated. */ if (ip->ip_off & htons(IP_MF | IP_OFFMASK)) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EINVAL; /* is there better errno? */ goto end; @@ -390,7 +390,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if ((m->m_data - msiz) < m->m_pktdat) { m0 = m_gethdr(M_NOWAIT, MT_DATA); if (m0 == NULL) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = ENOBUFS; goto end; @@ -415,7 +415,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, memcpy((caddr_t)(ip + 1), &mob_h, (unsigned)msiz); ip->ip_len = htons(ntohs(ip->ip_len) + msiz); } else { /* AF_INET */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EINVAL; goto end; @@ -440,7 +440,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, break; #endif default: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EAFNOSUPPORT; goto end; @@ -452,14 +452,14 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, hdrlen += sizeof(uint32_t); M_PREPEND(m, hdrlen, M_NOWAIT); } else { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EINVAL; goto end; } if (m == NULL) { /* mbuf allocation failed */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); error = ENOBUFS; goto end; } @@ -494,8 +494,8 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, gh->gi_len = htons(m->m_pkthdr.len); } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); /* * Send it off and with IP_FORWARD flag to prevent it from * overwriting the ip_id again. ip_id is already set to the @@ -505,7 +505,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, (struct ip_moptions *)NULL, (struct inpcb *)NULL); end: if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); } diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index 2c93b20a7c29..b03b70d79797 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -381,12 +381,12 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, IFQ_HANDOFF_ADJ(ifp, m, ISO88025_HDR_LEN + LLC_SNAPFRAMELEN, error); if (error) { printf("iso88025_output: packet dropped QFULL.\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } return (error); bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (m) m_freem(m); return (error); @@ -411,20 +411,20 @@ iso88025_input(ifp, m) */ if ((m->m_flags & M_PKTHDR) == 0) { if_printf(ifp, "discard frame w/o packet header\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } m = m_pullup(m, ISO88025_HDR_LEN); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } th = mtod(m, struct iso88025_header *); @@ -456,7 +456,7 @@ iso88025_input(ifp, m) /* * Update interface statistics. */ - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); getmicrotime(&ifp->if_lastchange); /* @@ -478,7 +478,7 @@ iso88025_input(ifp, m) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } mac_hdr_len = ISO88025_HDR_LEN; @@ -491,7 +491,7 @@ iso88025_input(ifp, m) m = m_pullup(m, LLC_SNAPFRAMELEN); if (m == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } l = mtod(m, struct llc *); @@ -501,14 +501,14 @@ iso88025_input(ifp, m) u_int16_t type; if ((l->llc_control != LLC_UI) || (l->llc_ssap != LLC_SNAP_LSAP)) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } if (l->llc_snap.org_code[0] != 0 || l->llc_snap.org_code[1] != 0 || l->llc_snap.org_code[2] != 0) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } @@ -537,7 +537,7 @@ iso88025_input(ifp, m) #endif /* INET6 */ default: printf("iso88025_input: unexpected llc_snap ether_type 0x%02x\n", type); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } break; @@ -546,7 +546,7 @@ iso88025_input(ifp, m) case LLC_ISO_LSAP: switch (l->llc_control) { case LLC_UI: - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; break; case LLC_XID: @@ -595,7 +595,7 @@ iso88025_input(ifp, m) } default: printf("iso88025_input: unexpected llc control 0x%02x\n", l->llc_control); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; break; } @@ -603,7 +603,7 @@ iso88025_input(ifp, m) #endif /* ISO */ default: printf("iso88025_input: unknown dsap 0x%x\n", l->llc_dsap); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; break; } @@ -613,7 +613,7 @@ iso88025_input(ifp, m) return; dropanyway: - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (m) m_freem(m); return; diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 068705029d4e..6d2b9143dfb1 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -226,8 +226,8 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); /* BPF writes need to be handled specially. */ if (dst->sa_family == AF_UNSPEC) @@ -358,8 +358,8 @@ if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen) m_freem(m); return (EAFNOSUPPORT); } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); netisr_queue(isr, m); /* mbuf is free'd on failure. */ return (0); } diff --git a/sys/net/if_spppfr.c b/sys/net/if_spppfr.c index 8fda38b8797e..d84cc46c7cb6 100644 --- a/sys/net/if_spppfr.c +++ b/sys/net/if_spppfr.c @@ -250,9 +250,9 @@ bad: m_freem (m); switch (proto) { default: - ++ifp->if_noproto; -drop: ++ifp->if_ierrors; - ++ifp->if_iqdrops; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); +drop: if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); m_freem (m); return; #ifdef INET @@ -394,7 +394,7 @@ void sppp_fr_keepalive (struct sppp *sp) (u_char) sp->pp_rseq[IDX_LCP]); if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* @@ -508,7 +508,7 @@ static void sppp_fr_arp (struct sppp *sp, struct arp_req *req, reply->ptarget2 = htonl (his_ip_address) >> 16; if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 3340612e6ff5..9dc55c5ba12c 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -518,7 +518,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) if (ifp->if_flags & IFF_UP) /* Count received bytes, add FCS and one flag */ - ifp->if_ibytes += m->m_pkthdr.len + 3; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len + 3); if (m->m_pkthdr.len <= PPP_HEADER_LEN) { /* Too small packet, drop it. */ @@ -530,8 +530,8 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) m_freem (m); SPPP_UNLOCK(sp); drop2: - ++ifp->if_ierrors; - ++ifp->if_iqdrops; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return; } @@ -570,7 +570,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) sppp_cp_send (sp, PPP_LCP, PROTO_REJ, ++sp->pp_seq[IDX_LCP], m->m_pkthdr.len + 2, &h->protocol); - ++ifp->if_noproto; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto drop; case PPP_LCP: sppp_cp_input(&lcp, sp, m); @@ -682,7 +682,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) } switch (ntohs (h->protocol)) { default: - ++ifp->if_noproto; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto invalid; case CISCO_KEEPALIVE: sppp_cisco_input (sp, m); @@ -906,7 +906,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, nobufs: if (debug) log(LOG_DEBUG, SPP_FMT "no memory for transmit header\n", SPP_ARGS(ifp)); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); SPPP_UNLOCK(sp); return (ENOBUFS); } @@ -966,7 +966,7 @@ nobufs: if (debug) #endif default: m_freem (m); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); SPPP_UNLOCK(sp); return (EAFNOSUPPORT); } @@ -981,7 +981,7 @@ nobufs: if (debug) else IFQ_HANDOFF_ADJ(ifp, m, 3, error); if (error) { - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); SPPP_UNLOCK(sp); return (rv? rv: ENOBUFS); } @@ -1393,7 +1393,7 @@ sppp_cisco_send(struct sppp *sp, int type, long par1, long par2) (u_long)ch->par2, (u_int)ch->rel, (u_int)ch->time0, (u_int)ch->time1); if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* @@ -1442,7 +1442,7 @@ sppp_cp_send(struct sppp *sp, u_short proto, u_char type, log(-1, ">\n"); } if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* @@ -1484,7 +1484,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s invalid conf-req length %d\n", SPP_ARGS(ifp), cp->name, len); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } /* handle states where RCR doesn't get a SCA/SCN */ @@ -1540,7 +1540,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case CONF_ACK: @@ -1549,7 +1549,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s id mismatch 0x%x != 0x%x\n", SPP_ARGS(ifp), cp->name, h->ident, sp->confid[cp->protoidx]); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } switch (sp->state[cp->protoidx]) { @@ -1584,7 +1584,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case CONF_NAK: @@ -1594,7 +1594,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s id mismatch 0x%x != 0x%x\n", SPP_ARGS(ifp), cp->name, h->ident, sp->confid[cp->protoidx]); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } if (h->type == CONF_NAK) @@ -1634,7 +1634,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; @@ -1667,7 +1667,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case TERM_ACK: @@ -1698,7 +1698,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case CODE_REJ: @@ -1725,7 +1725,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case PROTO_REJ: @@ -1784,7 +1784,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; } @@ -1800,7 +1800,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) if (debug) log(-1, SPP_FMT "lcp echo req but lcp closed\n", SPP_ARGS(ifp)); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } if (len < 8) { @@ -1834,7 +1834,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) if (cp->proto != PPP_LCP) goto illegal; if (h->ident != sp->lcp.echoid) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } if (len < 8) { @@ -1859,7 +1859,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, h->type); sppp_cp_send(sp, cp->proto, CODE_REJ, ++sp->pp_seq[cp->protoidx], m->m_pkthdr.len, h); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } } @@ -4740,7 +4740,7 @@ sppp_auth_send(const struct cp *cp, struct sppp *sp, log(-1, ">\n"); } if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 7b6fbcfb7418..b92346e9ec45 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -442,7 +442,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, /* just in case */ if ((ifp->if_flags & IFF_UP) == 0) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETDOWN; } @@ -454,7 +454,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, ia6 = stf_getsrcifa6(ifp); if (ia6 == NULL) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETDOWN; } @@ -462,7 +462,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, m = m_pullup(m, sizeof(*ip6)); if (!m) { ifa_free(&ia6->ia_ifa); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENOBUFS; } } @@ -481,7 +481,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, else { ifa_free(&ia6->ia_ifa); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETUNREACH; } bcopy(ptr, &in4, sizeof(in4)); @@ -503,7 +503,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, m = m_pullup(m, sizeof(struct ip)); if (m == NULL) { ifa_free(&ia6->ia_ifa); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENOBUFS; } ip = mtod(m, struct ip *); @@ -549,7 +549,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if (sc->sc_ro.ro_rt == NULL) { m_freem(m); mtx_unlock(&(sc)->sc_ro_mtx); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETUNREACH; } } @@ -557,7 +557,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, sendit: M_SETFIB(m, sc->sc_fibnum); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); error = ip_output(m, NULL, cached_route, 0, NULL, NULL); if (cached_route != NULL) @@ -770,8 +770,8 @@ in_stf_input(struct mbuf **mp, int *offp, int proto) * See net/if_gif.c for possible issues with packet processing * reorder due to extra queueing. */ - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); M_SETFIB(m, ifp->if_fib); netisr_dispatch(NETISR_IPV6, m); return (IPPROTO_DONE); diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 89cac22f264e..5de424ca9b45 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -682,7 +682,7 @@ tapifstart(struct ifnet *ifp) IF_DEQUEUE(&ifp->if_snd, m); if (m != NULL) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else break; } @@ -707,7 +707,7 @@ tapifstart(struct ifnet *ifp) selwakeuppri(&tp->tap_rsel, PZERO+1); KNOTE_LOCKED(&tp->tap_rsel.si_note, 0); - ifp->if_opackets ++; /* obytes are counted in ether_output */ + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* obytes are counted in ether_output */ } ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -947,7 +947,7 @@ tapwrite(struct cdev *dev, struct uio *uio, int flag) if ((m = m_uiotombuf(uio, M_NOWAIT, 0, ETHER_ALIGN, M_PKTHDR)) == NULL) { - ifp->if_ierrors ++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (ENOBUFS); } @@ -974,7 +974,7 @@ tapwrite(struct cdev *dev, struct uio *uio, int flag) CURVNET_SET(ifp->if_vnet); (*ifp->if_input)(ifp, m); CURVNET_RESTORE(); - ifp->if_ipackets ++; /* ibytes are counted in parent */ + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* ibytes are counted in parent */ return (0); } /* tapwrite */ diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index e4bc2afc7afc..89af2882643d 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -619,8 +619,8 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, /* if allocation failed drop packet */ if (m0 == NULL) { - ifp->if_iqdrops++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENOBUFS); } else { bcopy(dst, m0->m_data, dst->sa_len); @@ -633,8 +633,8 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, /* if allocation failed drop packet */ if (m0 == NULL) { - ifp->if_iqdrops++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENOBUFS); } else *(u_int32_t *)m0->m_data = htonl(af); @@ -651,7 +651,7 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, error = (ifp->if_transmit)(ifp, m0); if (error) return (ENOBUFS); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); return (0); } @@ -866,7 +866,7 @@ tunwrite(struct cdev *dev, struct uio *uio, int flag) } if ((m = m_uiotombuf(uio, M_NOWAIT, 0, 0, M_PKTHDR)) == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (ENOBUFS); } @@ -908,8 +908,8 @@ tunwrite(struct cdev *dev, struct uio *uio, int flag) } if (harvest.point_to_point) random_harvest(&(m->m_data), 12, 2, RANDOM_NET_TUN); - ifp->if_ibytes += m->m_pkthdr.len; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); CURVNET_SET(ifp->if_vnet); M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 1761c4af3c4a..c7a2d0193484 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1215,7 +1215,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) __func__, ifp->if_xname, ifp->if_type); #endif m_freem(m); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); return; } } @@ -1225,7 +1225,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) if (ifv == NULL || !UP_AND_RUNNING(ifv->ifv_ifp)) { TRUNK_RUNLOCK(trunk); m_freem(m); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); return; } TRUNK_RUNLOCK(trunk);