Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Apr 2009 14:06:26 +0000 (UTC)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r190967 - head/sys/netinet
Message-ID:  <200904121406.n3CE6QSH027497@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rwatson
Date: Sun Apr 12 14:06:26 2009
New Revision: 190967
URL: http://svn.freebsd.org/changeset/base/190967

Log:
  Update stats in struct pimstat using two new macros: PIMSTAT_ADD()
  and PIMSTAT_INC(), rather than directly manipulating the fields of
  the structure.  This will make it easier to change the
  implementation of these statistics, such as using per-CPU versions
  of the data structure.
  
  MFC after:	3 days

Modified:
  head/sys/netinet/ip_mroute.c
  head/sys/netinet/pim_var.h

Modified: head/sys/netinet/ip_mroute.c
==============================================================================
--- head/sys/netinet/ip_mroute.c	Sun Apr 12 14:00:36 2009	(r190966)
+++ head/sys/netinet/ip_mroute.c	Sun Apr 12 14:06:26 2009	(r190967)
@@ -1515,7 +1515,7 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp
 	if (pim_assert_enabled && (vifi < numvifs) && viftable[vifi].v_ifp) {
 
 	    if (ifp == &multicast_register_if)
-		pimstat.pims_rcv_registers_wrongiif++;
+		PIMSTAT_INC(pims_rcv_registers_wrongiif);
 
 	    /* Get vifi for the incoming packet */
 	    for (vifi=0; vifi < numvifs && viftable[vifi].v_ifp != ifp; vifi++)
@@ -2440,8 +2440,8 @@ pim_register_send_upcall(struct ip *ip, 
     }
 
     /* Keep statistics */
-    pimstat.pims_snd_registers_msgs++;
-    pimstat.pims_snd_registers_bytes += len;
+    PIMSTAT_INC(pims_snd_registers_msgs);
+    PIMSTAT_ADD(pims_snd_registers_bytes, len);
 
     return 0;
 }
@@ -2511,8 +2511,8 @@ pim_register_send_rp(struct ip *ip, stru
     send_packet(vifp, mb_first);
 
     /* Keep statistics */
-    pimstat.pims_snd_registers_msgs++;
-    pimstat.pims_snd_registers_bytes += len;
+    PIMSTAT_INC(pims_snd_registers_msgs);
+    PIMSTAT_ADD(pims_snd_registers_bytes, len);
 
     return 0;
 }
@@ -2554,14 +2554,14 @@ pim_input(struct mbuf *m, int off)
     int iphlen = off;
 
     /* Keep statistics */
-    pimstat.pims_rcv_total_msgs++;
-    pimstat.pims_rcv_total_bytes += datalen;
+    PIMSTAT_INC(pims_rcv_total_msgs);
+    PIMSTAT_ADD(pims_rcv_total_bytes, datalen);
 
     /*
      * Validate lengths
      */
     if (datalen < PIM_MINLEN) {
-	pimstat.pims_rcv_tooshort++;
+	PIMSTAT_INC(pims_rcv_tooshort);
 	CTR3(KTR_IPMF, "%s: short packet (%d) from %s",
 	    __func__, datalen, inet_ntoa(ip->ip_src));
 	m_freem(m);
@@ -2606,7 +2606,7 @@ pim_input(struct mbuf *m, int off)
     if (PIM_VT_T(pim->pim_vt) == PIM_REGISTER && in_cksum(m, PIM_MINLEN) == 0) {
 	/* do nothing, checksum okay */
     } else if (in_cksum(m, datalen)) {
-	pimstat.pims_rcv_badsum++;
+	PIMSTAT_INC(pims_rcv_badsum);
 	CTR1(KTR_IPMF, "%s: invalid checksum", __func__);
 	m_freem(m);
 	return;
@@ -2614,7 +2614,7 @@ pim_input(struct mbuf *m, int off)
 
     /* PIM version check */
     if (PIM_VT_V(pim->pim_vt) < PIM_VERSION) {
-	pimstat.pims_rcv_badversion++;
+	PIMSTAT_INC(pims_rcv_badversion);
 	CTR3(KTR_IPMF, "%s: bad version %d expect %d", __func__,
 	    (int)PIM_VT_V(pim->pim_vt), PIM_VERSION);
 	m_freem(m);
@@ -2653,8 +2653,8 @@ pim_input(struct mbuf *m, int off)
 	 * Validate length
 	 */
 	if (datalen < PIM_REG_MINLEN) {
-	    pimstat.pims_rcv_tooshort++;
-	    pimstat.pims_rcv_badregisters++;
+	    PIMSTAT_INC(pims_rcv_tooshort);
+	    PIMSTAT_INC(pims_rcv_badregisters);
 	    CTR1(KTR_IPMF, "%s: register packet size too small", __func__);
 	    m_freem(m);
 	    return;
@@ -2668,7 +2668,7 @@ pim_input(struct mbuf *m, int off)
 
 	/* verify the version number of the inner packet */
 	if (encap_ip->ip_v != IPVERSION) {
-	    pimstat.pims_rcv_badregisters++;
+	    PIMSTAT_INC(pims_rcv_badregisters);
 	    CTR1(KTR_IPMF, "%s: bad encap ip version", __func__);
 	    m_freem(m);
 	    return;
@@ -2676,7 +2676,7 @@ pim_input(struct mbuf *m, int off)
 
 	/* verify the inner packet is destined to a mcast group */
 	if (!IN_MULTICAST(ntohl(encap_ip->ip_dst.s_addr))) {
-	    pimstat.pims_rcv_badregisters++;
+	    PIMSTAT_INC(pims_rcv_badregisters);
 	    CTR2(KTR_IPMF, "%s: bad encap ip dest %s", __func__,
 		inet_ntoa(encap_ip->ip_dst));
 	    m_freem(m);
@@ -2724,8 +2724,8 @@ pim_input(struct mbuf *m, int off)
 
 	/* Keep statistics */
 	/* XXX: registers_bytes include only the encap. mcast pkt */
-	pimstat.pims_rcv_registers_msgs++;
-	pimstat.pims_rcv_registers_bytes += ntohs(encap_ip->ip_len);
+	PIMSTAT_INC(pims_rcv_registers_msgs);
+	PIMSTAT_ADD(pims_rcv_registers_bytes, ntohs(encap_ip->ip_len));
 
 	/*
 	 * forward the inner ip packet; point m_data at the inner ip.

Modified: head/sys/netinet/pim_var.h
==============================================================================
--- head/sys/netinet/pim_var.h	Sun Apr 12 14:00:36 2009	(r190966)
+++ head/sys/netinet/pim_var.h	Sun Apr 12 14:06:26 2009	(r190967)
@@ -59,6 +59,11 @@ struct pimstat {
 	u_quad_t pims_snd_registers_bytes; /* sent regs. bytes (data only)   */
 };
 
+#ifdef _KERNEL
+#define	PIMSTAT_ADD(name, val)	pimstat.name += (val)
+#define	PIMSTAT_INC(name)	PIMSTAT_ADD(name, 1)
+#endif
+
 /*
  * Names for PIM sysctl objects
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904121406.n3CE6QSH027497>