Skip to content

Conversation

louis-6wind
Copy link
Contributor

"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

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

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
"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>
@louis-6wind
Copy link
Contributor Author

ci:rerun

@ton31337
Copy link
Member

@Mergifyio backport stable/10.3 stable/10.2 stable/10.1 stable/10.0

Copy link

mergify bot commented May 13, 2025

backport stable/10.3 stable/10.2 stable/10.1 stable/10.0

✅ Backports have been created

@ton31337 ton31337 merged commit 3d9330a into FRRouting:master May 14, 2025
18 checks passed
donaldsharp added a commit that referenced this pull request May 14, 2025
donaldsharp added a commit that referenced this pull request May 14, 2025
donaldsharp added a commit that referenced this pull request May 14, 2025
donaldsharp added a commit that referenced this pull request May 14, 2025
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