Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 827eb35

Browse files
committed
fix(bpf): correct order of element assignments in trace_tcp and trace_udp
1 parent 28b097a commit 827eb35

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

bpf/kprobe/trace_tcp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ int trace_tcp_recvmsg(struct tcp_recvmsg_args *ctx) {
4343
struct network_event e = {};
4444
e.pid = pid;
4545
e.cgroup_id = cgroup_id;
46+
e.size = size;
4647
e.saddr = saddr;
4748
e.daddr = daddr;
4849
e.sport = sport;
4950
e.dport = dport;
50-
e.size = size;
5151
e.direction = DIRECTION_INBOUND;
5252
e.protocol = PROTOCOL_TCP;
5353

@@ -94,11 +94,11 @@ int trace_tcp_sendmsg(struct tcp_sendmsg_args *ctx) {
9494
struct network_event e = {};
9595
e.pid = pid;
9696
e.cgroup_id = cgroup_id;
97+
e.size = size;
9798
e.saddr = saddr;
9899
e.daddr = daddr;
99100
e.sport = sport;
100101
e.dport = dport;
101-
e.size = size;
102102
e.direction = DIRECTION_OUTBOUND;
103103
e.protocol = PROTOCOL_TCP;
104104

bpf/kprobe/trace_udp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ int trace_udp_recvmsg(struct udp_recvmsg_args *ctx) {
4242
struct network_event e = {};
4343
e.pid = pid;
4444
e.cgroup_id = cgroup_id;
45+
e.size = size;
4546
e.saddr = saddr;
4647
e.daddr = daddr;
4748
e.sport = sport;
4849
e.dport = dport;
49-
e.size = size;
5050
e.direction = DIRECTION_INBOUND;
5151
e.protocol = PROTOCOL_UDP;
5252

@@ -92,14 +92,15 @@ int trace_udp_sendmsg(struct udp_sendmsg_args *ctx) {
9292
}
9393

9494
struct network_event e = {};
95-
e.direction = DIRECTION_OUTBOUND;
96-
e.protocol = PROTOCOL_UDP;
9795
e.pid = pid;
9896
e.cgroup_id = cgroup_id;
97+
e.size = size;
9998
e.saddr = saddr;
10099
e.daddr = daddr;
101100
e.sport = sport;
102101
e.dport = dport;
102+
e.direction = DIRECTION_OUTBOUND;
103+
e.protocol = PROTOCOL_UDP;
103104

104105
bpf_ringbuf_output(&network_events_rb, &e, sizeof(e), BPF_RB_FORCE_WAKEUP);
105106
return 0;

0 commit comments

Comments
 (0)