-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Problem Description
The pdump module has a critical issue where packets are being silently lost when the ring buffer is written too fast and the reader doesn't catch up, but the code doesn't notify the user about these losses. This leads to incomplete packet captures without any indication that data has been lost.
Current Implementation Analysis
Ring Buffer Loss Detection
The controlplane already detects when packets are lost due to ring buffer overwrites in modules/pdump/controlplane/ring.go:
- Lines 171-248: The
workerArea.read()method detects overwrites by comparingreadableIdxwith the reader's position - Lines 222-248: When overwrites are detected, the code discards corrupted data and logs debug messages, but doesn't expose this information to users
- Lines 236-241: Complete overwrites result in all buffered data being discarded silently
Current User Interface
The CLI provides three main commands:
show- Display current configurationset- Configure capture parameters (filter, mode, snaplen, ring_size)read- Stream captured packets
The problem: There's no mechanism to report packet loss statistics to users during packet capture.
Proposed Solution
- Add Loss Notification Messages to Protobuf API
- Track and Report Losses in Ring Buffer
- Update Ring Buffer Readers to Send Loss Notifications
- Update Service to Handle Loss Notifications
- Update CLI to Display Loss Notifications
Usage Examples
# Run packet capture - losses will be shown on stderr in real-time
pdump read --cfg capture1 --instances 0 -o capture.pcap
# Example output to stderr:
# 15 packets were overwritten (worker 0)
# 8 packets were overwritten (worker 1)
# 23 packets were overwritten (worker 0)
# Total packets lost: 46
# Redirect only packet data to file, see losses on console
pdump read --cfg capture1 --instances 0 -f pcap > capture.pcapThis solution provides immediate feedback about packet losses during capture while maintaining a clean separation between packet data (stdout/files) and loss notifications (stderr). The terminology clearly distinguishes between packets lost due to ring buffer overwrites versus actual dropped packets that can be captured from drop queues.