Commit 4029ac96e1 for frr

commit 4029ac96e198f98bde525e97f2276b943a9c8fd6
Author: Donald Sharp <sharpd@nvidia.com>
Date:   Fri Oct 2 12:50:09 2026 -0400

    bgpd: Converge usage of %pBD in debugs

    When using a %pBD in a debug convert it to use this:

    "(%s:%u:%u)%pBD", bgp->name, vrf_id, table_id, dest

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

diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 37779dc0b9..86c7d2f18e 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -1744,9 +1744,12 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
 	 * the workqueue
 	 */
 	if (CHECK_FLAG(dest->flags, BGP_NODE_SELECT_DEFER)) {
-		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
-			zlog_debug("%s: SELECT_DEFER flag set for EVPN route %pBD, dest %p",
-				   bgp->name_pretty, dest, dest);
+		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) {
+			struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+			zlog_debug("%s: SELECT_DEFER flag set for EVPN route (%s:%u:%u)%pBD, dest %p",
+				   bgp->name_pretty, dv.name, dv.id, dv.table_id, dest, dest);
+		}

 		return ret;
 	}
@@ -2510,9 +2513,12 @@ evpn_cleanup_local_non_best_route(struct bgp *bgp, struct bgpevpn *vpn,
 				  struct bgp_path_info *local_pi)
 {
 	/* local path was not picked as the winner; kick it out */
-	if (bgp_debug_zebra(NULL))
-		zlog_debug("evicting local evpn prefix %pBD as remote won",
-			   dest);
+	if (bgp_debug_zebra(NULL)) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+		zlog_debug("evicting local evpn prefix (%s:%u:%u)%pBD as remote won", dv.name,
+			   dv.id, dv.table_id, dest);
+	}

 	evpn_delete_old_local_route(bgp, vpn, dest, local_pi, NULL);

@@ -7908,14 +7914,16 @@ void bgp_reimport_evpn_routes_upon_macvrf_soo_change(struct bgp *bgp,
 				if (old_soo_fnd && !new_soo_fnd) {
 					if (bgp_debug_update(pi->peer, p, NULL,
 							     1)) {
+						struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
 						char attr_str[BUFSIZ] = {0};

 						bgp_dump_attr(pi->attr,
 							      attr_str, BUFSIZ);

 						zlog_debug(
-							"mac-vrf soo changed: evaluating reimport of prefix %pBD with attr %s",
-							dest, attr_str);
+							"mac-vrf soo changed: evaluating reimport of prefix (%s:%u:%u)%pBD with attr %s",
+							dv.name, dv.id, dv.table_id, dest,
+							attr_str);
 					}

 					bgp_evpn_import_route(bgp, afi, safi, p,
@@ -7962,9 +7970,13 @@ static void bgp_evpn_log_martian_discard(struct bgp *bgp, struct bgp_path_info *
 	bgp_dump_attr(pi->attr, attr_str, sizeof(attr_str));
 	prefix2str(p, prefix_str, sizeof(prefix_str));

-	if (bgp_debug_update(pi->peer, p, NULL, 1))
-		zlog_debug("%u: prefix %pBD with attr %s - DISCARDED due to Martian/%s",
-			   bgp->vrf_id, dest, attr_str, bgp_martian_type2str(martian_type));
+	if (bgp_debug_update(pi->peer, p, NULL, 1)) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+		zlog_debug("(%s:%u:%u)%pBD with attr %s - DISCARDED due to Martian/%s", dv.name,
+			   dv.id, dv.table_id, dest, attr_str,
+			   bgp_martian_type2str(martian_type));
+	}

 	frrtrace(4, frr_bgp, upd_attr_discarded_due_to_martian, bgp->vrf_id, prefix_str, attr_str,
 		 bgp_martian_type2str(martian_type));
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index a75c7f85e2..6b9844a812 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -260,9 +260,13 @@ static void bgp_send_fec_register_label_msg(struct bgp_dest *dest, bool reg,
 	if (!bgp_zclient || bgp_zclient->sock < 0)
 		return;

-	if (BGP_DEBUG(labelpool, LABELPOOL))
-		zlog_debug("%s: FEC %sregister %pBD label_index=%u label=%u",
-			   __func__, reg ? "" : "un", dest, label_index, label);
+	if (BGP_DEBUG(labelpool, LABELPOOL)) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+		zlog_debug("%s: FEC %sregister (%s:%u:%u)%pBD label_index=%u label=%u", __func__,
+			   reg ? "" : "un", dv.name, dv.id, dv.table_id, dest, label_index,
+			   label);
+	}
 	/* If the route node has a local_label assigned or the
 	 * path node has an MPLS SR label index allowing zebra to
 	 * derive the label, proceed with registration. */
@@ -326,9 +330,12 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
 	dest = bgp_dest_unlock_node(dest);
 	assert(dest);

-	if (BGP_DEBUG(labelpool, LABELPOOL))
-		zlog_debug("%s: FEC %pBD label=%u, allocated=%d", __func__,
-			   dest, new_label, allocated);
+	if (BGP_DEBUG(labelpool, LABELPOOL)) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+		zlog_debug("%s: FEC (%s:%u:%u)%pBD label=%u, allocated=%d", __func__, dv.name,
+			   dv.id, dv.table_id, dest, new_label, allocated);
+	}

 	if (!allocated) {
 		/*
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index 2a0e60429b..81249bf7a8 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -449,6 +449,11 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
 	bool all_paths_lb;
 	char path_buf[PATH_ADDPATH_STR_BUFFER];
 	bool old_mpath, new_mpath;
+	struct bgp_debug_vrf dv = {
+		.name = "Unknown",
+		.id = VRF_UNKNOWN,
+		.table_id = 0,
+	};

 	mpath_changed = false;
 	maxpaths = multipath_num;
@@ -456,6 +461,8 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
 	old_mpath_count = 0;
 	old_cum_bw = cum_bw = 0;
 	debug = bgp_debug_bestpath(dest);
+	if (debug)
+		dv = bgp_dest_debug_vrf(dest);

 	if (old_best) {
 		old_mpath_count = bgp_path_info_mpath_count(dest);
@@ -480,9 +487,9 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
 	}

 	if (debug)
-		zlog_debug("%pBD(%s): starting mpath update, newbest %s num candidates %d old-mpath-count %d old-cum-bw %" PRIu64
+		zlog_debug("(%s:%u:%u)%pBD: starting mpath update, newbest %s num candidates %d old-mpath-count %d old-cum-bw %" PRIu64
 			   " maxpaths set %u",
-			   dest, bgp->name_pretty, new_best ? new_best->peer->host : "NONE",
+			   dv.name, dv.id, dv.table_id, dest, new_best ? new_best->peer->host : "NONE",
 			   num_candidates, old_mpath_count, old_cum_bw, maxpaths);

 	/*
@@ -518,15 +525,15 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
 			}

 			if (debug)
-				zlog_debug("%pBD(%s): Mpath count %u is equal to maximum paths allowed, finished comparison for MPATHS",
-					   dest, bgp->name_pretty, mpath_count);
+				zlog_debug("(%s:%u:%u)%pBD: Mpath count %u is equal to maximum paths allowed, finished comparison for MPATHS",
+					   dv.name, dv.id, dv.table_id, dest, mpath_count);

 			break;
 		}

 		if (debug)
-			zlog_debug("%pBD(%s): Candidate %s old_mpath: %u new_mpath: %u, Nexthop %pI4 current mpath count: %u",
-				   dest, bgp->name_pretty, cur_iterator->peer->host, old_mpath,
+			zlog_debug("(%s:%u:%u)%pBD: Candidate %s old_mpath: %u new_mpath: %u, Nexthop %pI4 current mpath count: %u",
+				   dv.name, dv.id, dv.table_id, dest, cur_iterator->peer->host, old_mpath,
 				   new_mpath, &cur_iterator->attr->nexthop, mpath_count);
 		/*
 		 * There is nothing to do if the cur_iterator is neither a old path
@@ -559,9 +566,9 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
 			if (debug) {
 				bgp_path_info_path_with_addpath_rx_str(cur_iterator, path_buf,
 								       sizeof(path_buf));
-				zlog_debug("%pBD(%s): add mpath %s nexthop %pI4, cur count %d cum_bw: %" PRIu64
+				zlog_debug("(%s:%u:%u)%pBD: add mpath %s nexthop %pI4, cur count %d cum_bw: %" PRIu64
 					   " all_paths_lb: %u",
-					   dest, bgp->name_pretty, path_buf,
+					   dv.name, dv.id, dv.table_id, dest, path_buf,
 					   &cur_iterator->attr->nexthop, mpath_count, cum_bw,
 					   all_paths_lb);
 			}
@@ -582,8 +589,8 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
 			bgp_path_info_mpath_lb_update(dest, true, all_paths_lb, cum_bw);
 		}
 		if (debug)
-			zlog_debug("%pBD(%s): New mpath count (incl newbest) %d mpath-change %s all_paths_lb %d cum_bw %" PRIu64,
-				   dest, bgp->name_pretty, mpath_count,
+			zlog_debug("(%s:%u:%u)%pBD: New mpath count (incl newbest) %d mpath-change %s all_paths_lb %d cum_bw %" PRIu64,
+				   dv.name, dv.id, dv.table_id, dest, mpath_count,
 				   mpath_changed ? "YES" : "NO", all_paths_lb,
 				   cum_bw);

diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index ff18935657..82888e2f5b 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -1260,12 +1260,20 @@ static struct bgp_path_info *leak_update(struct bgp *to_bgp, struct bgp_dest *bn
 	struct bgp *bgp_nexthop;
 	bool labelssame;
 	uint8_t i;
+	struct bgp_debug_vrf dv = {
+		.name = "Unknown",
+		.id = VRF_UNKNOWN,
+		.table_id = 0,
+	};
+
+	if (debug)
+		dv = bgp_dest_debug_vrf(bn);

 	if (debug)
 		zlog_debug(
-			"%s: entry: leak-to=%s, p=%pBD, type=%d, sub_type=%d",
-			__func__, to_bgp->name_pretty, bn, source_bpi->type,
-			source_bpi->sub_type);
+			"%s: entry: leak-to=%s, p=(%s:%u:%u)%pBD, type=%d, sub_type=%d",
+			__func__, to_bgp->name_pretty, dv.name, dv.id, dv.table_id, bn,
+			source_bpi->type, source_bpi->sub_type);

 	/*
 	 * Routes that are redistributed into BGP from zebra do not get
@@ -1349,8 +1357,9 @@ static struct bgp_path_info *leak_update(struct bgp *to_bgp, struct bgp_dest *bn
 					      bgp_orig, p,
 					      debug) == !!CHECK_FLAG(bpi->flags, BGP_PATH_VALID)) {
 			if (debug)
-				zlog_debug("%s: ->%s: %pBD: Found route, no change", __func__,
-					   to_bgp->name_pretty, bn);
+				zlog_debug("%s: ->%s: (%s:%u:%u)%pBD: Found route, no change",
+					   __func__, to_bgp->name_pretty, dv.name, dv.id,
+					   dv.table_id, bn);
 			return NULL;
 		}

@@ -1417,8 +1426,9 @@ static struct bgp_path_info *leak_update(struct bgp *to_bgp, struct bgp_dest *bn
 		bgp_process(to_bgp, bn, bpi, afi, safi);

 		if (debug)
-			zlog_debug("%s: ->%s: %pBD Found route, changed attr",
-				   __func__, to_bgp->name_pretty, bn);
+			zlog_debug("%s: ->%s: (%s:%u:%u)%pBD Found route, changed attr",
+				   __func__, to_bgp->name_pretty, dv.name, dv.id, dv.table_id,
+				   bn);

 		bgp_dest_unlock_node(bn);

@@ -1492,8 +1502,8 @@ static struct bgp_path_info *leak_update(struct bgp *to_bgp, struct bgp_dest *bn
 	bgp_process(to_bgp, bn, new, afi, safi);

 	if (debug)
-		zlog_debug("%s: ->%s: %pBD: Added new route", __func__,
-			   to_bgp->name_pretty, bn);
+		zlog_debug("%s: ->%s: (%s:%u:%u)%pBD: Added new route", __func__,
+			   to_bgp->name_pretty, dv.name, dv.id, dv.table_id, bn);

 	bgp_dest_unlock_node(bn);

@@ -2177,10 +2187,12 @@ void vpn_leak_from_vrf_withdraw(struct bgp *to_bgp,		/* to */
 	const char *debugmsg;

 	if (debug) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(path_vrf->net);
+
 		zlog_debug(
-			"%s: entry: leak-from=%s, p=%pBD, type=%d, sub_type=%d",
-			__func__, from_bgp->name_pretty, path_vrf->net,
-			path_vrf->type, path_vrf->sub_type);
+			"%s: entry: leak-from=%s, p=(%s:%u:%u)%pBD, type=%d, sub_type=%d",
+			__func__, from_bgp->name_pretty, dv.name, dv.id, dv.table_id,
+			path_vrf->net, path_vrf->type, path_vrf->sub_type);
 	}

 	if (!to_bgp)
