Hello BIRD team!

This patches (for master branch) modifies the output of the show route CLI 
command for BGP routes to always print the IGP metric value. In current BIRD, 
the IGP metric is only displayed if the AIGP attribute is not set.

Example, current BIRD:
    10.0.0.0/8          unicast [blabla] * (100/210) [AS12322i]
And with the patch:
    10.0.0.0/8          unicast [blabla] * (100/10/210) [AS12322i]

Even with AIGP it can be useful to see the IGP metric for each routes to 
troubleshoot routing issues (BGP best path selection can still consider IGP 
metric for routes with identical AIGP value).

Thanks!
--
Sébastien
From 2cbac464fc550d74090afeca0351503352d65eb3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Parisot?= <[email protected]>
Date: Tue, 12 Aug 2025 14:37:04 +0200
Subject: [PATCH] BGP: Always print igp_metric in show route output, even if
 AIGP is set

---
 proto/bgp/attrs.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index e853624b..58c3c494 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -2484,12 +2484,7 @@ bgp_get_route_info(rte *e, byte *buf)
   if (rte_stale(e))
     buf += bsprintf(buf, "s");
 
-  u64 metric = bgp_total_aigp_metric(e);
-  if (metric < BGP_AIGP_MAX)
-  {
-    buf += bsprintf(buf, "/%lu", metric);
-  }
-  else if (e->attrs->igp_metric)
+  if (e->attrs->igp_metric)
   {
     if (!rte_resolvable(e))
       buf += bsprintf(buf, "/-");
@@ -2497,7 +2492,15 @@ bgp_get_route_info(rte *e, byte *buf)
       buf += bsprintf(buf, "/?");
     else
       buf += bsprintf(buf, "/%d", e->attrs->igp_metric);
+  } else
+    buf += bsprintf(buf, "/");
+
+  u64 metric = bgp_total_aigp_metric(e);
+  if (metric < BGP_AIGP_MAX)
+  {
+    buf += bsprintf(buf, "/%lu", metric);
   }
+
   buf += bsprintf(buf, ") [");
 
   if (p && as_path_get_last(p->u.ptr, &origas))
-- 
2.39.5

Reply via email to