Skip to content

fix: implement conditional mandatory BGP attribute validation#281

Merged
digizeph merged 6 commits intobgpkit:mainfrom
ties:feature/mandatory-attribute-checks
Apr 15, 2026
Merged

fix: implement conditional mandatory BGP attribute validation#281
digizeph merged 6 commits intobgpkit:mainfrom
ties:feature/mandatory-attribute-checks

Conversation

@ties
Copy link
Copy Markdown
Contributor

@ties ties commented Apr 15, 2026

Update attribute verification to follow RFC 4760 (MP-BGP) rules where mandatory attributes depend on the message payload.

  • pure withdrawal (withdrawn routes or MP_UNREACH_NLRI) -> none.
  • ORIGIN + AS_PATH for announcements
  • NEXT_HOP: conditional. IPv4 NLRI present -> required, IPv4 NLRI not
  • present -> should be omitted.

Optimisation: the [bool; 256] tracking array is now a [u64; 4] bitmask.

Update attribute verification to follow RFC 4760 (MP-BGP) rules where mandatory
attributes depend on the message payload.

 - pure withdrawal (withdrawn routes or MP_UNREACH_NLRI) -> none.
 - ORIGIN + AS_PATH for announcements
 - NEXT_HOP: conditional. IPv4 NLRI present -> required, IPv4 NLRI not
 - present -> should be omitted.

Optimisation: the [bool; 256] tracking array is now a [u64; 4] bitmask.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.60%. Comparing base (632bbe7) to head (6679abf).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #281      +/-   ##
==========================================
+ Coverage   90.53%   90.60%   +0.06%     
==========================================
  Files          84       84              
  Lines       15835    15897      +62     
==========================================
+ Hits        14336    14403      +67     
+ Misses       1499     1494       -5     

☔ 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.

@ties
Copy link
Copy Markdown
Contributor Author

ties commented Apr 15, 2026

NEXT_HOP: conditional. IPv4 NLRI present -> required, IPv4 NLRI not

The check is not correct atm (Mixed case of IPv4 + IPv6 is not checked correctly).

…ning

Fixes build failure caused by missing attr_mask field in the serde
Deserialize implementation for Attributes. The mask is now computed
from the deserialized inner attribute vector.

Also collapses nested if statements to address clippy warning.

Changes:
- src/models/bgp/attributes/mod.rs: Fix Deserialize impl and clippy
- CHANGELOG.md: Document RFC 4760 validation changes
@digizeph digizeph force-pushed the feature/mandatory-attribute-checks branch from 6bf9d9c to 6679abf Compare April 15, 2026 21:27
@digizeph digizeph enabled auto-merge April 15, 2026 21:29
@digizeph digizeph merged commit a925d03 into bgpkit:main Apr 15, 2026
8 checks passed
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