lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aAfFilVul0zbE20U@mini-arch>
Date: Tue, 22 Apr 2025 09:36:26 -0700
From: Stanislav Fomichev <stfomichev@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
	pabeni@...hat.com, andrew+netdev@...n.ch, horms@...nel.org,
	donald.hunter@...il.com, sdf@...ichev.me, almasrymina@...gle.com,
	dw@...idwei.uk, asml.silence@...il.com, ap420073@...il.com,
	jdamato@...tly.com, dtatulea@...dia.com, michael.chan@...adcom.com
Subject: Re: [RFC net-next 21/22] selftests: drv-net: add helper/wrapper for
 bpftrace

On 04/21, Jakub Kicinski wrote:
> bpftrace is very useful for low level driver testing. perf or trace-cmd
> would also do for collecting data from tracepoints, but they require
> much more post-processing.
> 
> Add a wrapper for running bpftrace and sanitizing its output.
> bpftrace has JSON output, which is great, but it prints loose objects
> and in a slightly inconvenient format. We have to read the objects
> line by line, and while at it return them indexed by the map name.
> 
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
>  tools/testing/selftests/net/lib/py/utils.py | 33 +++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
> index 34470d65d871..760ccf6fcccc 100644
> --- a/tools/testing/selftests/net/lib/py/utils.py
> +++ b/tools/testing/selftests/net/lib/py/utils.py
> @@ -185,6 +185,39 @@ global_defer_queue = []
>      return tool('ethtool', args, json=json, ns=ns, host=host)
>  
>  
> +def bpftrace(expr, json=None, ns=None, host=None, timeout=None):
> +    """
> +    Run bpftrace and return map data (if json=True).
> +    The output of bpftrace is inconvenient, so the helper converts
> +    to a dict indexed by map name, e.g.:
> +     {
> +       "@":     { ... },
> +       "@map2": { ... },
> +     }
> +    """
> +    cmd_arr = ['bpftrace']
> +    # Throw in --quiet if json, otherwise the output has two objects
> +    if json:
> +        cmd_arr += ['-f', 'json', '-q']
> +    if timeout:
> +        expr += ' interval:s:' + str(timeout) + ' { exit(); }'

nit: any reason not to use format string here ^^

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