Skip to content

Commit

Permalink
bgpd: fix "used" json key on link-local nexthop
Browse files Browse the repository at this point in the history
When a peer has no IPv6 global address to send as nexthop, it sends the
IPv6 link-local instead as global. "show bgp ipv6 json" displays the
same address in global and link-local scopes.

> "nexthops": [
>   {
>     "ip": "fe80::a495:38ff:fea6:6ea3",
>     "afi": "ipv6",
>     "scope": "global",
>     "used": true
>   },
>   {
>     "ip": "fe80::a495:38ff:fea6:6ea3",
>     "afi": "ipv6",
>     "scope": "link-local"
>   }
> ]

However, "used" key is set on the global nexthop but not in link-local.
It is correct but it makes difficult to test JSON to expect the usage of
a link-local. The contrary is also correct.

Set "used" key on the link-local nexhop instead to facilitate the tests.

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Apr 23, 2024
1 parent ee0378c commit 2de4dfc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -9629,10 +9629,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
json_object_string_add(json_nexthop_ll, "scope",
"link-local");

if ((IPV6_ADDR_CMP(&attr->mp_nexthop_global,
&attr->mp_nexthop_local) !=
0) &&
!CHECK_FLAG(attr->nh_flags,
if (!CHECK_FLAG(attr->nh_flags,
BGP_ATTR_NH_MP_PREFER_GLOBAL))
json_object_boolean_true_add(
json_nexthop_ll, "used");
Expand Down

0 comments on commit 2de4dfc

Please sign in to comment.