summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/ip6_input.c
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2013-04-09 07:11:22 +0000
committerae <ae@FreeBSD.org>2013-04-09 07:11:22 +0000
commit844d612b2ac90320a94987519d82dca04334da1e (patch)
treea37444a753245c5a506d831125e8ba84425b9fc6 /sys/netinet6/ip6_input.c
parent11842319432af11ae4828f76bb503310ea1780a6 (diff)
downloadFreeBSD-src-844d612b2ac90320a94987519d82dca04334da1e.zip
FreeBSD-src-844d612b2ac90320a94987519d82dca04334da1e.tar.gz
Use IP6STAT_INC/IP6STAT_DEC macros to update ip6 stats.
MFC after: 1 week
Diffstat (limited to 'sys/netinet6/ip6_input.c')
-rw-r--r--sys/netinet6/ip6_input.c79
1 files changed, 40 insertions, 39 deletions
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index e037737..fcbe4cb 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -364,7 +364,7 @@ ip6_input_hbh(struct mbuf *m, uint32_t *plen, uint32_t *rtalert, int *off,
* contained, ip6_hopopts_input() must set a valid
* (non-zero) payload length to the variable plen.
*/
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
icmp6_error(m, ICMP6_PARAM_PROB,
@@ -379,7 +379,7 @@ ip6_input_hbh(struct mbuf *m, uint32_t *plen, uint32_t *rtalert, int *off,
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
sizeof(struct ip6_hbh));
if (hbh == NULL) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
goto out;
}
#endif
@@ -462,20 +462,21 @@ ip6_input(struct mbuf *m)
*/
if (m->m_flags & M_EXT) {
if (m->m_next)
- V_ip6stat.ip6s_mext2m++;
+ IP6STAT_INC(ip6s_mext2m);
else
- V_ip6stat.ip6s_mext1++;
+ IP6STAT_INC(ip6s_mext1);
} else {
#define M2MMAX (sizeof(V_ip6stat.ip6s_m2m)/sizeof(V_ip6stat.ip6s_m2m[0]))
if (m->m_next) {
if (m->m_flags & M_LOOP) {
- V_ip6stat.ip6s_m2m[V_loif->if_index]++;
+ IP6STAT_INC(ip6s_m2m[V_loif->if_index]);
} else if (m->m_pkthdr.rcvif->if_index < M2MMAX)
- V_ip6stat.ip6s_m2m[m->m_pkthdr.rcvif->if_index]++;
+ IP6STAT_INC(
+ ip6s_m2m[m->m_pkthdr.rcvif->if_index]);
else
- V_ip6stat.ip6s_m2m[0]++;
+ IP6STAT_INC(ip6s_m2m[0]);
} else
- V_ip6stat.ip6s_m1++;
+ IP6STAT_INC(ip6s_m1);
#undef M2MMAX
}
@@ -486,7 +487,7 @@ ip6_input(struct mbuf *m)
}
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive);
- V_ip6stat.ip6s_total++;
+ IP6STAT_INC(ip6s_total);
#ifndef PULLDOWN_TEST
/*
@@ -519,7 +520,7 @@ ip6_input(struct mbuf *m)
struct ifnet *inifp;
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);
return;
}
@@ -528,12 +529,12 @@ ip6_input(struct mbuf *m)
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;
}
- V_ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
+ IP6STAT_INC(ip6s_nxthist[ip6->ip6_nxt]);
/*
* Check against address spoofing/corruption.
@@ -543,7 +544,7 @@ ip6_input(struct mbuf *m)
/*
* XXX: "badscope" is not very suitable for a multicast source.
*/
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -555,7 +556,7 @@ ip6_input(struct mbuf *m)
* because ip6_mloopback() passes the "actual" interface
* as the outgoing/incoming interface.
*/
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -580,7 +581,7 @@ ip6_input(struct mbuf *m)
*/
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -594,7 +595,7 @@ ip6_input(struct mbuf *m)
*/
if (IN6_IS_ADDR_V4COMPAT(&ip6->ip6_src) ||
IN6_IS_ADDR_V4COMPAT(&ip6->ip6_dst)) {
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -657,12 +658,12 @@ passin:
* is not loopback.
*/
if (in6_clearscope(&ip6->ip6_src) || in6_clearscope(&ip6->ip6_dst)) {
- V_ip6stat.ip6s_badscope++; /* XXX */
+ IP6STAT_INC(ip6s_badscope); /* XXX */
goto bad;
}
if (in6_setscope(&ip6->ip6_src, m->m_pkthdr.rcvif, NULL) ||
in6_setscope(&ip6->ip6_dst, m->m_pkthdr.rcvif, NULL)) {
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
goto bad;
}
@@ -866,7 +867,7 @@ passin:
* and we're not a router.
*/
if (!V_ip6_forwarding) {
- V_ip6stat.ip6s_cantforward++;
+ IP6STAT_INC(ip6s_cantforward);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
goto bad;
}
@@ -920,7 +921,7 @@ passin:
* Drop packet if shorter than we expect.
*/
if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
goto bad;
}
@@ -972,7 +973,7 @@ passin:
*/
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@@ -980,13 +981,13 @@ passin:
/*
* Tell launch routine the next header
*/
- V_ip6stat.ip6s_delivered++;
+ IP6STAT_INC(ip6s_delivered);
in6_ifstat_inc(deliverifp, ifs6_in_deliver);
nest = 0;
while (nxt != IPPROTO_DONE) {
if (V_ip6_hdrnestlimit && (++nest > V_ip6_hdrnestlimit)) {
- V_ip6stat.ip6s_toomanyhdr++;
+ IP6STAT_INC(ip6s_toomanyhdr);
goto bad;
}
@@ -995,7 +996,7 @@ passin:
* more sanity checks in header chain processing.
*/
if (m->m_pkthdr.len < off) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
goto bad;
}
@@ -1089,14 +1090,14 @@ ip6_hopopts_input(u_int32_t *plenp, u_int32_t *rtalertp,
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m,
sizeof(struct ip6_hdr), sizeof(struct ip6_hbh));
if (hbh == NULL) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return -1;
}
hbhlen = (hbh->ip6h_len + 1) << 3;
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
hbhlen);
if (hbh == NULL) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return -1;
}
#endif
@@ -1141,7 +1142,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
break;
case IP6OPT_PADN:
if (hbhlen < IP6OPT_MINLEN) {
- V_ip6stat.ip6s_toosmall++;
+ IP6STAT_INC(ip6s_toosmall);
goto bad;
}
optlen = *(opt + 1) + 2;
@@ -1149,7 +1150,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
case IP6OPT_ROUTER_ALERT:
/* XXX may need check for alignment */
if (hbhlen < IP6OPT_RTALERT_LEN) {
- V_ip6stat.ip6s_toosmall++;
+ IP6STAT_INC(ip6s_toosmall);
goto bad;
}
if (*(opt + 1) != IP6OPT_RTALERT_LEN - 2) {
@@ -1166,7 +1167,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
case IP6OPT_JUMBO:
/* XXX may need check for alignment */
if (hbhlen < IP6OPT_JUMBO_LEN) {
- V_ip6stat.ip6s_toosmall++;
+ IP6STAT_INC(ip6s_toosmall);
goto bad;
}
if (*(opt + 1) != IP6OPT_JUMBO_LEN - 2) {
@@ -1184,7 +1185,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
*/
ip6 = mtod(m, struct ip6_hdr *);
if (ip6->ip6_plen) {
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt - opthead);
@@ -1208,7 +1209,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
* there's no explicit mention in specification.
*/
if (*plenp != 0) {
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt + 2 - opthead);
@@ -1220,7 +1221,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
* jumbo payload length must be larger than 65535.
*/
if (jumboplen <= IPV6_MAXPACKET) {
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt + 2 - opthead);
@@ -1231,7 +1232,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
break;
default: /* unknown option */
if (hbhlen < IP6OPT_MINLEN) {
- V_ip6stat.ip6s_toosmall++;
+ IP6STAT_INC(ip6s_toosmall);
goto bad;
}
optlen = ip6_unknown_opt(opt, m,
@@ -1268,11 +1269,11 @@ ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off)
m_freem(m);
return (-1);
case IP6OPT_TYPE_FORCEICMP: /* send ICMP even if multicasted */
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION, off);
return (-1);
case IP6OPT_TYPE_ICMP: /* send ICMP if not multicasted */
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
ip6 = mtod(m, struct ip6_hdr *);
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
(m->m_flags & (M_BCAST|M_MCAST)))
@@ -1451,14 +1452,14 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
ext = ip6_pullexthdr(m, sizeof(struct ip6_hdr),
ip6->ip6_nxt);
if (ext == NULL) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return;
}
hbh = mtod(ext, struct ip6_hbh *);
hbhlen = (hbh->ip6h_len + 1) << 3;
if (hbhlen != ext->m_len) {
m_freem(ext);
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return;
}
#endif
@@ -1525,7 +1526,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
#else
ext = ip6_pullexthdr(m, off, nxt);
if (ext == NULL) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return;
}
ip6e = mtod(ext, struct ip6_ext *);
@@ -1535,7 +1536,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
elen = (ip6e->ip6e_len + 1) << 3;
if (elen != ext->m_len) {
m_freem(ext);
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return;
}
#endif
OpenPOWER on IntegriCloud