Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing http2 connection info #1464

Merged
merged 3 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading