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

Allow core-dump; refactor NLRI parsing for add-path issue #42

Merged
merged 7 commits into from
Dec 9, 2021

Conversation

digizeph
Copy link
Member

@digizeph digizeph commented Dec 9, 2021

This PR enables parsing of NLRI block with potentially wrong
add-path type. In some cases, the BGP message with add-path might be
wrapped in a non-add-path message and causing trouble parsing NLRI block
in BGP message and in attributes.

This patch implements a workaround that can more intelligently "guess"
the add-path intention and revert back to regular parsing when guess
fails. Here is a brief description of the workaround:

  • If add-path is not set (i.e. not the add-path BGP msgs) and the first
    byte of an NLRI entry is 0, it is likely an add-path msg wrapped in
    non-add-path msg, treat as add-path. This covers both IPv4 and IPv6
    cases.
  • If an error happens when parsing, revert back to the original add-path
    setting (this only happens for 0.0.0.0/0 or 0::/0 prefixes without
    add-path, which is pretty rare) and re-parse the whole NLRI
    block. (needs to go back a few bytes to the beginning).
  • The unhandled cases are the ones where the first byte of path_id is
    not zero. In those cases, we will, unfortunately, parse the msg without
    path-id, and depending on the msg, we might see parsing errors
    later (e.g. not enough bytes, or extra bytes).

Test run show that the parsing of one problematic file is resolved back
to normal now. See #31 for
more details.

when seeing problematic MRT record, if `.enable_core_dump()` is called when creating
the parser, the parser then will create a new file `mrt_core_dump` on the current
working directory and dump the whole bytes of the current MRT record to file.

With #38 merged, we can directly read
the raw (uncompressed) dump file in debug session.
This refactor enables parsing of NLRI block with potentially wrong
add-path type. In some cases, the BGP message with add-path might be
wrapped in a non-add-path message and causing trouble parsing NLRI block
in BGP message and in attributes.

This patch implements a workaround that can more intelligently "guess"
the add-path intention and revert back to regular parsing when guess
fails. Here is a brief description of the workaround:

- If add-path is not set (i.e. not the add-path BGP msgs) and the first
byte of an NLRI entry is 0, it is likely an add-path msg wrapped in
non-add-path msg, treat as add-path. This covers both IPv4 and IPv6
cases.
- If an error happens when parsing, revert back to the original add-path
setting (this only happens for `0.0.0.0/0` or `0::/0` prefixes without
add-path, which is pretty rare) and re-parse the whole NLRI
block. (needs to go back a few bytes to the beginning).
- The unhandled cases are the ones where the first byte of path_id is
not zero. In those cases, we will, unfortunately, parse the msg without
path-id, and depending on the msg, we might see parsing errors
later (e.g. not enough bytes, or extra bytes).

Test run show that the parsing of one problematic file is resolved back
to normal now. See #31 for
more details.
in some cases, attributes marked as partial is not actually partial. we
now attempt to parse attributes and log warnings if parsing fails.
@digizeph digizeph merged commit 4b1286a into main Dec 9, 2021
@digizeph digizeph mentioned this pull request Dec 9, 2021
@digizeph digizeph deleted the feature_bytes_in_error branch December 9, 2021 06:23
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.

1 participant