Skip to content

Refactor FlowMeasure to use dynamic maps and shared locks - #33

Merged
ak2btvm merged 1 commit into
cdacmasterfrom
flow-measure-mod
May 18, 2026
Merged

Refactor FlowMeasure to use dynamic maps and shared locks#33
ak2btvm merged 1 commit into
cdacmasterfrom
flow-measure-mod

Conversation

@bhagathkrishnacdac

Copy link
Copy Markdown

What type of PR is this?

/kind bug fix

What this PR does / why we need it:
This PR fixes a critical crash in the UPF pod that occurs when the flow_measure module is enabled during UE attachment.
The previous implementation relied on a fixed-size DPDK rte_hash and a separate std::vector for statistics. This architecture was prone to crashes under high-concurrency scenarios (like a burst of UEs attaching) due to:

  1. Hash Insertion Failures: If the pre-allocated table filled up or encountered a collision limit, it could lead to unhandled errors in the dataplane.
  2. Race Conditions: The locking between the DPDK hash and the stats vector was insufficient, leading to memory corruption or out-of-bounds access during concurrent flow creation.

Changes made to resolve the crash:

  • Dynamic Allocation: Switched to std::unordered_map with pointer-based storage (SessionStats*). This allows the module to handle any number of UE sessions dynamically without crashing due to table exhaustion.
  • Thread Safety: Implemented std::shared_mutex to properly synchronize the dataplane (shared lookups) and control plane (unique locks for flow creation and table clearing), preventing the race conditions that caused the segmentation faults.
  • Safe Fallback: Added a fallback for missing timestamps to ensure that unexpected metadata states do not disrupt the processing logic.

Which issue(s) this PR fixes:

Fixes #32

Test Report Added?:

/kind TESTED

Test Report:

NA

Special notes for your reviewer:
The refactor focuses on moving away from fixed-size DPDK structures to more robust C++ standard containers. This provides the necessary memory safety and locking granularity to handle the bursty nature of UE attachment signaling. The get_or_create logic is the core of the fix, ensuring safe, atomic creation of new flow entries.

@ak2btvm ak2btvm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@ak2btvm
ak2btvm merged commit fddc659 into cdacmaster May 18, 2026
20 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.

UPF pod crash occurring during UE attachment

2 participants