Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jan 2014 13:24:59 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r260714 - stable/9/sys/netinet6
Message-ID:  <201401161324.s0GDOxlN008634@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Thu Jan 16 13:24:58 2014
New Revision: 260714
URL: http://svnweb.freebsd.org/changeset/base/260714

Log:
  MFC r260481:
    Add MRT6_DLOG() macro for debugging.
    Reduce number of MRT6DEBUG ifdefs and fix some broken format strings.

Modified:
  stable/9/sys/netinet6/ip6_mroute.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet6/ip6_mroute.c
==============================================================================
--- stable/9/sys/netinet6/ip6_mroute.c	Thu Jan 16 13:24:10 2014	(r260713)
+++ stable/9/sys/netinet6/ip6_mroute.c	Thu Jan 16 13:24:58 2014	(r260714)
@@ -218,6 +218,14 @@ static VNET_DEFINE(u_int, mrt6debug) = 0
 #define DEBUG_XMIT	0x10
 #define DEBUG_REG	0x20
 #define DEBUG_PIM	0x40
+#define	DEBUG_ERR	0x80
+#define	DEBUG_ANY	0x7f
+#define	MRT6_DLOG(m, fmt, ...)	\
+	if (V_mrt6debug & (m))	\
+		log(((m) & DEBUG_ERR) ? LOG_ERR: LOG_DEBUG, \
+		    "%s: " fmt "\n", __func__, ##__VA_ARGS__)
+#else
+#define	MRT6_DLOG(m, fmt, ...)
 #endif
 
 static void	expire_upcalls(void *);
@@ -523,12 +531,8 @@ static int
 ip6_mrouter_init(struct socket *so, int v, int cmd)
 {
 
-#ifdef MRT6DEBUG
-	if (V_mrt6debug)
-		log(LOG_DEBUG,
-		    "ip6_mrouter_init: so_type = %d, pr_protocol = %d\n",
-		    so->so_type, so->so_proto->pr_protocol);
-#endif
+	MRT6_DLOG(DEBUG_ANY, "so_type = %d, pr_protocol = %d",
+	    so->so_type, so->so_proto->pr_protocol);
 
 	if (so->so_type != SOCK_RAW ||
 	    so->so_proto->pr_protocol != IPPROTO_ICMPV6)
@@ -557,11 +561,7 @@ ip6_mrouter_init(struct socket *so, int 
 	    expire_upcalls, NULL);
 
 	MROUTER6_UNLOCK();
-
-#ifdef MRT6DEBUG
-	if (V_mrt6debug)
-		log(LOG_DEBUG, "ip6_mrouter_init\n");
-#endif
+	MRT6_DLOG(DEBUG_ANY, "finished");
 
 	return (0);
 }
@@ -639,11 +639,7 @@ X_ip6_mrouter_done(void)
 	V_ip6_mrouter_ver = 0;
 
 	MROUTER6_UNLOCK();
-
-#ifdef MRT6DEBUG
-	if (V_mrt6debug)
-		log(LOG_DEBUG, "ip6_mrouter_done\n");
-#endif
+	MRT6_DLOG(DEBUG_ANY, "finished");
 
 	return (0);
 }
@@ -724,14 +720,8 @@ add_m6if(struct mif6ctl *mifcp)
 		nummifs = mifcp->mif6c_mifi + 1;
 
 	MIF6_UNLOCK();
-
-#ifdef MRT6DEBUG
-	if (V_mrt6debug)
-		log(LOG_DEBUG,
-		    "add_mif #%d, phyint %s\n",
-		    mifcp->mif6c_mifi,
-		    ifp->if_xname);
-#endif
+	MRT6_DLOG(DEBUG_ANY, "mif #%d, phyint %s", mifcp->mif6c_mifi,
+	    if_name(ifp));
 
 	return (0);
 }
@@ -774,11 +764,7 @@ del_m6if_locked(mifi_t *mifip)
 		if (mif6table[mifi - 1].m6_ifp)
 			break;
 	nummifs = mifi;
-
-#ifdef MRT6DEBUG
-	if (V_mrt6debug)
-		log(LOG_DEBUG, "del_m6if %d, nummifs %d\n", *mifip, nummifs);
-#endif
+	MRT6_DLOG(DEBUG_ANY, "mif %d, nummifs %d", *mifip, nummifs);
 
 	return (0);
 }
@@ -814,15 +800,10 @@ add_m6fc(struct mf6cctl *mfccp)
 
 	/* If an entry already exists, just update the fields */
 	if (rt) {
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_MFC) {
-		    log(LOG_DEBUG,
-			"add_m6fc no upcall h %d o %s g %s p %x\n",
-			ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
-			ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
-			mfccp->mf6cc_parent);
-		}
-#endif
+		MRT6_DLOG(DEBUG_MFC, "no upcall o %s g %s p %x",
+		    ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
+		    ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
+		    mfccp->mf6cc_parent);
 
 		rt->mf6c_parent = mfccp->mf6cc_parent;
 		rt->mf6c_ifset = mfccp->mf6cc_ifset;
@@ -853,16 +834,12 @@ add_m6fc(struct mf6cctl *mfccp)
 					    &mfccp->mf6cc_mcastgrp.sin6_addr),
 				    mfccp->mf6cc_parent, rt->mf6c_stall);
 
-#ifdef MRT6DEBUG
-			if (V_mrt6debug & DEBUG_MFC)
-				log(LOG_DEBUG,
-				    "add_m6fc o %s g %s p %x dbg %x\n",
-				    ip6_sprintf(ip6bufo,
-					    &mfccp->mf6cc_origin.sin6_addr),
-				    ip6_sprintf(ip6bufg,
-					    &mfccp->mf6cc_mcastgrp.sin6_addr),
-				    mfccp->mf6cc_parent, rt->mf6c_stall);
-#endif
+			MRT6_DLOG(DEBUG_MFC, "o %s g %s p %x dbg %p",
+			    ip6_sprintf(ip6bufo,
+			    &mfccp->mf6cc_origin.sin6_addr),
+			    ip6_sprintf(ip6bufg,
+				&mfccp->mf6cc_mcastgrp.sin6_addr),
+			    mfccp->mf6cc_parent, rt->mf6c_stall);
 
 			rt->mf6c_origin     = mfccp->mf6cc_origin;
 			rt->mf6c_mcastgrp   = mfccp->mf6cc_mcastgrp;
@@ -895,15 +872,10 @@ add_m6fc(struct mf6cctl *mfccp)
 	 * It is possible that an entry is being inserted without an upcall
 	 */
 	if (nstl == 0) {
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_MFC)
-		    log(LOG_DEBUG,
-			"add_mfc no upcall h %d o %s g %s p %x\n",
-			hash,
-			ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
-			ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
-			mfccp->mf6cc_parent);
-#endif
+		MRT6_DLOG(DEBUG_MFC, "no upcall h %lu o %s g %s p %x", hash,
+		    ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
+		    ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
+		    mfccp->mf6cc_parent);
 
 		for (rt = mf6ctable[hash]; rt; rt = rt->mf6c_next) {
 
@@ -989,6 +961,9 @@ collate(struct timeval *t)
 static int
 del_m6fc(struct mf6cctl *mfccp)
 {
+#ifdef MRT6DEBUG
+	char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN];
+#endif
 	struct sockaddr_in6	origin;
 	struct sockaddr_in6	mcastgrp;
 	struct mf6c		*rt;
@@ -999,14 +974,9 @@ del_m6fc(struct mf6cctl *mfccp)
 	mcastgrp = mfccp->mf6cc_mcastgrp;
 	hash = MF6CHASH(origin.sin6_addr, mcastgrp.sin6_addr);
 
-#ifdef MRT6DEBUG
-	if (V_mrt6debug & DEBUG_MFC) {
-		char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN];
-		log(LOG_DEBUG,"del_m6fc orig %s mcastgrp %s\n",
-		    ip6_sprintf(ip6bufo, &origin.sin6_addr),
-		    ip6_sprintf(ip6bufg, &mcastgrp.sin6_addr));
-	}
-#endif
+	MRT6_DLOG(DEBUG_MFC, "orig %s mcastgrp %s",
+	    ip6_sprintf(ip6bufo, &origin.sin6_addr),
+	    ip6_sprintf(ip6bufg, &mcastgrp.sin6_addr));
 
 	MFC6_LOCK();
 
