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
This commit is contained in:
Robert Watson 2009-04-11 23:35:20 +00:00
parent 7970a63721
commit 86425c62a0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190951
13 changed files with 106 additions and 101 deletions

View File

@ -6153,7 +6153,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
if (r->rt == PF_FASTROUTE) {
in_rtalloc(ro, 0);
if (ro->ro_rt == 0) {
V_ipstat.ips_noroute++;
IPSTAT_INC(ips_noroute);
goto bad;
}
@ -6284,7 +6284,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
if ((ifp->if_capabilities & IFCAP_CSUM_IPv4) &&
ifp->if_bridge == NULL) {
m0->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT;
V_ipstat.ips_outhwcsum++;
IPSTAT_INC(ips_outhwcsum);
} else {
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m0, ip->ip_hl << 2);
@ -6303,7 +6303,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
* Must be able to put at least 8 bytes per fragment.
*/
if (ip->ip_off & htons(IP_DF)) {
V_ipstat.ips_cantfrag++;
IPSTAT_INC(ips_cantfrag);
if (r->rt != PF_DUPTO) {
#ifdef __FreeBSD__
/* icmp_error() expects host byte ordering */
@ -6360,7 +6360,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
}
if (error == 0)
V_ipstat.ips_fragmented++;
IPSTAT_INC(ips_fragmented);
done:
if (r->rt != PF_DUPTO)

View File

@ -3243,12 +3243,12 @@ bridge_ip_checkbasic(struct mbuf **mp)
if ((m = m_copyup(m, sizeof(struct ip),
(max_linkhdr + 3) & ~3)) == NULL) {
/* XXXJRT new stat, please */
V_ipstat.ips_toosmall++;
IPSTAT_INC(ips_toosmall);
goto bad;
}
} else if (__predict_false(m->m_len < sizeof (struct ip))) {
if ((m = m_pullup(m, sizeof (struct ip))) == NULL) {
V_ipstat.ips_toosmall++;
IPSTAT_INC(ips_toosmall);
goto bad;
}
}
@ -3256,17 +3256,17 @@ bridge_ip_checkbasic(struct mbuf **mp)
if (ip == NULL) goto bad;
if (ip->ip_v != IPVERSION) {
V_ipstat.ips_badvers++;
IPSTAT_INC(ips_badvers);
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen < sizeof(struct ip)) { /* minimum header length */
V_ipstat.ips_badhlen++;
IPSTAT_INC(ips_badhlen);
goto bad;
}
if (hlen > m->m_len) {
if ((m = m_pullup(m, hlen)) == 0) {
V_ipstat.ips_badhlen++;
IPSTAT_INC(ips_badhlen);
goto bad;
}
ip = mtod(m, struct ip *);
@ -3283,7 +3283,7 @@ bridge_ip_checkbasic(struct mbuf **mp)
}
}
if (sum) {
V_ipstat.ips_badsum++;
IPSTAT_INC(ips_badsum);
goto bad;
}
@ -3294,7 +3294,7 @@ bridge_ip_checkbasic(struct mbuf **mp)
* Check for additional length bogosity
*/
if (len < hlen) {
V_ipstat.ips_badlen++;
IPSTAT_INC(ips_badlen);
goto bad;
}
@ -3304,7 +3304,7 @@ bridge_ip_checkbasic(struct mbuf **mp)
* Drop packet if shorter than we expect.
*/
if (m->m_pkthdr.len < len) {
V_ipstat.ips_tooshort++;
IPSTAT_INC(ips_tooshort);
goto bad;
}
@ -3419,7 +3419,7 @@ bridge_fragment(struct ifnet *ifp, struct mbuf *m, struct ether_header *eh,
}
if (error == 0)
V_ipstat.ips_fragmented++;
IPSTAT_INC(ips_fragmented);
return (error);

View File

