From 316e27d3b55342f593a80cdf74932e70af4bd6ec Mon Sep 17 00:00:00 2001 From: Menglong Dong Date: Thu, 8 Dec 2022 16:15:20 +0800 Subject: [PATCH] nettrace: allow to use drop-stack in any mode Signed-off-by: Menglong Dong --- src/trace.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/trace.c b/src/trace.c index b467eba..a664f82 100644 --- a/src/trace.c +++ b/src/trace.c @@ -179,6 +179,7 @@ static void trace_all_set_ret() static int trace_prepare_args() { + trace_t *drop_trace = search_trace_enabled("kfree_skb"); trace_args_t *args = &trace_ctx.args; char *traces = args->traces; trace_t *trace; @@ -195,12 +196,15 @@ static int trace_prepare_args() if (args->intel) trace_ctx.mode = TRACE_MODE_INETL; + if (args->drop_stack) { + if (trace_set_stack(drop_trace)) + goto err; + } + if (args->drop) { trace_ctx.mode = TRACE_MODE_DROP; - traces = "kfree_skb"; - } else if (args->drop_stack) { - pr_err("--drop should be set!\n"); - goto err; + trace_set_enable(drop_trace); + goto skip_trace; } if (!traces) { @@ -247,15 +251,11 @@ static int trace_prepare_args() trace_group_enable("life"); break; case TRACE_MODE_BASIC: + break; case TRACE_MODE_DROP: { - trace_t *drop_trace = search_trace_enabled(traces); - if (!trace_ctx.drop_reason) pr_warn("skb drop reason is not support by your kernel" ", drop reason will not be printed\n"); - - if (args->drop_stack && trace_set_stack(drop_trace)) - goto err; break; } default: