tracing/ipv4/ipv6: Give size to name field in fib*_lookup_table event
Subsystems (3)
Steven Rostedt
maintainerPATCH 1/1 tracing/ipv4/ipv6: Give size to name field in fib*_lookup_table event
From: "Steven Rostedt (Google)" <[email protected]>
The fib_lookup_table and fib6_lookup_table events declare name as a dynamic_array, but also give it a fixed size, which defeats the purpose of the dynamic array, especially since the dynamic array also includes meta data in the event to specify its size.
Considering that the intent was to only reserve the size needed for the name and not a fixed size, convert the size part of the __dynamic_array() field to contain the necessary code to determine the size needed to save the name.
Alternatively, if the intent was to use a fixed size, then it should be converted into __array() of type char, which will remove the meta data in the event that stores the size.
--- include/trace/events/fib.h | 2 +- include/trace/events/fib6.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
include/trace/events/fib.h +1 -1
@@ -32,7 +32,7 @@ TRACE_EVENT(fib_table_lookup, __array( __u8, gw6, 16 ) __field( u16, sport ) __field( u16, dport ) -__dynamic_array (char, name,IFNAMSIZ ) +__dynamic_array (char, name, nhc && nhc->nhc_dev ?strlen (nhc->nhc_dev->name) +1 :sizeof ("-" ) ) ), TP_fast_assign(
include/trace/events/fib6.h +2 -1
@@ -31,7 +31,8 @@ TRACE_EVENT(fib6_table_lookup, __field( u16, dport ) __field( u8, proto ) __field( u8, rt_type ) - __dynamic_array( char, name, IFNAMSIZ ) +__dynamic_array ( char, name, res->nh && res->nh->fib_nh_dev ? + strlen(res->nh->fib_nh_dev->name) + 1 : sizeof("-") )__array ( __u8, gw,16 ) ),
Signature · 1 line
2.35.1
Quoted 7 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
The
fib_lookup_tableandfib6_lookup_tableevents declare name as adynamic_array, but also give it a fixed size, which defeats the purpose of the dynamic array, especially since the dynamic array also includes meta data in the event to specify its size.
Quoted 8 lines
Considering that the intent was to only reserve the size needed for the name and not a fixed size, convert the size part of the
__dynamic_array()field to contain the necessary code to determine the size needed to save the name.Alternatively, if the intent was to use a fixed size, then it should be converted into
__array()of type char, which will remove the meta data in the event that stores the size.
I would prefer this option over duplicating the all of the checks to save 14B.
Steven Rostedt
maintainerQuoted 6 lines · On Sun, 3 Jul 2022 13:03:20 -0600 David Ahern <[email protected]> wrote:
Quoted 3 lines
Alternatively, if the intent was to use a fixed size, then it should be converted into
__array()of type char, which will remove the meta data in the event that stores the size.I would prefer this option over duplicating the all of the checks to save 14B.
That's why I mentioned the alternative. To give you that option.
I'll send a v2 later that uses the static array.
-- Steve