@ -3413,7 +3413,7 @@ igmp_intr(struct mbuf *m)
CTR3(KTR_IGMPV3, "%s: dropped %p as ifindex %u went away.",
__func__, m, ifindex);
m_freem(m);
V_ipstat.ips_noroute++;
IPSTAT_INC(ips_noroute);
goto out;
}
@ -3441,7 +3441,7 @@ igmp_intr(struct mbuf *m)
if (m0 == NULL) {
CTR2(KTR_IGMPV3, "%s: dropped %p", __func__, m);
m_freem(m);
V_ipstat.ips_odropped++;
IPSTAT_INC(ips_odropped);
goto out;
}
}

View File

@ -273,14 +273,14 @@ in_gif_input(struct mbuf *m, int off)
sc = (struct gif_softc *)encap_getarg(m);
if (sc == NULL) {
m_freem(m);
V_ipstat.ips_nogif++;
IPSTAT_INC(ips_nogif);
return;
}
gifp = GIF2IFP(sc);
if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
m_freem(m);
V_ipstat.ips_nogif++;
IPSTAT_INC(ips_nogif);
return;
}
@ -340,7 +340,7 @@ in_gif_input(struct mbuf *m, int off)
break;
default:
V_ipstat.ips_nogif++;
IPSTAT_INC(ips_nogif);
m_freem(m);
return;
}

View File

@ -186,7 +186,7 @@ div_input(struct mbuf *m, int off)
{
INIT_VNET_INET(curvnet);
V_ipstat.ips_noproto++;
IPSTAT_INC(ips_noproto);
m_freem(m);
}
@ -307,8 +307,8 @@ divert_packet(struct mbuf *m, int incoming)
INP_INFO_RUNLOCK(&V_divcbinfo);
if (sa == NULL) {
m_freem(m);
V_ipstat.ips_noproto++;
V_ipstat.ips_delivered--;
IPSTAT_INC(ips_noproto);
IPSTAT_DEC(ips_delivered);
}
}
@ -394,7 +394,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
ip->ip_off = ntohs(ip->ip_off);
/* Send packet to output processing */
V_ipstat.ips_rawout++; /* XXX */
IPSTAT_INC(ips_rawout); /* XXX */
#ifdef MAC
mac_inpcb_create_mbuf(inp, m);
@ -570,7 +570,7 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
/* Packet must have a header (but that's about it) */
if (m->m_len < sizeof (struct ip) &&
(m = m_pullup(m, sizeof (struct ip))) == 0) {
V_ipstat.ips_toosmall++;
IPSTAT_INC(ips_toosmall);
m_freem(m);
return EINVAL;
}

View File

@ -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 @@ ip_fastforward(struct mbuf *m)
*/
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 @@ ip_fastforward(struct mbuf *m)
* 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 @@ ip_fastforward(struct mbuf *m)
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);

View File

@ -381,31 +381,31 @@ ip_input(struct mbuf *m)
goto ours;
}
V_ipstat.ips_total++;
IPSTAT_INC(ips_total);
if (m->m_pkthdr.len < sizeof(struct ip))
goto tooshort;
if (m->m_len < sizeof (struct ip) &&
(m = m_pullup(m, sizeof (struct ip))) == NULL) {
V_ipstat.ips_toosmall++;
IPSTAT_INC(ips_toosmall);
return;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
V_ipstat.ips_badvers++;
IPSTAT_INC(ips_badvers);
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen < sizeof(struct ip)) { /* minimum header length */
V_ipstat.ips_badhlen++;
IPSTAT_INC(ips_badhlen);
goto bad;
}
if (hlen > m->m_len) {
if ((m = m_pullup(m, hlen)) == NULL) {
V_ipstat.ips_badhlen++;
IPSTAT_INC(ips_badhlen);
return;
}
ip = mtod(m, struct ip *);
@ -415,7 +415,7 @@ ip_input(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) {
if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) == 0) {
V_ipstat.ips_badaddr++;
IPSTAT_INC(ips_badaddr);
goto bad;
}
}
@ -430,7 +430,7 @@ ip_input(struct mbuf *m)
}
}
if (sum) {
V_ipstat.ips_badsum++;
IPSTAT_INC(ips_badsum);
goto bad;
}
@ -445,7 +445,7 @@ ip_input(struct mbuf *m)
*/
ip->ip_len = ntohs(ip->ip_len);
if (ip->ip_len < hlen) {
V_ipstat.ips_badlen++;
IPSTAT_INC(ips_badlen);
goto bad;
}
ip->ip_off = ntohs(ip->ip_off);
@ -458,7 +458,7 @@ ip_input(struct mbuf *m)
*/
if (m->m_pkthdr.len < ip->ip_len) {
tooshort:
V_ipstat.ips_tooshort++;
IPSTAT_INC(ips_tooshort);
goto bad;
}
if (m->m_pkthdr.len > ip->ip_len) {
@ -609,7 +609,7 @@ ip_input(struct mbuf *m)
}
/* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */
if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) {
V_ipstat.ips_cantforward++;
IPSTAT_INC(ips_cantforward);
m_freem(m);
return;
}
@ -625,7 +625,7 @@ ip_input(struct mbuf *m)
*/
if (ip_mforward &&
ip_mforward(ip, m->m_pkthdr.rcvif, m, 0) != 0) {
V_ipstat.ips_cantforward++;
IPSTAT_INC(ips_cantforward);
m_freem(m);
return;
}
@ -637,7 +637,7 @@ ip_input(struct mbuf *m)
*/
if (ip->ip_p == IPPROTO_IGMP)
goto ours;
V_ipstat.ips_forward++;
IPSTAT_INC(ips_forward);
}
/*
* Assume the packet is for us, to avoid prematurely taking
@ -667,7 +667,7 @@ ip_input(struct mbuf *m)
* Not for us; forward if possible and desirable.
*/
if (V_ipforwarding == 0) {
V_ipstat.ips_cantforward++;
IPSTAT_INC(ips_cantforward);
m_freem(m);
} else {
#ifdef IPSEC
@ -727,7 +727,7 @@ ip_input(struct mbuf *m)
/*
* Switch out to protocol's input routine.
*/
V_ipstat.ips_delivered++;
IPSTAT_INC(ips_delivered);
(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);
return;
@ -825,8 +825,8 @@ ip_reass(struct mbuf *m)
/* If maxnipq or maxfragsperpacket are 0, never accept fragments. */
if (V_maxnipq == 0 || V_maxfragsperpacket == 0) {
V_ipstat.ips_fragments++;
V_ipstat.ips_fragdropped++;
IPSTAT_INC(ips_fragments);
IPSTAT_INC(ips_fragdropped);
m_freem(m);
return (NULL);
}
@ -868,14 +868,14 @@ ip_reass(struct mbuf *m)
for (i = 0; i < IPREASS_NHASH; i++) {
struct ipq *r = TAILQ_LAST(&V_ipq[i], ipqhead);
if (r) {
V_ipstat.ips_fragtimeout +=
r->ipq_nfrags;
IPSTAT_ADD(ips_fragtimeout,
r->ipq_nfrags);
ip_freef(&V_ipq[i], r);
break;
}
}
} else {
V_ipstat.ips_fragtimeout += q->ipq_nfrags;
IPSTAT_ADD(ips_fragtimeout, q->ipq_nfrags);
ip_freef(head, q);
}
}
@ -892,7 +892,7 @@ ip_reass(struct mbuf *m)
* that's a non-zero multiple of 8 bytes.
*/
if (ip->ip_len == 0 || (ip->ip_len & 0x7) != 0) {
V_ipstat.ips_toosmall++; /* XXX */
IPSTAT_INC(ips_toosmall); /* XXX */
goto dropfrag;
}
m->m_flags |= M_FRAG;
@ -905,7 +905,7 @@ ip_reass(struct mbuf *m)
* Attempt reassembly; if it succeeds, proceed.
* ip_reass() will return a different mbuf.
*/
V_ipstat.ips_fragments++;
IPSTAT_INC(ips_fragments);
m->m_pkthdr.header = ip;
/* Previous ip_reass() started here. */
@ -1016,7 +1016,7 @@ ip_reass(struct mbuf *m)
}
nq = q->m_nextpkt;
m->m_nextpkt = nq;
V_ipstat.ips_fragdropped++;
IPSTAT_INC(ips_fragdropped);
fp->ipq_nfrags--;
m_freem(q);
}
@ -1035,7 +1035,7 @@ ip_reass(struct mbuf *m)
for (p = NULL, q = fp->ipq_frags; q; p = q, q = q->m_nextpkt) {
if (GETIP(q)->ip_off != next) {
if (fp->ipq_nfrags > V_maxfragsperpacket) {
V_ipstat.ips_fragdropped += fp->ipq_nfrags;
IPSTAT_ADD(ips_fragdropped, fp->ipq_nfrags);
ip_freef(head, fp);
}
goto done;
@ -1045,7 +1045,7 @@ ip_reass(struct mbuf *m)
/* Make sure the last packet didn't have the IP_MF flag */
if (p->m_flags & M_FRAG) {
if (fp->ipq_nfrags > V_maxfragsperpacket) {
V_ipstat.ips_fragdropped += fp->ipq_nfrags;
IPSTAT_ADD(ips_fragdropped, fp->ipq_nfrags);
ip_freef(head, fp);
}
goto done;
@ -1057,8 +1057,8 @@ ip_reass(struct mbuf *m)
q = fp->ipq_frags;
ip = GETIP(q);
if (next + (ip->ip_hl << 2) > IP_MAXPACKET) {
V_ipstat.ips_toolong++;
V_ipstat.ips_fragdropped += fp->ipq_nfrags;
IPSTAT_INC(ips_toolong);
IPSTAT_ADD(ips_fragdropped, fp->ipq_nfrags);
ip_freef(head, fp);
goto done;
}
@ -1107,12 +1107,12 @@ ip_reass(struct mbuf *m)
/* some debugging cruft by sklower, below, will go away soon */
if (m->m_flags & M_PKTHDR) /* XXX this should be done elsewhere */
m_fixhdr(m);
V_ipstat.ips_reassembled++;
IPSTAT_INC(ips_reassembled);
IPQ_UNLOCK();
return (m);
dropfrag:
V_ipstat.ips_fragdropped++;
IPSTAT_INC(ips_fragdropped);
if (fp != NULL)
fp->ipq_nfrags--;
m_freem(m);
@ -1169,8 +1169,8 @@ ip_slowtimo(void)
fpp = fp;
fp = TAILQ_NEXT(fp, ipq_list);
if(--fpp->ipq_ttl == 0) {
V_ipstat.ips_fragtimeout +=
fpp->ipq_nfrags;
IPSTAT_ADD(ips_fragtimeout,
fpp->ipq_nfrags);
ip_freef(&V_ipq[i], fpp);
}
}
@ -1184,8 +1184,8 @@ ip_slowtimo(void)
for (i = 0; i < IPREASS_NHASH; i++) {
while (V_nipq > V_maxnipq &&
!TAILQ_EMPTY(&V_ipq[i])) {
V_ipstat.ips_fragdropped +=
TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
IPSTAT_ADD(ips_fragdropped,
TAILQ_FIRST(&V_ipq[i])->ipq_nfrags);
ip_freef(&V_ipq[i],
TAILQ_FIRST(&V_ipq[i]));
}
@ -1213,8 +1213,8 @@ ip_drain(void)
INIT_VNET_INET(vnet_iter);
for (i = 0; i < IPREASS_NHASH; i++) {
while(!TAILQ_EMPTY(&V_ipq[i])) {
V_ipstat.ips_fragdropped +=
TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
IPSTAT_ADD(ips_fragdropped,
TAILQ_FIRST(&V_ipq[i])->ipq_nfrags);
ip_freef(&V_ipq[i], TAILQ_FIRST(&V_ipq[i]));
}
}
@ -1346,7 +1346,7 @@ ip_forward(struct mbuf *m, int srcrt)
int error, type = 0, code = 0, mtu = 0;
if (m->m_flags & (M_BCAST|M_MCAST) || in_canforward(ip->ip_dst) == 0) {
V_ipstat.ips_cantforward++;
IPSTAT_INC(ips_cantforward);
m_freem(m);
return;
}
@ -1465,11 +1465,11 @@ ip_forward(struct mbuf *m, int srcrt)
RTFREE(ro.ro_rt);
if (error)
V_ipstat.ips_cantforward++;
IPSTAT_INC(ips_cantforward);
else {
V_ipstat.ips_forward++;
IPSTAT_INC(ips_forward);
if (type)
V_ipstat.ips_redirectsent++;
IPSTAT_INC(ips_redirectsent);
else {
if (mcopy)
m_freem(mcopy);
@ -1521,7 +1521,7 @@ ip_forward(struct mbuf *m, int srcrt)
else
mtu = ip_next_mtu(ip->ip_len, 0);
}
V_ipstat.ips_cantfrag++;
IPSTAT_INC(ips_cantfrag);
break;
case ENOBUFS:

View File

@ -129,7 +129,7 @@ ip_ipsec_fwd(struct mbuf *m)
KEY_FREESP(&sp);
splx(s);
if (error) {
V_ipstat.ips_cantforward++;
IPSTAT_INC(ips_cantforward);
return 1;
}
#endif /* IPSEC */

View File

@ -218,7 +218,7 @@ ip_dooptions(struct mbuf *m, int pass)
#ifdef IPSTEALTH
dropit:
#endif
V_ipstat.ips_cantforward++;
IPSTAT_INC(ips_cantforward);
m_freem(m);
return (1);
}
@ -366,7 +366,7 @@ ip_dooptions(struct mbuf *m, int pass)
return (0);
bad:
icmp_error(m, type, code, 0, 0);
V_ipstat.ips_badoptions++;
IPSTAT_INC(ips_badoptions);
return (1);
}

View File

@ -182,7 +182,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
ip->ip_v = IPVERSION;
ip->ip_hl = hlen >> 2;
ip->ip_id = ip_newid();
V_ipstat.ips_localout++;
IPSTAT_INC(ips_localout);
} else {
hlen = ip->ip_hl << 2;
}
@ -221,7 +221,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
if (flags & IP_SENDONES) {
if ((ia = ifatoia(ifa_ifwithbroadaddr(sintosa(dst)))) == NULL &&
(ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL) {
V_ipstat.ips_noroute++;
IPSTAT_INC(ips_noroute);
error = ENETUNREACH;
goto bad;
}
@ -233,7 +233,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
} else if (flags & IP_ROUTETOIF) {
if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL &&
(ia = ifatoia(ifa_ifwithnet(sintosa(dst)))) == NULL) {
V_ipstat.ips_noroute++;
IPSTAT_INC(ips_noroute);
error = ENETUNREACH;
goto bad;
}
@ -265,7 +265,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m));
#endif
if (ro->ro_rt == NULL) {
V_ipstat.ips_noroute++;
IPSTAT_INC(ips_noroute);
error = EHOSTUNREACH;
goto bad;
}
@ -322,7 +322,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
*/
if ((imo == NULL) || (imo->imo_multicast_vif == -1)) {
if ((ifp->if_flags & IFF_MULTICAST) == 0) {
V_ipstat.ips_noroute++;
IPSTAT_INC(ips_noroute);
error = ENETUNREACH;
goto bad;
}
@ -420,7 +420,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
#endif /* ALTQ */
{
error = ENOBUFS;
V_ipstat.ips_odropped++;
IPSTAT_INC(ips_odropped);
ifp->if_snd.ifq_drops += (ip->ip_len / ifp->if_mtu + 1);
goto bad;
}
@ -538,7 +538,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET ||
(ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) {
if ((ifp->if_flags & IFF_LOOPBACK) == 0) {
V_ipstat.ips_badaddr++;
IPSTAT_INC(ips_badaddr);
error = EADDRNOTAVAIL;
goto bad;
}
@ -602,7 +602,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
/* Balk when DF bit is set or the interface didn't support TSO. */
if ((ip->ip_off & IP_DF) || (m->m_pkthdr.csum_flags & CSUM_TSO)) {
error = EMSGSIZE;
V_ipstat.ips_cantfrag++;
IPSTAT_INC(ips_cantfrag);
goto bad;
}
@ -635,7 +635,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
}
if (error == 0)
V_ipstat.ips_fragmented++;
IPSTAT_INC(ips_fragmented);
done:
if (ro == &iproute && ro->ro_rt) {
@ -671,7 +671,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
int nfrags;
if (ip->ip_off & IP_DF) { /* Fragmentation not allowed */
V_ipstat.ips_cantfrag++;
IPSTAT_INC(ips_cantfrag);
return EMSGSIZE;
}
@ -752,7 +752,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
error = ENOBUFS;
V_ipstat.ips_odropped++;
IPSTAT_INC(ips_odropped);
goto done;
}
m->m_flags |= (m0->m_flags & M_MCAST) | M_FRAG;
@ -782,7 +782,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
if (m->m_next == NULL) { /* copy failed */
m_free(m);
error = ENOBUFS; /* ??? */
V_ipstat.ips_odropped++;
IPSTAT_INC(ips_odropped);
goto done;
}
m->m_pkthdr.len = mhlen + len;
@ -798,7 +798,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
*mnext = m;
mnext = &m->m_nextpkt;
}
V_ipstat.ips_ofragments += nfrags;
IPSTAT_ADD(ips_ofragments, nfrags);
/* set first marker for fragment chain */
m0->m_flags |= M_FIRSTFRAG | M_FRAG;

