Re: [PATCH net-next v2] net: skb: export skb drop reaons to user by TRACE_DEFINE_ENUM

From: Steven Rostedt
Date: Mon Sep 05 2022 - 10:40:33 EST


On Fri, 2 Sep 2022 08:43:07 -0700
Eric Dumazet <edumazet@xxxxxxxxxx> wrote:

> > ---
> > v2:
> > - undef FN/FNe after use it (Jakub Kicinski)
>
> I would love some feedback from Steven :)

The undef should be fine. I usually do not, but that's more of a preference
than a rule.

As long as the undef is done after the C portion of where the macro is used:

+#undef FN
+#define FN(reason) TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason);
+DEFINE_DROP_REASON(FN, FN) <<<--- C portion

+#undef FN
+#undef FNe
+#define FN(reason) { SKB_DROP_REASON_##reason, #reason },
+#define FNe(reason) { SKB_DROP_REASON_##reason, #reason }
+
/*
* Tracepoint for free an sk_buff:
*/
@@ -35,9 +44,13 @@ TRACE_EVENT(kfree_skb,

TP_printk("skbaddr=%p protocol=%u location=%p reason: %s",
__entry->skbaddr, __entry->protocol, __entry->location,
- drop_reasons[__entry->reason])
+ __print_symbolic(__entry->reason,
+ DEFINE_DROP_REASON(FN, FNe))) <<<--- C portion
);

+#undef FN
+#undef FNe

So for this part: Reviewed-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>

-- Steve