Skip to content

Commit a2c0802

Browse files
fix: ebpf tailcall segmentation output
1 parent 931bed0 commit a2c0802

3 files changed

Lines changed: 131 additions & 72 deletions

File tree

agent/src/ebpf/kernel/files_rw.bpf.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,19 @@ static __inline int trace_io_event_common(void *ctx,
427427
v->msg_type = MSG_COMMON;
428428
bpf_get_current_comm(v->comm, sizeof(v->comm));
429429
#if !defined(LINUX_VER_KFUNC) && !defined(LINUX_VER_5_2_PLUS)
430-
struct tail_calls_context *context =
431-
(struct tail_calls_context *)v->data;
430+
struct ctx_info_s *ctx_map = bpf_map_lookup_elem(&NAME(ctx_info), &k0);
431+
if (!ctx_map) {
432+
__sync_fetch_and_add(&tracer_ctx->push_buffer_refcnt, -1);
433+
return -1;
434+
}
435+
struct tail_calls_context *context = &ctx_map->tail_call;
432436
context->max_size_limit = data_max_sz;
433437
context->push_reassembly_bytes = 0;
434438
context->vecs = false;
435439
context->is_close = false;
436440
context->dir = direction;
441+
context->sent_bytes = 0;
442+
context->bytes_remaining = 0;
437443
#ifdef SUPPORTS_KPROBE_ONLY
438444
bpf_tail_call(ctx, &NAME(progs_jmp_kp_map), PROG_OUTPUT_DATA_KP_IDX);
439445
#else
@@ -442,7 +448,7 @@ static __inline int trace_io_event_common(void *ctx,
442448
return 0;
443449
#else
444450
return __output_data_common(ctx, tracer_ctx, v_buff, data_args,
445-
direction, false, data_max_sz, false, 0);
451+
direction, false, data_max_sz, false, 0, 0);
446452
#endif
447453
}
448454

agent/src/ebpf/kernel/include/socket_trace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ struct tail_calls_context {
219219
struct process_data_extra extra;
220220
__u32 bytes_count;
221221
struct member_fields_offset *offset;
222+
__u32 bytes_remaining; // remaining bytes to output for this syscall
223+
__u32 sent_bytes; // bytes already output for this syscall
222224
};
223225

224226
struct ctx_info_s {

0 commit comments

Comments
 (0)