diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-04-11 23:35:20 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-04-11 23:35:20 +0000 |
commit | 692f8aa2fac966ef1adc29843ad741d355db1ecd (patch) | |
tree | 10c5a6d474eb50a7cbc30483b13c043872a03382 /sys/netinet/ip_fastfwd.c | |
parent | 000707192e4b75299e3d0c78425c7da549319f08 (diff) | |
download | FreeBSD-src-692f8aa2fac966ef1adc29843ad741d355db1ecd.zip FreeBSD-src-692f8aa2fac966ef1adc29843ad741d355db1ecd.tar.gz |
Update stats in struct ipstat using four new macros, IPSTAT_ADD(),
IPSTAT_INC(), IPSTAT_SUB(), and IPSTAT_DEC(), rather than directly
manipulating the fields across the kernel. This will make it easier
to change the implementation of these statistics, such as using
per-CPU versions of the data structures.
MFC after: 3 days
Diffstat (limited to 'sys/netinet/ip_fastfwd.c')
-rw-r--r-- | sys/netinet/ip_fastfwd.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c index ea106df..0479064 100644 --- a/sys/netinet/ip_fastfwd.c +++ b/sys/netinet/ip_fastfwd.c @@ -140,8 +140,8 @@ ip_findroute(struct route *ro, struct in_addr dest, struct mbuf *m) if (rt->rt_flags & RTF_GATEWAY) dst = (struct sockaddr_in *)rt->rt_gateway; } else { - V_ipstat.ips_noroute++; - V_ipstat.ips_cantforward++; + IPSTAT_INC(ips_noroute); + IPSTAT_INC(ips_cantforward); if (rt) RTFREE(rt); icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0); @@ -193,7 +193,7 @@ ip_fastforward(struct mbuf *m) * Is entire packet big enough? */ if (m->m_pkthdr.len < sizeof(struct ip)) { - V_ipstat.ips_tooshort++; + IPSTAT_INC(ips_tooshort); goto drop; } @@ -202,7 +202,7 @@ ip_fastforward(struct mbuf *m) */ if (m->m_len < sizeof (struct ip) && (m = m_pullup(m, sizeof (struct ip))) == NULL) { - V_ipstat.ips_toosmall++; + IPSTAT_INC(ips_toosmall); return NULL; /* mbuf already free'd */ } @@ -212,7 +212,7 @@ ip_fastforward(struct mbuf *m) * Is it IPv4? */ if (ip->ip_v != IPVERSION) { - V_ipstat.ips_badvers++; + IPSTAT_INC(ips_badvers); goto drop; } @@ -221,12 +221,12 @@ ip_fastforward(struct mbuf *m) */ hlen = ip->ip_hl << 2; if (hlen < sizeof(struct ip)) { /* minimum header length */ - V_ipstat.ips_badlen++; + IPSTAT_INC(ips_badlen); goto drop; } if (hlen > m->m_len) { if ((m = m_pullup(m, hlen)) == NULL) { - V_ipstat.ips_badhlen++; + IPSTAT_INC(ips_badhlen); return NULL; /* mbuf already free'd */ } ip = mtod(m, struct ip *); @@ -244,7 +244,7 @@ ip_fastforward(struct mbuf *m) sum = in_cksum(m, hlen); } if (sum) { - V_ipstat.ips_badsum++; + IPSTAT_INC(ips_badsum); goto drop; } @@ -259,7 +259,7 @@ ip_fastforward(struct mbuf *m) * Is IP length longer than packet we have got? */ if (m->m_pkthdr.len < ip_len) { - V_ipstat.ips_tooshort++; + IPSTAT_INC(ips_tooshort); goto drop; } @@ -279,7 +279,7 @@ ip_fastforward(struct mbuf *m) */ if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET || (ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) { - V_ipstat.ips_badaddr++; + IPSTAT_INC(ips_badaddr); goto drop; } @@ -337,7 +337,7 @@ ip_fastforward(struct mbuf *m) if (in_localip(ip->ip_dst)) return m; - V_ipstat.ips_total++; + IPSTAT_INC(ips_total); /* * Step 3: incoming packet firewall processing @@ -519,7 +519,7 @@ passout: */ if ((ifp->if_snd.ifq_len + ip->ip_len / ifp->if_mtu + 1) >= ifp->if_snd.ifq_maxlen) { - V_ipstat.ips_odropped++; + IPSTAT_INC(ips_odropped); /* would send source quench here but that is depreciated */ goto drop; } @@ -558,7 +558,7 @@ passout: * Handle EMSGSIZE with icmp reply needfrag for TCP MTU discovery */ if (ip->ip_off & IP_DF) { - V_ipstat.ips_cantfrag++; + IPSTAT_INC(ips_cantfrag); icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG, 0, mtu); goto consumed; @@ -596,16 +596,16 @@ passout: m_freem(m); } } else - V_ipstat.ips_fragmented++; + IPSTAT_INC(ips_fragmented); } } if (error != 0) - V_ipstat.ips_odropped++; + IPSTAT_INC(ips_odropped); else { ro.ro_rt->rt_rmx.rmx_pksent++; - V_ipstat.ips_forward++; - V_ipstat.ips_fastforward++; + IPSTAT_INC(ips_forward); + IPSTAT_INC(ips_fastforward); } consumed: RTFREE(ro.ro_rt); |