Skip to content

Commit

Permalink
use inet_sock_destruct instead
Browse files Browse the repository at this point in the history
  • Loading branch information
akarpz committed Nov 5, 2024
1 parent 76e86c6 commit 9927c74
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/network/ebpf/c/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,17 @@ int BPF_KRETPROBE(kretprobe__tcp_close_flush) {
return 0;
}

SEC("kprobe/tcp_v4_destroy_sock")
int BPF_BYPASSABLE_KPROBE(kprobe__tcp_v4_destroy_sock, struct sock *sk) {
SEC("kprobe/inet_sock_destruct")
int BPF_BYPASSABLE_KPROBE(kprobe__inet_sock_destruct, struct sock *sk) {
conn_tuple_t t = {};
u64 pid_tgid = bpf_get_current_pid_tgid();

// Get network namespace id
log_debug("adamk kprobe/tcp_v4_destroy_sock: tgid: %llu, pid: %llu", pid_tgid >> 32, pid_tgid & 0xFFFFFFFF);
log_debug("adamk kprobe/inet_sock_destruct: tgid: %llu, pid: %llu", pid_tgid >> 32, pid_tgid & 0xFFFFFFFF);
if (!read_conn_tuple(&t, sk, pid_tgid, CONN_TYPE_TCP)) {
return 0;
}
log_debug("adamk kprobe/tcp_v4_destroy_sock: netns: %u, sport: %u, dport: %u", t.netns, t.sport, t.dport);
log_debug("adamk kprobe/inet_sock_destruct: netns: %u, sport: %u, dport: %u", t.netns, t.sport, t.dport);

bpf_map_delete_elem(&conn_close_flushed, &t);

Expand Down
4 changes: 2 additions & 2 deletions pkg/network/ebpf/probes/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ const (

// TCPClose traces the tcp_close() system call
TCPClose ProbeFuncName = "kprobe__tcp_close"
// TCPDestroySock does stuff
TCPDestroySock ProbeFuncName = "kprobe__tcp_v4_destroy_sock"
// TCPInetSockDestruct traces the inet_sock_destruct() system call
TCPInetSockDestruct ProbeFuncName = "kprobe__inet_sock_destruct"
// TCPDone traces the tcp_done() system call
TCPDone ProbeFuncName = "kprobe__tcp_done"
// TCPDoneFlushReturn traces the return of the tcp_done() system call
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/tracer/connection/kprobe/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func enabledProbes(c *config.Config, runtimeTracer, coreTracer bool) (map[probes
enableProbe(enabled, probes.TCPReadSock)
enableProbe(enabled, probes.TCPReadSockReturn)
enableProbe(enabled, probes.TCPClose)
enableProbe(enabled, probes.TCPDestroySock)
enableProbe(enabled, probes.TCPInetSockDestruct)
enableProbe(enabled, probes.TCPCloseFlushReturn)
enableProbe(enabled, probes.TCPConnect)
enableProbe(enabled, probes.TCPDone)
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/tracer/connection/kprobe/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var mainProbes = []probes.ProbeFuncName{
probes.TCPReadSock,
probes.TCPReadSockReturn,
probes.TCPClose,
probes.TCPDestroySock,
probes.TCPInetSockDestruct,
probes.TCPDone,
probes.TCPDoneFlushReturn,
probes.TCPCloseCleanProtocolsReturn,
Expand Down

0 comments on commit 9927c74

Please sign in to comment.