fix: enforce one IPFIX template owner - #304
Merged
mikemiles-dev merged 2 commits intoJul 22, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Enforces a single logical owner per IPFIX Template ID across native IPFIX and V9-style template encodings, preventing stale higher-priority cache entries from silently shadowing later on-wire definitions and aligning behavior with RFC 7011’s single Template ID namespace rule.
Changes:
- Reworked IPFIX template insertion to evict the same Template ID from the other three physical caches (and remove superseded keys from the optional
TemplateStore) before installing the new definition. - Added a dedicated regression test suite covering cross-kind ownership transitions, store cleanup, and the “expired opposite owner” metric behavior.
- Updated the bundled pcap integration expectations and documented the unified Template ID namespace behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/pcap_integration.rs | Updates expected cache size from the bundled IPFIX capture (17 → 15) to match the new ownership behavior. |
| tests/ipfix_template_id_ownership.rs | New regression tests for cross-kind Template ID ownership, store cleanup, and expired-opposite-owner metrics. |
| src/variable_versions/ipfix/types.rs | Documents the single logical Template ID namespace across accepted template representations. |
| src/variable_versions/ipfix/parser.rs | Implements cross-cache Template ID eviction on template installation and updates lookup commentary accordingly. |
| README.md | Documents unified Template ID namespace behavior in the cache behavior section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ktsaou
force-pushed
the
fix/ipfix-template-id-ownership
branch
from
July 21, 2026 08:09
d5299d6 to
53b43f1
Compare
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
The IPFIX parser accepts four template encodings:
These were stored in four independent caches. If the same Template ID was defined under two different encodings, both definitions remained cached. Data lookup used a fixed cache priority, so an older higher-priority definition could silently override the later wire definition.
The bundled IPFIX capture demonstrates the accounting symptom: it contains 15 unique Template IDs, but the parser retained 17 physical cache entries because IDs 262 and 263 were each defined as Options, then Data, then Options templates.
Protocol basis
RFC 7011 sections 3.4.1 and 3.4.2 require Templates and Options Templates to use one Template ID namespace within a Transport Session and Observation Domain. For UDP, section 8.4 says that a new different definition replaces the previous definition.
The v9-style encodings accepted by this parser follow the same logical ownership rule: one active definition per Template ID.
What this changes
The store removals are intentionally unconditional when a store is configured. An empty local cache does not prove that a persisted key is absent after restart or earlier divergence.
Compatibility
This corrects observable behavior for streams that reuse one Template ID across template encodings:
A store created by older code may already contain conflicting physical keys. Existing read-through priority remains unchanged until the next wire definition, which cleans the conflicting keys. General store migration and transactional store behavior are not changed here.
Tests
The regression suite covers:
The focused tests pass with default and no-default features. The complete project checks pass: formatting, Clippy, build, unit and integration tests, documentation tests, README synchronization, and benchmark compilation.