Skip to content

Commit

Permalink
Improve http2/grpc termination detection (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
grcevski authored May 23, 2024
1 parent 9d5da6c commit b61e5c7
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bpf/http_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ static __always_inline void http2_grpc_start(http2_conn_stream_t *s_key, void *u
}

static __always_inline void http2_grpc_end(http2_conn_stream_t *stream, http2_grpc_request_t *prev_info, void *u_buf) {
//bpf_dbg_printk("http2/grpc end prev_info=%llx", prev_info);
if (prev_info) {
prev_info->end_monotime_ns = bpf_ktime_get_ns();

Expand Down Expand Up @@ -491,10 +492,14 @@ static __always_inline void process_http2_grpc_frames(pid_connection_info_t *pid
} else {
// We only loop 6 times looking for the stream termination. If the data packed is large we'll miss the
// frame saying the stream closed. In that case we try this backup path.
if (!found_end_frame && prev_info && found_data_frame && saved_stream_id) {
stream.pid_conn = *pid_conn;
stream.stream_id = saved_stream_id;
found_end_frame = 1;
if (!found_end_frame && prev_info && saved_stream_id) {
if (found_data_frame ||
((prev_info->type == EVENT_HTTP_REQUEST) && (direction == TCP_SEND)) ||
((prev_info->type == EVENT_HTTP_CLIENT) && (direction == TCP_RECV))) {
stream.pid_conn = *pid_conn;
stream.stream_id = saved_stream_id;
found_end_frame = 1;
}
}
if (found_end_frame) {
http2_grpc_end(&stream, prev_info, (void *)((u8 *)u_buf + saved_buf_pos));
Expand Down
Binary file modified pkg/internal/ebpf/httpfltr/bpf_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpfltr/bpf_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpfltr/bpf_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpfltr/bpf_debug_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpfltr/bpf_tp_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpfltr/bpf_tp_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpfltr/bpf_tp_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpfltr/bpf_tp_debug_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_debug_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_tp_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_tp_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_tp_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/httpssl/bpf_tp_debug_bpfel_x86.o
Binary file not shown.

0 comments on commit b61e5c7

Please sign in to comment.