svn commit: r190962 - in head/sys: contrib/pf/net netinet

Robert Watson rwatson at FreeBSD.org
Sun Apr 12 11:42:42 UTC 2009


Author: rwatson
Date: Sun Apr 12 11:42:40 2009
New Revision: 190962
URL: http://svn.freebsd.org/changeset/base/190962

Log:
  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

Modified:
  head/sys/contrib/pf/net/pf.c
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet/udp_var.h

Modified: head/sys/contrib/pf/net/pf.c
==============================================================================
--- head/sys/contrib/pf/net/pf.c	Sun Apr 12 05:47:23 2009	(r190961)
+++ head/sys/contrib/pf/net/pf.c	Sun Apr 12 11:42:40 2009	(r190962)
@@ -6293,7 +6293,7 @@ pf_route(struct mbuf **m, struct pf_rule
 		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
 		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
 			TCPSTAT_INC(tcps_rcvbadsum);
 			break;
 		case IPPROTO_UDP:
-			V_udpstat.udps_badsum++;
+			UDPSTAT_INC(udps_badsum);
 			break;
 		case IPPROTO_ICMP:
 			V_icmpstat.icps_checksum++;

Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c	Sun Apr 12 05:47:23 2009	(r190961)
+++ head/sys/netinet/udp_usrreq.c	Sun Apr 12 11:42:40 2009	(r190962)
@@ -254,7 +254,7 @@ udp_append(struct inpcb *inp, struct ip 
 		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 mbu
 	((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);

Modified: head/sys/netinet/udp_var.h
==============================================================================
--- head/sys/netinet/udp_var.h	Sun Apr 12 05:47:23 2009	(r190961)
+++ head/sys/netinet/udp_var.h	Sun Apr 12 11:42:40 2009	(r190962)
@@ -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.
  */


More information about the svn-src-head mailing list