@@ -2267,8 +2279,10 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *to_bgp, struct bgp *from_bgp,
 		for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
 			bpi = bgp_dest_get_bgp_path_info(bn);
 			if (debug && bpi) {
-				zlog_debug("%s: looking at prefix %pBD",
-					   __func__, bn);
+				struct bgp_debug_vrf dv = bgp_dest_debug_vrf(bn);
+
+				zlog_debug("%s: looking at prefix (%s:%u:%u)%pBD", __func__,
+					   dv.name, dv.id, dv.table_id, bn);
 			}

 			for (; (bpi != NULL) && (next = bpi->next, 1);
@@ -2666,12 +2680,15 @@ static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp,	/* to */
 			num_labels = BGP_PATH_INFO_NUM_LABELS(bpi_ultimate);
 			label_pnt = num_labels ? bpi_ultimate->extra->labels->label : NULL;
 			labels_are_evpn = true;
-			if (debug)
-				zlog_debug("%s: VRF leak %pBD from %s to %s: copying D-VNI %u (source L3VNI %u)",
-					   __func__, path_vpn->net, src_vrf->name_pretty,
-					   to_bgp->name_pretty,
+			if (debug) {
+				struct bgp_debug_vrf dv = bgp_dest_debug_vrf(path_vpn->net);
+
+				zlog_debug("%s: VRF leak (%s:%u:%u)%pBD from %s to %s: copying D-VNI %u (source L3VNI %u)",
+					   __func__, dv.name, dv.id, dv.table_id, path_vpn->net,
+					   src_vrf->name_pretty, to_bgp->name_pretty,
 					   bgp_evpn_path_info_get_l3vni(bpi_ultimate),
 					   src_vrf->l3vni);
+			}
 		}
 	} else {
 		/*
@@ -2691,9 +2708,12 @@ static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp,	/* to */
 		label_pnt = num_labels ? path_vpn->extra->labels->label : NULL;
 	}

-	if (debug)
-		zlog_debug("%s: pfx %pBD: num_labels %d", __func__,
-			   path_vpn->net, num_labels);
+	if (debug) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(path_vpn->net);
+
+		zlog_debug("%s: pfx (%s:%u:%u)%pBD: num_labels %d", __func__, dv.name, dv.id,
+			   dv.table_id, path_vpn->net, num_labels);
+	}

 	if (!leak_update(to_bgp, bn, &static_attr, afi, safi, path_vpn, label_pnt, num_labels,
 			 labels_are_evpn, src_vrf, &nexthop_orig, nexthop_self_flag, debug,
@@ -2782,9 +2802,13 @@ void vpn_leak_to_vrf_withdraw(struct bgp_path_info *path_vpn)

 	int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF);

-	if (debug)
-		zlog_debug("%s: entry: p=%pBD, type=%d, sub_type=%d", __func__,
-			   path_vpn->net, path_vpn->type, path_vpn->sub_type);
+	if (debug) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(path_vpn->net);
+
+		zlog_debug("%s: entry: p=(%s:%u:%u)%pBD, type=%d, sub_type=%d", __func__,
+			   dv.name, dv.id, dv.table_id, path_vpn->net, path_vpn->type,
+			   path_vpn->sub_type);
+	}

 	if (debug)
 		zlog_debug("%s: start (path_vpn=%p)", __func__, path_vpn);
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 7a988aa968..26b33cecc3 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -1549,16 +1549,21 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc)
 			if (bgp_update_martian_nexthop(
 				    bnc->bgp, afi, safi, path->type,
 				    path->sub_type, path->attr, dest)) {
-				if (BGP_DEBUG(nht, NHT))
+				if (BGP_DEBUG(nht, NHT)) {
+					struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
 					zlog_debug(
-						"%s: prefix %pBD (vrf %s), ignoring path due to martian or self-next-hop",
-						__func__, dest, bgp_path->name);
+						"%s: prefix (%s:%u:%u)%pBD (vrf %s), ignoring path due to martian or self-next-hop",
+						__func__, dv.name, dv.id, dv.table_id, dest,
+						bgp_path->name);
+				}
 			} else
 				bnc_is_valid_nexthop =
 					bgp_isvalid_nexthop(bnc) ? true : false;
 		}

 		if (BGP_DEBUG(nht, NHT)) {
+			struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);

 			if (dest->pdest) {
 				char rd_buf[RD_ADDRSTRLEN];
@@ -1569,14 +1574,14 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc)
 					rd_buf, sizeof(rd_buf),
 					bgp_get_asnotation(bnc->bgp));
 				zlog_debug(
-					"... eval path %d/%d %pBD RD %s %s flags 0x%x",
-					afi, safi, dest, rd_buf,
+					"... eval path %d/%d (%s:%u:%u)%pBD RD %s %s flags 0x%x",
+					afi, safi, dv.name, dv.id, dv.table_id, dest, rd_buf,
 					bgp_path->name_pretty, path->flags);
 			} else
 				zlog_debug(
-					"... eval path %d/%d %pBD %s flags 0x%x",
-					afi, safi, dest, bgp_path->name_pretty,
-					path->flags);
+					"... eval path %d/%d (%s:%u:%u)%pBD %s flags 0x%x",
+					afi, safi, dv.name, dv.id, dv.table_id, dest,
+					bgp_path->name_pretty, path->flags);
 		}

 		/* Skip paths marked for removal or as history. */
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 96b79cadf0..9e8749ea9d 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -87,6 +87,42 @@

 #include "bgpd/bgp_route_clippy.c"

