Skip to content

Commit

Permalink
Use IP6STAT_INC/IP6STAT_DEC macros to update ip6 stats.
Browse files Browse the repository at this point in the history
MFC after:	1 week
  • Loading branch information
bu7cher committed Apr 9, 2013
1 parent 1184231 commit 844d612
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 101 deletions.
6 changes: 3 additions & 3 deletions sys/net/if_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3336,14 +3336,14 @@ bridge_ip6_checkbasic(struct mbuf **mp)
if ((m = m_copyup(m, sizeof(struct ip6_hdr),
(max_linkhdr + 3) & ~3)) == NULL) {
/* XXXJRT new stat, please */
V_ip6stat.ip6s_toosmall++;
IP6STAT_INC(ip6s_toosmall);
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
goto bad;
}
} else if (__predict_false(m->m_len < sizeof(struct ip6_hdr))) {
struct ifnet *inifp = m->m_pkthdr.rcvif;
if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
V_ip6stat.ip6s_toosmall++;
IP6STAT_INC(ip6s_toosmall);
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
goto bad;
}
Expand All @@ -3352,7 +3352,7 @@ bridge_ip6_checkbasic(struct mbuf **mp)
ip6 = mtod(m, struct ip6_hdr *);

if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
V_ip6stat.ip6s_badvers++;
IP6STAT_INC(ip6s_badvers);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
goto bad;
}
Expand Down
8 changes: 4 additions & 4 deletions sys/netinet/ip6.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,24 @@ do { \
if (((m)->m_flags & M_LOOP) && \
((m)->m_len < (off) + (hlen)) && \
(((m) = m_pullup((m), (off) + (hlen))) == NULL)) { \
V_ip6stat.ip6s_exthdrtoolong++; \
IP6STAT_INC(ip6s_exthdrtoolong); \
return ret; \
} else if ((m)->m_flags & M_EXT) { \
if ((m)->m_len < (off) + (hlen)) { \
V_ip6stat.ip6s_exthdrtoolong++; \
IP6STAT_INC(ip6s_exthdrtoolong); \
m_freem(m); \
return ret; \
} \
} else { \
if ((m)->m_len < (off) + (hlen)) { \
V_ip6stat.ip6s_exthdrtoolong++; \
IP6STAT_INC(ip6s_exthdrtoolong); \
m_freem(m); \
return ret; \
} \
} \
} else { \
if ((m)->m_len < (off) + (hlen)) { \
V_ip6stat.ip6s_tooshort++; \
IP6STAT_INC(ip6s_tooshort); \
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated); \
m_freem(m); \
return ret; \
Expand Down
2 changes: 1 addition & 1 deletion sys/netinet6/dest6.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dest6_input(struct mbuf **mp, int *offp, int proto)
for (optlen = 0; dstoptlen > 0; dstoptlen -= optlen, opt += optlen) {
if (*opt != IP6OPT_PAD1 &&
(dstoptlen < IP6OPT_MINLEN || *(opt + 1) + 2 > dstoptlen)) {
V_ip6stat.ip6s_toosmall++;
IP6STAT_INC(ip6s_toosmall);
goto bad;
}

Expand Down
14 changes: 7 additions & 7 deletions sys/netinet6/frag6.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
return IPPROTO_DONE;
}

V_ip6stat.ip6s_fragments++;
IP6STAT_INC(ip6s_fragments);
in6_ifstat_inc(dstifp, ifs6_reass_reqd);

/* offset now points to data portion */
Expand All @@ -228,7 +228,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
*/
if ((ip6f->ip6f_offlg & ~IP6F_RESERVED_MASK) == 0) {
/* XXX-BZ we want dedicated counters for this. */
V_ip6stat.ip6s_reassembled++;
IP6STAT_INC(ip6s_reassembled);
in6_ifstat_inc(dstifp, ifs6_reass_ok);
*offp = offset;
return (ip6f->ip6f_nxt);
Expand Down Expand Up @@ -603,7 +603,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
m->m_pkthdr.len = plen;
}

V_ip6stat.ip6s_reassembled++;
IP6STAT_INC(ip6s_reassembled);
in6_ifstat_inc(dstifp, ifs6_reass_ok);

/*
Expand All @@ -619,7 +619,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
dropfrag:
IP6Q_UNLOCK();
in6_ifstat_inc(dstifp, ifs6_reass_fail);
V_ip6stat.ip6s_fragdropped++;
IP6STAT_INC(ip6s_fragdropped);
m_freem(m);
return IPPROTO_DONE;
}
Expand Down Expand Up @@ -743,7 +743,7 @@ frag6_slowtimo(void)
--q6->ip6q_ttl;
q6 = q6->ip6q_next;
if (q6->ip6q_prev->ip6q_ttl == 0) {
V_ip6stat.ip6s_fragtimeout++;
IP6STAT_INC(ip6s_fragtimeout);
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(q6->ip6q_prev);
}
Expand All @@ -755,7 +755,7 @@ frag6_slowtimo(void)
*/
while (V_frag6_nfragpackets > (u_int)V_ip6_maxfragpackets &&
V_ip6q.ip6q_prev) {
V_ip6stat.ip6s_fragoverflow++;
IP6STAT_INC(ip6s_fragoverflow);
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(V_ip6q.ip6q_prev);
}
Expand All @@ -781,7 +781,7 @@ frag6_drain(void)
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
while (V_ip6q.ip6q_next != &V_ip6q) {
V_ip6stat.ip6s_fragdropped++;
IP6STAT_INC(ip6s_fragdropped);
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(V_ip6q.ip6q_next);
}
Expand Down
6 changes: 3 additions & 3 deletions sys/netinet6/in6_gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ in6_gif_input(struct mbuf **mp, int *offp, int proto)
sc = (struct gif_softc *)encap_getarg(m);
if (sc == NULL) {
m_freem(m);
V_ip6stat.ip6s_nogif++;
IP6STAT_INC(ip6s_nogif);
return IPPROTO_DONE;
}

gifp = GIF2IFP(sc);
if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
m_freem(m);
V_ip6stat.ip6s_nogif++;
IP6STAT_INC(ip6s_nogif);
return IPPROTO_DONE;
}

Expand Down Expand Up @@ -361,7 +361,7 @@ in6_gif_input(struct mbuf **mp, int *offp, int proto)
break;

default:
V_ip6stat.ip6s_nogif++;
IP6STAT_INC(ip6s_nogif);
m_freem(m);
return IPPROTO_DONE;
}
Expand Down
8 changes: 4 additions & 4 deletions sys/netinet6/in6_src.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
#define REPLACE(r) do {\
if ((r) < sizeof(V_ip6stat.ip6s_sources_rule) / \
sizeof(V_ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
V_ip6stat.ip6s_sources_rule[(r)]++; \
IP6STAT_INC(ip6s_sources_rule[(r)]); \
/* { \
char ip6buf[INET6_ADDRSTRLEN], ip6b[INET6_ADDRSTRLEN]; \
printf("in6_selectsrc: replace %s with %s by %d\n", ia_best ? ip6_sprintf(ip6buf, &ia_best->ia_addr.sin6_addr) : "none", ip6_sprintf(ip6b, &ia->ia_addr.sin6_addr), (r)); \
Expand All @@ -163,7 +163,7 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
#define NEXT(r) do {\
if ((r) < sizeof(V_ip6stat.ip6s_sources_rule) / \
sizeof(V_ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
V_ip6stat.ip6s_sources_rule[(r)]++; \
IP6STAT_INC(ip6s_sources_rule[(r)]); \
/* { \
char ip6buf[INET6_ADDRSTRLEN], ip6b[INET6_ADDRSTRLEN]; \
printf("in6_selectsrc: keep %s against %s by %d\n", ia_best ? ip6_sprintf(ip6buf, &ia_best->ia_addr.sin6_addr) : "none", ip6_sprintf(ip6b, &ia->ia_addr.sin6_addr), (r)); \
Expand All @@ -173,7 +173,7 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
#define BREAK(r) do { \
if ((r) < sizeof(V_ip6stat.ip6s_sources_rule) / \
sizeof(V_ip6stat.ip6s_sources_rule[0])) /* check for safety */ \
V_ip6stat.ip6s_sources_rule[(r)]++; \
IP6STAT_INC(ip6s_sources_rule[(r)]); \
goto out; /* XXX: we can't use 'break' here */ \
} while(0)

Expand Down Expand Up @@ -734,7 +734,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
error = EHOSTUNREACH;
}
if (error == EHOSTUNREACH)
V_ip6stat.ip6s_noroute++;
IP6STAT_INC(ip6s_noroute);

if (retifp != NULL) {
*retifp = ifp;
Expand Down
34 changes: 17 additions & 17 deletions sys/netinet6/ip6_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ ip6_forward(struct mbuf *m, int srcrt)
if ((m->m_flags & (M_BCAST|M_MCAST)) != 0 ||
IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
V_ip6stat.ip6s_cantforward++;
IP6STAT_INC(ip6s_cantforward);
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */
if (V_ip6_log_time + V_ip6_log_interval < time_second) {
V_ip6_log_time = time_second;
Expand Down Expand Up @@ -183,7 +183,7 @@ ip6_forward(struct mbuf *m, int srcrt)
IP_FORWARDING, &error);
if (sp == NULL) {
V_ipsec6stat.out_inval++;
V_ip6stat.ip6s_cantforward++;
IP6STAT_INC(ip6s_cantforward);
if (mcopy) {
#if 0
/* XXX: what icmp ? */
Expand All @@ -204,7 +204,7 @@ ip6_forward(struct mbuf *m, int srcrt)
* This packet is just discarded.
*/
V_ipsec6stat.out_polvio++;
V_ip6stat.ip6s_cantforward++;
IP6STAT_INC(ip6s_cantforward);
KEY_FREESP(&sp);
if (mcopy) {
#if 0
Expand All @@ -226,7 +226,7 @@ ip6_forward(struct mbuf *m, int srcrt)
if (sp->req == NULL) {
/* XXX should be panic ? */
printf("ip6_forward: No IPsec request specified.\n");
V_ip6stat.ip6s_cantforward++;
IP6STAT_INC(ip6s_cantforward);
KEY_FREESP(&sp);
if (mcopy) {
#if 0
Expand Down Expand Up @@ -310,7 +310,7 @@ ip6_forward(struct mbuf *m, int srcrt)
/* don't show these error codes to the user */
break;
}
V_ip6stat.ip6s_cantforward++;
IP6STAT_INC(ip6s_cantforward);
if (mcopy) {
#if 0
/* XXX: what icmp ? */
Expand Down Expand Up @@ -362,7 +362,7 @@ ip6_forward(struct mbuf *m, int srcrt)
if (rin6.ro_rt != NULL)
RT_UNLOCK(rin6.ro_rt);
else {
V_ip6stat.ip6s_noroute++;
IP6STAT_INC(ip6s_noroute);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute);
if (mcopy) {
icmp6_error(mcopy, ICMP6_DST_UNREACH,
Expand All @@ -387,22 +387,22 @@ ip6_forward(struct mbuf *m, int srcrt)
src_in6 = ip6->ip6_src;
if (in6_setscope(&src_in6, rt->rt_ifp, &outzone)) {
/* XXX: this should not happen */
V_ip6stat.ip6s_cantforward++;
V_ip6stat.ip6s_badscope++;
IP6STAT_INC(ip6s_cantforward);
IP6STAT_INC(ip6s_badscope);
goto bad;
}
if (in6_setscope(&src_in6, m->m_pkthdr.rcvif, &inzone)) {
V_ip6stat.ip6s_cantforward++;
V_ip6stat.ip6s_badscope++;
IP6STAT_INC(ip6s_cantforward);
IP6STAT_INC(ip6s_badscope);
goto bad;
}
if (inzone != outzone
#ifdef IPSEC
&& !ipsecrt
#endif
) {
V_ip6stat.ip6s_cantforward++;
V_ip6stat.ip6s_badscope++;
IP6STAT_INC(ip6s_cantforward);
IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard);

if (V_ip6_log_time + V_ip6_log_interval < time_second) {
Expand Down Expand Up @@ -432,8 +432,8 @@ ip6_forward(struct mbuf *m, int srcrt)
if (in6_setscope(&dst_in6, m->m_pkthdr.rcvif, &inzone) != 0 ||
in6_setscope(&dst_in6, rt->rt_ifp, &outzone) != 0 ||
inzone != outzone) {
V_ip6stat.ip6s_cantforward++;
V_ip6stat.ip6s_badscope++;
IP6STAT_INC(ip6s_cantforward);
IP6STAT_INC(ip6s_badscope);
goto bad;
}

Expand Down Expand Up @@ -623,12 +623,12 @@ ip6_forward(struct mbuf *m, int srcrt)
error = nd6_output(rt->rt_ifp, origifp, m, dst, rt);
if (error) {
in6_ifstat_inc(rt->rt_ifp, ifs6_out_discard);
V_ip6stat.ip6s_cantforward++;
IP6STAT_INC(ip6s_cantforward);
} else {
V_ip6stat.ip6s_forward++;
IP6STAT_INC(ip6s_forward);
in6_ifstat_inc(rt->rt_ifp, ifs6_out_forward);
if (type)
V_ip6stat.ip6s_redirectsent++;
IP6STAT_INC(ip6s_redirectsent);
else {
if (mcopy)
goto freecopy;
Expand Down
Loading

0 comments on commit 844d612

Please sign in to comment.