Skip to content

Conversation

@digizeph
Copy link
Member

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 -- localhost 8282

To start a functional RTR server with Docker:

docker run -it --rm -p 8282:8282 rpki/stayrtr -cache https://rpki.cloudflare.com/rpki.json

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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 98.00250% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.31%. Comparing base (574a244) to head (26b5d07).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/parser/rpki/rtr.rs 96.59% 32 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

digizeph and others added 2 commits December 22, 2025 16:49
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.
@digizeph digizeph merged commit 6ca8ce5 into main Dec 23, 2025
5 checks passed
@digizeph digizeph deleted the feature/rfc-6810-rpki-rtr branch December 23, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants