Skip to content

Conversation

@digizeph
Copy link
Member

@digizeph digizeph commented Aug 5, 2025

Summary

This PR implements BGP Flow Specification (Flow-Spec) parsing support following RFC 8955 (IPv4 Flow-Spec), RFC 8956 (IPv6 Flow-Spec), and RFC 9117 (Flow-Spec validation procedures).

  • FlowSpecNlri data structure with all 13 component types (destination/source prefixes, ports, protocols, TCP flags, packet length, DSCP, fragment flags, flow label)
  • Numeric and bitmask operators for traffic matching rules with proper AND/OR logic
  • Flow-Spec Extended Communities for traffic actions (rate limiting, marking, redirect)
  • IPv6-specific components including prefix offset support and flow label matching
  • SAFI definitions for Flow-Spec (133) and L3VPN Flow-Spec (134)
  • HashMap/HashSet compatibility through custom Eq implementation for f32-containing types

The implementation focuses on data structure representation and parsing without packet evaluation logic, making it suitable for BGP message processing and analysis tools.

Test plan

  • All existing tests continue to pass (314 tests)
  • 22 new Flow-Spec specific tests covering RFC examples and edge cases
  • Code formatting and clippy checks pass
  • Build verification with and without default features
  • Integration with existing NLRI and BGP attribute parsing
  • Round-trip encoding/decoding verification
  • HashMap/HashSet key compatibility verified

This commit implements Flow-Spec NLRI parsing and extended communities
support following RFC 8955 (IPv4 Flow-Spec), RFC 8956 (IPv6 Flow-Spec),
and RFC 9117 (Flow-Spec validation procedures).

Key additions:
- FlowSpecNlri data structure with 13 component types
- Numeric and bitmask operators for traffic matching rules
- Flow-Spec Extended Communities (rate limiting, marking, redirect)
- IPv6-specific Flow-Spec components with prefix offset support
- SAFI 133 (Flow-Spec) and SAFI 134 (L3VPN Flow-Spec) definitions
- Custom Eq implementation for f32-containing types using bit comparison
- Integration with existing NLRI and BGP attribute parsing

The implementation focuses on data structure representation and parsing
without packet evaluation logic, making it suitable for BGP message
processing and analysis tools.

All 22 Flow-Spec tests pass and BGP attributes maintain HashMap/HashSet
compatibility through proper Eq trait implementation.
@codecov
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 94.17786% with 91 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.37%. Comparing base (787f4bf) to head (554d83e).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/models/bgp/flowspec/nlri.rs 92.23% 26 Missing ⚠️
.../bgp/attributes/attr_16_25_extended_communities.rs 80.48% 24 Missing ⚠️
src/models/bgp/flowspec/tests.rs 95.82% 20 Missing ⚠️
src/models/bgp/community.rs 87.95% 10 Missing ⚠️
src/models/bgp/flowspec/operators.rs 97.45% 9 Missing ⚠️
src/models/bgp/flowspec/mod.rs 96.92% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #233      +/-   ##
==========================================
+ Coverage   89.79%   90.37%   +0.58%     
==========================================
  Files          75       79       +4     
  Lines       10099    11654    +1555     
==========================================
+ Hits         9068    10532    +1464     
- Misses       1031     1122      +91     

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

Add 32 additional unit tests to improve test coverage for Flow-Spec
implementation, focusing on previously uncovered code paths:

- FlowSpecComponent methods and type classification
- FlowSpecNlri IPv4/IPv6 detection and component validation
- FlowSpecError Display implementation and error handling
- Numeric/bitmask operator creation with various value lengths
- Operator byte encoding/decoding edge cases
- NLRI parsing error conditions and boundary cases

Total Flow-Spec tests increased from 22 to 54, providing comprehensive
coverage of public APIs, error conditions, and edge cases.
@digizeph digizeph merged commit aa6053b into main Aug 6, 2025
5 checks passed
@digizeph digizeph deleted the flowspec-support branch August 6, 2025 14:00
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