8000 TCP socket events for EBPF by haesbaert · Pull Request #112 · elastic/quark · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

TCP socket events for EBPF #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged

TCP socket events for EBPF #112

merged 1 commit into from
Feb 5, 2025

Conversation

haesbaert
Copy link
Collaborator
@haesbaert haesbaert commented Jan 21, 2025

This implements basic socket events for TCP, it tracks
connect(2)/accept(2)/close(2) on respective sockets as well as builds the
initial snapshot of existing sockets by parsing /proc.

Sockets are expressed in quark_socket{} and correlate with processes. Since a
socket might be in more than one process, two fields are provided:

  • pid_origin, the pid that established the connection.
  • pid_last_use, the last pid that affected it, if another process did the final
    close, pid_origin remains the same, but pid_last_use points to the last one.

We stash the lookup of quark_process_lookup(pid_origin) in the event process
pointer, which can be NULL, and the socket itself is stashed in the socket
member.

quark_event{} might need some adjustments in the future.

The EBPF probes are a bit subpar and they currently have two issues:

I don't think this is good enough and will consider it experimental until both
issues are solved, first one has a fix on the way, second one likely involves
rewriting the whole probe.

Quark sockets don't produce snapshot events, because snapshot will be removed
and the user will have to use the iterator if desired.

In order to test this, pass -S to quark-mon(8).

Co-authored-by: Nicholas Berlin 56366649+nicholasberlin@users.noreply.github.com

@haesbaert haesbaert marked this pull request as ready for review February 5, 2025 08:37
@haesbaert haesbaert requested a review from a team as a code owner February 5, 2025 08:37
@haesbaert
Copy link
Collaborator Author
haesbaert commented Feb 5, 2025

Pushed the proposed final version.
Relevant changes:

  • Renamed connection to sock
  • Reworked socket allocation and insertion
  • Addressed the review comments
  • Updated the commit message and this PR
  • SOCK_CONN is disabled by default and must be enabled with -S in quark-mon(8)

@haesbaert haesbaert changed the title WIP - add socket events to quark TCP socket events for EBPF Feb 5, 2025
This implements basic socket events for TCP, it tracks
connect(2)/accept(2)/close(2) on respective sockets as well as builds the
initial snapshot of existing sockets by parsing /proc.

Sockets are expressed in quark_socket{} and correlate with processes. Since a
socket might be in more than one process, two fields are provided:
 - pid_origin, the pid that established the connection.
 - pid_last_use, the last pid that affected it, if another process did the final
   close, pid_origin remains the same, but pid_last_use points to the last one.

We stash the lookup of quark_process_lookup(pid_origin) in the event process
pointer, which *can* be NULL, and the socket itself is stashed in the socket
member.

quark_event{} might need some adjustments in the future.

The EBPF probes are a bit subpar and they currently have two issues:
 - A connection that never sent a byte doesn't produce an exit event.
   elastic/ebpf#217
 - Exit events happen before TCP close is issued
   elastic/ebpf#216

I don't think this is good enough and will consider it experimental until both
issues are solved, first one has a fix on the way, second one likely involves
rewriting the whole probe.

Quark sockets don't produce snapshot events, because snapshot will be removed
and the user will have to use the iterator if desired.

In order to test this, pass -S to quark-mon(8).

Co-authored-by: Nicholas Berlin <56366649+nicholasberlin@users.noreply.github.com>
@haesbaert haesbaert merged commit d7f3b2f into main Feb 5, 2025
2 checks passed
@haesbaert haesbaert deleted the net2 branch April 2, 2025 11:14
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.

2 participants
0