Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

tanneberger
Copy link
Member

@tanneberger tanneberger commented Jan 29, 2024

Introduction

This PR introduces compatibility for RTR version 2 and handling of ASPA RTR PDUs as specified in draft-ietf-sidrops-8210bis-11, section 5.12 and adds AS_PATH verification according to draft-ietf-sidrops-aspa-verification-16, section 6.

Overview

This PR adds a new module called aspa which defines a new aspa_table organizing validated Autonomous System Provider Authorization data received from an RPKI-RTR cache server. The rtr module was enhanced to parse ASPA PDUs and update the aspa_table accordingly. Analogous to rtr_mgr_validate (prefixes/ROAs) and rtr_mgr_get_spki, we're introducing a new function rtr_mgr_verify_as_path for AS_PATH verification. rtrclient has gained a new option, -a, for printing ASPA data in addition to -p (prefixes) and -k.

Detailed Design

Storing ASPA Records

ASPA records are structs derived from RTR ASPA PDUs, each containing a customer ASN and a set of providers attested by the customer. The aspa_table consists of a linked list where each node holds a reference to an rtr_socket and an aspa_array⏤an ordered dynamic array of ASPA records. Each aspa_array is comprised of a contiguous block of memory of ASPA records ordered by their customer ASN, enabling faster lookups by binary searching the array of records.

Updating an ASPA Table

The ASPA table implements aggregated updating using an array of add record and remove record operations that will be performed sequentially on the ASPA table. This drastically decreases the number of iterations necessary on the existing aspa_array to 1. This PR implements two update mechanisms:

  • In-Place: The aspa_array is manipulated in-place in a single iteration, reducing new memory allocations while blocking callers wanting to verify an AS_PATH (therefore needing read access to the table).
  • Swap-In: A new aspa_array is created, incorporating both existing records and simultaneously adding new records in a single iteration. While this approach enables non-blocking updates, it's got a slightly higher memory demand.

Details: aspa_private.h

Alternatives Considered

Other Data Structures

  • splaytree-4
  • kbtree-4
  • dynarray (only sorted by cas)
  • binsearch (provider arrays and cas are sorted)

This plot shows how the different data structures compare in different benchmarks against each other:

AS_PATH Verification Algorithm Implementation

We tested several implementations of the verification algorithm: netd-tud/IETF-ASPA/hackathon. The algorithm integrated into this PR is an optimized version of the draft algorithm which avoids checking any AS hop twice.

Tests & Quality

This PR has test coverage for

  • ASPA PDUs,
  • modifications and search on an aspa_array,
  • updates to an aspa_table and rtr_sync with ASPA
  • AS_PATH verification
  • Interoperability tests with standard RTR-Cache Server implementations (Routinator) were successfully performed.

Additionally, we checked for memory leaks and other faulty memory access using valgrind --leak-check=full.

Stats

Based on ASRank relationships we estimate ~75K ASPA records inferred from BGP paths. As an upper limit we consider an ASPA record to take up 24 bytes of memory.

Update Mechanism Performance Measurements

We conducted performance tests on both update approaches:

  • Using the In-Place approach, adding 75K ASPA records in single update function call took ~100 ms on a reasonably sized laptop.
  • The Swap-In mechanism has almost no effect on the time read access is blocked due to the old array just being swapped out in exchange for the new one.

Ping: @waehlisch @mroethke @fho

@waehlisch
Copy link
Member

@mroethke @fho do you have time to give some feedback on this PR? ASPA is getting momentum and it would be important to provide ASPA support in the RTRlib.

@fho
Copy link
Member

fho commented Feb 29, 2024

@mroethke @fho do you have time to give some feedback on this PR? ASPA is getting momentum and it would be important to provide ASPA support in the RTRlib.

Yes, I'll have a look before end of next week.

@fho fho requested review from fho and mroethke February 29, 2024 19:31
@fho fho linked an issue Feb 29, 2024 that may be closed by this pull request
@fho fho mentioned this pull request Feb 29, 2024
1 task
Copy link
Member

@fho fho left a comment

Choose a reason for hiding this comment

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

The implementation looks great to me, well structured, simple to follow and understand. The PR description was very helpful, it made it easy for me to get into it.
I could not find any issues, only trivial things that could be improved.
I was not able to verify every detail but everything I looked up is aligned with the draft.

Comment on lines +548 to +549
if (((struct pdu_aspa *)pdu)->afi_flags != 0b11)
RTR_DBG1("Warning: AFI flags of received ASPA PDU not set to 0x03");
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if ignoring an unexpected value here might cause issue when afi_flags in the future also supports other values with a different meaning. But that probably only happens when the protocol version is also incremented and therefore it is safe to ignore it.

@carl-tud
Copy link
Contributor

Thanks, @fho. I don’t really have time this week, but I’ll address the changes you requested next week

@tanneberger
Copy link
Member Author

@fho Did you take a look at the new changes yet?

@fho
Copy link
Member

fho commented May 2, 2024

@fho Did you take a look at the new changes yet?

No, I was still waiting for an answer regarding the changed rtr_mgr_init signature + compatibility (#285 (comment))

@fho
Copy link
Member

fho commented May 2, 2024

@tanneberger I think there is a confusion because you replied on another thread, that I did not meant. (or you reply was not related to my last comment).
The rtr_mgr_init discussion is still open (#285 (comment)).
That you changed the array allocation I saw (#285 (comment))

@tanneberger
Copy link
Member Author

@fho yeah also just realized that, now the comment is in the correct thread.

@tanneberger
Copy link
Member Author

tanneberger commented May 2, 2024

@fho I went a head and quickly implemented by suggestion, see (6d1222b)

@waehlisch
Copy link
Member

CI: rerun

@waehlisch
Copy link
Member

can you rebase?

tanneberger and others added 6 commits May 4, 2024 16:11
- add support for rtrv2 including aspa pdus
- move rtr pdus to separate header
- refactor undo-update logic
- add aspa in-place and swap-in update mechanism

Co-authored-by: mrzslz <[email protected]>
Co-authored-by: carl <[email protected]>
- add `aspa_array`, an ordered dynamic array
- add `aspa_table` for storing and managing aspa data
- add aspa table update functions
- add AS_PATH verification algorithm

Co-authored-by: mrzslz <[email protected]>
Co-authored-by: carl <[email protected]>
- add aspa_table to rtr_mgr functions
- fix typos and format

Co-authored-by: mrzslz <[email protected]>
Co-authored-by: carl <[email protected]>
- add tests for AS_PATH verification
- add tests for `aspa_array`
- add tests for aspa pdu parsing and `aspa_table` updating
- add tests for live interaction with rtr cache servers

Co-authored-by: mrzslz <[email protected]>
Co-authored-by: carl <[email protected]>
- update main cmake file

Co-authored-by: mrzslz <[email protected]>
Co-authored-by: carl <[email protected]>
- removing self-explanatory comments
- renaming include guards of ASPA_ARRAY
- removing double negation
- moving pthread_unlock
@tanneberger
Copy link
Member Author

CI: rerun

@fho
Copy link
Member

fho commented May 11, 2024

Let's merge it as soon as @tanneberger gives the final go.

- adjusted tests and tools
- added function rtr_mgr_setup_sockets with functionality that
  previously resided in rtr_mgr_init
- using lrtr_realloc instead of malloc & memcpy
- decreasing the capacity of the array when possible
- added null ptr checks in pfx_validate, aspa_verify and spki_validate
- added warnings if the user tries to validate objects where there is no
  table
@tanneberger
Copy link
Member Author

@fho I also had to change the user interface: see 0dbb123

-> rtr_mgr_init also creates the sockets and copies the pointers to the (prefix/spki/aspa) table into the socket struct. This is problematic because at this point the various tables have not yet been initialized and the socket therefore only has null pointers.
-> By creating a new function rtr_mgr_setup_sockets which is called by the user after all correct table pointers have been copied to the sockets

I also added more validation to handle the new scenario that the user only initialized some tables. I added checks in the validation functions and in the update functions: See this commit: 7a2b951

@fho
Copy link
Member

fho commented May 25, 2024

Link to aspa_array_reserve discussion: 6eed5ee#r142285681

I had a hard time to find it in the UI, GitHub has hidden after a small bubble symbol next to the commit

@tanneberger tanneberger force-pushed the new-history branch 2 times, most recently from 2fa0c7f to 1de3677 Compare February 6, 2025 08:49
- updating README
- up- and downscaling now uses an linear offset of 1000
@tanneberger tanneberger merged commit 295cb8e into rtrlib:master Feb 6, 2025
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.

ASPA support
4 participants