From 95ba22d5317b921f1db7bc6449ba7fefbc8be63b Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 4 Oct 2022 11:32:39 +0300 Subject: [PATCH] bgpd: Show why the prefix is inaccessible in show commands ``` donatas-pc# show ip bgp 100.100.100.0/24 longer-prefixes BGP table version is 13, local router ID is 10.10.10.10, vrf id 0 Default local pref 100, local AS 65000 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path 100.100.100.0/24 0.0.0.0 0 32768 i Displayed 1 routes and 15 total paths donatas-pc# show ip bgp 100.100.100.0/24 BGP routing table entry for 100.100.100.0/24, version 0 Paths: (1 available, no best path) Not advertised to any peer Local 0.0.0.0 (inaccessible, import-check enabled) from 0.0.0.0 (10.10.10.10) Origin IGP, metric 0, weight 32768, invalid, sourced, local Last update: Tue Oct 4 11:31:44 2022 donatas-pc# show ip bgp 100.100.100.0/24 json { "prefix":"100.100.100.0\/24", "version":0, "paths":[ { "aspath":{ "string":"Local", "segments":[ ], "length":0 }, "origin":"IGP", "metric":0, "weight":32768, "valid":false, "version":0, "sourced":true, "local":true, "lastUpdate":{ "epoch":1664872304, "string":"Tue Oct 4 11:31:44 2022\n" }, "nexthops":[ { "ip":"0.0.0.0", "hostname":"donatas-pc", "afi":"ipv4", "accessible":false, "importCheckEnabled":true, "used":true } ], "peer":{ "peerId":"0.0.0.0", "routerId":"10.10.10.10" } } ] } donatas-pc# ``` Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index a8e016a890..7d4110029e 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10287,11 +10287,17 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, /* Display the IGP cost or 'inaccessible' */ if (!CHECK_FLAG(path->flags, BGP_PATH_VALID)) { - if (json_paths) + bool import = CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); + + if (json_paths) { json_object_boolean_false_add(json_nexthop_global, "accessible"); - else - vty_out(vty, " (inaccessible)"); + json_object_boolean_add(json_nexthop_global, + "importCheckEnabled", import); + } else { + vty_out(vty, " (inaccessible%s)", + import ? ", import-check enabled" : ""); + } } else { if (path->extra && path->extra->igpmetric) { if (json_paths) -- 2.39.5