Skip to content

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented May 14, 2025

"show bgp vpn rd RD json" returns in invalid JSON unless RD is the last
route-distinguisher in the table. A trailing "," is present.

r1# sh bgp ipv4 vpn rd 102:1 json
{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 2,
"routerId": "192.0.2.1",
"defaultLocPrf": 100,
"localAS": 65001,
"routes": { "routeDistinguishers" : { "102:1" : { "2.2.2.2/32": [{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"external","prefix":"2.2.2.2","prefixLen":32,"network":"2.2.2.2/32","version":1,"metric":0,"weight":0,"peerId":"192.0.2.2","path":"65002","origin":"incomplete","nexthops":[{"ip":"192.0.2.2","hostname":"r2","afi":"ipv4","used":true}]
}]
,"192.0.2.2/32": [{"pathFrom":"external","prefix":"192.0.2.2","prefixLen":32,"network":"192.0.2.2/32","version":0,"metric":0,"weight":0,"peerId":"192.0.2.2","path":"65002","origin":"incomple
te","nexthops":[{"ip":"192.0.2.2","hostname":"r2","afi":"ipv4","used":true}]}]
,"192.0.2.8/32": [{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"external","prefix":"192.0.2.8","prefixLen":32,"network":"192.0.2.8/32","version":2,"metric
":0,"weight":0,"peerId":"192.0.2.2","path":"65002","origin":"incomplete","nexthops":[{"ip":"192.0.2.2","hostname":"r2","afi":"ipv4","used":true}]}]
}, r1#

When there is another rd, "next" is set although it refers to another rd
that won't be displayed. And "next" is used to set the "is_last"
variable of bgp_show_table() that instructs whether to add a trailing ","

Do not set next if there no more rd to display.

Fixes: 1ae44df ("bgpd: unify 'show bgp' with RD with normal unicast bgp show")
Signed-off-by: Maxime Gouin maxime.gouin@6wind.com
Signed-off-by: Louis Scalbert louis.scalbert@6wind.com


This is an automatic backport of pull request #18802 done by Mergify.

louis-6wind and others added 2 commits May 14, 2025 08:12
Check that "show bgp vpn rd RD json" output is correct.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 1de26be)
"show bgp vpn rd RD json" returns in invalid JSON unless RD is the last
route-distinguisher in the table. A trailing "," is present.

> r1# sh bgp ipv4 vpn rd 102:1 json
> {
>  "vrfId": 0,
>  "vrfName": "default",
>  "tableVersion": 2,
>  "routerId": "192.0.2.1",
>  "defaultLocPrf": 100,
>  "localAS": 65001,
>  "routes": {  "routeDistinguishers" : { "102:1" : { "2.2.2.2/32": [{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"external","prefix":"2.2.2.2","prefixLen":32,"network":"2.2.2.2/32","version":1,"metric":0,"weight":0,"peerId":"192.0.2.2","path":"65002","origin":"incomplete","nexthops":[{"ip":"192.0.2.2","hostname":"r2","afi":"ipv4","used":true}]
> }]
> ,"192.0.2.2/32": [{"pathFrom":"external","prefix":"192.0.2.2","prefixLen":32,"network":"192.0.2.2/32","version":0,"metric":0,"weight":0,"peerId":"192.0.2.2","path":"65002","origin":"incomple
> te","nexthops":[{"ip":"192.0.2.2","hostname":"r2","afi":"ipv4","used":true}]}]
> ,"192.0.2.8/32": [{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"external","prefix":"192.0.2.8","prefixLen":32,"network":"192.0.2.8/32","version":2,"metric
> ":0,"weight":0,"peerId":"192.0.2.2","path":"65002","origin":"incomplete","nexthops":[{"ip":"192.0.2.2","hostname":"r2","afi":"ipv4","used":true}]}]
>  }, r1#

When there is another rd, "next" is set although it refers to another rd
that won't be displayed. And "next" is used to set the "is_last"
variable of bgp_show_table() that instructs whether to add a trailing ","

Do not set next if there no more rd to display.

Fixes: 1ae44df ("bgpd: unify 'show bgp' with RD with normal unicast bgp show")
Signed-off-by: Maxime Gouin <maxime.gouin@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 03f782b)
@donaldsharp donaldsharp merged commit 3eb35eb into stable/10.3 May 14, 2025
18 checks passed
@Jafaral Jafaral deleted the mergify/bp/stable/10.3/pr-18802 branch July 31, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants