Commit a7eefa8
authored
fix(bpf): Correctly parse IP headers with options (#337)
* feat(bpf): Improve PID attribution and IP parsing
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.
* refactor(bpf): Remove unsafe PID fallback
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.1 parent 2b157b7 commit a7eefa8
11 files changed
+46
-6
lines changedBinary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
80 | 95 | | |
81 | 96 | | |
82 | 97 | | |
| |||
122 | 137 | | |
123 | 138 | | |
124 | 139 | | |
125 | | - | |
| 140 | + | |
126 | 141 | | |
127 | 142 | | |
128 | 143 | | |
129 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
130 | 148 | | |
131 | | - | |
132 | 149 | | |
| 150 | + | |
133 | 151 | | |
134 | 152 | | |
135 | 153 | | |
| |||
0 commit comments