[PATCH net-next v2 3/4] selftests: drv-net: Strip '@' prefix from bpftrace map keys

Breno Leitao posted 4 patches 3 months, 2 weeks ago
There is a newer version of this series
[PATCH net-next v2 3/4] selftests: drv-net: Strip '@' prefix from bpftrace map keys
Posted by Breno Leitao 3 months, 2 weeks ago
The '@' prefix in bpftrace map keys is specific to bpftrace and can be
safely removed when processing results. This patch modifies the bpftrace
utility to strip the '@' from map keys before storing them in the result
dictionary, making the keys more consistent with Python conventions.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 tools/testing/selftests/net/lib/py/utils.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index c4e26567ee6fb..31d4d63621c5f 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -216,6 +216,8 @@ def bpftrace(expr, json=None, ns=None, host=None, timeout=None):
             if one.get('type') != 'map':
                 continue
             for k, v in one["data"].items():
+                if k.startswith('@'):
+                    k = k.lstrip('@')
                 ret[k] = v
         return ret
     return cmd_obj

-- 
2.47.1
Re: [PATCH net-next v2 3/4] selftests: drv-net: Strip '@' prefix from bpftrace map keys
Posted by Jakub Kicinski 3 months, 2 weeks ago
On Wed, 25 Jun 2025 04:39:48 -0700 Breno Leitao wrote:
> The '@' prefix in bpftrace map keys is specific to bpftrace and can be
> safely removed when processing results. This patch modifies the bpftrace
> utility to strip the '@' from map keys before storing them in the result
> dictionary, making the keys more consistent with Python conventions.

Make sense, tho, could you double check or ask Alastair if all outputs
are prefixed with @? Maybe there's some map type or other thingamajig
that doesn't have the prefix?
Re: [PATCH net-next v2 3/4] selftests: drv-net: Strip '@' prefix from bpftrace map keys
Posted by Breno Leitao 3 months, 2 weeks ago
On Wed, Jun 25, 2025 at 03:07:10PM -0700, Jakub Kicinski wrote:
> On Wed, 25 Jun 2025 04:39:48 -0700 Breno Leitao wrote:
> > The '@' prefix in bpftrace map keys is specific to bpftrace and can be
> > safely removed when processing results. This patch modifies the bpftrace
> > utility to strip the '@' from map keys before storing them in the result
> > dictionary, making the keys more consistent with Python conventions.
> 
> Make sense, tho, could you double check or ask Alastair if all outputs
> are prefixed with @? Maybe there's some map type or other thingamajig
> that doesn't have the prefix? 

I have a quick chat with Alastair earlier today, and I understood that
all map symbols start with @.

CCing him.