feat: add RPKI RTR protocol support (RFC 6810/8210)#257
Merged
Conversation
Add full support for the RPKI-to-Router (RTR) protocol, enabling downstream clients to communicate with RTR cache servers and fetch Route Origin Authorizations (ROAs). Models (src/models/rpki/rtr.rs): - Core enums: RtrProtocolVersion (V0/V1), RtrPduType, RtrErrorCode - All 10 PDU structs: SerialNotify, SerialQuery, ResetQuery, CacheResponse, IPv4Prefix, IPv6Prefix, EndOfData, CacheReset, RouterKey, ErrorReport - Unified RtrPdu enum for generic PDU handling - Helper methods: is_announcement(), is_withdrawal(), timing defaults - Serde support behind feature flag Parser (src/parser/rpki/rtr.rs): - parse_rtr_pdu(): parse PDU from byte slice - read_rtr_pdu(): read PDU from impl Read - RtrEncode trait with encode() for all PDU types - RtrError enum for comprehensive error handling - Support for v0/v1 differences (EndOfData length, RouterKey) Testing: - 37 unit tests covering all PDU types - Round-trip tests (encode -> parse) - Version-specific tests (v0 vs v1) - Error case coverage Documentation: - Module-level docs with examples - New "RPKI RTR Protocol Support" section in lib.rs - RTR RFCs added to supported RFCs list - New rtr_client example demonstrating ROA fetching and route validation Example usage: cargo run --example rtr_client -- rtr.rpki.cloudflare.com 8282
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive support for the RPKI-to-Router (RTR) protocol (RFC 6810 v0 and RFC 8210 v1), enabling downstream clients to communicate with RTR cache servers and fetch Route Origin Authorizations (ROAs).
Key changes:
- Complete implementation of RTR protocol PDU data structures and parsing/encoding logic
- Support for both RTR protocol versions (v0 and v1) with version-specific handling
- Comprehensive test suite with 37 unit tests covering all PDU types and error cases
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/models/rpki/rtr.rs | Core RTR protocol data structures including 3 enums (RtrProtocolVersion, RtrPduType, RtrErrorCode) and 10 PDU structs with helper methods |
| src/parser/rpki/rtr.rs | RTR PDU parsing and encoding functions with comprehensive error handling and 37 unit tests |
| src/models/rpki/mod.rs | Module definition for RPKI-related data structures |
| src/parser/rpki/mod.rs | Module definition for RPKI protocol parsers |
| src/models/mod.rs | Added rpki module export |
| src/parser/mod.rs | Added rpki module export |
| src/lib.rs | Added extensive documentation for RTR protocol support with examples and PDU type table |
| examples/rtr_client.rs | Complete working example demonstrating RTR client implementation with ROA validation |
| examples/README.md | Added documentation for rtr_client example |
| README.md | Added RPKI RTR Protocol Support section with examples |
| CHANGELOG.md | Added Unreleased section documenting the new RTR protocol feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #257 +/- ##
==========================================
+ Coverage 90.50% 91.31% +0.80%
==========================================
Files 81 84 +3
Lines 13260 14862 +1602
==========================================
+ Hits 12001 13571 +1570
- Misses 1259 1291 +32 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add unit tests covering PDU enum behavior (type/version), From impls for all PDU types, and error report constructors. Extend parser tests to exercise RtrError Display and source, conversion from I/O errors, parsing edge cases (short/truncated lengths, invalid error codes/UTF-8, invalid IPv6 max length), Router Key minimal SPKI, encoding v0 PDUs, reading multiple PDUs from a stream, parsing with extra bytes, and a full ErrorReport roundtrip with encapsulated PDU and text.
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.
Add full support for the RPKI-to-Router (RTR) protocol, enabling downstream clients to communicate with RTR cache servers and fetch Route Origin Authorizations (ROAs).
Models (src/models/rpki/rtr.rs):
Parser (src/parser/rpki/rtr.rs):
Testing:
Documentation:
Example usage:
To start a functional RTR server with Docker: