fix(bpf): Correctly parse IP headers with options#337
Merged
Conversation
This commit introduces several improvements to the eBPF probe to enhance robustness and feature completeness. - feat: Add fallback for PID attribution Uses `bpf_get_current_task()` as a fallback mechanism to resolve the process ID for a packet. This significantly improves PID attribution for scenarios where the primary flow-based mapping might fail, such as with short-lived connections. Includes a check for kernel support to ensure backward compatibility. - fix: Correctly parse IP headers with options The IP header length is now dynamically calculated based on the IHL (Internet Header Length) field. This fixes a bug where packets with IP options would be parsed incorrectly, leading to errors in L4 (TCP/UDP) header analysis. - chore: Clean up debug logs Commented out several `debug_log` statements to reduce noise and performance overhead.
Removes the PID fallback mechanism that uses bpf_get_current_task(). This is unsafe without a reliable way to detect interrupt context (e.g., bpf_in_interrupt()), as it can lead to incorrect PID association. The explanatory comment is updated to reflect this.
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.
This commit introduces several improvements to the eBPF probe to enhance robustness and feature completeness.
feat: Add fallback for PID attributionUsesbpf_get_current_task()as a fallback mechanism to resolve the process ID for a packet. This significantly improves PID attribution for scenarios where the primary flow-based mapping might fail, such as with short-lived connections. Includes a check for kernel support to ensure backward compatibility.fix: Correctly parse IP headers with options
The IP header length is now dynamically calculated based on the IHL (Internet Header Length) field. This fixes a bug where packets with IP options would be parsed incorrectly, leading to errors in L4 (TCP/UDP) header analysis.
chore: Clean up debug logs
Commented out several
debug_logstatements to reduce noise and performance overhead.