From dbe7c0e568007d4e66cc7eb51e034fa0b66a3067 Mon Sep 17 00:00:00 2001 From: Menglong Dong Date: Thu, 30 May 2024 14:13:47 +0800 Subject: [PATCH] bpf: fix skb_clone trace exception Signed-off-by: Menglong Dong --- src/progs/kprobe.c | 4 ---- src/trace.c | 2 +- src/trace.h | 11 ++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/progs/kprobe.c b/src/progs/kprobe.c index fd2fdfb..dcad4af 100644 --- a/src/progs/kprobe.c +++ b/src/progs/kprobe.c @@ -95,11 +95,7 @@ static inline int default_handle_entry(context_info_t *info); static __always_inline int get_ret_key(int func) { -#ifndef BPF_MAP_TYPE_PERCPU_ARRAY - return func * bpf_get_smp_processor_id(); -#else return func; -#endif } static inline void get_ret(context_info_t *info) diff --git a/src/trace.c b/src/trace.c index d14288f..6396a58 100644 --- a/src/trace.c +++ b/src/trace.c @@ -721,7 +721,7 @@ static void trace_print_enabled() } else { fmt = "tracepoint"; } - pr_verb("\t%s: %s, prog: %s, status: %x\n", fmt, trace->name, + pr_verb("\t%s: %s, prog: %s, status: 0x%x\n", fmt, trace->name, trace->prog, trace_get_status(trace->index)); } } diff --git a/src/trace.h b/src/trace.h index 50f16ac..872ddf7 100644 --- a/src/trace.h +++ b/src/trace.h @@ -225,8 +225,14 @@ static inline bool trace_is_usable(trace_t *t) return trace_is_enable(t) && !trace_is_invalid(t); } +static inline void trace_set_status(int func, int status) +{ + trace_ctx.bpf_args.trace_status[func] |= status; +} + static inline void trace_set_ret(trace_t *t) { + trace_set_status(t->index, FUNC_STATUS_RET); t->status |= TRACE_RET; } @@ -245,11 +251,6 @@ static inline bool trace_is_retonly(trace_t *t) return t->status & TRACE_RET_ONLY; } -static inline void trace_set_status(int func, int status) -{ - trace_ctx.bpf_args.trace_status[func] |= status; -} - static inline u8 trace_get_status(int func) { return trace_ctx.bpf_args.trace_status[func];