Date: Sun, 12 Apr 2009 14:00:36 +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: r190966 - head/sys/netinet Message-ID: <200904121400.n3CE0aiO027344@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rwatson Date: Sun Apr 12 14:00:36 2009 New Revision: 190966 URL: http://svn.freebsd.org/changeset/base/190966 Log: Update stats in struct mrtstat using two new macros: MRTSTAT_ADD() and MRTSTAT_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/ip_mroute.h Modified: head/sys/netinet/ip_mroute.c ============================================================================== --- head/sys/netinet/ip_mroute.c Sun Apr 12 13:41:13 2009 (r190965) +++ head/sys/netinet/ip_mroute.c Sun Apr 12 14:00:36 2009 (r190966) @@ -1266,7 +1266,7 @@ X_ip_mforward(struct ip *ip, struct ifne /* * Determine forwarding vifs from the forwarding cache table */ - ++mrtstat.mrts_mfc_lookups; + MRTSTAT_INC(mrts_mfc_lookups); rt = mfc_find(&ip->ip_src, &ip->ip_dst); /* Entry exists, so forward if necessary */ @@ -1286,9 +1286,8 @@ X_ip_mforward(struct ip *ip, struct ifne u_long hash; int hlen = ip->ip_hl << 2; - ++mrtstat.mrts_mfc_misses; - - mrtstat.mrts_no_route++; + MRTSTAT_INC(mrts_mfc_misses); + MRTSTAT_INC(mrts_no_route); CTR2(KTR_IPMF, "ip_mforward: no mfc for (%s,%lx)", inet_ntoa(ip->ip_src), (u_long)ntohl(ip->ip_dst.s_addr)); @@ -1360,12 +1359,12 @@ X_ip_mforward(struct ip *ip, struct ifne im->im_mbz = 0; im->im_vif = vifi; - mrtstat.mrts_upcalls++; + MRTSTAT_INC(mrts_upcalls); k_igmpsrc.sin_addr = ip->ip_src; if (socket_send(V_ip_mrouter, mm, &k_igmpsrc) < 0) { CTR0(KTR_IPMF, "ip_mforward: socket queue full"); - ++mrtstat.mrts_upq_sockfull; + MRTSTAT_INC(mrts_upq_sockfull); fail1: free(rt, M_MRTABLE); fail: @@ -1399,7 +1398,7 @@ fail: } else { /* determine if queue has overflowed */ if (rt->mfc_nstall > MAX_UPQ) { - mrtstat.mrts_upq_ovflw++; + MRTSTAT_INC(mrts_upq_ovflw); non_fatal: free(rte, M_MRTABLE); m_freem(mb0); @@ -1456,7 +1455,7 @@ expire_upcalls(void *unused) free(x, M_BWMETER); } - ++mrtstat.mrts_cache_cleanups; + MRTSTAT_INC(mrts_cache_cleanups); CTR3(KTR_IPMF, "%s: expire (%lx, %lx)", __func__, (u_long)ntohl(rt->mfc_origin.s_addr), (u_long)ntohl(rt->mfc_mcastgrp.s_addr)); @@ -1503,7 +1502,7 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp if ((vifi >= numvifs) || (viftable[vifi].v_ifp != ifp)) { CTR4(KTR_IPMF, "%s: rx on wrong ifp %p (vifi %d, v_ifp %p)", __func__, ifp, (int)vifi, viftable[vifi].v_ifp); - ++mrtstat.mrts_wrong_if; + MRTSTAT_INC(mrts_wrong_if); ++rt->mfc_wrong_if; /* * If we are doing PIM assert processing, send a message @@ -1543,12 +1542,12 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp im->im_mbz = 0; im->im_vif = vifi; - mrtstat.mrts_upcalls++; + MRTSTAT_INC(mrts_upcalls); k_igmpsrc.sin_addr = im->im_src; if (socket_send(V_ip_mrouter, mm, &k_igmpsrc) < 0) { CTR1(KTR_IPMF, "%s: socket queue full", __func__); - ++mrtstat.mrts_upq_sockfull; + MRTSTAT_INC(mrts_upq_sockfull); return ENOBUFS; } } @@ -2082,10 +2081,10 @@ bw_upcalls_send(void) * Send the upcalls * XXX do we need to set the address in k_igmpsrc ? */ - mrtstat.mrts_upcalls++; + MRTSTAT_INC(mrts_upcalls); if (socket_send(V_ip_mrouter, m, &k_igmpsrc) < 0) { log(LOG_WARNING, "bw_upcalls_send: ip_mrouter socket queue full\n"); - ++mrtstat.mrts_upq_sockfull; + MRTSTAT_INC(mrts_upq_sockfull); } } @@ -2432,11 +2431,11 @@ pim_register_send_upcall(struct ip *ip, k_igmpsrc.sin_addr = ip->ip_src; - mrtstat.mrts_upcalls++; + MRTSTAT_INC(mrts_upcalls); if (socket_send(V_ip_mrouter, mb_first, &k_igmpsrc) < 0) { CTR1(KTR_IPMF, "%s: socket queue full", __func__); - ++mrtstat.mrts_upq_sockfull; + MRTSTAT_INC(mrts_upq_sockfull); return ENOBUFS; } Modified: head/sys/netinet/ip_mroute.h ============================================================================== --- head/sys/netinet/ip_mroute.h Sun Apr 12 13:41:13 2009 (r190965) +++ head/sys/netinet/ip_mroute.h Sun Apr 12 14:00:36 2009 (r190966) @@ -221,6 +221,11 @@ struct mrtstat { u_long mrts_upq_sockfull; /* upcalls dropped - socket full */ }; +#ifdef _KERNEL +#define MRTSTAT_ADD(name, val) mrtstat.name += (val) +#define MRTSTAT_INC(name) MRTSTAT_ADD(name, 1) +#endif + /* * Argument structure used by mrouted to get src-grp pkt counts */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904121400.n3CE0aiO027344>