fix parsing add_path rib dump entry #68
Merged
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.
Background
RFC6396 defines the the RIB dump entry format (before ADD_PATH). In the definition, one prefix can have multiple corresponding RIB entries.
RFC7911 introduced the additional paths support (ADD_PATH). The encoding of NLRI is also extended to include path identifier:
RFC8050 defines the MRT extension for ADD_PATH, which adds the
Path Identifier
to the RIB entry (the per-peer one).Issue
The parser mistakenly uses the NLRI parsing for the RIB's prefix part (length and prefix). In the case of an ADD_PATH RIB entry, it will attempt to read an additional path identifier that should not exists. This messes up the parsing of the remaining bytes.
The route-views5's RIB dump encoding is correct in this example.
The fix
Instead of we parse prefix based on whether it has
add_path
(let prefix = input.read_nlri_prefix(&afi, add_path)?;
), we change it to always only parse length and prefix based on RFC 6396 (let prefix = input.read_nlri_prefix(&afi, false)?;
).This fixes issue #67.