@@ -1077,13 +1047,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, stru
 	mifi_t mifi;
 	char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
 
-#ifdef MRT6DEBUG
-	if (V_mrt6debug & DEBUG_FORWARD)
-		log(LOG_DEBUG, "ip6_mforward: src %s, dst %s, ifindex %d\n",
-		    ip6_sprintf(ip6bufs, &ip6->ip6_src),
-		    ip6_sprintf(ip6bufd, &ip6->ip6_dst),
-		    ifp->if_index);
-#endif
+	MRT6_DLOG(DEBUG_FORWARD, "src %s, dst %s, ifindex %d",
+	    ip6_sprintf(ip6bufs, &ip6->ip6_src),
+	    ip6_sprintf(ip6bufd, &ip6->ip6_dst), ifp->if_index);
 
 	/*
 	 * Don't forward a packet with Hop limit of zero or one,
@@ -1145,12 +1111,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, stru
 #endif /* UPCALL_TIMING */
 
 		MRT6STAT_INC(mrt6s_no_route);
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & (DEBUG_FORWARD | DEBUG_MFC))
-			log(LOG_DEBUG, "ip6_mforward: no rte s %s g %s\n",
-			    ip6_sprintf(ip6bufs, &ip6->ip6_src),
-			    ip6_sprintf(ip6bufd, &ip6->ip6_dst));
-#endif
+		MRT6_DLOG(DEBUG_FORWARD | DEBUG_MFC, "no rte s %s g %s",
+		    ip6_sprintf(ip6bufs, &ip6->ip6_src),
+		    ip6_sprintf(ip6bufd, &ip6->ip6_dst));
 
 		/*
 		 * Allocate mbufs early so that we don't do extra work if we
@@ -1246,11 +1209,8 @@ X_ip6_mforward(struct ip6_hdr *ip6, stru
 				return (EINVAL);
 			}
 
-#ifdef MRT6DEBUG
-			if (V_mrt6debug & DEBUG_FORWARD)
-				log(LOG_DEBUG,
-				    "getting the iif info in the kernel\n");
-#endif
+			MRT6_DLOG(DEBUG_FORWARD,
+			    "getting the iif info in the kernel");
 
 			for (mifp = mif6table, mifi = 0;
 			     mifi < nummifs && mifp->m6_ifp != ifp;
@@ -1336,6 +1296,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, stru
 static void
 expire_upcalls(void *unused)
 {
+#ifdef MRT6DEBUG
+	char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN];
+#endif
 	struct rtdetq *rte;
 	struct mf6c *mfc, **nptr;
 	u_long i;
@@ -1355,15 +1318,9 @@ expire_upcalls(void *unused)
 			if (rte != NULL &&
 			    mfc->mf6c_expire != 0 &&
 			    --mfc->mf6c_expire == 0) {
-#ifdef MRT6DEBUG
-				if (V_mrt6debug & DEBUG_EXPIRE) {
-					char ip6bufo[INET6_ADDRSTRLEN];
-					char ip6bufg[INET6_ADDRSTRLEN];
-					log(LOG_DEBUG, "expire_upcalls: expiring (%s %s)\n",
-					    ip6_sprintf(ip6bufo, &mfc->mf6c_origin.sin6_addr),
-					    ip6_sprintf(ip6bufg, &mfc->mf6c_mcastgrp.sin6_addr));
-				}
-#endif
+				MRT6_DLOG(DEBUG_EXPIRE, "expiring (%s %s)",
+				    ip6_sprintf(ip6bufo, &mfc->mf6c_origin.sin6_addr),
+				    ip6_sprintf(ip6bufg, &mfc->mf6c_mcastgrp.sin6_addr));
 				/*
 				 * drop all the packets
 				 * free the mbuf with the pkt, if, timing info
@@ -1423,13 +1380,9 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
 	mifi = rt->mf6c_parent;
 	if ((mifi >= nummifs) || (mif6table[mifi].m6_ifp != ifp)) {
 		/* came in the wrong interface */
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_FORWARD)
-			log(LOG_DEBUG,
-			    "wrong if: ifid %d mifi %d mififid %x\n",
-			    ifp->if_index, mifi,
-			    mif6table[mifi].m6_ifp->if_index);
-#endif
+		MRT6_DLOG(DEBUG_FORWARD,
+		    "wrong if: ifid %d mifi %d mififid %x", ifp->if_index,
+		    mifi, mif6table[mifi].m6_ifp->if_index);
 		MRT6STAT_INC(mrt6s_wrong_if);
 		rt->mf6c_wrong_if++;
 		/*
@@ -1506,10 +1459,8 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
 				MRT6STAT_INC(mrt6s_upcalls);
 
 				if (socket_send(V_ip6_mrouter, mm, &sin6) < 0) {
-#ifdef MRT6DEBUG
-					if (V_mrt6debug)
-						log(LOG_WARNING, "mdq, ip6_mrouter socket queue full\n");
-#endif
+					MRT6_DLOG(DEBUG_ANY,
+					    "ip6_mrouter socket queue full");
 					MRT6STAT_INC(mrt6s_upq_sockfull);
 					return (ENOBUFS);
 				}	/* if socket Q full */
@@ -1573,6 +1524,9 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
 static void
 phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
 {
+#ifdef MRT6DEBUG
+	char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
+#endif
 	struct mbuf *mb_copy;
 	struct ifnet *ifp = mifp->m6_ifp;
 	int error = 0;
@@ -1610,11 +1564,8 @@ phyint_send(struct ip6_hdr *ip6, struct 
 		error = ip6_output(mb_copy, NULL, NULL, IPV6_FORWARDING, &im6o,
 		    NULL, NULL);
 
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_XMIT)
-			log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
-			    mifp - mif6table, error);
-#endif
+		MRT6_DLOG(DEBUG_XMIT, "mif %u err %d",
+		    (uint16_t)(mifp - mif6table), error);
 		return;
 	}
 
@@ -1650,11 +1601,8 @@ phyint_send(struct ip6_hdr *ip6, struct 
 		 */
 		error = (*ifp->if_output)(ifp, mb_copy,
 		    (struct sockaddr *)&dst6, NULL);
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_XMIT)
-			log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
-			    mifp - mif6table, error);
-#endif
+		MRT6_DLOG(DEBUG_XMIT, "mif %u err %d",
+		    (uint16_t)(mifp - mif6table), error);
 	} else {
 		/*
 		 * pMTU discovery is intentionally disabled by default, since
@@ -1664,19 +1612,11 @@ phyint_send(struct ip6_hdr *ip6, struct 
 		if (V_ip6_mcast_pmtu)
 			icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, linkmtu);
 		else {
-#ifdef MRT6DEBUG
-			if (V_mrt6debug & DEBUG_XMIT) {
-				char ip6bufs[INET6_ADDRSTRLEN];
-				char ip6bufd[INET6_ADDRSTRLEN];
-				log(LOG_DEBUG,
-				    "phyint_send: packet too big on %s o %s "
-				    "g %s size %d(discarded)\n",
-				    if_name(ifp),
-				    ip6_sprintf(ip6bufs, &ip6->ip6_src),
-				    ip6_sprintf(ip6bufd, &ip6->ip6_dst),
-				    mb_copy->m_pkthdr.len);
-			}
-#endif /* MRT6DEBUG */
+			MRT6_DLOG(DEBUG_XMIT, " packet too big on %s o %s "
+			    "g %s size %d (discarded)", if_name(ifp),
+			    ip6_sprintf(ip6bufs, &ip6->ip6_src),
+			    ip6_sprintf(ip6bufd, &ip6->ip6_dst),
+			    mb_copy->m_pkthdr.len);
 			m_freem(mb_copy); /* simply discard the packet */
 		}
 	}
@@ -1685,19 +1625,17 @@ phyint_send(struct ip6_hdr *ip6, struct 
 static int
 register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
 {
+#ifdef MRT6DEBUG
+	char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
+#endif
 	struct mbuf *mm;
 	int i, len = m->m_pkthdr.len;
 	static struct sockaddr_in6 sin6 = { sizeof(sin6), AF_INET6 };
 	struct mrt6msg *im6;
 
-#ifdef MRT6DEBUG
-	if (V_mrt6debug) {
-		char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
-		log(LOG_DEBUG, "** IPv6 register_send **\n src %s dst %s\n",
-		    ip6_sprintf(ip6bufs, &ip6->ip6_src),
-		    ip6_sprintf(ip6bufd, &ip6->ip6_dst));
-	}
-#endif
+	MRT6_DLOG(DEBUG_ANY, "src %s dst %s",
+	    ip6_sprintf(ip6bufs, &ip6->ip6_src),
+	    ip6_sprintf(ip6bufd, &ip6->ip6_dst));
 	PIM6STAT_INC(pim6s_snd_registers);
 
 	/* Make a copy of the packet to send to the user level process */
@@ -1736,11 +1674,7 @@ register_send(struct ip6_hdr *ip6, struc
 	MRT6STAT_INC(mrt6s_upcalls);
 
 	if (socket_send(V_ip6_mrouter, mm, &sin6) < 0) {
-#ifdef MRT6DEBUG
-		if (V_mrt6debug)
-			log(LOG_WARNING,
-			    "register_send: ip6_mrouter socket queue full\n");
-#endif
+		MRT6_DLOG(DEBUG_ANY, "ip6_mrouter socket queue full");
 		MRT6STAT_INC(mrt6s_upq_sockfull);
 		return (ENOBUFS);
 	}
@@ -1792,10 +1726,7 @@ pim6_input(struct mbuf **mp, int *offp, 
 	 */
 	if (pimlen < PIM_MINLEN) {
 		PIM6STAT_INC(pim6s_rcv_tooshort);
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_PIM)
-			log(LOG_DEBUG,"pim6_input: PIM packet too short\n");
-#endif
+		MRT6_DLOG(DEBUG_PIM, "PIM packet too short");
 		m_freem(m);
 		return (IPPROTO_DONE);
 	}
@@ -1845,11 +1776,7 @@ pim6_input(struct mbuf **mp, int *offp, 
 
 		if (in6_cksum(m, IPPROTO_PIM, off, cksumlen)) {
 			PIM6STAT_INC(pim6s_rcv_badsum);
-#ifdef MRT6DEBUG
-			if (V_mrt6debug & DEBUG_PIM)
-				log(LOG_DEBUG,
-				    "pim6_input: invalid checksum\n");
-#endif
+			MRT6_DLOG(DEBUG_PIM, "invalid checksum");
 			m_freem(m);
 			return (IPPROTO_DONE);
 		}
@@ -1859,11 +1786,9 @@ pim6_input(struct mbuf **mp, int *offp, 
 	/* PIM version check */
 	if (pim->pim_ver != PIM_VERSION) {
 		PIM6STAT_INC(pim6s_rcv_badversion);
-#ifdef MRT6DEBUG
-		log(LOG_ERR,
-		    "pim6_input: incorrect version %d, expecting %d\n",
+		MRT6_DLOG(DEBUG_ANY | DEBUG_ERR,
+		    "incorrect version %d, expecting %d",
 		    pim->pim_ver, PIM_VERSION);
-#endif
 		m_freem(m);
 		return (IPPROTO_DONE);
 	}
@@ -1887,12 +1812,8 @@ pim6_input(struct mbuf **mp, int *offp, 
 		PIM6STAT_INC(pim6s_rcv_registers);
 
 		if ((reg_mif_num >= nummifs) || (reg_mif_num == (mifi_t) -1)) {
-#ifdef MRT6DEBUG
-			if (V_mrt6debug & DEBUG_PIM)
-				log(LOG_DEBUG,
-				    "pim6_input: register mif not set: %d\n",
-				    reg_mif_num);
-#endif
+			MRT6_DLOG(DEBUG_PIM, "register mif not set: %d",
+			    reg_mif_num);
 			m_freem(m);
 			return (IPPROTO_DONE);
 		}
@@ -1908,35 +1829,25 @@ pim6_input(struct mbuf **mp, int *offp, 
 		if (pimlen < PIM6_REG_MINLEN) {
 			PIM6STAT_INC(pim6s_rcv_tooshort);
 			PIM6STAT_INC(pim6s_rcv_badregisters);
-#ifdef MRT6DEBUG
-			log(LOG_ERR,
-			    "pim6_input: register packet size too "
-			    "small %d from %s\n",
+			MRT6_DLOG(DEBUG_ANY | DEBUG_ERR, "register packet "
+			    "size too small %d from %s",
 			    pimlen, ip6_sprintf(ip6bufs, &ip6->ip6_src));
-#endif
 			m_freem(m);
 			return (IPPROTO_DONE);
 		}
 
 		eip6 = (struct ip6_hdr *) (reghdr + 1);
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_PIM)
-			log(LOG_DEBUG,
-			    "pim6_input[register], eip6: %s -> %s, "
-			    "eip6 plen %d\n",
-			    ip6_sprintf(ip6bufs, &eip6->ip6_src),
-			    ip6_sprintf(ip6bufd, &eip6->ip6_dst),
-			    ntohs(eip6->ip6_plen));
-#endif
+		MRT6_DLOG(DEBUG_PIM, "eip6: %s -> %s, eip6 plen %d",
+		    ip6_sprintf(ip6bufs, &eip6->ip6_src),
+		    ip6_sprintf(ip6bufd, &eip6->ip6_dst),
+		    ntohs(eip6->ip6_plen));
 
 		/* verify the version number of the inner packet */
 		if ((eip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
 			PIM6STAT_INC(pim6s_rcv_badregisters);
-#ifdef MRT6DEBUG
-			log(LOG_DEBUG, "pim6_input: invalid IP version (%d) "
-			    "of the inner packet\n",
+			MRT6_DLOG(DEBUG_ANY, "invalid IP version (%d) "
+			    "of the inner packet",
 			    (eip6->ip6_vfc & IPV6_VERSION));
-#endif
 			m_freem(m);
 			return (IPPROTO_NONE);
 		}
@@ -1944,13 +1855,9 @@ pim6_input(struct mbuf **mp, int *offp, 
 		/* verify the inner packet is destined to a mcast group */
 		if (!IN6_IS_ADDR_MULTICAST(&eip6->ip6_dst)) {
 			PIM6STAT_INC(pim6s_rcv_badregisters);
-#ifdef MRT6DEBUG
-			if (V_mrt6debug & DEBUG_PIM)
-				log(LOG_DEBUG,
-				    "pim6_input: inner packet of register "
-				    "is not multicast %s\n",
-				    ip6_sprintf(ip6bufd, &eip6->ip6_dst));
-#endif
+			MRT6_DLOG(DEBUG_PIM, "inner packet of register "
+			    "is not multicast %s",
+			    ip6_sprintf(ip6bufd, &eip6->ip6_dst));
 			m_freem(m);
 			return (IPPROTO_DONE);
 		}
@@ -1960,11 +1867,8 @@ pim6_input(struct mbuf **mp, int *offp, 
 		 */
 		mcp = m_copy(m, 0, off + PIM6_REG_MINLEN);
 		if (mcp == NULL) {
-#ifdef MRT6DEBUG
-			log(LOG_ERR,
-			    "pim6_input: pim register: "
-			    "could not copy register head\n");
-#endif
+			MRT6_DLOG(DEBUG_ANY | DEBUG_ERR, "pim register: "
+			    "could not copy register head");
 			m_freem(m);
 			return (IPPROTO_DONE);
 		}
@@ -1973,16 +1877,10 @@ pim6_input(struct mbuf **mp, int *offp, 
 		 * forward the inner ip6 packet; point m_data at the inner ip6.
 		 */
 		m_adj(m, off + PIM_MINLEN);
-#ifdef MRT6DEBUG
-		if (V_mrt6debug & DEBUG_PIM) {
-			log(LOG_DEBUG,
-			    "pim6_input: forwarding decapsulated register: "
-			    "src %s, dst %s, mif %d\n",
-			    ip6_sprintf(ip6bufs, &eip6->ip6_src),
-			    ip6_sprintf(ip6bufd, &eip6->ip6_dst),
-			    reg_mif_num);
-		}
-#endif
+		MRT6_DLOG(DEBUG_PIM, "forwarding decapsulated register: "
+		    "src %s, dst %s, mif %d",
+		    ip6_sprintf(ip6bufs, &eip6->ip6_src),
+		    ip6_sprintf(ip6bufd, &eip6->ip6_dst), reg_mif_num);
 
 		rc = if_simloop(mif6table[reg_mif_num].m6_ifp, m,
 				dst.sin6_family, 0);



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