Commit 3d5f79b815 for frr

commit 3d5f79b815d273bf4ae4cb3236e39f16762edaec
Author: Donald Sharp <sharpd@nvidia.com>
Date:   Tue Oct 20 11:07:25 2026 -0400

    pimd: Standardize (S,G) output, %pSG, in debugs

    Currently there are two problems with using %pSG in pimd
    debugs:

    a) The vrf name, vrf id and table were not being output for
    every debug.  When the same (S,G) is used in multiple vrf's
    it is difficult to know if the debug being looked at is for
    the instance of interest.

    b) The output was not standardized.  A few debugs had the vrf
    name in front of the (S,G) and most had nothing at all.
    Solidify on "(%s:%u:%u)%pSG", vrf_name, vrf_id, table_id,
    (S,G).  This allows very easy grepping.

    The MLAG debugs look up the vrf from the name in the message
    before the first debug so that the vrf id and table are known.
    pim_msdp_pkt_sa_dump_one() is passed the msdp peer so that the
    pim instance is available.

    Signed-off-by: Donald Sharp <sharpd@nvidia.com>

diff --git a/pimd/pim6_mld.c b/pimd/pim6_mld.c
index 13ec2c513a..b527dcc4d1 100644
--- a/pimd/pim6_mld.c
+++ b/pimd/pim6_mld.c
@@ -59,9 +59,9 @@ static void gm_sg_timer_start(struct gm_if *gm_ifp, struct gm_sg *sg,
 		&pkt_src->sin6_addr
 #define log_pkt_dst(msg)                                                       \
 	"[MLD %s:%s %pI6] " msg, gm_ifp->ifp->vrf->name, gm_ifp->ifp->name, pkt_dst
-#define log_sg(sg, msg)                                                        \
-	"[MLD %s:%s %pSG] " msg, sg->iface->ifp->vrf->name,                    \
-		sg->iface->ifp->name, &sg->sgaddr
+#define log_sg(sg, msg)                                                                           \
+	"[MLD %s (%s:%u:%u)%pSG] " msg, sg->iface->ifp->name, PIM_DEBUG_VRF(sg->iface->ifp->vrf), \
+		&sg->sgaddr

 /* clang-format off */
 static const pim_addr gm_all_hosts = {
@@ -519,12 +519,12 @@ static void gm_sg_update(struct gm_sg *sg, bool has_expired)
 		sg->tib_joined = tib_sg_gm_join(gm_ifp->pim, sg->sgaddr,
 						gm_ifp->ifp, &sg->oil);
 		if (!sg->tib_joined)
-			zlog_warn(
-				"MLD join for %pSG%%%s not propagated into TIB",
-				&sg->sgaddr, gm_ifp->ifp->name);
-		else
-			zlog_info(log_ifp("%pSG%%%s TIB joined"), &sg->sgaddr,
+			zlog_warn("MLD join for (%s:%u:%u)%pSG%%%s not propagated into TIB",
+				  PIM_DEBUG_VRF(sg->iface->pim->vrf), &sg->sgaddr,
 				  gm_ifp->ifp->name);
+		else
+			zlog_info(log_ifp("(%s:%u:%u)%pSG%%%s TIB joined"),
+				  PIM_DEBUG_VRF(gm_ifp->ifp->vrf), &sg->sgaddr, gm_ifp->ifp->name);

 	} else if (sg->tib_joined && !new_join) {
 		tib_sg_gm_prune(gm_ifp->pim, sg->sgaddr, gm_ifp->ifp, &sg->oil);
diff --git a/pimd/pim_dm.c b/pimd/pim_dm.c
index 763952ab7d..fa12760e65 100644
--- a/pimd/pim_dm.c
+++ b/pimd/pim_dm.c
@@ -142,8 +142,8 @@ static void pim_dm_assert_wrongif(struct interface *ifp, pim_sgaddr sg, struct p

 	if (ch->upstream != up) {
 		if (PIM_DEBUG_PIM_J_P)
-			zlog_debug("%s: (S,G)=%pSG ifchannel upstream mismatch on %s", __func__,
-				   &sg, ifp->name);
+			zlog_debug("%s: (S,G)=(%s:%u:%u)%pSG ifchannel upstream mismatch on %s",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), &sg, ifp->name);
 		return;
 	}

@@ -181,13 +181,13 @@ void pim_dm_wrongif(struct interface *ifp, pim_sgaddr sg, struct pim_upstream *u

 	if (if_is_pointopoint(ifp)) {
 		if (PIM_DEBUG_PIM_J_P)
-			zlog_debug("%s: Dense Mode WRONGVIF on P2P %s, immediate prune (S,G)=%pSG",
-				   __func__, ifp->name, &sg);
+			zlog_debug("%s: Dense Mode WRONGVIF on P2P %s, immediate prune (S,G)=(%s:%u:%u)%pSG",
+				   __func__, ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 		pim_dm_prune_wrongif(ifp, sg, up);
 	} else {
 		if (PIM_DEBUG_PIM_J_P)
-			zlog_debug("%s: Dense Mode WRONGVIF on LAN %s, starting Assert (S,G)=%pSG",
-				   __func__, ifp->name, &sg);
+			zlog_debug("%s: Dense Mode WRONGVIF on LAN %s, starting Assert (S,G)=(%s:%u:%u)%pSG",
+				   __func__, ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 		pim_dm_assert_wrongif(ifp, sg, up);
 	}
 }
@@ -220,8 +220,9 @@ void pim_dm_prune_wrongif(struct interface *ifp, pim_sgaddr sg, struct pim_upstr
 		for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
 			rpf.source_nexthop.mrib_nexthop_addr = neigh->source_addr;
 			if (PIM_DEBUG_PIM_J_P)
-				zlog_debug("%s: Sending immediate prune for (S,G)=%pSG to neighbor %pPA on interface %s",
-					   __func__, &up->sg, &neigh->source_addr, ifp->name);
+				zlog_debug("%s: Sending immediate prune for (S,G)=(%s:%u:%u)%pSG to neighbor %pPA on interface %s",
+					   __func__, PIM_DEBUG_VRF(ifp->vrf), &up->sg,
+					   &neigh->source_addr, ifp->name);
 			pim_dm_prune_send(rpf, up, 0);
 		}
 		prune_limit_timer_start(up);
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index b3cc28e566..d5d72c0bc5 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -453,8 +453,8 @@ void pim_ifchannel_find(struct interface *ifp, pim_sgaddr *sg, struct pim_ifchan
 	pim_ifp = ifp->info;

 	if (!pim_ifp) {
-		zlog_warn("%s: (S,G)=%pSG: multicast not enabled on interface %s",
-			  __func__, sg, ifp->name);
+		zlog_warn("%s: (S,G)=(%s:%u:%u)%pSG: multicast not enabled on interface %s",
+			  __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name);
 		*ch = NULL;
 		*chrpt = NULL;
 		return;
@@ -699,8 +699,8 @@ static void on_ifjoin_prune_pending_timer(struct event *t)
 	ch = EVENT_ARG(t);

 	if (PIM_DEBUG_PIM_TRACE)
-		zlog_debug("%s: IFCHANNEL%pSG %s Prune Pending Timer Popped",
-			   __func__, &ch->sg,
+		zlog_debug("%s: IFCHANNEL(%s:%u:%u)%pSG %s Prune Pending Timer Popped", __func__,
+			   PIM_DEBUG_VRF(ch->interface->vrf), &ch->sg,
 			   pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags));

 	if (ch->ifjoin_state == PIM_IFJOIN_PRUNE_PENDING) {
@@ -839,10 +839,9 @@ static int nonlocal_upstream(int is_join, struct interface *recv_ifp,
 		return 0;

 	if (PIM_DEBUG_PIM_TRACE_DETAIL)
-		zlog_warn(
-			"%s: recv %s (S,G)=%pSG to non-local upstream=%pPAs on %s",
-			__func__, is_join ? "join" : "prune", sg, &upstream,
-			recv_ifp->name);
+		zlog_warn("%s: recv %s (S,G)=(%s:%u:%u)%pSG to non-local upstream=%pPAs on %s",
+			  __func__, is_join ? "join" : "prune", PIM_DEBUG_VRF(recv_ifp->vrf), sg,
+			  &upstream, recv_ifp->name);

 	/*
 	 * Since recv upstream addr was not directed to our primary
@@ -1056,9 +1055,8 @@ void pim_ifchannel_prune(struct interface *ifp, pim_addr upstream,
 		ch = chrpt;
 	if (!ch && !(source_flags & PIM_ENCODE_RPT_BIT)) {
 		if (PIM_DEBUG_PIM_TRACE)
-			zlog_debug("%s: Received prune with no relevant ifchannel %s%pSG state: %d",
-				   __func__, ifp->name, sg,
-				   source_flags);
+			zlog_debug("%s: Received prune with no relevant ifchannel %s(%s:%u:%u)%pSG state: %d",
+				   __func__, ifp->name, PIM_DEBUG_VRF(ifp->vrf), sg, source_flags);
 		return;
 	}

@@ -1192,15 +1190,15 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, pim_sgaddr *sg,
 	pim_ifp = ifp->info;
 	if (!pim_ifp) {
 		if (PIM_DEBUG_EVENTS)
-			zlog_debug("%s:%pSG Expected pim interface setup for %s",
-				   __func__, sg, ifp->name);
+			zlog_debug("%s:(%s:%u:%u)%pSG Expected pim interface setup for %s",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name);
 		return 0;
 	}

 	if (!pim_ifp->pim_enable) {
 		if (PIM_DEBUG_EVENTS)
-			zlog_debug("%s:%pSG PIM is not configured on this interface %s",
-				   __func__, sg, ifp->name);
+			zlog_debug("%s:(%s:%u:%u)%pSG PIM is not configured on this interface %s",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name);
 		return 0;
 	}

@@ -1210,8 +1208,8 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, pim_sgaddr *sg,
 	if (pim_addr_is_any(sg->src)) {
 		if (pim_is_grp_ssm(pim, sg->grp)) {
 			if (PIM_DEBUG_PIM_EVENTS)
-				zlog_debug("%s: local membership (S,G)=%pSG ignored as group is SSM",
-					   __func__, sg);
+				zlog_debug("%s: local membership (S,G)=(%s:%u:%u)%pSG ignored as group is SSM",
+					   __func__, PIM_DEBUG_VRF(ifp->vrf), sg);
 			return 1;
 		}
 	}
diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c
index ddab9a39d4..5d43b0b372 100644
--- a/pimd/pim_igmp.c
+++ b/pimd/pim_igmp.c
@@ -94,26 +94,23 @@ static void igmp_source_forward_reevaluate_one(struct pim_instance *pim,
 		if (pim_addr_is_any(source->source_addr)) {
 			if (is_grp_ssm) {
 				if (PIM_DEBUG_PIM_EVENTS)
-					zlog_debug(
-						"local membership del for %pSG as G is now SSM",
-						&sg);
+					zlog_debug("local membership del for (%s:%u:%u)%pSG as G is now SSM",
+						   PIM_DEBUG_VRF(pim->vrf), &sg);
 				igmp_source_forward_stop(source);
 			}
 		} else {
 			if (!is_grp_ssm) {
 				if (PIM_DEBUG_PIM_EVENTS)
-					zlog_debug(
-						"local membership del for %pSG as G is now ASM",
-						&sg);
+					zlog_debug("local membership del for (%s:%u:%u)%pSG as G is now ASM",
+						   PIM_DEBUG_VRF(pim->vrf), &sg);
 				igmp_source_forward_stop(source);
 			}
 		}
 	} else {
 		if (!pim_addr_is_any(source->source_addr) && (is_grp_ssm)) {
 			if (PIM_DEBUG_PIM_EVENTS)
-				zlog_debug(
-					"local membership add for %pSG as G is now SSM",
-					&sg);
+				zlog_debug("local membership add for (%s:%u:%u)%pSG as G is now SSM",
+					   PIM_DEBUG_VRF(pim->vrf), &sg);
 			igmp_source_forward_start(pim, source);
 		}
 	}
@@ -182,8 +179,8 @@ void igmp_source_forward_start(struct pim_instance *pim,
 	sg.grp = source->source_group->group_addr;

 	if (PIM_DEBUG_GM_TRACE) {
-		zlog_debug("%s: (S,G)=%pSG oif=%s fwd=%d", __func__, &sg,
-			   source->source_group->interface->name,
+		zlog_debug("%s: (S,G)=(%s:%u:%u)%pSG oif=%s fwd=%d", __func__,
+			   PIM_DEBUG_VRF(pim->vrf), &sg, source->source_group->interface->name,
 			   IGMP_SOURCE_TEST_FORWARDING(source->source_flags));
 	}

@@ -193,9 +190,8 @@ void igmp_source_forward_start(struct pim_instance *pim,
 	 */
 	if ((!pim_is_grp_ssm(pim, source->source_group->group_addr)) &&
 	    !pim_addr_is_any(source->source_addr)) {
-		zlog_warn(
-			"%s: (S,G)=%pSG ASM range having source address, not allowed to create PIM state",
-			__func__, &sg);
+		zlog_warn("%s: (S,G)=(%s:%u:%u)%pSG ASM range having source address, not allowed to create PIM state",
+			  __func__, PIM_DEBUG_VRF(pim->vrf), &sg);
 		return;
 	}

@@ -227,7 +223,8 @@ void igmp_source_forward_stop(struct gm_source *source)
 	sg.grp = source->source_group->group_addr;

 	if (PIM_DEBUG_GM_TRACE) {
-		zlog_debug("%s: (S,G)=%pSG oif=%s fwd=%d", __func__, &sg,
+		zlog_debug("%s: (S,G)=(%s:%u:%u)%pSG oif=%s fwd=%d", __func__,
+			   PIM_DEBUG_VRF(source->source_group->interface->vrf), &sg,
 			   source->source_group->interface->name,
 			   IGMP_SOURCE_TEST_FORWARDING(source->source_flags));
 	}
diff --git a/pimd/pim_join.c b/pimd/pim_join.c
index 219144e3d5..4552344a38 100644
--- a/pimd/pim_join.c
+++ b/pimd/pim_join.c
@@ -47,11 +47,11 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh, uint16_
 #endif /* PIM_IPV == 6 */

 	if (PIM_DEBUG_PIM_J_P)
-		zlog_debug(
-			"%s: join (S,G)=%pSG rpt=%d wc=%d upstream=%pPAs holdtime=%d from %pPA on %s",
-			__func__, sg, !!(source_flags & PIM_RPT_BIT_MASK),
-			!!(source_flags & PIM_WILDCARD_BIT_MASK), &upstream,
-			holdtime, &neigh->source_addr, ifp->name);
+		zlog_debug("%s: join (S,G)=(%s:%u:%u)%pSG rpt=%d wc=%d upstream=%pPAs holdtime=%d from %pPA on %s",
+			   __func__, PIM_DEBUG_VRF(ifp->vrf), sg,
+			   !!(source_flags & PIM_RPT_BIT_MASK),
+			   !!(source_flags & PIM_WILDCARD_BIT_MASK), &upstream, holdtime,
+			   &neigh->source_addr, ifp->name);

 	pim_ifp = ifp->info;

@@ -75,9 +75,8 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh, uint16_
 		 */
 		if (!CHECK_FLAG(source_flags, PIM_RPT_BIT_MASK)) {
 			if (PIM_DEBUG_PIM_J_P)
-				zlog_debug(
-					"Discarding (*,G)=%pSG join since WC bit is set but RPT bit is unset",
-					sg);
+				zlog_debug("Discarding (*,G)=(%s:%u:%u)%pSG join since WC bit is set but RPT bit is unset",
+					   PIM_DEBUG_VRF(ifp->vrf), sg);

 			return;
 		}
@@ -86,8 +85,8 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh, uint16_
 		pim_addr rpf_addr;

 		if (!rp) {
-			zlog_warn("%s: Lookup of RP failed for %pSG", __func__,
-				  sg);
+			zlog_warn("%s: Lookup of RP failed for (%s:%u:%u)%pSG", __func__,
+				  PIM_DEBUG_VRF(ifp->vrf), sg);
 			return;
 		}

@@ -133,11 +132,10 @@ static void recv_prune(struct interface *ifp, struct pim_neighbor *neigh,
 	struct pim_interface *pim_ifp = NULL;

 	if (PIM_DEBUG_PIM_J_P)
-		zlog_debug(
-			"%s: prune (S,G)=%pSG rpt=%d wc=%d upstream=%pPAs holdtime=%d from %pPA on %s",
-			__func__, sg, source_flags & PIM_RPT_BIT_MASK,
-			source_flags & PIM_WILDCARD_BIT_MASK, &upstream,
-			holdtime, &neigh->source_addr, ifp->name);
+		zlog_debug("%s: prune (S,G)=(%s:%u:%u)%pSG rpt=%d wc=%d upstream=%pPAs holdtime=%d from %pPA on %s",
+			   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, source_flags & PIM_RPT_BIT_MASK,
+			   source_flags & PIM_WILDCARD_BIT_MASK, &upstream, holdtime,
+			   &neigh->source_addr, ifp->name);

 	pim_ifp = ifp->info;

@@ -154,9 +152,8 @@ static void recv_prune(struct interface *ifp, struct pim_neighbor *neigh,
 		 */
 		if (!CHECK_FLAG(source_flags, PIM_RPT_BIT_MASK)) {
 			if (PIM_DEBUG_PIM_J_P)
-				zlog_debug(
-					"Discarding (*,G)=%pSG prune since WC bit is set but RPT bit is unset",
-					sg);
+				zlog_debug("Discarding (*,G)=(%s:%u:%u)%pSG prune since WC bit is set but RPT bit is unset",
+					   PIM_DEBUG_VRF(ifp->vrf), sg);

 			return;
 		}
@@ -167,8 +164,8 @@ static void recv_prune(struct interface *ifp, struct pim_neighbor *neigh,
 		 * RP in the message does not match RP(G).
 		 */
 		if (PIM_DEBUG_PIM_J_P)
-			zlog_debug("%s: Prune received with RP(%pPAs) for %pSG",
-				   __func__, &sg->src, sg);
+			zlog_debug("%s: Prune received with RP(%pPAs) for (%s:%u:%u)%pSG",
+				   __func__, &sg->src, PIM_DEBUG_VRF(ifp->vrf), sg);

 		sg->src = PIMADDR_ANY;
 	}
diff --git a/pimd/pim_mlag.c b/pimd/pim_mlag.c
index 39e9a6de04..a1e136494c 100644
--- a/pimd/pim_mlag.c
+++ b/pimd/pim_mlag.c
@@ -247,14 +247,15 @@ static void pim_mlag_up_peer_add(struct mlag_mroute_add *msg)
 	sg.src.s_addr = htonl(msg->source_ip);
 	sg.grp.s_addr = htonl(msg->group_ip);

+	vrf = vrf_lookup_by_name(msg->vrf_name);
+
 	if (PIM_DEBUG_MLAG)
-		zlog_debug("peer MLAG mroute add %s:%pSG cost %d",
-			   msg->vrf_name, &sg, msg->cost_to_rp);
+		zlog_debug("peer MLAG mroute add (%s:%u:%u)%pSG cost %d", PIM_DEBUG_VRF(vrf), &sg,
+			   msg->cost_to_rp);

 	/* XXX - this is not correct. we MUST cache updates to avoid losing
 	 * an entry because of race conditions with the peer switch.
 	 */
-	vrf = vrf_lookup_by_name(msg->vrf_name);
 	if  (!vrf) {
 		if (PIM_DEBUG_MLAG)
 			zlog_debug(
@@ -279,9 +280,8 @@ static void pim_mlag_up_peer_add(struct mlag_mroute_add *msg)

 		if (!up) {
 			if (PIM_DEBUG_MLAG)
-				zlog_debug(
-					"peer MLAG mroute add failed %s:%pSG",
-					vrf->name, &sg);
+				zlog_debug("peer MLAG mroute add failed (%s:%u:%u)%pSG",
+					   PIM_DEBUG_VRF(vrf), &sg);
 			return;
 		}
 	}
@@ -320,10 +320,11 @@ static void pim_mlag_up_peer_del(struct mlag_mroute_del *msg)
 	sg.src.s_addr = htonl(msg->source_ip);
 	sg.grp.s_addr = htonl(msg->group_ip);

+	vrf = vrf_lookup_by_name(msg->vrf_name);
+
 	if (PIM_DEBUG_MLAG)
-		zlog_debug("peer MLAG mroute del %s:%pSG", msg->vrf_name, &sg);
+		zlog_debug("peer MLAG mroute del (%s:%u:%u)%pSG", PIM_DEBUG_VRF(vrf), &sg);

-	vrf = vrf_lookup_by_name(msg->vrf_name);
 	if  (!vrf) {
 		if (PIM_DEBUG_MLAG)
 			zlog_debug(
@@ -336,9 +337,8 @@ static void pim_mlag_up_peer_del(struct mlag_mroute_del *msg)
 	up = pim_upstream_find(pim, &sg);
 	if  (!up) {
 		if (PIM_DEBUG_MLAG)
-			zlog_debug(
-				"peer MLAG mroute del skipped %s:%pSG; no up",
-				vrf->name, &sg);
+			zlog_debug("peer MLAG mroute del skipped (%s:%u:%u)%pSG; no up",
+				   PIM_DEBUG_VRF(vrf), &sg);
 		return;
 	}

@@ -741,19 +741,18 @@ static void pim_mlag_process_vxlan_update(struct mlag_vxlan *msg)
 static void pim_mlag_process_mroute_add(struct mlag_mroute_add msg)
 {
 	if (PIM_DEBUG_MLAG) {
+		struct vrf *vrf = vrf_lookup_by_name(msg.vrf_name);
 		pim_sgaddr sg;

 		sg.grp.s_addr = ntohl(msg.group_ip);
 		sg.src.s_addr = ntohl(msg.source_ip);

-		zlog_debug(
-			"%s: msg dump: vrf_name: %s, s.ip: 0x%x, g.ip: 0x%x (%pSG) cost: %u",
-			__func__, msg.vrf_name, msg.source_ip, msg.group_ip,
-			&sg, msg.cost_to_rp);
-		zlog_debug(
-			"(%pSG)owner_id: %d, DR: %d, Dual active: %d, vrf_id: 0x%x intf_name: %s",
-			&sg, msg.owner_id, msg.am_i_dr, msg.am_i_dual_active,
-			msg.vrf_id, msg.intf_name);
+		zlog_debug("%s: msg dump: vrf_name: %s, s.ip: 0x%x, g.ip: 0x%x ((%s:%u:%u)%pSG) cost: %u",
+			   __func__, msg.vrf_name, msg.source_ip, msg.group_ip, PIM_DEBUG_VRF(vrf),
+			   &sg, msg.cost_to_rp);
+		zlog_debug("((%s:%u:%u)%pSG)owner_id: %d, DR: %d, Dual active: %d, vrf_id: 0x%x intf_name: %s",
+			   PIM_DEBUG_VRF(vrf), &sg, msg.owner_id, msg.am_i_dr,
+			   msg.am_i_dual_active, msg.vrf_id, msg.intf_name);
 	}

 	if (!(router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)) {
@@ -771,16 +770,16 @@ static void pim_mlag_process_mroute_add(struct mlag_mroute_add msg)
 static void pim_mlag_process_mroute_del(struct mlag_mroute_del msg)
 {
 	if (PIM_DEBUG_MLAG) {
+		struct vrf *vrf = vrf_lookup_by_name(msg.vrf_name);
 		pim_sgaddr sg;

 		sg.grp.s_addr = ntohl(msg.group_ip);
 		sg.src.s_addr = ntohl(msg.source_ip);
-		zlog_debug(
-			"%s: msg dump: vrf_name: %s, s.ip: 0x%x, g.ip: 0x%x(%pSG)",
-			__func__, msg.vrf_name, msg.source_ip, msg.group_ip,
-			&sg);
-		zlog_debug("(%pSG)owner_id: %d, vrf_id: 0x%x intf_name: %s",
-			   &sg, msg.owner_id, msg.vrf_id, msg.intf_name);
+		zlog_debug("%s: msg dump: vrf_name: %s, s.ip: 0x%x, g.ip: 0x%x((%s:%u:%u)%pSG)",
+			   __func__, msg.vrf_name, msg.source_ip, msg.group_ip, PIM_DEBUG_VRF(vrf),
+			   &sg);
+		zlog_debug("((%s:%u:%u)%pSG)owner_id: %d, vrf_id: 0x%x intf_name: %s",
+			   PIM_DEBUG_VRF(vrf), &sg, msg.owner_id, msg.vrf_id, msg.intf_name);
 	}

 	if (!(router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)) {
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index df96978bb6..f68ece132d 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -211,15 +211,16 @@ static void pim_mroute_nocache_forward_existing(struct interface *ifp, pim_sgadd
 	 */
 	if (!pim_nht_lookup_ecmp(pim, &rpf_nh, sg->src, &grp, false, ifp)) {
 		if (PIM_DEBUG_MROUTE_DETAIL)
-			zlog_debug("%s: %pSG NOCACHE on %s, no RPF route to source", __func__, sg,
-				   ifp->name);
+			zlog_debug("%s: (%s:%u:%u)%pSG NOCACHE on %s, no RPF route to source",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name);
 		return;
 	}

 	if (!rpf_nh.interface || rpf_nh.interface->ifindex != ifp->ifindex) {
 		if (PIM_DEBUG_MROUTE_DETAIL)
-			zlog_debug("%s: %pSG NOCACHE on %s, RPF interface is %s", __func__, sg,
-				   ifp->name, rpf_nh.interface ? rpf_nh.interface->name : "(none)");
+			zlog_debug("%s: (%s:%u:%u)%pSG NOCACHE on %s, RPF interface is %s",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name,
+				   rpf_nh.interface ? rpf_nh.interface->name : "(none)");
 		return;
 	}

@@ -237,8 +238,8 @@ static void pim_mroute_nocache_forward_existing(struct interface *ifp, pim_sgadd
 	pim_upstream_inherited_olist_decide(pim, up);
 	if (pim_upstream_empty_inherited_olist(up)) {
 		if (PIM_DEBUG_MROUTE_DETAIL)
-			zlog_debug("%s: %pSG NOCACHE on %s, no local receivers", __func__, sg,
-				   ifp->name);
+			zlog_debug("%s: (%s:%u:%u)%pSG NOCACHE on %s, no local receivers",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name);
 		return;
 	}

@@ -274,12 +275,10 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)

 	if (!pim_ifp || !pim_ifp->pim_enable) {
 		if (PIM_DEBUG_MROUTE)
-			zlog_debug(
-				"%s: %s on interface, dropping packet to %pSG",
-				ifp->name,
-				!pim_ifp ? "Multicast not enabled"
-					 : "PIM not enabled",
-				&sg);
+			zlog_debug("%s: %s on interface, dropping packet to (%s:%u:%u)%pSG",
+				   ifp->name,
+				   !pim_ifp ? "Multicast not enabled" : "PIM not enabled",
+				   PIM_DEBUG_VRF(ifp->vrf), &sg);
 		return 0;
 	}

@@ -318,11 +317,12 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)
 			rpg = RP(pim_ifp->pim, msg->msg_im_dst);
 			if (!rpg) {
 				if (PIM_DEBUG_MROUTE)
-					zlog_debug("%s: no RPF for packet to %pSG", ifp->name, &sg);
+					zlog_debug("%s: no RPF for packet to (%s:%u:%u)%pSG",
+						   ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 			} else if (pim_rpf_addr_is_inaddr_any(rpg)) {
 				if (PIM_DEBUG_MROUTE)
-					zlog_debug("%s: null RPF for packet to %pSG", ifp->name,
-						   &sg);
+					zlog_debug("%s: null RPF for packet to (%s:%u:%u)%pSG",
+						   ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 				rpg = NULL;
 			}
 		}
@@ -391,8 +391,9 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)
 			 * (duplicate NOCACHE or kernel/user mismatch).
 			 */
 			if (up->channel_oil->installed && mfc_was_installed) {
-				zlog_warn("%s: NOCACHE [%s] %s: %pSG MFC already installed before this upcall; resyncing (duplicate kernel upcall or transient MFC drop)",
-					  __func__, pim_ifp->pim->vrf->name, ifp->name, &sg);
+				zlog_warn("%s: NOCACHE [%s] %s: (%s:%u:%u)%pSG MFC already installed before this upcall; resyncing (duplicate kernel upcall or transient MFC drop)",
+					  __func__, pim_ifp->pim->vrf->name, ifp->name,
+					  PIM_DEBUG_VRF(ifp->vrf), &sg);
 				desync = true;
 			}
 		}
@@ -407,8 +408,8 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)
 		if (!up->rpf.source_nexthop.interface ||
 		    up->rpf.source_nexthop.interface->ifindex != ifp->ifindex) {
 			if (PIM_DEBUG_PIM_J_P)
-				zlog_debug("%s: Dense Mode WRONGVIF on %s for (S,G)=%pSG",
-					   __func__, ifp->name, &sg);
+				zlog_debug("%s: Dense Mode WRONGVIF on %s for (S,G)=(%s:%u:%u)%pSG",
+					   __func__, ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 			pim_dm_wrongif(ifp, sg, up);
 			return 0;
 		}
@@ -471,9 +472,8 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)

 	if (!pim_if_connected_to_source(ifp, msg->msg_im_src)) {
 		if (PIM_DEBUG_MROUTE)
-			zlog_debug(
-				"%s: incoming packet to %pSG from non-connected source",
-				ifp->name, &sg);
+			zlog_debug("%s: incoming packet to (%s:%u:%u)%pSG from non-connected source",
+				   ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 		pim_mroute_nocache_forward_existing(ifp, &sg);
 		return 0;
 	}
@@ -484,9 +484,8 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)
 		 * "normal operation" category and thus under _DETAIL
 		 */
 		if (PIM_DEBUG_MROUTE_DETAIL)
-			zlog_debug(
-				"%s: not DR on interface, not forwarding traffic for %pSG",
-				ifp->name, &sg);
+			zlog_debug("%s: not DR on interface, not forwarding traffic for (%s:%u:%u)%pSG",
+				   ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);

 		/*
 		 * We are not the DR, but we are still receiving packets
@@ -519,8 +518,9 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)
 		up = pre_up;

 		if (up->channel_oil->installed && mfc_was_installed) {
-			zlog_warn("%s: NOCACHE [%s] %s: %pSG MFC already installed before this upcall; resyncing (duplicate kernel upcall or transient MFC drop)",
-				  __func__, pim_ifp->pim->vrf->name, ifp->name, &sg);
+			zlog_warn("%s: NOCACHE [%s] %s: (%s:%u:%u)%pSG MFC already installed before this upcall; resyncing (duplicate kernel upcall or transient MFC drop)",
+				  __func__, pim_ifp->pim->vrf->name, ifp->name,
+				  PIM_DEBUG_VRF(ifp->vrf), &sg);
 			desync = true;
 		}
 	}
@@ -628,8 +628,8 @@ int pim_mroute_msg_wholepkt(int fd, struct interface *ifp, const char *buf,
 				    pim_upstream_could_register(up))
 					pim_register_join(up);
 				if (PIM_DEBUG_MROUTE)
-					zlog_debug("%s: Treat WHOLEPKT on pimreg as FHR for %pSG",
-						   __func__, &sg);
+					zlog_debug("%s: Treat WHOLEPKT on pimreg as FHR for (%s:%u:%u)%pSG",
+						   __func__, PIM_DEBUG_VRF(ifp->vrf), &sg);
 				goto have_up;
 			} else {
 				up = pim_upstream_add(pim_ifp->pim, &sg, ifp,
@@ -647,9 +647,8 @@ int pim_mroute_msg_wholepkt(int fd, struct interface *ifp, const char *buf,
 			}
 		}
 		if (PIM_DEBUG_MROUTE_DETAIL) {
-			zlog_debug(
-				"%s: Unable to find upstream channel WHOLEPKT%pSG",
-				__func__, &sg);
+			zlog_debug("%s: Unable to find upstream channel WHOLEPKT(%s:%u:%u)%pSG",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), &sg);
 		}
 		return 0;
 	}
@@ -680,9 +679,8 @@ have_up:
 	if (!event_is_scheduled(up->t_rs_timer)) {
 		if (pim_is_grp_ssm(pim_ifp->pim, sg.grp)) {
 			if (PIM_DEBUG_PIM_REG)
-				zlog_debug(
-					"%pSG register forward skipped as group is SSM",
-					&sg);
+				zlog_debug("(%s:%u:%u)%pSG register forward skipped as group is SSM",
+					   PIM_DEBUG_VRF(ifp->vrf), &sg);
 			return 0;
 		}

@@ -874,8 +872,8 @@ static int pim_mroute_wrongvif_prefer_ingress(struct interface *ifp, pim_sgaddr
 	 */
 	if (!pim_nht_lookup_ecmp(pim, &rpf_nh, sg->src, &grp, false, ifp)) {
 		if (PIM_DEBUG_MROUTE_DETAIL)
-			zlog_debug("%s: %pSG WRONGVIF on %s, no RPF route to source", __func__, sg,
-				   ifp->name);
+			zlog_debug("%s: (%s:%u:%u)%pSG WRONGVIF on %s, no RPF route to source",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name);
 		return -1;
 	}

@@ -890,13 +888,13 @@ static int pim_mroute_wrongvif_prefer_ingress(struct interface *ifp, pim_sgaddr
 		if (pim_if_connected_to_source(ifp, sg->src)) {
 			force_connected_ingress = true;
 			if (PIM_DEBUG_MROUTE_DETAIL)
-				zlog_debug("%s: %pSG WRONGVIF on %s, forcing connected ingress (RPF is %s)",
-					   __func__, sg, ifp->name,
+				zlog_debug("%s: (%s:%u:%u)%pSG WRONGVIF on %s, forcing connected ingress (RPF is %s)",
+					   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name,
 					   rpf_nh.interface ? rpf_nh.interface->name : "(none)");
 		} else {
 			if (PIM_DEBUG_MROUTE_DETAIL)
-				zlog_debug("%s: %pSG WRONGVIF on %s, ingress is not RPF interface (RPF is %s)",
-					   __func__, sg, ifp->name,
+				zlog_debug("%s: (%s:%u:%u)%pSG WRONGVIF on %s, ingress is not RPF interface (RPF is %s)",
+					   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name,
 					   rpf_nh.interface ? rpf_nh.interface->name : "(none)");
 			return -1;
 		}
@@ -933,8 +931,8 @@ static int pim_mroute_wrongvif_prefer_ingress(struct interface *ifp, pim_sgaddr
 	pim_upstream_inherited_olist_decide(pim, up);
 	if (pim_upstream_empty_inherited_olist(up)) {
 		if (PIM_DEBUG_MROUTE_DETAIL)
-			zlog_debug("%s: %pSG WRONGVIF on %s, no local receivers", __func__, sg,
-				   ifp->name);
+			zlog_debug("%s: (%s:%u:%u)%pSG WRONGVIF on %s, no local receivers",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name);
 		/*
 		 * Handled: do not fall through to WRVIFWHOLE compat, which can
 		 * install/update MFC without this empty-OIL guard.
@@ -959,8 +957,9 @@ static int pim_mroute_wrongvif_prefer_ingress(struct interface *ifp, pim_sgaddr
 		pim_upstream_mroute_iif_update(up->channel_oil, __func__);

 	if (PIM_DEBUG_MROUTE)
-		zlog_debug("%s: %pSG WRONGVIF on %s, realigned MFC iif to ingress%s", __func__, sg,
-			   ifp->name, force_connected_ingress ? " (connected)" : "");
+		zlog_debug("%s: (%s:%u:%u)%pSG WRONGVIF on %s, realigned MFC iif to ingress%s",
+			   __func__, PIM_DEBUG_VRF(ifp->vrf), sg, ifp->name,
+			   force_connected_ingress ? " (connected)" : "");

 	return 0;
 }
@@ -990,18 +989,16 @@ int pim_mroute_msg_wrongvif(int fd, struct interface *ifp, const kernmsg *msg)

 	if (!ifp) {
 		if (PIM_DEBUG_MROUTE)
-			zlog_debug(
-				"%s: WRONGVIF (S,G)=%pSG could not find input interface for input_vif_index=%d",
-				__func__, &sg, msg->msg_im_vif);
+			zlog_debug("%s: WRONGVIF (S,G)=(%s:%u:%u)%pSG could not find input interface for input_vif_index=%d",
+				   __func__, "UNKNOWN", VRF_UNKNOWN, 0, &sg, msg->msg_im_vif);
 		return -1;
 	}

 	pim_ifp = ifp->info;
 	if (!pim_ifp) {
 		if (PIM_DEBUG_MROUTE)
-			zlog_debug(
-				"%s: WRONGVIF (S,G)=%pSG multicast not enabled on interface %s",
-				__func__, &sg, ifp->name);
+			zlog_debug("%s: WRONGVIF (S,G)=(%s:%u:%u)%pSG multicast not enabled on interface %s",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), &sg, ifp->name);
 		return -2;
 	}

@@ -1016,17 +1013,16 @@ int pim_mroute_msg_wrongvif(int fd, struct interface *ifp, const kernmsg *msg)
 		pim_sgaddr star_g = sg;

 		if (PIM_DEBUG_MROUTE)
-			zlog_debug(
-				"%s: WRONGVIF (S,G)=%pSG could not find channel on interface %s",
-				__func__, &sg, ifp->name);
+			zlog_debug("%s: WRONGVIF (S,G)=(%s:%u:%u)%pSG could not find channel on interface %s",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), &sg, ifp->name);

 		star_g.src = PIMADDR_ANY;
 		pim_ifchannel_find(ifp, &star_g, &ch, &throwaway);
 		if (ch)
 			any_channel = true;
 		else if (PIM_DEBUG_MROUTE)
-			zlog_debug("%s: WRONGVIF (*,G)=%pSG could not find channel on interface %s",
-				   __func__, &star_g, ifp->name);
+			zlog_debug("%s: WRONGVIF (*,G)=(%s:%u:%u)%pSG could not find channel on interface %s",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), &star_g, ifp->name);
 	}

 	if (!sg_channel && !pim_iface_grp_dm(pim_ifp, sg.grp) && ifp != pim_ifp->pim->regiface) {
@@ -1077,13 +1073,13 @@ int pim_mroute_msg_wrongvif(int fd, struct interface *ifp, const kernmsg *msg)

 		if (!up) {
 			if (PIM_DEBUG_MROUTE)
-				zlog_debug("%s: Dense Mode WRONGVIF on %s for (S,G)=%pSG, no upstream",
-					   __func__, ifp->name, &sg);
+				zlog_debug("%s: Dense Mode WRONGVIF on %s for (S,G)=(%s:%u:%u)%pSG, no upstream",
+					   __func__, ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 			return 0;
 		}
 		if (PIM_DEBUG_PIM_J_P)
-			zlog_debug("%s: Dense Mode WRONGVIF on %s for (S,G)=%pSG", __func__,
-				   ifp->name, &sg);
+			zlog_debug("%s: Dense Mode WRONGVIF on %s for (S,G)=(%s:%u:%u)%pSG",
+				   __func__, ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 		pim_dm_wrongif(ifp, sg, up);
 		return 0;
 	}
@@ -1162,13 +1158,14 @@ int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, const char *buf,
 		up = pim_upstream_find(pim, &sg);
 		if (!up) {
 			if (PIM_DEBUG_MROUTE)
-				zlog_debug("WRVIFWHOLE (S,G)=%pSG dense mode, no upstream", &sg);
+				zlog_debug("WRVIFWHOLE (S,G)=(%s:%u:%u)%pSG dense mode, no upstream",
+					   PIM_DEBUG_VRF(ifp->vrf), &sg);
 			return 0;
 		}

 		if (PIM_DEBUG_PIM_J_P)
-			zlog_debug("%s: Dense Mode WRVIFWHOLE on %s for (S,G)=%pSG", __func__,
-				   ifp->name, &sg);
+			zlog_debug("%s: Dense Mode WRVIFWHOLE on %s for (S,G)=(%s:%u:%u)%pSG",
+				   __func__, ifp->name, PIM_DEBUG_VRF(ifp->vrf), &sg);
 		pim_dm_wrongif(ifp, sg, up);
 		return 0;
 	}
@@ -1306,9 +1303,8 @@ int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, const char *buf,
 		up = pim_upstream_add(pim_ifp->pim, &sg, ifp, up_flags, __func__, NULL);
 		if (!up) {
 			if (PIM_DEBUG_MROUTE)
-				zlog_debug(
-					"%pSG: WRONGVIF%s unable to create upstream on interface",
-					&sg, ifp->name);
+				zlog_debug("(%s:%u:%u)%pSG: WRONGVIF%s unable to create upstream on interface",
+					   PIM_DEBUG_VRF(ifp->vrf), &sg, ifp->name);
 			return -2;
 		}
 		if (up_flags == PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE)
@@ -2096,8 +2092,8 @@ void pim_mroute_update_counters(struct channel_oil *c_oil)

 			sg.src = c_oil->source;
 			sg.grp = c_oil->group;
-			zlog_debug("Channel%pSG is not installed no need to collect data from kernel",
-				   &sg);
+			zlog_debug("Channel(%s:%u:%u)%pSG is not installed no need to collect data from kernel",
+				   PIM_DEBUG_VRF(c_oil->pim->vrf), &sg);
 		}
 		return;
 	}
@@ -2122,10 +2118,9 @@ void pim_mroute_update_counters(struct channel_oil *c_oil)
 		sg.src = c_oil->source;
 		sg.grp = c_oil->group;

-		zlog_warn(
-			"ioctl(PIM_SIOCGETSGCNT=%lu) failure for (S,G)=%pSG: errno=%d: %s",
-			(unsigned long)PIM_SIOCGETSGCNT, &sg, errno,
-			safe_strerror(errno));
+		zlog_warn("ioctl(PIM_SIOCGETSGCNT=%lu) failure for (S,G)=(%s:%u:%u)%pSG: errno=%d: %s",
+			  (unsigned long)PIM_SIOCGETSGCNT, PIM_DEBUG_VRF(c_oil->pim->vrf), &sg,
+			  errno, safe_strerror(errno));
 		return;
 	}

diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 77e74319b9..1130af56cd 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -652,7 +652,7 @@ static void pim_msdp_up_xg_del(struct pim_instance *pim, pim_sgaddr *sg)
 	struct pim_msdp_sa *sa;

 	if (PIM_DEBUG_MSDP_INTERNAL) {
-		zlog_debug("MSDP %pSG del", sg);
+		zlog_debug("MSDP (%s:%u:%u)%pSG del", PIM_DEBUG_VRF(pim->vrf), sg);
 	}

 	/* If this is not really an XG entry just move on */
@@ -673,7 +673,7 @@ static void pim_msdp_up_xg_del(struct pim_instance *pim, pim_sgaddr *sg)
 void pim_msdp_up_del(struct pim_instance *pim, pim_sgaddr *sg)
 {
 	if (PIM_DEBUG_MSDP_INTERNAL) {
-		zlog_debug("MSDP up %pSG del", sg);
+		zlog_debug("MSDP up (%s:%u:%u)%pSG del", PIM_DEBUG_VRF(pim->vrf), sg);
 	}
 	if (pim_addr_is_any(sg->src)) {
 		pim_msdp_up_xg_del(pim, sg);
diff --git a/pimd/pim_msdp_packet.c b/pimd/pim_msdp_packet.c
index 0b19cfeced..5f00f12e3c 100644
--- a/pimd/pim_msdp_packet.c
+++ b/pimd/pim_msdp_packet.c
@@ -56,7 +56,7 @@ static char *pim_msdp_pkt_type_dump(enum pim_msdp_tlv type, char *buf,
 	return buf;
 }

-static void pim_msdp_pkt_sa_dump_one(struct stream *s)
+static void pim_msdp_pkt_sa_dump_one(struct pim_msdp_peer *mp, struct stream *s)
 {
 	pim_sgaddr sg;

@@ -69,10 +69,10 @@ static void pim_msdp_pkt_sa_dump_one(struct stream *s)
 	sg.grp.s_addr = stream_get_ipv4(s);
 	sg.src.s_addr = stream_get_ipv4(s);

-	zlog_debug("  sg %pSG", &sg);
+	zlog_debug("  sg (%s:%u:%u)%pSG", PIM_DEBUG_VRF(mp->pim->vrf), &sg);
 }

-static void pim_msdp_pkt_sa_dump(struct stream *s)
+static void pim_msdp_pkt_sa_dump(struct pim_msdp_peer *mp, struct stream *s)
 {
 	const size_t header_length = PIM_MSDP_SA_X_SIZE - PIM_MSDP_HEADER_SIZE;
 	size_t payload_length;
@@ -101,7 +101,7 @@ static void pim_msdp_pkt_sa_dump(struct stream *s)

 	/* dump SAs */
 	for (i = 0; i < entry_cnt; ++i) {
-		pim_msdp_pkt_sa_dump_one(s);
+		pim_msdp_pkt_sa_dump_one(mp, s);
 	}
 }

@@ -126,7 +126,7 @@ static void pim_msdp_pkt_dump(struct pim_msdp_peer *mp, int type, int len,

 	switch (type) {
 	case PIM_MSDP_V4_SOURCE_ACTIVE:
-		pim_msdp_pkt_sa_dump(s);
+		pim_msdp_pkt_sa_dump(mp, s);
 		break;
 	default:;
 	}
@@ -579,7 +579,7 @@ static void pim_msdp_pkt_sa_rx_one(struct pim_msdp_peer *mp, struct in_addr rp)
 		return;
 	}
 	if (PIM_DEBUG_MSDP_PACKETS) {
-		zlog_debug("  sg %pSG", &sg);
+		zlog_debug("  sg (%s:%u:%u)%pSG", PIM_DEBUG_VRF(mp->pim->vrf), &sg);
 	}

 	/* Filter incoming SA with configured access list. */
diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c
index a4d6fea652..bd65d4e7ba 100644
--- a/pimd/pim_oil.c
+++ b/pimd/pim_oil.c
@@ -130,9 +130,9 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
 		pim_upstream_mroute_iif_update(c_oil, __func__);

 		if (PIM_DEBUG_MROUTE)
-			zlog_debug(
-				"%s(%s): Existing oil for %pSG Ref Count: %d (Post Increment)",
-				__func__, name, sg, c_oil->oil_ref_count);
+			zlog_debug("%s(%s): Existing oil for (%s:%u:%u)%pSG Ref Count: %d (Post Increment)",
+				   __func__, name, PIM_DEBUG_VRF(pim->vrf), sg,
+				   c_oil->oil_ref_count);
 		return c_oil;
 	}

@@ -151,7 +151,8 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
 	rb_pim_oil_add(&pim->channel_oil_head, c_oil);

 	if (PIM_DEBUG_MROUTE)
-		zlog_debug("%s(%s): c_oil %pSG add", __func__, name, sg);
+		zlog_debug("%s(%s): c_oil (%s:%u:%u)%pSG add", __func__, name,
+			   PIM_DEBUG_VRF(pim->vrf), sg);

 	return c_oil;
 }
@@ -199,9 +200,9 @@ struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil,
 	if (PIM_DEBUG_MROUTE) {
 		pim_sgaddr sg = { .src = c_oil->source, .grp = c_oil->group };

-		zlog_debug(
-			"%s(%s): Del oil for %pSG, Ref Count: %d (Predecrement)",
-			__func__, name, &sg, c_oil->oil_ref_count);
+		zlog_debug("%s(%s): Del oil for (%s:%u:%u)%pSG, Ref Count: %d (Predecrement)",
+			   __func__, name, PIM_DEBUG_VRF(c_oil->pim->vrf), &sg,
+			   c_oil->oil_ref_count);
 	}
 	--c_oil->oil_ref_count;

diff --git a/pimd/pim_register.c b/pimd/pim_register.c
index ceb001e7ba..5ef32b6657 100644
--- a/pimd/pim_register.c
+++ b/pimd/pim_register.c
@@ -72,8 +72,8 @@ void pim_register_stop_send(struct interface *ifp, pim_sgaddr *sg, pim_addr src,
 	uint8_t *b1;

 	if (PIM_DEBUG_PIM_REG) {
-		zlog_debug("Sending Register stop for %pSG to %pPA on %s", sg,
-			   &originator, ifp->name);
+		zlog_debug("Sending Register stop for (%s:%u:%u)%pSG to %pPA on %s",
+			   PIM_DEBUG_VRF(ifp->vrf), sg, &originator, ifp->name);
 	}

 	memset(buffer, 0, 10000);
@@ -175,13 +175,14 @@ int pim_register_stop_recv(struct interface *ifp, pim_addr src_addr, uint8_t *bu
 	}

 	if (PIM_DEBUG_PIM_REG)
-		zlog_debug("Received Register stop for %pSG", &sg);
+		zlog_debug("Received Register stop for (%s:%u:%u)%pSG", PIM_DEBUG_VRF(ifp->vrf),
+			   &sg);

 	rp = RP(pim_ifp->pim, sg.grp);
 	if (!rp) {
 		if (PIM_DEBUG_PIM_REG)
-			zlog_debug("%s: Ignoring Register-Stop%pSG from %pPA with no RP mapping",
-				   __func__, &sg, &src_addr);
+			zlog_debug("%s: Ignoring Register-Stop(%s:%u:%u)%pSG from %pPA with no RP mapping",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), &sg, &src_addr);
 		return 0;
 	}

@@ -192,8 +193,9 @@ int pim_register_stop_recv(struct interface *ifp, pim_addr src_addr, uint8_t *bu
 	 */
 	if (pim_addr_cmp(src_addr, rp->rpf_addr) != 0) {
 		if (PIM_DEBUG_PIM_REG)
-			zlog_debug("%s: Ignoring Register-Stop%pSG from %pPA, expected RP %pPA",
-				   __func__, &sg, &src_addr, &rp->rpf_addr);
+			zlog_debug("%s: Ignoring Register-Stop(%s:%u:%u)%pSG from %pPA, expected RP %pPA",
+				   __func__, PIM_DEBUG_VRF(ifp->vrf), &sg, &src_addr,
+				   &rp->rpf_addr);
 		return 0;
 	}

@@ -612,8 +614,8 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,

 		if (tlv_buf_size < (int)(sizeof(struct ip6_hdr) + sizeof(struct pim_msg_header))) {
 			if (PIM_DEBUG_PIM_PACKETS)
-				zlog_debug("Ignoring Null Register message%pSG from %pPA due to truncated encapsulated dummy PIM header",
-					   &sg, &src_addr);
+				zlog_debug("Ignoring Null Register message(%s:%u:%u)%pSG from %pPA due to truncated encapsulated dummy PIM header",
+					   PIM_DEBUG_VRF(ifp->vrf), &sg, &src_addr);
 			return 0;
 		}

@@ -630,9 +632,8 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,

 		if (computed_checksum != received_checksum) {
 			if (PIM_DEBUG_PIM_PACKETS)
-				zlog_debug(
-					"Ignoring Null Register message%pSG from %pPA due to bad checksum in Encapsulated dummy PIM header",
-					&sg, &src_addr);
+				zlog_debug("Ignoring Null Register message(%s:%u:%u)%pSG from %pPA due to bad checksum in Encapsulated dummy PIM header",
+					   PIM_DEBUG_VRF(ifp->vrf), &sg, &src_addr);
 			return 0;
 		}
 	}
@@ -640,9 +641,8 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
 	i_am_rp = I_am_RP(pim, sg.grp);

 	if (PIM_DEBUG_PIM_REG)
-		zlog_debug(
-			"Received Register message%pSG from %pPA on %s, rp: %d",
-			&sg, &src_addr, ifp->name, i_am_rp);
+		zlog_debug("Received Register message(%s:%u:%u)%pSG from %pPA on %s, rp: %d",
+			   PIM_DEBUG_VRF(ifp->vrf), &sg, &src_addr, ifp->name, i_am_rp);

 	if (pim_is_grp_ssm(pim_ifp->pim, sg.grp)) {
 		if (pim_addr_is_any(sg.src)) {
@@ -656,8 +656,8 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,

 	rpg = RP(pim, sg.grp);
 	if (!rpg) {
-		zlog_warn("%s: Received Register Message %pSG from %pPA on %s where the RP could not be looked up",
-			  __func__, &sg, &src_addr, ifp->name);
+		zlog_warn("%s: Received Register Message (%s:%u:%u)%pSG from %pPA on %s where the RP could not be looked up",
+			  __func__, PIM_DEBUG_VRF(ifp->vrf), &sg, &src_addr, ifp->name);
 		return 0;
 	}

@@ -679,9 +679,9 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
 				pim_register_stop_send(ifp, &sg, dest_addr,
 						       src_addr);
 				if (PIM_DEBUG_PIM_PACKETS)
-					zlog_debug(
-						"%s: Sending register-stop to %pPA for %pSG due to prefix-list denial, dropping packet",
-						__func__, &src_addr, &sg);
+					zlog_debug("%s: Sending register-stop to %pPA for (%s:%u:%u)%pSG due to prefix-list denial, dropping packet",
+						   __func__, &src_addr, PIM_DEBUG_VRF(ifp->vrf),
+						   &sg);

 				return 0;
 			}
@@ -774,11 +774,11 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
 	} else {
 		if (PIM_DEBUG_PIM_REG) {
 			if (!i_am_rp)
-				zlog_debug("Received Register packet for %pSG, Rejecting packet because I am not the RP configured for group",
-					   &sg);
+				zlog_debug("Received Register packet for (%s:%u:%u)%pSG, Rejecting packet because I am not the RP configured for group",
+					   PIM_DEBUG_VRF(ifp->vrf), &sg);
 			else
-				zlog_debug("Received Register packet for %pSG, Rejecting packet because the dst ip address is not the actual RP",
-					   &sg);
+				zlog_debug("Received Register packet for (%s:%u:%u)%pSG, Rejecting packet because the dst ip address is not the actual RP",
+					   PIM_DEBUG_VRF(ifp->vrf), &sg);
 		}
 		pim_register_stop_send(ifp, &sg, dest_addr, src_addr);
 	}
diff --git a/pimd/pim_static.c b/pimd/pim_static.c
index 80aaa615f4..da9508fa7c 100644
--- a/pimd/pim_static.c
+++ b/pimd/pim_static.c
@@ -440,13 +440,14 @@ int pim_static_nocache_resolve(struct pim_instance *pim, struct interface *ifp,

 	if (pim_mroute_add(&s_route->c_oil, __func__)) {
 		if (PIM_DEBUG_MROUTE)
-			zlog_debug("%s: failed to reinstall static mroute %pSG on %s", __func__,
-				   sg, ifp->name);
+			zlog_debug("%s: failed to reinstall static mroute (%s:%u:%u)%pSG on %s",
+				   __func__, PIM_DEBUG_VRF(pim->vrf), sg, ifp->name);
 		return -1;
 	}

 	if (PIM_DEBUG_MROUTE)
-		zlog_debug("%s: reinstalled static mroute %pSG on %s", __func__, sg, ifp->name);
+		zlog_debug("%s: reinstalled static mroute (%s:%u:%u)%pSG on %s", __func__,
+			   PIM_DEBUG_VRF(pim->vrf), sg, ifp->name);

 	return 0;
 }
diff --git a/pimd/pim_tib.c b/pimd/pim_tib.c
index 7887bad0fd..b36177966f 100644
--- a/pimd/pim_tib.c
+++ b/pimd/pim_tib.c
@@ -52,13 +52,13 @@ tib_sg_oil_setup(struct pim_instance *pim, pim_sgaddr sg, struct interface *oif)
 		input_iface_vif_index = pim_nht_lookup_ecmp_if_vif_index(pim, vif_source, &grp);

 	if (PIM_DEBUG_ZEBRA)
-		zlog_debug("%s: NHT %pSG vif_source %pPAs vif_index:%d",
-			   __func__, &sg, &vif_source, input_iface_vif_index);
+		zlog_debug("%s: NHT (%s:%u:%u)%pSG vif_source %pPAs vif_index:%d", __func__,
+			   PIM_DEBUG_VRF(pim->vrf), &sg, &vif_source, input_iface_vif_index);

 	if (input_iface_vif_index < 1) {
 		if (PIM_DEBUG_GM_TRACE)
-			zlog_debug("%s %s: could not find vif index of interface with NH to RP for %pSG",
-				   __FILE__, __func__, &sg);
+			zlog_debug("%s %s: could not find vif index of interface with NH to RP for (%s:%u:%u)%pSG",
+				   __FILE__, __func__, PIM_DEBUG_VRF(pim->vrf), &sg);

 		return pim_channel_oil_add(pim, &sg, __func__);
 	}
@@ -71,10 +71,9 @@ tib_sg_oil_setup(struct pim_instance *pim, pim_sgaddr sg, struct interface *oif)
 	 */
 	if ((input_iface_vif_index == pim_oif->mroute_vif_index) && !(PIM_I_am_DR(pim_oif))) {
 		if (PIM_DEBUG_GM_TRACE)
-			zlog_debug(
-				"%s: ignoring request for looped MFC entry (S,G)=%pSG: oif=%s vif_index=%d",
-				__func__, &sg, oif->name,
-				input_iface_vif_index);
+			zlog_debug("%s: ignoring request for looped MFC entry (S,G)=(%s:%u:%u)%pSG: oif=%s vif_index=%d",
+				   __func__, PIM_DEBUG_VRF(pim->vrf), &sg, oif->name,
+				   input_iface_vif_index);

 		return NULL;
 	}
@@ -256,8 +255,9 @@ static void tib_sg_proxy_prune_uncovered_sources(struct pim_instance *pim, pim_a
 			continue;

 		if (PIM_DEBUG_GM_TRACE)
-			zlog_debug("%s: prune uncovered proxy %pSG on %s after (*,G) leave on %s",
-				   __func__, &check, proxy_ifp->name, leave_oif->name);
+			zlog_debug("%s: prune uncovered proxy (%s:%u:%u)%pSG on %s after (*,G) leave on %s",
+				   __func__, PIM_DEBUG_VRF(pim->vrf), &check, proxy_ifp->name,
+				   leave_oif->name);

 		pim_if_gm_join_del(proxy_ifp, group, ij->source_addr, GM_JOIN_PROXY);
 	}
@@ -326,8 +326,9 @@ void tib_sg_proxy_join_prune_check(struct pim_instance *pim, pim_sgaddr sg,
 				pim_if_gm_join_add(ifp, sg.grp, sg.src, GM_JOIN_PROXY);
 			} else if (tib_sg_downstream_receivers_remain(pim, sg, oif, ifp)) {
 				if (PIM_DEBUG_GM_TRACE)
-					zlog_debug("%s: skip proxy prune for %pSG after leave on %s; other unfiltered receivers remain for %s",
-						   __func__, &sg, oif->name, ifp->name);
+					zlog_debug("%s: skip proxy prune for (%s:%u:%u)%pSG after leave on %s; other unfiltered receivers remain for %s",
+						   __func__, PIM_DEBUG_VRF(pim->vrf), &sg,
+						   oif->name, ifp->name);
 			} else {
 				pim_if_gm_join_del(ifp, sg.grp, sg.src, GM_JOIN_PROXY);
 				/*
@@ -405,9 +406,8 @@ bool tib_sg_gm_join(struct pim_instance *pim, pim_sgaddr sg,
 		}
 	} else {
 		if (PIM_DEBUG_GM_TRACE)
-			zlog_debug(
-				"%s: %pSG was received on %s interface but we are not DR for that interface",
-				__func__, &sg, oif->name);
+			zlog_debug("%s: (%s:%u:%u)%pSG was received on %s interface but we are not DR for that interface",
+				   __func__, PIM_DEBUG_VRF(pim->vrf), &sg, oif->name);

 		return false;
 	}
@@ -417,9 +417,8 @@ bool tib_sg_gm_join(struct pim_instance *pim, pim_sgaddr sg,
 	 */
 	if (!pim_ifchannel_local_membership_add(oif, &sg, false /*is_vxlan*/)) {
 		if (PIM_DEBUG_MROUTE)
-			zlog_warn(
-				"%s: Failure to add local membership for %pSG",
-				__func__, &sg);
+			zlog_warn("%s: Failure to add local membership for (%s:%u:%u)%pSG",
+				  __func__, PIM_DEBUG_VRF(pim->vrf), &sg);

 		pim_channel_del_oif(*oilp, oif, PIM_OIF_FLAG_PROTO_GM,
 				    __func__);
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index 5ce41fa388..49c7527b5e 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -427,8 +427,8 @@ static void on_prune_limit_timer(struct event *t)

 	up = EVENT_ARG(t);
 	if (PIM_DEBUG_PIM_J_P)
-		zlog_debug("%s: Prune limit timer expired for upstream (s,g)=%pSG", __func__,
-			   &up->sg);
+		zlog_debug("%s: Prune limit timer expired for upstream (s,g)=(%s:%u:%u)%pSG",
+			   __func__, PIM_DEBUG_VRF(up->pim->vrf), &up->sg);
 }


@@ -513,8 +513,8 @@ void prune_limit_timer_start(struct pim_upstream *up)
 	event_add_timer(router->master, on_prune_limit_timer, up, router->t_prune_limit,
 			&up->t_prune_limit_timer);
 	if (PIM_DEBUG_PIM_J_P)
-		zlog_debug("%s: Started Prune limit timer (%ds) for upstream (s,g)=%pSG", __func__,
-			   router->t_prune_limit, &up->sg);
+		zlog_debug("%s: Started Prune limit timer (%ds) for upstream (s,g)=(%s:%u:%u)%pSG",
+			   __func__, router->t_prune_limit, PIM_DEBUG_VRF(up->pim->vrf), &up->sg);
 }

 bool should_limit_prune(struct pim_upstream *up)
@@ -2178,8 +2178,8 @@ static void pim_upstream_register_probe_timer(struct event *t)
 	if (!up->rpf.source_nexthop.interface ||
 	    !up->rpf.source_nexthop.interface->info) {
 		if (PIM_DEBUG_PIM_REG)
-			zlog_debug("cannot send Null register for %pSG, no path to RP",
-				   &up->sg);
+			zlog_debug("cannot send Null register for (%s:%u:%u)%pSG, no path to RP",
+				   PIM_DEBUG_VRF(up->pim->vrf), &up->sg);
 	} else {
 		up->reg_state = PIM_REG_JOIN_PENDING;
 		if (PIM_DEBUG_PIM_TRACE) {
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index f5b895d75e..b1aa406f95 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -326,8 +326,8 @@ static int pim_zebra_vxlan_sg_proc(ZAPI_CALLBACK_ARGS)
 	stream_get(&sg.grp, s, prefixlen);

 	if (PIM_DEBUG_ZEBRA)
-		zlog_debug("%s:recv SG %s %pSG", VRF_LOGNAME(pim->vrf),
-			   (cmd == ZEBRA_VXLAN_SG_ADD) ? "add" : "del", &sg);
+		zlog_debug("recv SG %s (%s:%u:%u)%pSG", (cmd == ZEBRA_VXLAN_SG_ADD) ? "add" : "del",
+			   PIM_DEBUG_VRF(pim->vrf), &sg);

 	if (cmd == ZEBRA_VXLAN_SG_ADD)
 		pim_vxlan_sg_add(pim, &sg);
@@ -463,8 +463,9 @@ void pim_forward_start(struct pim_ifchannel *ch)
 	uint32_t mask = 0;

 	if (PIM_DEBUG_PIM_TRACE)
-		zlog_debug("%s: (S,G)=%pSG oif=%s (%pPA)", __func__, &ch->sg,
-			   ch->interface->name, &up->upstream_addr);
+		zlog_debug("%s: (S,G)=(%s:%u:%u)%pSG oif=%s (%pPA)", __func__,
+			   PIM_DEBUG_VRF(ch->interface->vrf), &ch->sg, ch->interface->name,
+			   &up->upstream_addr);

 	if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags))
 		mask = PIM_OIF_FLAG_PROTO_GM;
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 61ea224150..d56d7d017e 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -600,9 +600,9 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
 	if (PIM_DEBUG_ZEBRA) {
 		more.src = c_oil->source;
 		more.grp = c_oil->group;
-		zlog_debug("Sending Request for New Channel Oil Information%pSG VIIF %d(%s:%s)",
-			   &more, c_oil->iif.index, ifp ? ifp->name : "Unknown",
-			   c_oil->pim->vrf->name);
+		zlog_debug("Sending Request for New Channel Oil Information(%s:%u:%u)%pSG VIIF %d(%s:%s)",
+			   PIM_DEBUG_VRF(c_oil->pim->vrf), &more, c_oil->iif.index,
+			   ifp ? ifp->name : "Unknown", c_oil->pim->vrf->name);
 	}

 	if (!ifp)
@@ -654,10 +654,9 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
 	more.grp = c_oil->group;
 	if (pim_sgaddr_cmp(sg, more)) {
 		if (PIM_DEBUG_ZEBRA)
-			flog_err(
-				EC_LIB_ZAPI_MISSMATCH,
-				"%s: Received wrong %pSG(%s) information requested",
-				__func__, &more, c_oil->pim->vrf->name);
+			flog_err(EC_LIB_ZAPI_MISSMATCH,
+				 "%s: Received wrong (%s:%u:%u)%pSG information requested",
+				 __func__, PIM_DEBUG_VRF(c_oil->pim->vrf), &more);
 		zclient_lookup_failed(pim_zlookup);
 		return -3;
 	}