View File

@ -132,6 +132,11 @@ struct ipstat {
#ifdef _KERNEL
#define IPSTAT_ADD(name, val) V_ipstat.name += (val)
#define IPSTAT_SUB(name, val) V_ipstat.name -= (val)
#define IPSTAT_INC(name) IPSTAT_ADD(name, 1)
#define IPSTAT_DEC(name) IPSTAT_SUB(name, 1)
/* flags passed to ip_output as last parameter */
#define IP_FORWARDING 0x1 /* most of ip header exists */
#define IP_RAWOUTPUT 0x2 /* raw ip header exists */

View File

@ -345,7 +345,7 @@ rip_input(struct mbuf *m, int off)
(struct sockaddr *)&group,
(struct sockaddr *)&ripsrc);
if (blocked != MCAST_PASS) {
V_ipstat.ips_notmember++;
IPSTAT_INC(ips_notmember);
continue;
}
}
@ -364,12 +364,12 @@ rip_input(struct mbuf *m, int off)
INP_INFO_RUNLOCK(&V_ripcbinfo);
if (last != NULL) {
if (rip_append(last, ip, m, &ripsrc) != 0)
V_ipstat.ips_delivered--;
IPSTAT_INC(ips_delivered);
INP_RUNLOCK(last);
} else {
m_freem(m);
V_ipstat.ips_noproto++;
V_ipstat.ips_delivered--;
IPSTAT_INC(ips_noproto);
IPSTAT_DEC(ips_delivered);
}
}
@ -450,7 +450,7 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
* XXX prevent ip_output from overwriting header fields.
*/
flags |= IP_RAWOUTPUT;
V_ipstat.ips_rawout++;
IPSTAT_INC(ips_rawout);
}
if (inp->inp_flags & INP_ONESBCAST)

View File

@ -439,7 +439,7 @@ udp_input(struct mbuf *m, int off)
(struct sockaddr *)&udp_in);
if (blocked != MCAST_PASS) {
if (blocked == MCAST_NOTGMEMBER)
V_ipstat.ips_notmember++;
IPSTAT_INC(ips_notmember);
if (blocked == MCAST_NOTSMEMBER ||
blocked == MCAST_MUTED)
V_udpstat.udps_filtermcast++;