Repository navigation
feat(flowspec): add opt-in source-prefix matching - #307
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Persisted routing identities and exact withdrawal behavior across both backends warrant final human review despite extensive coverage and reported passing CI.
No open issues 🎉
What changed in this PR
Adds opt-in source-prefix matching to manual FlowSpec discard and police rules across the controller, both BGP backends and operator interfaces. Scrubber redirection remains outside this PR.
Changes:
- Validates and canonicalizes same-family source CIDRs while preserving source-free identities and enforcing the default-off guardrail.
- Includes source prefixes in encoding, ownership, withdrawal and reconciliation, with lifecycle and interoperability coverage.
- Adds capability-gated dashboard submission, source-scope displays and upgrade/downgrade guidance.
| File | Description |
|---|---|
tests/integration.rs |
Tests API opt-in, validation, persistence and independent withdrawal. |
tests/integration_rustbgpd.rs |
Tests source components against released rustbgpd. |
tests/integration_rustbgpd_peer.rs |
Extends peer and restart fixtures with source-scoped rules. |
tests/integration_gobgp.rs |
Tests source components against released GoBGP. |
tests/common/speaker_contract.rs |
Adds source variants and exact-withdrawal checks. |
tests/common/peer_receipt.rs |
Decodes source components in receiving-peer evidence. |
src/scheduler/reconcile.rs |
Tests source-aware reconciliation and immutable withdrawal retries. |
src/guardrails/mod.rs |
Enforces and tests the source-prefix opt-in. |
src/guardrails/blackhole.rs |
Rejects source criteria for blackhole intent. |
src/error.rs |
Names the required source-prefix guardrail in errors. |
src/domain/withdrawal.rs |
Tests canonical identities, ownership and exact withdrawal. |
src/domain/mitigation.rs |
Adds canonical source-prefix serialization. |
src/domain/flowspec.rs |
Adds source validation and versioned source-aware identities. |
src/domain/blackhole.rs |
Rejects stored blackholes containing source criteria. |
src/config/settings.rs |
Makes the existing source-prefix flag effective. |
src/bin/prefixdctl.rs |
Displays source prefixes in match summaries. |
src/bgp/rustbgpd.rs |
Encodes and strictly decodes source components. |
src/bgp/rustbgpd_tests.rs |
Tests source-aware RPC identity and inventory failure. |
src/bgp/gobgp.rs |
Encodes and validates source-prefix read-back. |
src/bgp/gobgp_tests.rs |
Tests codecs, matching and whole-inventory refusal. |
src/bgp/announcer.rs |
Adds source capability reporting and match comparison. |
src/api/openapi.rs |
Checks source-field schema coverage. |
src/api/handlers.rs |
Accepts and returns source CIDRs; rejects them for blackholes. |
frontend/lib/api.ts |
Adds source types and capability checks before submission. |
frontend/components/dashboard/flowspec-rule-dialog.tsx |
Adds source input, validation and request mapping. |
frontend/components/dashboard/flowspec-preview.tsx |
Includes source scope in summaries and rule previews. |
frontend/app/(dashboard)/mitigations/[id]/page.tsx |
Displays the mitigation’s source prefix. |
frontend/__tests__/amplification-surfaces.test.tsx |
Tests source displays, validation and compatibility safeguards. |
FEATURES.md |
Documents manual source matching and automatic-selection limits. |
docs/reference/speaker-backends.md |
Documents source capabilities and strict decoding limits. |
docs/reference/configuration.md |
Explains opt-in behavior and source restrictions. |
docs/reference/cli.md |
Documents source-aware CLI output. |
docs/reference/api.md |
Documents source requests, responses and capability checks. |
docs/how-to/upgrading.md |
Adds source-rule draining and downgrade precautions. |
docs/adr/README.md |
Indexes the source-prefix decision. |
docs/adr/031-source-prefix-matches.md |
Records design, compatibility and qualification limits. |
configs/prefixd.yaml |
Clarifies the existing default-off setting in a comment. |
CHANGELOG.md |
Records the feature and compatibility requirements. |
Review effort: Balanced
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.
Issue #305 also asks for source-prefix selection. Add optional same-family
src_prefixCIDRs to manual FlowSpec discard and police rules across the API, dashboard, CLI and rule previews.guardrails.allow_src_prefix_matchis enforced and remains false by default. Sources are canonicalized and participate in scope, ownership, immutable withdrawal and reconciliation identity. Source-free hashes and stored JSON remain unchanged; explicit /0 remains distinct from omission. Both speakers encode IPv4 and offset-zero IPv6 type 2 and refuse an entire inventory containing an unrepresentable source. Blackholes reject source criteria. Detectors and playbooks do not choose sources.The dashboard confirms controller capability before each source-prefix submission. ADR031 and the upgrade guide cover controller-first upgrades, drain-before-downgrade requirements and evidence limits. Redirect-to-IP remains the separate design in #306.
Validation at
a6b62c3:just gatepassed on 2026-10-22 with Node 26.12.0 and Bun 1.4.3: strict Clippy in both feature configurations, 502 GoBGP-only and 541 all-feature unit tests, 250 API tests per configuration, PostgreSQL/ownership/lease controls, all three locked Rust 1.89 matrices, release build, frontend lint/types/472 tests/build, Python, alert rules, proto checksum and dependency policy.The native Linux result supersedes the earlier macOS gate limitation for delivery. Router source-prefix filtering and scrubber enforcement are not qualified by these checks.
Refs #305.