Commit 5256cb0fcf for frr

commit 5256cb0fcffc69d3e550eaa2a8dc0906703b2707
Author: Donald Sharp <sharpd@nvidia.com>
Date:   Tue Oct 20 11:29:57 2026 -0400

    eigrpd: Standardize prefix output, %pFX, in debugs

    Currently there are two problems with using %pFX in eigrpd
    debugs:

    a) The vrf name, vrf id and table were not being output for
    every debug.  When a prefix 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.  Solidify on
    "(%s:%u:%u)%pFX", vrf_name, vrf_id, table_id, prefix.  This
    allows very easy grepping.

    Add EIGRP_DEBUG_VRF() and EIGRP_DEBUG_VRF_ID() to generate the
    vrf name, vrf id and table id arguments.
    eigrp_prefix_descriptor_add() is passed the eigrp instance,
    instead of just the topology table, so the debug has a vrf to
    look at.

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

diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c
index 72512b5afd..4c5b8b2d71 100644
--- a/eigrpd/eigrp_fsm.c
+++ b/eigrpd/eigrp_fsm.c
@@ -403,10 +403,11 @@ int eigrp_fsm_event(struct eigrp_fsm_action_message *msg)
 {
 	enum eigrp_fsm_events event = eigrp_get_fsm_event(msg);

-	zlog_info("EIGRP AS: %d State: %s Event: %s Network: %pFX Packet Type: %s Reply RIJ Count: %d change: %s",
+	zlog_info("EIGRP AS: %d State: %s Event: %s Network: (%s:%u:%u)%pFX Packet Type: %s Reply RIJ Count: %d change: %s",
 		  msg->eigrp->AS, prefix_state2str(msg->prefix->state), fsm_state2str(event),
-		  &msg->prefix->destination, packet_type2str(msg->packet_type),
-		  msg->prefix->rij->count, change2str(msg->change));
+		  EIGRP_DEBUG_VRF(msg->eigrp), &msg->prefix->destination,
+		  packet_type2str(msg->packet_type), msg->prefix->rij->count,
+		  change2str(msg->change));
 	(*(NSM[msg->prefix->state][event].func))(msg);

 	return 1;
diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c
index 6b17df2ae7..5beff93a47 100644
--- a/eigrpd/eigrp_interface.c
+++ b/eigrpd/eigrp_interface.c
@@ -611,7 +611,7 @@ static void eigrp_connected_advertise(struct eigrp_connected *ec,
 		pe->state = EIGRP_FSM_STATE_PASSIVE;
 		pe->fdistance = eigrp_calculate_metrics(eigrp, metric);
 		pe->req_action |= EIGRP_FSM_NEED_UPDATE;
-		eigrp_prefix_descriptor_add(eigrp->topology_table, pe);
+		eigrp_prefix_descriptor_add(eigrp, pe);
 		listnode_add(eigrp->topology_changes_internalIPV4, pe);

 		eigrp_route_descriptor_add(eigrp, pe, ne);
diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c
index f205c77d96..ea9d298cfb 100644
--- a/eigrpd/eigrp_reply.c
+++ b/eigrpd/eigrp_reply.c
@@ -173,10 +173,9 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph,
 		 * Destination must exists
 		 */
 		if (!dest) {
-			flog_err(
-				EC_EIGRP_PACKET,
-				"%s: Received prefix %pFX which we do not know about",
-				__func__, &dest_addr);
+			flog_err(EC_EIGRP_PACKET,
+				 "%s: Received prefix (%s:%u:%u)%pFX which we do not know about",
+				 __func__, EIGRP_DEBUG_VRF(eigrp), &dest_addr);
 			eigrp_IPv4_InternalTLV_free(tlv);
 			continue;
 		}
diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c
index f4835d2650..e497407bd7 100644
--- a/eigrpd/eigrp_topology.c
+++ b/eigrpd/eigrp_topology.c
@@ -114,16 +114,15 @@ void eigrp_topology_free(struct eigrp *eigrp, struct route_table *table)
 /*
  * Adding topology node to topology table
  */
-void eigrp_prefix_descriptor_add(struct route_table *topology,
-				 struct eigrp_prefix_descriptor *pe)
+void eigrp_prefix_descriptor_add(struct eigrp *eigrp, struct eigrp_prefix_descriptor *pe)
 {
 	struct route_node *rn;

-	rn = route_node_get(topology, &pe->destination);
+	rn = route_node_get(eigrp->topology_table, &pe->destination);
 	if (rn->info) {
 		if (IS_DEBUG_EIGRP_EVENT)
-			zlog_debug("%s: %pFX Should we have found this entry in the topo table?",
-				   __func__, &pe->destination);
+			zlog_debug("%s: (%s:%u:%u)%pFX Should we have found this entry in the topo table?",
+				   __func__, EIGRP_DEBUG_VRF(eigrp), &pe->destination);
 		route_unlock_node(rn);
 	}

diff --git a/eigrpd/eigrp_topology.h b/eigrpd/eigrp_topology.h
index aa393e7624..65785c2d3b 100644
--- a/eigrpd/eigrp_topology.h
+++ b/eigrpd/eigrp_topology.h
@@ -27,8 +27,7 @@ extern void eigrp_topology_init(struct route_table *table);
 extern struct eigrp_prefix_descriptor *eigrp_prefix_descriptor_new(void);
 extern struct eigrp_route_descriptor *eigrp_route_descriptor_new(void);
 extern void eigrp_topology_free(struct eigrp *eigrp, struct route_table *table);
-extern void eigrp_prefix_descriptor_add(struct route_table *table,
-					struct eigrp_prefix_descriptor *pe);
+extern void eigrp_prefix_descriptor_add(struct eigrp *eigrp, struct eigrp_prefix_descriptor *pe);
 extern struct eigrp_route_descriptor *
 eigrp_route_descriptor_lookup_ei(struct eigrp_prefix_descriptor *node,
 				 struct eigrp_neighbor *adv_router,
diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c
index 711ec0fa63..c5fb97deb6 100644
--- a/eigrpd/eigrp_update.c
+++ b/eigrpd/eigrp_update.c
@@ -128,7 +128,8 @@ static void eigrp_update_receive_GR_ask(struct eigrp *eigrp,

 	/* iterate over all prefixes which weren't advertised by neighbor */
 	for (ALL_LIST_ELEMENTS_RO(nbr_prefixes, node1, prefix)) {
-		zlog_debug("GR receive: Neighbor not advertised %pFX", &prefix->destination);
+		zlog_debug("GR receive: Neighbor not advertised (%s:%u:%u)%pFX",
+			   EIGRP_DEBUG_VRF(eigrp), &prefix->destination);

 		fsm_msg.metrics = prefix->reported_metric;
 		/* set delay to MAX */
@@ -360,8 +361,7 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,
 				ne->flags =
 					EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG;

-				eigrp_prefix_descriptor_add(
-					eigrp->topology_table, pe);
+				eigrp_prefix_descriptor_add(eigrp, pe);
 				eigrp_route_descriptor_add(eigrp, pe, ne);
 				pe->distance = pe->fdistance = pe->rdistance =
 					ne->distance;
diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c
index 82824a0de2..57bd15fccd 100644
--- a/eigrpd/eigrp_zebra.c
+++ b/eigrpd/eigrp_zebra.c
@@ -168,8 +168,8 @@ static int eigrp_interface_address_add(ZAPI_CALLBACK_ARGS)
 		return 0;

 	if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
-		zlog_debug("Zebra: interface %s address add %pFX", c->ifp->name,
-			   c->address);
+		zlog_debug("Zebra: interface %s address add (%s:%u:%u)%pFX", c->ifp->name,
+			   EIGRP_DEBUG_VRF_ID(vrf_id), c->address);

 	eigrp_if_update(c->ifp);

@@ -189,8 +189,8 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
 		return 0;

 	if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
-		zlog_debug("Zebra: interface %s address delete %pFX",
-			   c->ifp->name, c->address);
+		zlog_debug("Zebra: interface %s address delete (%s:%u:%u)%pFX", c->ifp->name,
+			   EIGRP_DEBUG_VRF_ID(vrf_id), c->address);

 	ifp = c->ifp;

@@ -274,7 +274,7 @@ void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p,
 	api.nexthop_num = count;

 	if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
-		zlog_debug("Zebra: Route add %pFX", p);
+		zlog_debug("Zebra: Route add (%s:%u:%u)%pFX", EIGRP_DEBUG_VRF(eigrp), p);
 	}

 	zclient_route_send(ZEBRA_ROUTE_ADD, eigrp_zclient, &api);
@@ -295,7 +295,7 @@ void eigrp_zebra_route_delete(struct eigrp *eigrp, struct prefix *p)
 	zclient_route_send(ZEBRA_ROUTE_DELETE, eigrp_zclient, &api);

 	if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE))
-		zlog_debug("Zebra: Route del %pFX", p);
+		zlog_debug("Zebra: Route del (%s:%u:%u)%pFX", EIGRP_DEBUG_VRF(eigrp), p);

 	return;
 }
diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c
index 598ca01168..28bb6ab559 100644
--- a/eigrpd/eigrpd.c
+++ b/eigrpd/eigrpd.c
@@ -300,6 +300,20 @@ void eigrp_finish_final(struct eigrp *eigrp)
 }

 /*Look for existing eigrp process*/
+const char *eigrp_vrf_id_to_name(vrf_id_t vrf_id)
+{
+	struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+
+	return vrf ? vrf->name : "NIL";
+}
+
+uint32_t eigrp_vrf_id_to_table_id(vrf_id_t vrf_id)
+{
+	struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+
+	return vrf ? vrf->data.l.table_id : 0;
+}
+
 struct eigrp *eigrp_lookup(vrf_id_t vrf_id)
 {
 	struct eigrp *eigrp, lookup;
diff --git a/eigrpd/eigrpd.h b/eigrpd/eigrpd.h
index 28b1dc9a11..2796158325 100644
--- a/eigrpd/eigrpd.h
+++ b/eigrpd/eigrpd.h
@@ -64,6 +64,22 @@ extern void eigrp_finish_final(struct eigrp *eigrp);
 extern void eigrp_finish(struct eigrp *eigrp);
 extern struct eigrp *eigrp_get(uint16_t as, vrf_id_t vrf_id);
 extern struct eigrp *eigrp_lookup(vrf_id_t vrf_id);
+extern const char *eigrp_vrf_id_to_name(vrf_id_t vrf_id);
+extern uint32_t eigrp_vrf_id_to_table_id(vrf_id_t vrf_id);
+
+/*
+ * Arguments for the "(%s:%u:%u)" vrf name, vrf id, table id prefix
+ * used in front of a prefix in debugs.  For example:
+ *
+ *   zlog_debug("route (%s:%u:%u)%pFX", EIGRP_DEBUG_VRF(eigrp), p);
+ *
+ * Note that the argument is evaluated more than once.
+ */
+#define EIGRP_DEBUG_VRF(eigrp) EIGRP_DEBUG_VRF_ID((eigrp)->vrf_id)
+
+/* Same as above, but for when only the vrf id is available. */
+#define EIGRP_DEBUG_VRF_ID(vrf_id)                                                                \
+	eigrp_vrf_id_to_name((vrf_id)), (vrf_id), eigrp_vrf_id_to_table_id((vrf_id))
 extern void eigrp_router_id_update(struct eigrp *eigrp);

 extern int eigrp_master_hash_cmp(const struct eigrp *a, const struct eigrp *b);