+struct bgp_debug_vrf bgp_debug_vrf_get(struct bgp *bgp)
+{
+	struct bgp_debug_vrf dv = {
+		.name = "Unknown",
+		.id = VRF_UNKNOWN,
+		.table_id = 0,
+	};
+	struct vrf *vrf;
+
+	if (!bgp)
+		return dv;
+
+	vrf = bgp_vrf_lookup_by_instance_type(bgp);
+	if (vrf) {
+		dv.name = vrf->name;
+		dv.id = vrf->vrf_id;
+		dv.table_id = vrf->data.l.table_id;
+		return dv;
+	}
+
+	dv.name = bgp->name_pretty ? bgp->name_pretty : "Unknown";
+	dv.id = bgp->vrf_id;
+	return dv;
+}
+
+struct bgp_debug_vrf bgp_dest_debug_vrf(struct bgp_dest *dest)
+{
+	struct bgp_table *table;
+
+	if (!dest || !dest->rn)
+		return bgp_debug_vrf_get(NULL);
+
+	table = bgp_dest_table(dest);
+	return bgp_debug_vrf_get(table ? table->bgp : NULL);
+}
+
 static bool bgp_attr_nexthop_same(const struct attr *attr1, const struct attr *attr2, afi_t afi)
 {
 	afi_t nh_afi1 = BGP_ATTR_NH_AFI(afi, attr1);
@@ -575,13 +611,11 @@ int bgp_dest_set_defer_flag(struct bgp_dest *dest, bool delete)

 	if (CHECK_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED)) {
 		if (BGP_DEBUG(update, UPDATE_OUT)) {
-			table = bgp_dest_table(dest);
-			if (table)
-				bgp = table->bgp;
+			struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);

 			zlog_debug(
-				"Route %pBD(%s) is in workqueue and being processed, not deferred.",
-				dest, bgp ? bgp->name_pretty : "(Unknown)");
+				"Route (%s:%u:%u)%pBD is in workqueue and being processed, not deferred.",
+				dv.name, dv.id, dv.table_id, dest);
 		}

 		return 0;
@@ -654,8 +688,12 @@ int bgp_dest_set_defer_flag(struct bgp_dest *dest, bool delete)
 		if (!CHECK_FLAG(dest->flags, BGP_NODE_SELECT_DEFER))
 			bgp->gr_info[afi][safi].gr_deferred++;
 		SET_FLAG(dest->flags, BGP_NODE_SELECT_DEFER);
-		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
-			zlog_debug("%s: Defer route %pBD, dest %p", bgp->name_pretty, dest, dest);
+		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) {
+			struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+			zlog_debug("%s: Defer route (%s:%u:%u)%pBD, dest %p", bgp->name_pretty,
+				   dv.name, dv.id, dv.table_id, dest, dest);
+		}
 		return 0;
 	}

@@ -3541,7 +3579,12 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 	struct bgp_path_info *pi2;
 	int paths_eq, do_mpath;
 	bool debug, any_comparisons;
-	char pfx_buf[PREFIX2STR_BUFFER + VRF_NAMSIZ + 2] = {};
+	struct bgp_debug_vrf dv = {
+		.name = "Unknown",
+		.id = VRF_UNKNOWN,
+		.table_id = 0,
+	};
+	char pfx_buf[PREFIX2STR_BUFFER + VRF_NAMSIZ + 64] = {};
 	char path_buf[PATH_ADDPATH_STR_BUFFER];
 	enum bgp_path_selection_reason reason = bgp_path_selection_none;
 	bool unsorted_items = true;
@@ -3552,8 +3595,11 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,

 	debug = bgp_debug_bestpath(dest);

-	if (debug)
-		snprintfrr(pfx_buf, sizeof(pfx_buf), "%pBD(%s)", dest, bgp->name_pretty);
+	if (debug) {
+		dv = bgp_dest_debug_vrf(dest);
+		snprintfrr(pfx_buf, sizeof(pfx_buf), "(%s:%u:%u)%pBD", dv.name, dv.id,
+			   dv.table_id, dest);
+	}

 	/* bgp deterministic-med */
 	new_select = NULL;
@@ -3619,8 +3665,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 				bgp_path_info_path_with_addpath_rx_str(
 					new_select, path_buf, sizeof(path_buf));
 				zlog_debug(
-					"%pBD(%s): %s is the bestpath from AS %u",
-					dest, bgp->name_pretty, path_buf,
+					"(%s:%u:%u)%pBD: %s is the bestpath from AS %u",
+					dv.name, dv.id, dv.table_id, dest, path_buf,
 					aspath_get_first_as(
 						new_select->attr->aspath));
 			}
@@ -3707,8 +3753,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 			 * selected route must stay for a while longer though
 			 */
 			if (debug)
