summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2025-01-17 17:28:00 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2025-01-20 09:32:28 +0100
commit0bf47adc64b05736285fe392365b8733b6f7c507 (patch)
treebc3e6ffbb7ee76de48e07089688a8e5f0c393cac /bgpd
parent084ebc9473abb8845e575511e0aa2897f15234fc (diff)
bgpd: fix display json value of interface for BGP unnumbered
The 'show bgp ipv[4,6] json' command does not display the interface value of the nexthop, when BGP sessions are unnumbered, whereas the non json output displays it correctly. The below example indicates 'r1-eth0' wheras in json, the value is not displayed. > r1# show bgp ipv4 > BGP table version is 3, local router ID is 10.254.254.1, vrf id 0 > Default local pref 100, local AS 101 > Status codes: s suppressed, d damped, h history, u unsorted, * 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 > *> 10.254.254.1/32 0.0.0.0 0 32768 ? > *> 10.254.254.2/32 r1-eth0 0 0 102 ? > > Displayed 2 routes and 2 total paths Fix this by adding an 'interface' keyword in the json attributes. > "nexthops":[{"ip":"2001:db8:1::2","hostname":"r2","afi":"ipv6", > "scope":"global"},{"interface":"r1-eth0","ip":"fe80::1868:d7ff:fe66:45ae", > "hostname":"r2","afi":"ipv6","scope":"link-local","used":true}]}] Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_route.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index f27f0b97c0..a1b12e5a86 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -9915,6 +9915,9 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
|| (path->peer->conf_if)) {
json_nexthop_ll = json_object_new_object();
+ if (path->peer->conf_if)
+ json_object_string_add(json_nexthop_ll, "interface",
+ path->peer->conf_if);
json_object_string_addf(
json_nexthop_ll, "ip", "%pI6",
&attr->mp_nexthop_local);