Skip to content

Commit f8042e8

Browse files
committed
Fix stdlib http2 tracing for Go 1.24
Signed-off-by: Dom Del Nano <[email protected]>
1 parent 4ba9b64 commit f8042e8

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

src/stirling/source_connectors/socket_tracer/bcc_bpf/go_http2_trace.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,15 @@ static __inline int32_t get_fd_from_http2_Framer(const void* framer_ptr,
141141
static __inline int32_t get_fd_from_http_http2Framer(const void* framer_ptr,
142142
const struct go_http2_symaddrs_t* symaddrs) {
143143
REQUIRE_SYMADDR(symaddrs->http2Framer_w_offset, kInvalidFD);
144-
REQUIRE_SYMADDR(symaddrs->http2bufferedWriter_w_offset, kInvalidFD);
144+
int32_t inner_intf_offset = symaddrs->http2bufferedWriter_w_offset;
145+
bool conn_intf = false;
146+
// Go 1.24 dropped the io.Writer w member from http2bufferedWriter,
147+
// moving forward it uses a conn member (net.Conn interface) instead.
148+
if (inner_intf_offset == -1) {
149+
inner_intf_offset = symaddrs->http2bufferedWriter_conn_offset;
150+
REQUIRE_SYMADDR(inner_intf_offset, kInvalidFD);
151+
conn_intf = true;
152+
}
145153

146154
struct go_interface io_writer_interface;
147155
BPF_PROBE_READ_VAR(io_writer_interface, framer_ptr + symaddrs->http2Framer_w_offset);
@@ -152,11 +160,13 @@ static __inline int32_t get_fd_from_http_http2Framer(const void* framer_ptr,
152160
return kInvalidFD;
153161
}
154162

155-
struct go_interface inner_io_writer_interface;
156-
BPF_PROBE_READ_VAR(inner_io_writer_interface,
157-
io_writer_interface.ptr + symaddrs->http2bufferedWriter_w_offset);
163+
struct go_interface inner_intf;
164+
bpf_probe_read(&inner_intf, sizeof(inner_intf), io_writer_interface.ptr + inner_intf_offset);
158165

159-
return get_fd_from_io_writer_intf(inner_io_writer_interface.ptr);
166+
if (conn_intf) {
167+
return get_fd_from_conn_intf(inner_intf);
168+
}
169+
return get_fd_from_io_writer_intf(inner_intf.ptr);
160170
}
161171

162172
//-----------------------------------------------------------------------------
@@ -525,7 +535,7 @@ int probe_http2_server_operate_headers(struct pt_regs* ctx) {
525535
// Symbol:
526536
// net/http.(*http2serverConn).processHeaders
527537
//
528-
// Verified to be stable from go1.?? to t go.1.13.
538+
// Verified to be stable from go1.?? to go.1.13.
529539
int probe_http_http2serverConn_processHeaders(struct pt_regs* ctx) {
530540
uint32_t tgid = bpf_get_current_pid_tgid() >> 32;
531541
struct go_http2_symaddrs_t* symaddrs = http2_symaddrs_map.lookup(&tgid);
@@ -629,7 +639,7 @@ int probe_http_http2serverConn_processHeaders(struct pt_regs* ctx) {
629639
// Symbol:
630640
// golang.org/x/net/http2/hpack.(*Encoder).WriteField
631641
//
632-
// Verified to be stable from at least go1.6 to t go.1.13.
642+
// Verified to be stable from at least go1.6 to go.1.13.
633643
int probe_hpack_header_encoder(struct pt_regs* ctx) {
634644
uint32_t tgid = bpf_get_current_pid_tgid() >> 32;
635645
struct go_http2_symaddrs_t* symaddrs = http2_symaddrs_map.lookup(&tgid);
@@ -679,7 +689,7 @@ int probe_hpack_header_encoder(struct pt_regs* ctx) {
679689
// Symbol:
680690
// net/http.(*http2writeResHeaders).writeFrame
681691
//
682-
// Verified to be stable from go1.?? to t go.1.13.
692+
// Verified to be stable from go1.?? to go.1.13.
683693
int probe_http_http2writeResHeaders_write_frame(struct pt_regs* ctx) {
684694
uint32_t tgid = bpf_get_current_pid_tgid() >> 32;
685695
struct go_http2_symaddrs_t* symaddrs = http2_symaddrs_map.lookup(&tgid);
@@ -857,7 +867,7 @@ static __inline void go_http2_submit_data(struct pt_regs* ctx, enum http2_probe_
857867
// Symbol:
858868
// golang.org/x/net/http2.(*Framer).checkFrameOrder
859869
//
860-
// Verified to be stable from at least go1.6 to t go.1.13.
870+
// Verified to be stable from at least go1.6 to go.1.13.
861871
int probe_http2_framer_check_frame_order(struct pt_regs* ctx) {
862872
uint32_t tgid = bpf_get_current_pid_tgid() >> 32;
863873
struct go_http2_symaddrs_t* symaddrs = http2_symaddrs_map.lookup(&tgid);
@@ -1066,7 +1076,7 @@ int probe_http_http2framer_check_frame_order(struct pt_regs* ctx) {
10661076
// Symbol:
10671077
// golang.org/x/net/http2.(*Framer).WriteDataPadded
10681078
//
1069-
// Verified to be stable from go1.7 to t go.1.13.
1079+
// Verified to be stable from go1.7 to go.1.13.
10701080
int probe_http2_framer_write_data(struct pt_regs* ctx) {
10711081
uint32_t tgid = bpf_get_current_pid_tgid() >> 32;
10721082
struct go_http2_symaddrs_t* symaddrs = http2_symaddrs_map.lookup(&tgid);
@@ -1134,7 +1144,7 @@ int probe_http2_framer_write_data(struct pt_regs* ctx) {
11341144
// Symbol:
11351145
// net/http.(*http2Framer).WriteDataPadded
11361146
//
1137-
// Verified to be stable from go1.?? to t go.1.13.
1147+
// Verified to be stable from go1.?? to go.1.23.
11381148
int probe_http_http2framer_write_data(struct pt_regs* ctx) {
11391149
uint32_t tgid = bpf_get_current_pid_tgid() >> 32;
11401150
struct go_http2_symaddrs_t* symaddrs = http2_symaddrs_map.lookup(&tgid);

src/stirling/source_connectors/socket_tracer/bcc_bpf_intf/symaddrs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ struct go_http2_symaddrs_t {
235235

236236
// Members of net/http.http2bufferedWriter
237237
int32_t http2bufferedWriter_w_offset; // 0
238+
// Go 1.24 switched from a w io.Writer to a conn net.Conn member.
239+
int32_t http2bufferedWriter_conn_offset;
238240
};
239241

240242
struct go_tls_symaddrs_t {

src/stirling/source_connectors/socket_tracer/uprobe_symaddrs.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ Status PopulateHTTP2DebugSymbols(DwarfReader* dwarf_reader, std::string_view ven
345345
dwarf_reader->GetStructMemberOffset(
346346
"net/http.http2bufferedWriter",
347347
"w"));
348+
349+
LOG_ASSIGN_STATUSOR(symaddrs->http2bufferedWriter_conn_offset,
350+
dwarf_reader->GetStructMemberOffset(
351+
"net/http.http2bufferedWriter",
352+
"conn"));
348353
// clang-format on
349354

350355
const std::map<std::string, obj_tools::ArgInfo> kEmptyMap;

0 commit comments

Comments
 (0)