-				zlog_debug("%s: %pBD(%s) pi %p from %s in holddown",
-					   __func__, dest, bgp->name_pretty,
+				zlog_debug("%s: (%s:%u:%u)%pBD pi %p from %s in holddown",
+					   __func__, dv.name, dv.id, dv.table_id, dest,
 					   first, first->peer->host);

 			if (old_select != first &&
@@ -3737,8 +3783,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 		    !CHECK_FLAG(first->peer->sflags, PEER_STATUS_NSF_WAIT) &&
 		    !peer_established(first->peer->connection)) {
 			if (debug)
-				zlog_debug("%s: %pBD(%s) pi %p from %s is not in established state",
-					   __func__, dest, bgp->name_pretty, first,
+				zlog_debug("%s: (%s:%u:%u)%pBD pi %p from %s is not in established state",
+					   __func__, dv.name, dv.id, dv.table_id, dest, first,
 					   first->peer->host);

 			/*
@@ -3777,8 +3823,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 				 * selected route must stay for a while longer though
 				 */
 				if (debug)
-					zlog_debug("%s: %pBD(%s) pi from %s %p in holddown",
-						   __func__, dest, bgp->name_pretty,
+					zlog_debug("%s: (%s:%u:%u)%pBD pi from %s %p in holddown",
+						   __func__, dv.name, dv.id, dv.table_id, dest,
 						   look_thru->peer ? look_thru->peer->host
 								   : "Unknown",
 						   look_thru);
@@ -3801,9 +3847,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 				if (!peer_established(
 					    look_thru->peer->connection)) {
 					if (debug)
-						zlog_debug("%s: %pBD(%s) non self peer %s not estab state",
-							   __func__, dest,
-							   bgp->name_pretty,
+						zlog_debug("%s: (%s:%u:%u)%pBD non self peer %s not estab state",
+							   __func__, dv.name, dv.id, dv.table_id, dest,
 							   look_thru->peer->host);

 					continue;
@@ -3924,15 +3969,15 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 		bgp_path_info_path_with_addpath_rx_str(new_select, path_buf,
 						       sizeof(path_buf));
 		zlog_debug(
-			"%pBD(%s): After path selection, newbest is %s oldbest was %s",
-			dest, bgp->name_pretty, path_buf,
+			"(%s:%u:%u)%pBD: After path selection, newbest is %s oldbest was %s",
+			dv.name, dv.id, dv.table_id, dest, path_buf,
 			old_select ? old_select->peer->host : "NONE");
 	}

 	if (new_select) {
 		if (debug)
-			zlog_debug("%pBD(%s): %s is the bestpath, add to the multipath list", dest,
-				   bgp->name_pretty, path_buf);
+			zlog_debug("(%s:%u:%u)%pBD: %s is the bestpath, add to the multipath list",
+				   dv.name, dv.id, dv.table_id, dest, path_buf);
 		SET_FLAG(new_select->flags, BGP_PATH_MULTIPATH_NEW);
 		num_candidates++;
 	}
@@ -3969,8 +4014,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
 			if (paths_eq) {
 				if (debug)
 					zlog_debug(
-						"%pBD(%s): %s is equivalent to the bestpath, add to the multipath list",
-						dest, bgp->name_pretty,
+						"(%s:%u:%u)%pBD: %s is equivalent to the bestpath, add to the multipath list",
+						dv.name, dv.id, dv.table_id, dest,
 						path_buf);
 				SET_FLAG(pi->flags, BGP_PATH_MULTIPATH_NEW);
 				num_candidates++;
@@ -4349,6 +4394,11 @@ void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, saf
 	struct bgp_path_info *old_select;
 	struct bgp_path_info_pair old_and_new;
 	int debug = 0;
+	struct bgp_debug_vrf dv = {
+		.name = "Unknown",
+		.id = VRF_UNKNOWN,
+		.table_id = 0,
+	};

 	/*
 	 * For default bgp instance, which is deleted i.e. marked hidden
@@ -4362,10 +4412,12 @@ void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, saf
 	if (BGP_INSTANCE_HIDDEN_DELETE_IN_PROGRESS(bgp, afi, safi)) {
 		if (dest)
 			debug = bgp_debug_bestpath(dest);
-		if (debug)
+		if (debug) {
+			dv = bgp_dest_debug_vrf(dest);
 			zlog_debug(
-				"%s: bgp delete in progress, ignoring event, p=%pBD(%s)",
-				__func__, dest, bgp->name_pretty);
+				"%s: bgp delete in progress, ignoring event, p=(%s:%u:%u)%pBD",
+				__func__, dv.name, dv.id, dv.table_id, dest);
+		}
 		return;
 	}
 	/* Is it end of initial update? (after startup) */
@@ -4403,8 +4455,10 @@ void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, saf

 	debug = bgp_debug_bestpath(dest);
 	if (debug)
-		zlog_debug("%s: p=%pBD(%s) afi=%s, safi=%s start", __func__,
-			   dest, bgp->name_pretty, afi2str(afi),
+		dv = bgp_dest_debug_vrf(dest);
+	if (debug)
+		zlog_debug("%s: p=(%s:%u:%u)%pBD afi=%s, safi=%s start", __func__,
+			   dv.name, dv.id, dv.table_id, dest, afi2str(afi),
 			   safi2str(safi));

 	/* The best path calculation for the route is deferred if
@@ -4441,8 +4495,8 @@ void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, saf

 	if (debug)
 		zlog_debug(
-			"%s: p=%pBD(%s) afi=%s, safi=%s, old_select=%p, new_select=%p",
-			__func__, dest, bgp->name_pretty, afi2str(afi),
+			"%s: p=(%s:%u:%u)%pBD afi=%s, safi=%s, old_select=%p, new_select=%p",
+			__func__, dv.name, dv.id, dv.table_id, dest, afi2str(afi),
 			safi2str(safi), old_select, new_select);

 	/* If best route remains the same and this is not due to user-initiated
@@ -4531,8 +4585,8 @@ void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, saf
 		bgp_path_info_unset_flag(dest, old_select, BGP_PATH_SELECTED);
 	if (new_select) {
 		if (debug)
-			zlog_debug("%s: %pBD(%s) setting SELECTED flag", __func__, dest,
-				   bgp->name_pretty);
+			zlog_debug("%s: (%s:%u:%u)%pBD setting SELECTED flag", __func__,
+				   dv.name, dv.id, dv.table_id, dest);
 		bgp_path_info_set_flag(dest, new_select, BGP_PATH_SELECTED);
 		bgp_path_info_unset_flag(dest, new_select,
 					 BGP_PATH_ATTR_CHANGED);
@@ -4694,11 +4748,15 @@ void bgp_dest_increment_gr_fib_install_pending_count(struct bgp_dest *dest)
 	if (BGP_SUPPRESS_FIB_ENABLED(bgp) && bgp->gr_route_sync_pending &&
 	    !CHECK_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING)) {
 		bgp->gr_info[afi][safi].gr_route_fib_install_pending_cnt++;
-		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
-			zlog_debug("%s: GR route FIB install count incremented to %u for %s (prefix: %pBD)",
+		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) {
+			struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+			zlog_debug("%s: GR route FIB install count incremented to %u for %s (prefix: (%s:%u:%u)%pBD)",
 				   bgp->name_pretty,
 				   bgp->gr_info[afi][safi].gr_route_fib_install_pending_cnt,
-				   get_afi_safi_str(afi, safi, false), dest);
+				   get_afi_safi_str(afi, safi, false), dv.name, dv.id,
+				   dv.table_id, dest);
+		}
 	}
 }

@@ -4722,11 +4780,15 @@ void bgp_dest_decrement_gr_fib_install_pending_count(struct bgp_dest *dest)
 	    CHECK_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING) &&
 	    bgp->gr_info[afi][safi].gr_route_fib_install_pending_cnt > 0) {
 		bgp->gr_info[afi][safi].gr_route_fib_install_pending_cnt--;
-		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
-			zlog_debug("%s: GR route FIB install count decremented to %u for %s (prefix: %pBD)",
+		if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) {
+			struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+			zlog_debug("%s: GR route FIB install count decremented to %u for %s (prefix: (%s:%u:%u)%pBD)",
 				   bgp->name_pretty,
 				   bgp->gr_info[afi][safi].gr_route_fib_install_pending_cnt,
-				   get_afi_safi_str(afi, safi, false), dest);
+				   get_afi_safi_str(afi, safi, false), dv.name, dv.id,
+				   dv.table_id, dest);
+		}
 	}

 	/* Check if graceful restart deferral completion is needed */
@@ -5081,10 +5143,10 @@ static void process_subq_early_route(struct bgp_dest *dest)
 	struct bgp_table *table = bgp_dest_table(dest);

 	if (bgp_debug_bestpath(dest)) {
-		struct bgp *bgp = table->bgp;
+		struct bgp_debug_vrf dv = bgp_debug_vrf_get(table->bgp);

-		zlog_debug("%pBD(%s) dequeued from sub-queue %s", dest, bgp->name_pretty,
-			   subqueue2str(META_QUEUE_EARLY_ROUTE));
+		zlog_debug("(%s:%u:%u)%pBD dequeued from sub-queue %s", dv.name, dv.id,
+			   dv.table_id, dest, subqueue2str(META_QUEUE_EARLY_ROUTE));
 	}

 	/* note, new DESTs may be added as part of processing */
@@ -5101,10 +5163,10 @@ static void process_subq_other_route(struct bgp_dest *dest)
 	struct bgp_table *table = bgp_dest_table(dest);

 	if (bgp_debug_bestpath(dest)) {
-		struct bgp *bgp = table->bgp;
+		struct bgp_debug_vrf dv = bgp_debug_vrf_get(table->bgp);

-		zlog_debug("%pBD(%s) dequeued from sub-queue %s", dest, bgp->name_pretty,
-			   subqueue2str(META_QUEUE_OTHER_ROUTE));
+		zlog_debug("(%s:%u:%u)%pBD dequeued from sub-queue %s", dv.name, dv.id,
+			   dv.table_id, dest, subqueue2str(META_QUEUE_OTHER_ROUTE));
 	}

 	/* note, new DESTs may be added as part of processing */
@@ -5205,11 +5267,10 @@ static int early_route_meta_queue_add(struct meta_queue *mq, void *data)
 	struct bgp_dest *dest = data;

 	if (bgp_debug_bestpath(dest)) {
-		struct bgp_table *table = bgp_dest_table(dest);
-		struct bgp *bgp = table->bgp;
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);

-		zlog_debug("%pBD(%s) queued into sub-queue %s", dest, bgp->name_pretty,
-			   subqueue2str(qindex));
+		zlog_debug("(%s:%u:%u)%pBD queued into sub-queue %s", dv.name, dv.id,
+			   dv.table_id, dest, subqueue2str(qindex));
 	}

 	assert(STAILQ_NEXT(dest, pq) == NULL);
@@ -5224,11 +5285,10 @@ static int other_route_meta_queue_add(struct meta_queue *mq, void *data)
 	struct bgp_dest *dest = data;

 	if (bgp_debug_bestpath(dest)) {
-		struct bgp_table *table = bgp_dest_table(dest);
-		struct bgp *bgp = table->bgp;
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);

-		zlog_debug("%pBD(%s) queued into sub-queue %s", dest, bgp->name_pretty,
-			   subqueue2str(qindex));
+		zlog_debug("(%s:%u:%u)%pBD queued into sub-queue %s", dv.name, dv.id,
+			   dv.table_id, dest, subqueue2str(qindex));
 	}

 	assert(STAILQ_NEXT(dest, pq) == NULL);
@@ -5449,9 +5509,12 @@ static void bgp_process_internal(struct bgp *bgp, struct bgp_dest *dest,
 	}

 	if (CHECK_FLAG(dest->flags, BGP_NODE_NHT_RESOLVED_NODE)) {
-		if (BGP_DEBUG(update, UPDATE_OUT))
-			zlog_debug("Early route processing triggered by NHT for route %pBD",
-				   dest);
+		if (BGP_DEBUG(update, UPDATE_OUT)) {
+			struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+			zlog_debug("Early route processing triggered by NHT for route (%s:%u:%u)%pBD",
+				   dv.name, dv.id, dv.table_id, dest);
+		}
 		early_process = true;
 	}

@@ -8018,7 +8081,11 @@ static struct bgp_dest *clearing_dest_helper(struct bgp_table *table,

 			zlog_debug("%s: returns RD dest %s (%p)", __func__, buf, dest);
 		} else {
-			zlog_debug("%s: returns dest %pBD", __func__, dest);
+			struct bgp_debug_vrf dv = dest ? bgp_dest_debug_vrf(dest)
+							     : bgp_debug_vrf_get(table->bgp);
+
+			zlog_debug("%s: returns dest (%s:%u:%u)%pBD", __func__, dv.name, dv.id,
+				   dv.table_id, dest);
 		}
 	}

@@ -8066,9 +8133,12 @@ static int walk_batch_table_helper(struct bgp_clearing_info *cinfo,
 	UNSET_FLAG(cinfo->flags, (BGP_CLEARING_INFO_FLAG_RESUME |
 				  BGP_CLEARING_INFO_FLAG_INNER));

-	if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
-		zlog_debug("%s: table %s/%s, dest %pBD", __func__, afi2str(table->afi),
-			   safi2str(table->safi), dest);
+	if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL)) {
+		struct bgp_debug_vrf dv = bgp_debug_vrf_get(table->bgp);
+
+		zlog_debug("%s: table %s/%s, (%s:%u:%u)%pBD", __func__, afi2str(table->afi),
+			   safi2str(table->safi), dv.name, dv.id, dv.table_id, dest);
+	}

 	if (dest == NULL) {
 		/* Nothing more to do for this table? */
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index a8b96cb1fa..c43b753f9b 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -20,6 +20,21 @@ struct bgp_nexthop_cache;
 struct bgp_route_evpn;
 struct bgp_unreach_nlri;

+/*
+ * VRF name, id, and kernel table id for debug output of the form
+ * (%s:%u:%u)%pBD. Call only from a debug path: resolving the VRF walks
+ * the VRF hash. BGP views have no VRF; the printable instance name is
+ * used and the table id is 0.
+ */
+struct bgp_debug_vrf {
+	const char *name;
+	vrf_id_t id;
+	uint32_t table_id;
+};
+
+extern struct bgp_debug_vrf bgp_debug_vrf_get(struct bgp *bgp);
+extern struct bgp_debug_vrf bgp_dest_debug_vrf(struct bgp_dest *dest);
+
 enum bgp_show_type {
 	bgp_show_type_normal,
 	bgp_show_type_regexp,
diff --git a/bgpd/bgp_srv6.c b/bgpd/bgp_srv6.c
index e2d076683b..b4fa41dee9 100644
--- a/bgpd/bgp_srv6.c
+++ b/bgpd/bgp_srv6.c
@@ -348,8 +348,12 @@ void bgp_srv6_unicast_register_route(struct bgp *bgp, afi_t afi, struct bgp_dest
 				if (dest->srv6_unicast)
 					bgp_srv6_unicast_unregister_route(dest);

-				if (BGP_DEBUG(update, UPDATE_OUT))
-					zlog_debug("srv6 unicast prefix %pBD denied", dest);
+				if (BGP_DEBUG(update, UPDATE_OUT)) {
+					struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+					zlog_debug("srv6 unicast prefix (%s:%u:%u)%pBD denied",
+						   dv.name, dv.id, dv.table_id, dest);
+				}

 				return;
 			}
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index d29e9560ff..3fe637ef20 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -229,9 +229,12 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
 	peer = UPDGRP_PEER(updgrp);
 	addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);

-	if (BGP_DEBUG(update, UPDATE_OUT))
-		zlog_debug("%s: afi=%s, safi=%s, p=%pBD", __func__,
-			   afi2str(afi), safi2str(safi), ctx->dest);
+	if (BGP_DEBUG(update, UPDATE_OUT)) {
+		struct bgp_debug_vrf dv = bgp_dest_debug_vrf(ctx->dest);
+
+		zlog_debug("%s: afi=%s, safi=%s, p=(%s:%u:%u)%pBD", __func__, afi2str(afi),
+			   safi2str(safi), dv.name, dv.id, dv.table_id, ctx->dest);
+	}

 	UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
 		/* An update-group that uses addpath */
@@ -553,6 +556,11 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
 	struct bgp *bgp;
 	struct attr *attr_new;
 	bool debug;
+	struct bgp_debug_vrf dv = {
+		.name = "Unknown",
+		.id = VRF_UNKNOWN,
+		.table_id = 0,
+	};

 	peer = SUBGRP_PEER(subgrp);
 	afi = SUBGRP_AFI(subgrp);
@@ -563,6 +571,8 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
 		return false;

 	debug = BGP_DEBUG(update, UPDATE_OUT);
+	if (debug)
+		dv = bgp_dest_debug_vrf(dest);

 	/* Look for adjacency information. */
 	adj = adj_lookup(
@@ -604,8 +614,9 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,

 			bgp_dump_attr(attr_new, attr_str, sizeof(attr_str));

-			zlog_debug("%s suppress UPDATE %pBD w/ attr: %s, afi=%s, safi=%s",
-				   peer->host, dest, attr_str, afi2str(afi), safi2str(safi));
+			zlog_debug("%s suppress UPDATE (%s:%u:%u)%pBD w/ attr: %s, afi=%s, safi=%s",
+				   peer->host, dv.name, dv.id, dv.table_id, dest, attr_str,
+				   afi2str(afi), safi2str(safi));
 		}

 		/*
@@ -615,8 +626,9 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
 		 */
 		if (adj->adv && (attr_new == adj->attr)) {
 			if (debug) {
-				zlog_debug("%s delete queued UPDATE %pBD, afi=%s, safi=%s",
-					   peer->host, dest, afi2str(afi), safi2str(safi));
+				zlog_debug("%s delete queued UPDATE (%s:%u:%u)%pBD, afi=%s, safi=%s",
+					   peer->host, dv.name, dv.id, dv.table_id, dest,
+					   afi2str(afi), safi2str(safi));
 			}

 			bgp_advertise_clean_subgroup(subgrp, adj);
@@ -664,8 +676,8 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
 	bgp_advertise_add(adv->baa, adv);

 	if (debug) {
-		zlog_debug("%s queue UPDATE %pBD, afi=%s, safi=%s", peer->host, dest, afi2str(afi),
-			   safi2str(safi));
+		zlog_debug("%s queue UPDATE (%s:%u:%u)%pBD, afi=%s, safi=%s", peer->host, dv.name,
+			   dv.id, dv.table_id, dest, afi2str(afi), safi2str(safi));
 	}

 	/*
@@ -749,12 +761,15 @@ void bgp_adj_out_unset_subgroup(struct bgp_dest *dest, struct update_subgroup *s
 			bgp_adv_fifo_add_tail(&subgrp->sync->withdraw, adv);

 			if (BGP_DEBUG(update, UPDATE_OUT)) {
+				struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
 				peer = SUBGRP_PEER(subgrp);
 				afi = SUBGRP_AFI(subgrp);
 				safi = SUBGRP_SAFI(subgrp);

-				zlog_debug("%s queue UPDATE (withdraw) %pBD, afi=%s, safi=%s",
-					   peer->host, dest, afi2str(afi), safi2str(safi));
+				zlog_debug("%s queue UPDATE (withdraw) (%s:%u:%u)%pBD, afi=%s, safi=%s",
+					   peer->host, dv.name, dv.id, dv.table_id, dest,
+					   afi2str(afi), safi2str(safi));
 			}
 		} else {
 			/* Free allocated information.  */
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 65af1b13ce..fccc52c0bc 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1904,11 +1904,14 @@ static void bgp_handle_route_announcements_to_zebra(struct event *e)
 				dest);
 		}

-		if (BGP_DEBUG(zebra, ZEBRA))
-			zlog_debug("BGP %s%s route %pBD(%s) with dest %p and flags 0x%x to zebra",
+		if (BGP_DEBUG(zebra, ZEBRA)) {
+			struct bgp_debug_vrf dv = bgp_debug_vrf_get(table->bgp);
+
+			zlog_debug("BGP %s%s route (%s:%u:%u)%pBD with dest %p and flags 0x%x to zebra",
 				   install ? "announcing" : "withdrawing",
-				   is_evpn ? " evpn" : " ", dest,
-				   table->bgp->name_pretty, dest, dest->flags);
+				   is_evpn ? " evpn" : " ", dv.name, dv.id, dv.table_id, dest,
+				   dest, dest->flags);
+		}

 		if (install) {
 			if (is_evpn)
@@ -3044,6 +3047,11 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
 	struct bgp_dest *dest BGP_DEST_AUTOUNLOCK = NULL;
 	struct bgp *bgp;
 	struct bgp_path_info *pi, *new_select;
+	struct bgp_debug_vrf dv = {
+		.name = "Unknown",
+		.id = VRF_UNKNOWN,
+		.table_id = 0,
+	};

 	if (!zapi_route_notify_decode(zclient->ibuf, &p, &table_id, &note,
 				      &afi, &safi)) {
@@ -3071,6 +3079,8 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
 	}

 	frrtrace(3, frr_bgp, bgp_zebra_route_notify_owner, note, dest, &p);
+	if (BGP_DEBUG(zebra, ZEBRA))
+		dv = bgp_dest_debug_vrf(dest);
 	switch (note) {
 	case ZAPI_ROUTE_INSTALLED:
 		new_select = NULL;
@@ -3079,7 +3089,8 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
 		UNSET_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING);
 		SET_FLAG(dest->flags, BGP_NODE_FIB_INSTALLED);
 		if (BGP_DEBUG(zebra, ZEBRA))
-			zlog_debug("route %pBD : INSTALLED", dest);
+			zlog_debug("route (%s:%u:%u)%pBD : INSTALLED", dv.name, dv.id,
+				   dv.table_id, dest);
 		/* Find the best route */
 		for (pi = dest->info; pi; pi = pi->next) {
 			if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
@@ -3107,13 +3118,14 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
 		 */
 		UNSET_FLAG(dest->flags, BGP_NODE_FIB_INSTALLED);
 		if (BGP_DEBUG(zebra, ZEBRA))
-			zlog_debug("route %pBD: Removed from Fib", dest);
+			zlog_debug("route (%s:%u:%u)%pBD: Removed from Fib", dv.name, dv.id,
+				   dv.table_id, dest);
 		break;
 	case ZAPI_ROUTE_FAIL_INSTALL:
 		new_select = NULL;
 		if (BGP_DEBUG(zebra, ZEBRA))
-			zlog_debug("route: %pBD Failed to Install into Fib",
-				   dest);
+			zlog_debug("route: (%s:%u:%u)%pBD Failed to Install into Fib", dv.name,
+				   dv.id, dv.table_id, dest);
 		bgp_dest_decrement_gr_fib_install_pending_count(dest);
 		UNSET_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING);
 		UNSET_FLAG(dest->flags, BGP_NODE_FIB_INSTALLED);
@@ -3127,8 +3139,8 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
 		break;
 	case ZAPI_ROUTE_BETTER_ADMIN_WON:
 		if (BGP_DEBUG(zebra, ZEBRA))
-			zlog_debug("route: %pBD removed due to better admin won",
-				   dest);
+			zlog_debug("route: (%s:%u:%u)%pBD removed due to better admin won",
+				   dv.name, dv.id, dv.table_id, dest);
 		new_select = NULL;
 		bgp_dest_decrement_gr_fib_install_pending_count(dest);
 		UNSET_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING);
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index 00602b9a03..5ced36cf23 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -1834,8 +1834,12 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
 			if (!bgp_dest_has_bgp_path_info_data(dest))
 				continue;

-			vnc_zlog_debug_verbose("%s: checking prefix %pBD",
-					       __func__, dest);
+			if (VNC_DEBUG(VERBOSE)) {
+				struct bgp_debug_vrf dv = bgp_dest_debug_vrf(dest);
+
+				zlog_debug("%s: checking prefix (%s:%u:%u)%pBD", __func__,
+					   dv.name, dv.id, dv.table_id, dest);
+			}

 			dest_p = bgp_dest_get_prefix(dest);