Skip to content

Commit

Permalink
clean up pid map in tcp close
Browse files Browse the repository at this point in the history
  • Loading branch information
akarpz committed Nov 5, 2024
1 parent 9927c74 commit 884d0da
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/network/ebpf/c/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ int BPF_BYPASSABLE_KPROBE(kprobe__tcp_close, struct sock *sk) {
skp_conn_tuple_t skp_conn = {.sk = sk, .tup = t};
skp_conn.tup.pid = 0;

// bpf_map_delete_elem(&tcp_ongoing_connect_pid, &skp_conn);
bpf_map_delete_elem(&tcp_ongoing_connect_pid, &skp_conn);

if (!tcp_failed_connections_enabled()) {
cleanup_conn(ctx, &t, sk);
Expand Down Expand Up @@ -332,16 +332,23 @@ int BPF_BYPASSABLE_KPROBE(kprobe__inet_sock_destruct, struct sock *sk) {
// Get network namespace id
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)) {
log_debug("adamk kprobe/inet_sock_destruct: FAILED TO READ conn tuple");
return 0;
}
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);
int code = bpf_map_delete_elem(&conn_close_flushed, &t);
if (code != 0) {
log_debug("adamk kprobe/inet_sock_destruct: FAILED TO DELETE conn_close_flushed");
}

skp_conn_tuple_t skp_conn = {.sk = sk, .tup = t};
skp_conn.tup.pid = 0;

bpf_map_delete_elem(&tcp_ongoing_connect_pid, &skp_conn);
int ret = bpf_map_delete_elem(&tcp_ongoing_connect_pid, &skp_conn);
if (ret != 0) {
log_debug("adamk kprobe/inet_sock_destruct: FAILED TO DELETE tcp_ongoing_connect_pid");
}
return 0;
}

Expand Down

0 comments on commit 884d0da

Please sign in to comment.