Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parsing add_path rib dump entry #68

Merged
merged 1 commit into from
Aug 6, 2022
Merged

Conversation

digizeph
Copy link
Member

@digizeph digizeph commented Aug 6, 2022

Background

RFC6396 defines the the RIB dump entry format (before ADD_PATH). In the definition, one prefix can have multiple corresponding RIB entries.


        0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                         Sequence Number                       |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       | Prefix Length |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                        Prefix (variable)                      |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |         Entry Count           |  RIB Entries (variable)
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Figure 8: RIB Entry Header

RFC7911 introduced the additional paths support (ADD_PATH). The encoding of NLRI is also extended to include path identifier:


                  +--------------------------------+
                  | Path Identifier (4 octets)     |
                  +--------------------------------+
                  | Length (1 octet)               |
                  +--------------------------------+
                  | Prefix (variable)              |
                  +--------------------------------+

RFC8050 defines the MRT extension for ADD_PATH, which adds the Path Identifier to the RIB entry (the per-peer one).

        0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |         Peer Index            |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                         Originated Time                       |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                         Path Identifier                       |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |      Attribute Length         |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                    BGP Attributes... (variable)
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

       Figure 1: RIB Entries for AFI/SAFI-Specific RIB Subtypes with
                       Support for Additional Paths

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.

@digizeph digizeph linked an issue Aug 6, 2022 that may be closed by this pull request
@digizeph digizeph merged commit 6d1677e into main Aug 6, 2022
@digizeph digizeph deleted the fix/add-path-rib-dump branch August 6, 2022 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[bug] cannot parse route-views5 recent rib file
1 participant