[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250714123825.6f0485c9@batman.local.home>
Date: Mon, 14 Jul 2025 12:38:25 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Thorsten Blum <thorsten.blum@...ux.dev>
Cc: Masami Hiramatsu <mhiramat@...nel.org>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, Guillaume Nault <gnault@...hat.com>,
Paolo Abeni <pabeni@...hat.com>, Ido Schimmel <idosch@...dia.com>, Petr
Machata <petrm@...dia.com>, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] tracing: ipv6: Replace deprecated strcpy()
with strscpy()
On Mon, 14 Jul 2025 09:54:33 +0200
Thorsten Blum <thorsten.blum@...ux.dev> wrote:
> diff --git a/include/trace/events/fib6.h b/include/trace/events/fib6.h
> index 8d22b2e98d48..903a18836bc6 100644
> --- a/include/trace/events/fib6.h
> +++ b/include/trace/events/fib6.h
> @@ -64,11 +64,9 @@ TRACE_EVENT(fib6_table_lookup,
> __entry->dport = 0;
> }
>
> - if (res->nh && res->nh->fib_nh_dev) {
> - strscpy(__entry->name, res->nh->fib_nh_dev->name, IFNAMSIZ);
> - } else {
> - strcpy(__entry->name, "-");
> - }
> + strscpy(__entry->name, res->nh && res->nh->fib_nh_dev ?
> + res->nh->fib_nh_dev->name : "-");
> +
> if (res->f6i == net->ipv6.fib6_null_entry) {
> in6 = (struct in6_addr *)__entry->gw;
> *in6 = in6addr_any;
Hmm, why is that string hard coded to 16 bytes and doesn't use the
dynamic string facility? Perhaps something like this?
[ I didn't even compile the below, so it may have a syntax error ]
-- Steve
diff --git a/include/trace/events/fib6.h b/include/trace/events/fib6.h
index 8d22b2e98d48..98d2edb02431 100644
--- a/include/trace/events/fib6.h
+++ b/include/trace/events/fib6.h
@@ -32,7 +32,8 @@ TRACE_EVENT(fib6_table_lookup,
__field( u16, dport )
__field( u8, proto )
__field( u8, rt_type )
- __array( char, name, IFNAMSIZ )
+ __string( name, res->nh && res->nh->fib_nh_dev ?
+ res->nh->fib_nh_dev->name : "-")
__array( __u8, gw, 16 )
),
@@ -64,11 +65,7 @@ TRACE_EVENT(fib6_table_lookup,
__entry->dport = 0;
}
- if (res->nh && res->nh->fib_nh_dev) {
- strscpy(__entry->name, res->nh->fib_nh_dev->name, IFNAMSIZ);
- } else {
- strcpy(__entry->name, "-");
- }
+ __assign_str(name);
if (res->f6i == net->ipv6.fib6_null_entry) {
in6 = (struct in6_addr *)__entry->gw;
*in6 = in6addr_any;
@@ -82,7 +79,7 @@ TRACE_EVENT(fib6_table_lookup,
__entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
__entry->src, __entry->sport, __entry->dst, __entry->dport,
__entry->flowlabel, __entry->tos, __entry->scope,
- __entry->flags, __entry->name, __entry->gw, __entry->err)
+ __entry->flags, __get_str(name), __entry->gw, __entry->err)
);
#endif /* _TRACE_FIB6_H */
Powered by blists - more mailing lists