Update stats in struct udpstat using two new macros, UDPSTAT_ADD()

and UDPSTAT_INC(), 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-12 11:42:40 +00:00
parent cc2a51aaf7
commit 026decb8f3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190962
3 changed files with 19 additions and 14 deletions

View File

@ -6293,7 +6293,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
if (m0->m_pkthdr.csum_flags & M_TCPV4_CSUM_OUT)
TCPSTAT_INC(tcpstat.tcps_outhwcsum);
else if (m0->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT)
V_udpstat.udps_outhwcsum++;
UDPSTAT_INC(udps_outhwcsum);
error = (*ifp->if_output)(ifp, m0, sintosa(dst), NULL);
goto done;
}
@ -6641,7 +6641,7 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p, sa_family_t a
case IPPROTO_UDP:
{
INIT_VNET_INET(curvnet);
V_udpstat.udps_badsum++;
UDPSTAT_INC(udps_badsum);
break;
}
case IPPROTO_ICMP:
@ -6744,7 +6744,7 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p,
TCPSTAT_INC(tcps_rcvbadsum);
break;
case IPPROTO_UDP:
V_udpstat.udps_badsum++;
UDPSTAT_INC(udps_badsum);
break;
case IPPROTO_ICMP:
V_icmpstat.icps_checksum++;

View File

@ -254,7 +254,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off,
m_freem(n);
if (opts)
m_freem(opts);
V_udpstat.udps_fullsock++;
UDPSTAT_INC(udps_fullsock);
} else
sorwakeup_locked(so);
}
@ -276,7 +276,7 @@ udp_input(struct mbuf *m, int off)
#endif
ifp = m->m_pkthdr.rcvif;
V_udpstat.udps_ipackets++;
UDPSTAT_INC(udps_ipackets);
/*
* Strip IP options, if any; should skip this, make available to
@ -294,7 +294,7 @@ udp_input(struct mbuf *m, int off)
ip = mtod(m, struct ip *);
if (m->m_len < iphlen + sizeof(struct udphdr)) {
if ((m = m_pullup(m, iphlen + sizeof(struct udphdr))) == 0) {
V_udpstat.udps_hdrops++;
UDPSTAT_INC(udps_hdrops);
return;
}
ip = mtod(m, struct ip *);
@ -324,7 +324,7 @@ udp_input(struct mbuf *m, int off)
len = ntohs((u_short)uh->uh_ulen);
if (ip->ip_len != len) {
if (len > ip->ip_len || len < sizeof(struct udphdr)) {
V_udpstat.udps_badlen++;
UDPSTAT_INC(udps_badlen);
goto badunlocked;
}
m_adj(m, len - ip->ip_len);
@ -364,12 +364,12 @@ udp_input(struct mbuf *m, int off)
bcopy(b, ((struct ipovly *)ip)->ih_x1, 9);
}
if (uh_sum) {
V_udpstat.udps_badsum++;
UDPSTAT_INC(udps_badsum);
m_freem(m);
return;
}
} else
V_udpstat.udps_nosum++;
UDPSTAT_INC(udps_nosum);
#ifdef IPFIREWALL_FORWARD
/*
@ -442,7 +442,7 @@ udp_input(struct mbuf *m, int off)
IPSTAT_INC(ips_notmember);
if (blocked == MCAST_NOTSMEMBER ||
blocked == MCAST_MUTED)
V_udpstat.udps_filtermcast++;
UDPSTAT_INC(udps_filtermcast);
INP_RUNLOCK(inp);
continue;
}
@ -494,7 +494,7 @@ udp_input(struct mbuf *m, int off)
* to send an ICMP Port Unreachable for a broadcast
* or multicast datgram.)
*/
V_udpstat.udps_noportbcast++;
UDPSTAT_INC(udps_noportbcast);
goto badheadlocked;
}
if (last->inp_ppcb == NULL) {
@ -531,9 +531,9 @@ udp_input(struct mbuf *m, int off)
buf, ntohs(uh->uh_dport), inet_ntoa(ip->ip_src),
ntohs(uh->uh_sport));
}
V_udpstat.udps_noport++;
UDPSTAT_INC(udps_noport);
if (m->m_flags & (M_BCAST | M_MCAST)) {
V_udpstat.udps_noportbcast++;
UDPSTAT_INC(udps_noportbcast);
goto badheadlocked;
}
if (V_udp_blackhole)
@ -1072,7 +1072,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
V_udpstat.udps_opackets++;
UDPSTAT_INC(udps_opackets);
if (unlock_udbinfo == 2)
INP_INFO_WUNLOCK(&V_udbinfo);

View File

@ -71,6 +71,11 @@ struct udpstat {
u_long udps_filtermcast; /* blocked by multicast filter */
};
#ifdef _KERNEL
#define UDPSTAT_ADD(name, val) V_udpstat.name += (val)
#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1)
#endif
/*
* Names for UDP sysctl objects.
*/