|
13 | 13 | #include "ipv6.h" |
14 | 14 | #include "sock.h" |
15 | 15 | #include "port_range.h" |
| 16 | +#include "pid_tgid.h" |
16 | 17 |
|
17 | 18 | #include "protocols/classification/dispatcher-helpers.h" |
| 19 | +#include "protocols/flush.h" |
18 | 20 | #include "protocols/http/buffer.h" |
19 | 21 | #include "protocols/http/http.h" |
20 | 22 | #include "protocols/http2/decoding.h" |
|
23 | 25 | #include "protocols/postgres/decoding.h" |
24 | 26 | #include "protocols/redis/decoding.h" |
25 | 27 | #include "protocols/sockfd-probes.h" |
26 | | -#include "protocols/tls/java/erpc_dispatcher.h" |
27 | | -#include "protocols/tls/java/erpc_handlers.h" |
28 | 28 | #include "protocols/tls/go-tls-types.h" |
29 | 29 | #include "protocols/tls/go-tls-goid.h" |
30 | 30 | #include "protocols/tls/go-tls-location.h" |
@@ -56,48 +56,13 @@ int uprobe__tls_protocol_dispatcher_kafka(struct pt_regs *ctx) { |
56 | 56 | return 0; |
57 | 57 | }; |
58 | 58 |
|
59 | | -SEC("kprobe/tcp_sendmsg") |
60 | | -int BPF_BYPASSABLE_KPROBE(kprobe__tcp_sendmsg, struct sock *sk) { |
61 | | - log_debug("kprobe/tcp_sendmsg: sk=%p", sk); |
62 | | - // map connection tuple during SSL_do_handshake(ctx) |
63 | | - map_ssl_ctx_to_sock(sk); |
64 | | - |
65 | | - return 0; |
66 | | -} |
67 | | - |
68 | | -static __always_inline int flush(void *ctx) { |
69 | | - // flush batch to userspace |
70 | | - // because perf events can't be sent from socket filter programs |
71 | | - http_batch_flush(ctx); |
72 | | - http2_batch_flush(ctx); |
73 | | - terminated_http2_batch_flush(ctx); |
74 | | - kafka_batch_flush(ctx); |
75 | | - postgres_batch_flush(ctx); |
76 | | - redis_batch_flush(ctx); |
77 | | - return 0; |
78 | | -} |
79 | | - |
80 | | -SEC("raw_tracepoint/net/netif_receive_skb") |
81 | | -int BPF_PROG(raw_tracepoint__net__netif_receive_skb) { |
82 | | - CHECK_BPF_PROGRAM_BYPASSED() |
83 | | - log_debug("raw_tracepoint/net/netif_receive_skb"); |
84 | | - return flush(ctx); |
85 | | -} |
86 | | - |
87 | | -SEC("tracepoint/net/netif_receive_skb") |
88 | | -int tracepoint__net__netif_receive_skb(void *ctx) { |
89 | | - CHECK_BPF_PROGRAM_BYPASSED() |
90 | | - log_debug("tracepoint/net/netif_receive_skb"); |
91 | | - return flush(ctx); |
92 | | -} |
93 | | - |
94 | 59 | // GO TLS PROBES |
95 | 60 |
|
96 | 61 | // func (c *Conn) Write(b []byte) (int, error) |
97 | 62 | SEC("uprobe/crypto/tls.(*Conn).Write") |
98 | 63 | int BPF_BYPASSABLE_UPROBE(uprobe__crypto_tls_Conn_Write) { |
99 | 64 | u64 pid_tgid = bpf_get_current_pid_tgid(); |
100 | | - u64 pid = pid_tgid >> 32; |
| 65 | + u64 pid = GET_USER_MODE_PID(pid_tgid); |
101 | 66 | tls_offsets_data_t* od = get_offsets_data(); |
102 | 67 | if (od == NULL) { |
103 | 68 | log_debug("[go-tls-write] no offsets data in map for pid %llu", pid); |
@@ -130,15 +95,15 @@ int BPF_BYPASSABLE_UPROBE(uprobe__crypto_tls_Conn_Write) { |
130 | 95 | return 0; |
131 | 96 | } |
132 | 97 |
|
133 | | - bpf_map_update_elem(&go_tls_write_args, &call_key, &call_data, BPF_ANY); |
| 98 | + bpf_map_update_with_telemetry(go_tls_write_args, &call_key, &call_data, BPF_ANY); |
134 | 99 | return 0; |
135 | 100 | } |
136 | 101 |
|
137 | 102 | // func (c *Conn) Write(b []byte) (int, error) |
138 | 103 | SEC("uprobe/crypto/tls.(*Conn).Write/return") |
139 | 104 | int BPF_BYPASSABLE_UPROBE(uprobe__crypto_tls_Conn_Write__return) { |
140 | 105 | u64 pid_tgid = bpf_get_current_pid_tgid(); |
141 | | - u64 pid = pid_tgid >> 32; |
| 106 | + u64 pid = GET_USER_MODE_PID(pid_tgid); |
142 | 107 | tls_offsets_data_t* od = get_offsets_data(); |
143 | 108 | if (od == NULL) { |
144 | 109 | log_debug("[go-tls-write-return] no offsets data in map for pid %llu", pid); |
@@ -213,42 +178,42 @@ int BPF_BYPASSABLE_UPROBE(uprobe__crypto_tls_Conn_Write__return) { |
213 | 178 | SEC("uprobe/crypto/tls.(*Conn).Read") |
214 | 179 | int BPF_BYPASSABLE_UPROBE(uprobe__crypto_tls_Conn_Read) { |
215 | 180 | u64 pid_tgid = bpf_get_current_pid_tgid(); |
216 | | - u64 pid = pid_tgid >> 32; |
| 181 | + u64 pid = GET_USER_MODE_PID(pid_tgid); |
217 | 182 | tls_offsets_data_t* od = get_offsets_data(); |
218 | 183 | if (od == NULL) { |
219 | | - log_debug("[go-tls-read] no offsets data in map for pid %llu", pid_tgid >> 32); |
| 184 | + log_debug("[go-tls-read] no offsets data in map for pid %llu", pid); |
220 | 185 | return 0; |
221 | 186 | } |
222 | 187 |
|
223 | 188 | // Read the PID and goroutine ID to make the partial call key |
224 | 189 | go_tls_function_args_key_t call_key = {0}; |
225 | 190 | call_key.pid = pid; |
226 | 191 | if (read_goroutine_id(ctx, &od->goroutine_id, &call_key.goroutine_id)) { |
227 | | - log_debug("[go-tls-read] failed reading go routine id for pid %llu", pid_tgid >> 32); |
| 192 | + log_debug("[go-tls-read] failed reading go routine id for pid %llu", pid); |
228 | 193 | return 0; |
229 | 194 | } |
230 | 195 |
|
231 | 196 | // Read the parameters to make the partial call data |
232 | 197 | // (since the parameters might not be live by the time the return probe is hit). |
233 | 198 | go_tls_read_args_data_t call_data = {0}; |
234 | 199 | if (read_location(ctx, &od->read_conn_pointer, sizeof(call_data.conn_pointer), &call_data.conn_pointer)) { |
235 | | - log_debug("[go-tls-read] failed reading conn pointer for pid %llu", pid_tgid >> 32); |
| 200 | + log_debug("[go-tls-read] failed reading conn pointer for pid %llu", pid); |
236 | 201 | return 0; |
237 | 202 | } |
238 | 203 | if (read_location(ctx, &od->read_buffer.ptr, sizeof(call_data.b_data), &call_data.b_data)) { |
239 | | - log_debug("[go-tls-read] failed reading buffer pointer for pid %llu", pid_tgid >> 32); |
| 204 | + log_debug("[go-tls-read] failed reading buffer pointer for pid %llu", pid); |
240 | 205 | return 0; |
241 | 206 | } |
242 | 207 |
|
243 | | - bpf_map_update_elem(&go_tls_read_args, &call_key, &call_data, BPF_ANY); |
| 208 | + bpf_map_update_with_telemetry(go_tls_read_args, &call_key, &call_data, BPF_ANY); |
244 | 209 | return 0; |
245 | 210 | } |
246 | 211 |
|
247 | 212 | // func (c *Conn) Read(b []byte) (int, error) |
248 | 213 | SEC("uprobe/crypto/tls.(*Conn).Read/return") |
249 | 214 | int BPF_BYPASSABLE_UPROBE(uprobe__crypto_tls_Conn_Read__return) { |
250 | 215 | u64 pid_tgid = bpf_get_current_pid_tgid(); |
251 | | - u64 pid = pid_tgid >> 32; |
| 216 | + u64 pid = GET_USER_MODE_PID(pid_tgid); |
252 | 217 | tls_offsets_data_t* od = get_offsets_data(); |
253 | 218 | if (od == NULL) { |
254 | 219 | log_debug("[go-tls-read-return] no offsets data in map for pid %llu", pid); |
@@ -318,27 +283,27 @@ int BPF_BYPASSABLE_UPROBE(uprobe__crypto_tls_Conn_Close) { |
318 | 283 | u64 pid_tgid = bpf_get_current_pid_tgid(); |
319 | 284 | tls_offsets_data_t* od = get_offsets_data(); |
320 | 285 | if (od == NULL) { |
321 | | - log_debug("[go-tls-close] no offsets data in map for pid %llu", pid_tgid >> 32); |
| 286 | + log_debug("[go-tls-close] no offsets data in map for pid %llu", GET_USER_MODE_PID(pid_tgid)); |
322 | 287 | return 0; |
323 | 288 | } |
324 | 289 |
|
325 | 290 | // Read the PID and goroutine ID to make the partial call key |
326 | 291 | go_tls_function_args_key_t call_key = {0}; |
327 | | - call_key.pid = pid_tgid >> 32; |
| 292 | + call_key.pid = GET_USER_MODE_PID(pid_tgid); |
328 | 293 | if (read_goroutine_id(ctx, &od->goroutine_id, &call_key.goroutine_id) == 0) { |
329 | 294 | bpf_map_delete_elem(&go_tls_read_args, &call_key); |
330 | 295 | bpf_map_delete_elem(&go_tls_write_args, &call_key); |
331 | 296 | } |
332 | 297 |
|
333 | 298 | void* conn_pointer = NULL; |
334 | 299 | if (read_location(ctx, &od->close_conn_pointer, sizeof(conn_pointer), &conn_pointer)) { |
335 | | - log_debug("[go-tls-close] failed reading close conn pointer for pid %llu", pid_tgid >> 32); |
| 300 | + log_debug("[go-tls-close] failed reading close conn pointer for pid %llu", GET_USER_MODE_PID(pid_tgid)); |
336 | 301 | return 0; |
337 | 302 | } |
338 | 303 |
|
339 | 304 | conn_tuple_t* t = conn_tup_from_tls_conn(od, conn_pointer, pid_tgid); |
340 | 305 | if (t == NULL) { |
341 | | - log_debug("[go-tls-close] failed getting conn tup from tls conn for pid %llu", pid_tgid >> 32); |
| 306 | + log_debug("[go-tls-close] failed getting conn tup from tls conn for pid %llu", GET_USER_MODE_PID(pid_tgid)); |
342 | 307 | return 0; |
343 | 308 | } |
344 | 309 |
|
|
0 commit comments