-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit refactors the getPidByAddr function to handle some unusual cases where the source IP address in the IP packet header has been rewritten by iptables, nftables, or eBPF. In such cases, the function attempts to retrieve the process ID (pid) and destination address (destAddr) using the local IP address (127.0.0.1 for IPv4 or [::1] for IPv6). The original getPidByAddr function is renamed to _getPidByAddr, and a new getPidByAddr function is introduced. The new function first calls _getPidByAddr to obtain the pid and destAddr. If either of them is empty, it checks for the unusual case mentioned above and tries again with the local IP address. The commit also includes a detailed comment explaining the rationale behind this change and the limitations of using the pidAddrMap directly in concurrent situations. Note: This change does not address the case where the client binds to an IP address other than the local IP before the connect call, as this scenario is also considered unusual.
- Loading branch information
Showing
3 changed files
with
50 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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