fix: enforce one NetFlow v9 template owner - #303
Merged
mikemiles-dev merged 2 commits intoJul 22, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes NetFlow v9 Template ID ownership so that ordinary (data) templates and Options templates share a single logical Template ID namespace, ensuring the most recent valid definition in wire order is the sole owner (per RFC 3954 §7). This prevents data flowsets from being decoded against a stale template when exporters reuse a Template ID across template kinds.
Changes:
- Enforced cross-kind “single owner” semantics during template installation (cross-kind replacement removes the other kind from cache/store and is tracked as a collision when live).
- Updated v9 parser documentation and README to describe the shared Template ID namespace behavior.
- Added regression tests covering cross-kind replacement, persistent
TemplateStorebehavior, and expired-opposite-kind metrics handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/variable_versions/v9/parser.rs |
Centralizes template installation to enforce single-owner Template ID semantics across ordinary vs Options templates (including store key cleanup and metrics updates). |
tests/v9_template_id_ownership.rs |
Adds focused regression tests proving wire-order ownership, persistent store key cleanup, and correct collision/expiration accounting. |
README.md |
Documents that v9 ordinary and Options templates share one Template ID namespace and latest definition wins. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ktsaou
force-pushed
the
fix/v9-template-id-ownership
branch
from
July 21, 2026 08:12
a6ca0e0 to
4aa5599
Compare
Owner
|
Can you |
ktsaou
force-pushed
the
fix/v9-template-id-ownership
branch
from
July 22, 2026 07:28
4aa5599 to
069217b
Compare
Contributor
Author
|
rebased |
Merged
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.
What was wrong
NetFlow v9 uses one Template ID namespace for both data templates and Options Templates. The parser stored those two kinds in separate caches, so both could own the same ID at the same time.
Data lookup checks the data-template cache first. If an exporter changed an ID from a data template to an Options Template, records could therefore be decoded using the older data template instead of the latest definition.
Required behavior
RFC 3954 section 7 requires a collector to discard the previous definition when a Template ID is reused and use the new definition. Akvorado and GoFlow2 follow the same pattern: one stored value per version, Observation Domain, and Template ID, regardless of template kind.
What this changes
The public API and the two physical LRU caches remain unchanged. Data-record lookup receives no additional work; the added operations run only when a template definition is received.
Persistent-store operations retain their existing best-effort error behavior. Stores populated by an older parser are not rewritten eagerly; the next valid template announcement corrects any pre-existing conflicting keys.
Tests
Three focused regression tests prove:
TemplateStore, and a fresh parser restores it correctly;The focused tests fail on the previous implementation and pass with this change. The complete project checks pass, including formatting, Clippy, build, unit and integration tests, documentation tests, README synchronization, benchmark compilation, and focused tests without default features.