Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bgpd: fix display json value of interface for BGP unnumbered
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
pguibert6WIND committed Jan 17, 2025
1 parent acc3cfe commit aa43346
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit aa43346

Please sign in to comment.