[Midnightbsd-cvs] src [9308] trunk: MFC r249294:
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Mar 2 18:34:51 EST 2017
Revision: 9308
http://svnweb.midnightbsd.org/src/?rev=9308
Author: laffer1
Date: 2017-03-02 18:34:51 -0500 (Thu, 02 Mar 2017)
Log Message:
-----------
MFC r249294:
Use IP6STAT_INC/IP6STAT_DEC macros to update ip6 stats.
MFC r249528,249546:
Add accounting to the source address selection algorithm for cases, when
it fails to select an address, also add several another counters to
the statistics.
MFC r249543,249552:
Replace hardcoded numbers.
MFC r249544:
Use IP6S_M2MMAX macro.
MFC r249545:
Replace hardcoded numbers. Also use interface-local scope name instead
of node-local.
Obtained from: FreeBSD
Revision Links:
--------------
http://svnweb.midnightbsd.org/src/?rev=249294
http://svnweb.midnightbsd.org/src/?rev=249528
http://svnweb.midnightbsd.org/src/?rev=249543
http://svnweb.midnightbsd.org/src/?rev=249544
http://svnweb.midnightbsd.org/src/?rev=249545
Modified Paths:
--------------
trunk/sys/net/if_bridge.c
trunk/sys/netinet/ip6.h
trunk/sys/netinet6/dest6.c
trunk/sys/netinet6/frag6.c
trunk/sys/netinet6/in6_gif.c
trunk/sys/netinet6/in6_src.c
trunk/sys/netinet6/ip6_forward.c
trunk/sys/netinet6/ip6_input.c
trunk/sys/netinet6/ip6_ipsec.c
trunk/sys/netinet6/ip6_mroute.c
trunk/sys/netinet6/ip6_output.c
trunk/sys/netinet6/ip6_var.h
trunk/sys/netinet6/raw_ip6.c
trunk/sys/netinet6/route6.c
trunk/sys/netipsec/ipsec_input.c
trunk/sys/netipsec/ipsec_output.c
trunk/usr.bin/netstat/inet6.c
Modified: trunk/sys/net/if_bridge.c
===================================================================
--- trunk/sys/net/if_bridge.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/net/if_bridge.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -3398,7 +3398,7 @@
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;
}
@@ -3405,7 +3405,7 @@
} 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;
}
@@ -3414,7 +3414,7 @@
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;
}
Modified: trunk/sys/netinet/ip6.h
===================================================================
--- trunk/sys/netinet/ip6.h 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet/ip6.h 2017-03-02 23:34:51 UTC (rev 9308)
@@ -276,17 +276,17 @@
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; \
} \
@@ -293,7 +293,7 @@
} \
} 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; \
Modified: trunk/sys/netinet6/dest6.c
===================================================================
--- trunk/sys/netinet6/dest6.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/dest6.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -94,7 +94,7 @@
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;
}
Modified: trunk/sys/netinet6/frag6.c
===================================================================
--- trunk/sys/netinet6/frag6.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/frag6.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -216,7 +216,7 @@
return IPPROTO_DONE;
}
- V_ip6stat.ip6s_fragments++;
+ IP6STAT_INC(ip6s_fragments);
in6_ifstat_inc(dstifp, ifs6_reass_reqd);
/* offset now points to data portion */
@@ -229,7 +229,7 @@
*/
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);
@@ -604,7 +604,7 @@
m->m_pkthdr.len = plen;
}
- V_ip6stat.ip6s_reassembled++;
+ IP6STAT_INC(ip6s_reassembled);
in6_ifstat_inc(dstifp, ifs6_reass_ok);
/*
@@ -620,7 +620,7 @@
dropfrag:
IP6Q_UNLOCK();
in6_ifstat_inc(dstifp, ifs6_reass_fail);
- V_ip6stat.ip6s_fragdropped++;
+ IP6STAT_INC(ip6s_fragdropped);
m_freem(m);
return IPPROTO_DONE;
}
@@ -744,7 +744,7 @@
--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);
}
@@ -756,7 +756,7 @@
*/
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);
}
@@ -782,7 +782,7 @@
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);
}
Modified: trunk/sys/netinet6/in6_gif.c
===================================================================
--- trunk/sys/netinet6/in6_gif.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/in6_gif.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -302,7 +302,7 @@
sc = (struct gif_softc *)encap_getarg(m);
if (sc == NULL) {
m_freem(m);
- V_ip6stat.ip6s_nogif++;
+ IP6STAT_INC(ip6s_nogif);
return IPPROTO_DONE;
}
@@ -309,7 +309,7 @@
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;
}
@@ -364,7 +364,7 @@
break;
default:
- V_ip6stat.ip6s_nogif++;
+ IP6STAT_INC(ip6s_nogif);
m_freem(m);
return IPPROTO_DONE;
}
Modified: trunk/sys/netinet6/in6_src.c
===================================================================
--- trunk/sys/netinet6/in6_src.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/in6_src.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -152,9 +152,8 @@
* an entry to the caller for later use.
*/
#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)]); \
+ 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)); \
@@ -162,9 +161,6 @@
goto replace; \
} while(0)
#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)]++; \
/* { \
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)); \
@@ -172,9 +168,8 @@
goto next; /* XXX: we can't use 'continue' here */ \
} while(0)
#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)]); \
+ rule = (r); \
goto out; /* XXX: we can't use 'break' here */ \
} while(0)
@@ -191,7 +186,7 @@
struct in6_addrpolicy *dst_policy = NULL, *best_policy = NULL;
u_int32_t odstzone;
int prefer_tempaddr;
- int error;
+ int error, rule;
struct ip6_moptions *mopts;
KASSERT(srcp != NULL, ("%s: srcp is NULL", __func__));
@@ -307,6 +302,7 @@
if (error)
return (error);
+ rule = 0;
IN6_IFADDR_RLOCK();
TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) {
int new_scope = -1, new_matchlen = -1;
@@ -488,6 +484,7 @@
if ((ia = ia_best) == NULL) {
IN6_IFADDR_RUNLOCK();
+ IP6STAT_INC(ip6s_sources_none);
return (EADDRNOTAVAIL);
}
@@ -504,6 +501,7 @@
if (cred != NULL && prison_local_ip6(cred, &tmp, (inp != NULL &&
(inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0) {
IN6_IFADDR_RUNLOCK();
+ IP6STAT_INC(ip6s_sources_none);
return (EADDRNOTAVAIL);
}
@@ -511,6 +509,16 @@
*ifpp = ifp;
bcopy(&tmp, srcp, sizeof(*srcp));
+ if (ia->ia_ifp == ifp)
+ IP6STAT_INC(ip6s_sources_sameif[best_scope]);
+ else
+ IP6STAT_INC(ip6s_sources_otherif[best_scope]);
+ if (dst_scope == best_scope)
+ IP6STAT_INC(ip6s_sources_samescope[best_scope]);
+ else
+ IP6STAT_INC(ip6s_sources_otherscope[best_scope]);
+ if (IFA6_IS_DEPRECATED(ia))
+ IP6STAT_INC(ip6s_sources_deprecated[best_scope]);
IN6_IFADDR_RUNLOCK();
return (0);
}
@@ -734,7 +742,7 @@
error = EHOSTUNREACH;
}
if (error == EHOSTUNREACH)
- V_ip6stat.ip6s_noroute++;
+ IP6STAT_INC(ip6s_noroute);
if (retifp != NULL) {
*retifp = ifp;
Modified: trunk/sys/netinet6/ip6_forward.c
===================================================================
--- trunk/sys/netinet6/ip6_forward.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/ip6_forward.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -136,7 +136,7 @@
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;
@@ -184,7 +184,7 @@
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 ? */
@@ -205,7 +205,7 @@
* This packet is just discarded.
*/
V_ipsec6stat.out_polvio++;
- V_ip6stat.ip6s_cantforward++;
+ IP6STAT_INC(ip6s_cantforward);
KEY_FREESP(&sp);
if (mcopy) {
#if 0
@@ -227,7 +227,7 @@
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
@@ -311,7 +311,7 @@
/* 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 ? */
@@ -363,7 +363,7 @@
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,
@@ -388,13 +388,13 @@
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
@@ -402,8 +402,8 @@
&& !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) {
@@ -433,8 +433,8 @@
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;
}
@@ -624,12 +624,12 @@
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;
Modified: trunk/sys/netinet6/ip6_input.c
===================================================================
--- trunk/sys/netinet6/ip6_input.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/ip6_input.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -358,7 +358,7 @@
* 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,
@@ -373,7 +373,7 @@
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
@@ -456,21 +456,20 @@
*/
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]++;
- } else if (m->m_pkthdr.rcvif->if_index < M2MMAX)
- V_ip6stat.ip6s_m2m[m->m_pkthdr.rcvif->if_index]++;
+ IP6STAT_INC(ip6s_m2m[V_loif->if_index]);
+ } else if (m->m_pkthdr.rcvif->if_index < IP6S_M2MMAX)
+ 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++;
-#undef M2MMAX
+ IP6STAT_INC(ip6s_m1);
}
/* drop the packet if IPv6 operation is disabled on the IF */
@@ -480,7 +479,7 @@
}
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive);
- V_ip6stat.ip6s_total++;
+ IP6STAT_INC(ip6s_total);
#ifndef PULLDOWN_TEST
/*
@@ -518,7 +517,7 @@
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;
}
@@ -527,12 +526,12 @@
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.
@@ -542,7 +541,7 @@
/*
* 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;
}
@@ -554,7 +553,7 @@
* 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;
}
@@ -579,7 +578,7 @@
*/
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;
}
@@ -593,7 +592,7 @@
*/
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;
}
@@ -656,12 +655,12 @@
* 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;
}
@@ -865,7 +864,7 @@
* 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;
}
@@ -919,7 +918,7 @@
* 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;
}
@@ -971,7 +970,7 @@
*/
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;
}
@@ -979,13 +978,13 @@
/*
* 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;
}
@@ -994,7 +993,7 @@
* 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;
}
@@ -1088,7 +1087,7 @@
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;
@@ -1095,7 +1094,7 @@
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
@@ -1140,7 +1139,7 @@
break;
case IP6OPT_PADN:
if (hbhlen < IP6OPT_MINLEN) {
- V_ip6stat.ip6s_toosmall++;
+ IP6STAT_INC(ip6s_toosmall);
goto bad;
}
optlen = *(opt + 1) + 2;
@@ -1148,7 +1147,7 @@
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) {
@@ -1165,7 +1164,7 @@
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) {
@@ -1183,7 +1182,7 @@
*/
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);
@@ -1207,7 +1206,7 @@
* 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);
@@ -1219,7 +1218,7 @@
* 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);
@@ -1230,7 +1229,7 @@
break;
default: /* unknown option */
if (hbhlen < IP6OPT_MINLEN) {
- V_ip6stat.ip6s_toosmall++;
+ IP6STAT_INC(ip6s_toosmall);
goto bad;
}
optlen = ip6_unknown_opt(opt, m,
@@ -1267,11 +1266,11 @@
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)))
@@ -1450,7 +1449,7 @@
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 *);
@@ -1457,7 +1456,7 @@
hbhlen = (hbh->ip6h_len + 1) << 3;
if (hbhlen != ext->m_len) {
m_freem(ext);
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return;
}
#endif
@@ -1524,7 +1523,7 @@
#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 *);
@@ -1534,7 +1533,7 @@
elen = (ip6e->ip6e_len + 1) << 3;
if (elen != ext->m_len) {
m_freem(ext);
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return;
}
#endif
Modified: trunk/sys/netinet6/ip6_ipsec.c
===================================================================
--- trunk/sys/netinet6/ip6_ipsec.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/ip6_ipsec.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -153,7 +153,7 @@
KEY_FREESP(&sp);
splx(s);
if (error) {
- V_ip6stat.ip6s_cantforward++;
+ IP6STAT_INC(ip6s_cantforward);
return 1;
}
#endif /* IPSEC */
Modified: trunk/sys/netinet6/ip6_mroute.c
===================================================================
--- trunk/sys/netinet6/ip6_mroute.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/ip6_mroute.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -1101,7 +1101,7 @@
* (although such packets must normally set 1 to the hop limit field).
*/
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
- V_ip6stat.ip6s_cantforward++;
+ IP6STAT_INC(ip6s_cantforward);
if (V_ip6_log_time + V_ip6_log_interval < time_second) {
V_ip6_log_time = time_second;
log(LOG_DEBUG,
@@ -1536,7 +1536,7 @@
dst0 = ip6->ip6_dst;
if ((error = in6_setscope(&src0, ifp, &iszone)) != 0 ||
(error = in6_setscope(&dst0, ifp, &idzone)) != 0) {
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
return (error);
}
for (mifp = mif6table, mifi = 0; mifi < nummifs; mifp++, mifi++) {
@@ -1556,7 +1556,7 @@
&odzone) ||
iszone != oszone ||
idzone != odzone) {
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
continue;
}
}
Modified: trunk/sys/netinet6/ip6_output.c
===================================================================
--- trunk/sys/netinet6/ip6_output.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/ip6_output.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -499,16 +499,16 @@
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) &&
(flags & IPV6_UNSPECSRC) == 0) {
error = EOPNOTSUPP;
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
goto bad;
}
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) {
error = EOPNOTSUPP;
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
goto bad;
}
- V_ip6stat.ip6s_localout++;
+ IP6STAT_INC(ip6s_localout);
/*
* Route packet.
@@ -714,7 +714,7 @@
goto routefound;
badscope:
- V_ip6stat.ip6s_badscope++;
+ IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(origifp, ifs6_out_discard);
if (error == 0)
error = EHOSTUNREACH; /* XXX */
@@ -743,7 +743,7 @@
* Confirm that the outgoing interface supports multicast.
*/
if (!(ifp->if_flags & IFF_MULTICAST)) {
- V_ip6stat.ip6s_noroute++;
+ IP6STAT_INC(ip6s_noroute);
in6_ifstat_inc(ifp, ifs6_out_discard);
error = ENETUNREACH;
goto bad;
@@ -1076,7 +1076,7 @@
if (qslots <= 0 || ((u_int)qslots * (mtu - hlen)
< tlen /* - hlen */)) {
error = ENOBUFS;
- V_ip6stat.ip6s_odropped++;
+ IP6STAT_INC(ip6s_odropped);
goto bad;
}
@@ -1126,7 +1126,7 @@
MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (!m) {
error = ENOBUFS;
- V_ip6stat.ip6s_odropped++;
+ IP6STAT_INC(ip6s_odropped);
goto sendorfree;
}
m->m_pkthdr.rcvif = NULL;
@@ -1139,7 +1139,7 @@
m->m_len = sizeof(*mhip6);
error = ip6_insertfraghdr(m0, m, hlen, &ip6f);
if (error) {
- V_ip6stat.ip6s_odropped++;
+ IP6STAT_INC(ip6s_odropped);
goto sendorfree;
}
ip6f->ip6f_offlg = htons((u_short)((off - hlen) & ~7));
@@ -1151,7 +1151,7 @@
sizeof(*ip6f) - sizeof(struct ip6_hdr)));
if ((m_frgpart = m_copy(m0, off, len)) == 0) {
error = ENOBUFS;
- V_ip6stat.ip6s_odropped++;
+ IP6STAT_INC(ip6s_odropped);
goto sendorfree;
}
m_cat(m, m_frgpart);
@@ -1160,7 +1160,7 @@
ip6f->ip6f_reserved = 0;
ip6f->ip6f_ident = id;
ip6f->ip6f_nxt = nextproto;
- V_ip6stat.ip6s_ofragments++;
+ IP6STAT_INC(ip6s_ofragments);
in6_ifstat_inc(ifp, ifs6_out_fragcreat);
}
@@ -1189,7 +1189,7 @@
}
if (error == 0)
- V_ip6stat.ip6s_fragmented++;
+ IP6STAT_INC(ip6s_fragmented);
done:
if (ro == &ip6route)
Modified: trunk/sys/netinet6/ip6_var.h
===================================================================
--- trunk/sys/netinet6/ip6_var.h 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/ip6_var.h 2017-03-02 23:34:51 UTC (rev 9308)
@@ -205,9 +205,11 @@
u_quad_t ip6s_rawout; /* total raw ip packets generated */
u_quad_t ip6s_badscope; /* scope error */
u_quad_t ip6s_notmember; /* don't join this multicast group */
- u_quad_t ip6s_nxthist[256]; /* next header history */
+#define IP6S_HDRCNT 256 /* headers count */
+ u_quad_t ip6s_nxthist[IP6S_HDRCNT]; /* next header history */
u_quad_t ip6s_m1; /* one mbuf */
- u_quad_t ip6s_m2m[32]; /* two or more mbuf */
+#define IP6S_M2MMAX 32
+ u_quad_t ip6s_m2m[IP6S_M2MMAX]; /* two or more mbuf */
u_quad_t ip6s_mext1; /* one ext mbuf */
u_quad_t ip6s_mext2m; /* two or more ext mbuf */
u_quad_t ip6s_exthdrtoolong; /* ext hdr are not contiguous */
@@ -219,27 +221,29 @@
* algorithm:
* XXX: hardcoded 16 = # of ip6 multicast scope types + 1
*/
+#define IP6S_RULESMAX 16
+#define IP6S_SCOPECNT 16
/* number of times that address selection fails */
u_quad_t ip6s_sources_none;
/* number of times that an address on the outgoing I/F is chosen */
- u_quad_t ip6s_sources_sameif[16];
+ u_quad_t ip6s_sources_sameif[IP6S_SCOPECNT];
/* number of times that an address on a non-outgoing I/F is chosen */
- u_quad_t ip6s_sources_otherif[16];
+ u_quad_t ip6s_sources_otherif[IP6S_SCOPECNT];
/*
* number of times that an address that has the same scope
* from the destination is chosen.
*/
- u_quad_t ip6s_sources_samescope[16];
+ u_quad_t ip6s_sources_samescope[IP6S_SCOPECNT];
/*
* number of times that an address that has a different scope
* from the destination is chosen.
*/
- u_quad_t ip6s_sources_otherscope[16];
+ u_quad_t ip6s_sources_otherscope[IP6S_SCOPECNT];
/* number of times that a deprecated address is chosen */
- u_quad_t ip6s_sources_deprecated[16];
+ u_quad_t ip6s_sources_deprecated[IP6S_SCOPECNT];
/* number of times that each rule of source selection is applied. */
- u_quad_t ip6s_sources_rule[16];
+ u_quad_t ip6s_sources_rule[IP6S_RULESMAX];
};
#ifdef _KERNEL
Modified: trunk/sys/netinet6/raw_ip6.c
===================================================================
--- trunk/sys/netinet6/raw_ip6.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/raw_ip6.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -297,7 +297,7 @@
if ((last != NULL) && ipsec6_in_reject(m, last)) {
m_freem(m);
V_ipsec6stat.in_polvio++;
- V_ip6stat.ip6s_delivered--;
+ IP6STAT_DEC(ip6s_delivered);
/* Do not inject data into pcb. */
INP_RUNLOCK(last);
} else
@@ -329,7 +329,7 @@
ICMP6_PARAMPROB_NEXTHEADER,
prvnxtp - mtod(m, char *));
}
- V_ip6stat.ip6s_delivered--;
+ IP6STAT_DEC(ip6s_delivered);
}
return (IPPROTO_DONE);
}
Modified: trunk/sys/netinet6/route6.c
===================================================================
--- trunk/sys/netinet6/route6.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netinet6/route6.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -70,7 +70,7 @@
if (ip6a) {
/* XXX reject home-address option before rthdr */
if (ip6a->ip6a_flags & IP6A_SWAP) {
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
m_freem(m);
return IPPROTO_DONE;
}
@@ -85,7 +85,7 @@
ip6 = mtod(m, struct ip6_hdr *);
IP6_EXTHDR_GET(rh, struct ip6_rthdr *, m, off, sizeof(*rh));
if (rh == NULL) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
return IPPROTO_DONE;
}
#endif
@@ -101,7 +101,7 @@
rhlen = (rh->ip6r_len + 1) << 3;
break; /* Final dst. Just ignore the header. */
}
- V_ip6stat.ip6s_badoptions++;
+ IP6STAT_INC(ip6s_badoptions);
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
(caddr_t)&rh->ip6r_type - (caddr_t)ip6);
return (IPPROTO_DONE);
Modified: trunk/sys/netipsec/ipsec_input.c
===================================================================
--- trunk/sys/netipsec/ipsec_input.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netipsec/ipsec_input.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -768,7 +768,7 @@
nxt = nxt8;
while (nxt != IPPROTO_DONE) {
if (V_ip6_hdrnestlimit && (++nest > V_ip6_hdrnestlimit)) {
- V_ip6stat.ip6s_toomanyhdr++;
+ IP6STAT_INC(ip6s_toomanyhdr);
error = EINVAL;
goto bad;
}
@@ -778,7 +778,7 @@
* more sanity checks in header chain processing.
*/
if (m->m_pkthdr.len < skip) {
- V_ip6stat.ip6s_tooshort++;
+ IP6STAT_INC(ip6s_tooshort);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
error = EINVAL;
goto bad;
Modified: trunk/sys/netipsec/ipsec_output.c
===================================================================
--- trunk/sys/netipsec/ipsec_output.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/sys/netipsec/ipsec_output.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -869,7 +869,7 @@
rtalloc_ign_fib(state->ro, 0UL, M_GETFIB(m));
}
if (state->ro->ro_rt == NULL) {
- V_ip6stat.ip6s_noroute++;
+ IP6STAT_INC(ip6s_noroute);
V_ipsec6stat.ips_out_noroute++;
error = EHOSTUNREACH;
goto bad;
Modified: trunk/usr.bin/netstat/inet6.c
===================================================================
--- trunk/usr.bin/netstat/inet6.c 2017-03-02 23:33:22 UTC (rev 9307)
+++ trunk/usr.bin/netstat/inet6.c 2017-03-02 23:34:51 UTC (rev 9308)
@@ -408,7 +408,7 @@
p(ip6s_cantfrag, "\t%ju datagram%s that can't be fragmented\n");
p(ip6s_badscope, "\t%ju packet%s that violated scope rules\n");
p(ip6s_notmember, "\t%ju multicast packet%s which we don't join\n");
- for (first = 1, i = 0; i < 256; i++)
+ for (first = 1, i = 0; i < IP6S_HDRCNT; i++)
if (ip6stat.ip6s_nxthist[i] != 0) {
if (first) {
printf("\tInput histogram:\n");
@@ -419,7 +419,7 @@
}
printf("\tMbuf statistics:\n");
printf("\t\t%ju one mbuf\n", (uintmax_t)ip6stat.ip6s_m1);
- for (first = 1, i = 0; i < 32; i++) {
+ for (first = 1, i = 0; i < IP6S_M2MMAX; i++) {
char ifbuf[IFNAMSIZ];
if (ip6stat.ip6s_m2m[i] != 0) {
if (first) {
@@ -445,7 +445,7 @@
#define PRINT_SCOPESTAT(s,i) do {\
switch(i) { /* XXX hardcoding in each case */\
case 1:\
- p(s, "\t\t%ju node-local%s\n");\
+ p(s, "\t\t%ju interface-local%s\n");\
break;\
case 2:\
p(s,"\t\t%ju link-local%s\n");\
@@ -464,7 +464,7 @@
p(ip6s_sources_none,
"\t%ju failure%s of source address selection\n");
- for (first = 1, i = 0; i < 16; i++) {
+ for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_sameif[i]) {
if (first) {
printf("\tsource addresses on an outgoing I/F\n");
@@ -473,7 +473,7 @@
PRINT_SCOPESTAT(ip6s_sources_sameif[i], i);
}
}
- for (first = 1, i = 0; i < 16; i++) {
+ for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_otherif[i]) {
if (first) {
printf("\tsource addresses on a non-outgoing I/F\n");
@@ -482,7 +482,7 @@
PRINT_SCOPESTAT(ip6s_sources_otherif[i], i);
}
}
- for (first = 1, i = 0; i < 16; i++) {
+ for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_samescope[i]) {
if (first) {
printf("\tsource addresses of same scope\n");
@@ -491,7 +491,7 @@
PRINT_SCOPESTAT(ip6s_sources_samescope[i], i);
}
}
- for (first = 1, i = 0; i < 16; i++) {
+ for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_otherscope[i]) {
if (first) {
printf("\tsource addresses of a different scope\n");
@@ -500,7 +500,7 @@
PRINT_SCOPESTAT(ip6s_sources_otherscope[i], i);
}
}
- for (first = 1, i = 0; i < 16; i++) {
+ for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_deprecated[i]) {
if (first) {
printf("\tdeprecated source addresses\n");
@@ -511,7 +511,7 @@
}
printf("\tSource addresses selection rule applied:\n");
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < IP6S_RULESMAX; i++) {
if (ip6stat.ip6s_sources_rule[i])
printf("\t\t%ju %s\n",
(uintmax_t)ip6stat.ip6s_sources_rule[i],
More information about the Midnightbsd-cvs
mailing list