diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2016-11-14 03:51:54 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2016-11-14 03:51:54 +0000 |
commit | fc674f9894d986b47cfa77e09298d752aaf88a86 (patch) | |
tree | 5f6625cc3c701dbec6e85a033c355f4ff47ab185 /sys/net | |
parent | e0ce1e1136e22dfdf32c6e56000621f1fc333891 (diff) |
turn ipstat into a set of percpu counters.
each counter is identified by an enum value which correspond to the
original members of the ipstat struct.
ipstat_inc(ips_foo) replaces ipstat.ips_foo++ for the actual updates.
ipstat_inc is a thin wrapper around counters_inc.
counters are still returned to userland via the ipstat struct for now.
ok mpi@ mikeb@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_bridge.c | 20 | ||||
-rw-r--r-- | sys/net/if_etherip.c | 4 | ||||
-rw-r--r-- | sys/net/pf.c | 12 |
3 files changed, 18 insertions, 18 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 7b0c364cf60..e74be534663 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.287 2016/10/03 15:53:09 rzalamena Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.288 2016/11/14 03:51:53 dlg Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -1603,25 +1603,25 @@ bridge_ip(struct bridge_softc *sc, int dir, struct ifnet *ifp, /* Copy minimal header, and drop invalids */ if (m->m_len < sizeof(struct ip) && (m = m_pullup(m, sizeof(struct ip))) == NULL) { - ipstat.ips_toosmall++; + ipstat_inc(ips_toosmall); return (NULL); } ip = mtod(m, struct ip *); if (ip->ip_v != IPVERSION) { - ipstat.ips_badvers++; + ipstat_inc(ips_badvers); goto dropit; } hlen = ip->ip_hl << 2; /* get whole header length */ if (hlen < sizeof(struct ip)) { - ipstat.ips_badhlen++; + ipstat_inc(ips_badhlen); goto dropit; } if (hlen > m->m_len) { if ((m = m_pullup(m, hlen)) == NULL) { - ipstat.ips_badhlen++; + ipstat_inc(ips_badhlen); return (NULL); } ip = mtod(m, struct ip *); @@ -1629,13 +1629,13 @@ bridge_ip(struct bridge_softc *sc, int dir, struct ifnet *ifp, if ((m->m_pkthdr.csum_flags & M_IPV4_CSUM_IN_OK) == 0) { if (m->m_pkthdr.csum_flags & M_IPV4_CSUM_IN_BAD) { - ipstat.ips_badsum++; + ipstat_inc(ips_badsum); goto dropit; } - ipstat.ips_inswcsum++; + ipstat_inc(ips_inswcsum); if (in_cksum(m, hlen) != 0) { - ipstat.ips_badsum++; + ipstat_inc(ips_badsum); goto dropit; } } @@ -1678,7 +1678,7 @@ bridge_ip(struct bridge_softc *sc, int dir, struct ifnet *ifp, if (0 && (ifp->if_capabilities & IFCAP_CSUM_IPv4)) m->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT; else { - ipstat.ips_outswcsum++; + ipstat_inc(ips_outswcsum); ip->ip_sum = in_cksum(m, hlen); } @@ -1848,7 +1848,7 @@ bridge_fragment(struct bridge_softc *sc, struct ifnet *ifp, } if (error == 0) - ipstat.ips_fragmented++; + ipstat_inc(ips_fragmented); return; dropit: diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c index ad58c5208c5..d203fa2f8f5 100644 --- a/sys/net/if_etherip.c +++ b/sys/net/if_etherip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_etherip.c,v 1.7 2016/04/13 11:41:15 mpi Exp $ */ +/* $OpenBSD: if_etherip.c,v 1.8 2016/11/14 03:51:53 dlg Exp $ */ /* * Copyright (c) 2015 Kazuya GODA <goda@openbsd.org> * @@ -430,7 +430,7 @@ ip_etherip_input(struct mbuf *m, ...) if (ip->ip_p != IPPROTO_ETHERIP) { m_freem(m); - ipstat.ips_noproto++; + ipstat_inc(ips_noproto); return; } diff --git a/sys/net/pf.c b/sys/net/pf.c index 1a9bd5ee2dd..903618151b5 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.996 2016/10/28 07:54:19 sashan Exp $ */ +/* $OpenBSD: pf.c,v 1.997 2016/11/14 03:51:53 dlg Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -5825,7 +5825,7 @@ pf_route(struct mbuf **m, struct pf_pdesc *pd, struct pf_rule *r, if (!r->rt) { rt = rtalloc(sintosa(dst), RT_RESOLVE, rtableid); if (rt == NULL) { - ipstat.ips_noroute++; + ipstat_inc(ips_noroute); goto bad; } @@ -5859,7 +5859,7 @@ pf_route(struct mbuf **m, struct pf_pdesc *pd, struct pf_rule *r, rt = rtalloc(sintosa(dst), RT_RESOLVE, rtableid); if (rt == NULL) { - ipstat.ips_noroute++; + ipstat_inc(ips_noroute); goto bad; } } @@ -5887,7 +5887,7 @@ pf_route(struct mbuf **m, struct pf_pdesc *pd, struct pf_rule *r, if (ifp->if_capabilities & IFCAP_CSUM_IPv4) m0->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT; else { - ipstat.ips_outswcsum++; + ipstat_inc(ips_outswcsum); ip->ip_sum = in_cksum(m0, ip->ip_hl << 2); } error = ifp->if_output(ifp, m0, sintosa(dst), rt); @@ -5899,7 +5899,7 @@ pf_route(struct mbuf **m, struct pf_pdesc *pd, struct pf_rule *r, * Must be able to put at least 8 bytes per fragment. */ if (ip->ip_off & htons(IP_DF)) { - ipstat.ips_cantfrag++; + ipstat_inc(ips_cantfrag); if (r->rt != PF_DUPTO) { icmp_error(m0, ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG, 0, ifp->if_mtu); @@ -5925,7 +5925,7 @@ pf_route(struct mbuf **m, struct pf_pdesc *pd, struct pf_rule *r, } if (error == 0) - ipstat.ips_fragmented++; + ipstat_inc(ips_fragmented); done: if (r->rt != PF_DUPTO) |