Skip to content

Commit

Permalink
fix(bpf): correct order of element assignments in trace_tcp and trace…
Browse files Browse the repository at this point in the history
…_udp
  • Loading branch information
nullswan committed Sep 22, 2024
1 parent 28b097a commit 827eb35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bpf/kprobe/trace_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ int trace_tcp_recvmsg(struct tcp_recvmsg_args *ctx) {
struct network_event e = {};
e.pid = pid;
e.cgroup_id = cgroup_id;
e.size = size;
e.saddr = saddr;
e.daddr = daddr;
e.sport = sport;
e.dport = dport;
e.size = size;
e.direction = DIRECTION_INBOUND;
e.protocol = PROTOCOL_TCP;

Expand Down Expand Up @@ -94,11 +94,11 @@ int trace_tcp_sendmsg(struct tcp_sendmsg_args *ctx) {
struct network_event e = {};
e.pid = pid;
e.cgroup_id = cgroup_id;
e.size = size;
e.saddr = saddr;
e.daddr = daddr;
e.sport = sport;
e.dport = dport;
e.size = size;
e.direction = DIRECTION_OUTBOUND;
e.protocol = PROTOCOL_TCP;

Expand Down
7 changes: 4 additions & 3 deletions bpf/kprobe/trace_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ int trace_udp_recvmsg(struct udp_recvmsg_args *ctx) {
struct network_event e = {};
e.pid = pid;
e.cgroup_id = cgroup_id;
e.size = size;
e.saddr = saddr;
e.daddr = daddr;
e.sport = sport;
e.dport = dport;
e.size = size;
e.direction = DIRECTION_INBOUND;
e.protocol = PROTOCOL_UDP;

Expand Down Expand Up @@ -92,14 +92,15 @@ int trace_udp_sendmsg(struct udp_sendmsg_args *ctx) {
}

struct network_event e = {};
e.direction = DIRECTION_OUTBOUND;
e.protocol = PROTOCOL_UDP;
e.pid = pid;
e.cgroup_id = cgroup_id;
e.size = size;
e.saddr = saddr;
e.daddr = daddr;
e.sport = sport;
e.dport = dport;
e.direction = DIRECTION_OUTBOUND;
e.protocol = PROTOCOL_UDP;

bpf_ringbuf_output(&network_events_rb, &e, sizeof(e), BPF_RB_FORCE_WAKEUP);
return 0;
Expand Down

0 comments on commit 827eb35

Please sign in to comment.