Skip to content

Commit

Permalink
Fix missing http2 connection info (#1464)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikola Grcevski <grcevski@gmail.com>
  • Loading branch information
rafaelroquetto and grcevski authored Dec 14, 2024
1 parent 0d8cdc3 commit 5770689
Show file tree
Hide file tree
Showing 24 changed files with 162 additions and 26 deletions.
32 changes: 23 additions & 9 deletions bpf/go_nethttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,13 +721,7 @@ struct {
} http2_req_map SEC(".maps");
#endif

SEC("uprobe/http2RoundTrip")
int beyla_uprobe_http2RoundTrip(struct pt_regs *ctx) {
// we use the usual start helper, just like for normal http calls, but we later save
// more context, like the streamID
roundTripStartHelper(ctx);

void *cc_ptr = GO_PARAM1(ctx);
static __always_inline void setup_http2_client_conn(void *goroutine_addr, void *cc_ptr) {
off_table_t *ot = get_offsets_table();

if (cc_ptr) {
Expand All @@ -746,7 +740,6 @@ int beyla_uprobe_http2RoundTrip(struct pt_regs *ctx) {
u8 ok = get_conn_info(tconn_conn, &conn);

if (ok) {
void *goroutine_addr = GOROUTINE_PTR(ctx);
bpf_dbg_printk("goroutine_addr %lx", goroutine_addr);
go_addr_key_t g_key = {};
go_addr_key_from_id(&g_key, goroutine_addr);
Expand All @@ -764,13 +757,34 @@ int beyla_uprobe_http2RoundTrip(struct pt_regs *ctx) {

bpf_dbg_printk("cc_ptr = %llx, nextStreamID=%d", cc_ptr, stream_id);
if (stream_id) {
void *goroutine_addr = GOROUTINE_PTR(ctx);
go_addr_key_t s_key = {};
go_addr_key_from_id(&s_key, (void *)(uintptr_t)stream_id);
bpf_map_update_elem(&http2_req_map, &s_key, &goroutine_addr, BPF_ANY);
}
#endif
}
}

SEC("uprobe/http2RoundTrip")
int beyla_uprobe_http2RoundTrip(struct pt_regs *ctx) {
// we use the usual start helper, just like for normal http calls, but we later save
// more context, like the streamID
roundTripStartHelper(ctx);

void *goroutine_addr = GOROUTINE_PTR(ctx);
void *cc_ptr = GO_PARAM1(ctx);

setup_http2_client_conn(goroutine_addr, cc_ptr);

return 0;
}

SEC("uprobe/http2RoundTripConn")
int beyla_uprobe_http2RoundTripConn(struct pt_regs *ctx) {
void *goroutine_addr = GOROUTINE_PTR(ctx);
void *cc_ptr = GO_PARAM1(ctx);

setup_http2_client_conn(goroutine_addr, cc_ptr);

return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions configs/offsets/tracker_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
"net/http.conn": [
"rwc",
"tlsState"
],
"net/http.http2ClientConn": [
"nextStreamID",
"tconn"
],
"net/http.http2serverConn": [
"conn"
]
}
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_arm64_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/internal/ebpf/gotracer/bpf_arm64_bpfel.o
Git LFS file not shown
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_debug_arm64_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/internal/ebpf/gotracer/bpf_debug_arm64_bpfel.o
Git LFS file not shown
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_debug_x86_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/internal/ebpf/gotracer/bpf_debug_x86_bpfel.o
Git LFS file not shown
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_tp_arm64_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/internal/ebpf/gotracer/bpf_tp_arm64_bpfel.o
Git LFS file not shown
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_tp_debug_arm64_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/internal/ebpf/gotracer/bpf_tp_debug_arm64_bpfel.o
Git LFS file not shown
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_tp_debug_x86_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/internal/ebpf/gotracer/bpf_tp_debug_x86_bpfel.o
Git LFS file not shown
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_tp_x86_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/internal/ebpf/gotracer/bpf_tp_x86_bpfel.o
Git LFS file not shown
3 changes: 3 additions & 0 deletions pkg/internal/ebpf/gotracer/bpf_x86_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5770689

Please sign in to comment.