FRR: Handle empty results and missing attributes properly#344
Open
sinuscosinustan wants to merge 3 commits intothatmattlove:mainfrom
Open
FRR: Handle empty results and missing attributes properly#344sinuscosinustan wants to merge 3 commits intothatmattlove:mainfrom
sinuscosinustan wants to merge 3 commits intothatmattlove:mainfrom
Conversation
In case a route is not present in the RIB, FRR returns an empty JSON
object:
```
$ vtysh -c "show bgp ipv4 unicast 1.2.3.4 json"
{}
```
Skip these empty objects to prevent the parser from failing.
Signed-off-by: Tan Siewert <tan@siewert.io>
The metric and used fields might not be returned, causing the parser to
fail if they are not present. The absence was observed in FRR 10.4.1
with a multipath IPv6 route that has two next-hops (one GUA, one LL):
```
$ vtysh -c "show bgp ipv6 unicast 2003::/19 json" | jq '.paths[].nexthops'
[
{
"ip": "2a0d:2146:bdff:120::1",
"afi": "ipv6",
"scope": "global",
"linkLocalOnly": false,
"length": 32,
"metric": 0,
"accessible": true
},
{
"ip": "fe80::3e61:408:1e3e:cff0",
"afi": "ipv6",
"scope": "link-local",
"length": 32,
"accessible": true,
"used": true
}
]
[
{
"ip": "2a0d:2146:bdff:120::1",
"afi": "ipv6",
"scope": "global",
"linkLocalOnly": false,
"length": 32,
"metric": 0,
"accessible": true
},
{
"ip": "fe80::3e61:408:1e3e:cff0",
"afi": "ipv6",
"scope": "link-local",
"length": 32,
"accessible": true,
"used": true
}
]
```
Tested: Query a prefix with multiple next-hops where the metric or used
attributes are missing on one of them.
Signed-off-by: Tan Siewert <tan@siewert.io>
Local prefixes usually do not have an AS_PATH:
```
vtysh -c "show bgp ipv4 unicast 10.10.10.10 json" | jq '.paths[].aspath'
{
"string": "Local",
"segments": [],
"length": 0
}
```
Set AS0 as a temporary solution when AS_PATH length is zero. This
avoids parser failures for local prefixes, though ideally we should
use the device's actual ASN (see TODO in code).
Signed-off-by: Tan Siewert <tan@siewert.io>
9e9f088 to
79d235c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes three edge cases in the FRR parser that cause failures:
metricandused) on next-hops in multipath routesAS_PATHPlease see individual commit messages for detailed explanations and examples.
Related Issues
None that I could find.
Motivation and Context
When I set up hyperglass backed by an FRR instance I noticed that some edge cases cause the parser to fail (like a route that's not in the DFZ and so on).
Tests
Test Environment: Docker on Ubuntu 24.04, with FRR as device
Devices Tested: FRR 10.4.1 with bgpd enabled
Test Cases: