From 2cbac464fc550d74090afeca0351503352d65eb3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Parisot?= <sparisot@iliad-free.fr>
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

