<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/tools/bpf/bpftool/map.c, branch v6.19.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2025-11-06T01:31:25+00:00</updated>
<entry>
<title>bpftool: Recognize insn_array map type</title>
<updated>2025-11-06T01:31:25+00:00</updated>
<author>
<name>Anton Protopopov</name>
<email>a.s.protopopov@gmail.com</email>
</author>
<published>2025-11-05T09:04:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=18a187bf258421b3d7c0ba32b2e1fde2fdf0f112'/>
<id>urn:sha1:18a187bf258421b3d7c0ba32b2e1fde2fdf0f112</id>
<content type='text'>
Teach bpftool to recognize instruction array map type.

Signed-off-by: Anton Protopopov &lt;a.s.protopopov@gmail.com&gt;
Acked-by: Quentin Monnet &lt;qmo@kernel.org&gt;
Link: https://lore.kernel.org/r/20251105090410.1250500-3-a.s.protopopov@gmail.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpftool: Use appropriate permissions for map access</title>
<updated>2025-06-20T18:13:03+00:00</updated>
<author>
<name>Slava Imameev</name>
<email>slava.imameev@crowdstrike.com</email>
</author>
<published>2025-06-20T15:18:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d32179e8c2583f1613f7bc9710612091c3c038d8'/>
<id>urn:sha1:d32179e8c2583f1613f7bc9710612091c3c038d8</id>
<content type='text'>
Modify several functions in tools/bpf/bpftool/common.c to allow
specification of requested access for file descriptors, such as
read-only access.

Update bpftool to request only read access for maps when write
access is not required. This fixes errors when reading from maps
that are protected from modification via security_bpf_map.

Signed-off-by: Slava Imameev &lt;slava.imameev@crowdstrike.com&gt;
Reviewed-by: Quentin Monnet &lt;qmo@kernel.org&gt;
Link: https://lore.kernel.org/r/20250620151812.13952-1-slava.imameev@crowdstrike.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpftool: Check map name length when map create</title>
<updated>2025-02-14T04:11:38+00:00</updated>
<author>
<name>Rong Tao</name>
<email>rongtao@cestc.cn</email>
</author>
<published>2025-02-12T12:45:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a4585442ade5ac722248137dc650bff55ebb8ca0'/>
<id>urn:sha1:a4585442ade5ac722248137dc650bff55ebb8ca0</id>
<content type='text'>
The size of struct bpf_map::name is BPF_OBJ_NAME_LEN (16).

bpf(2) {
  map_create() {
    bpf_obj_name_cpy(map-&gt;name, attr-&gt;map_name, sizeof(attr-&gt;map_name));
  }
}

When specifying a map name using bpftool map create name, no error is
reported if the name length is greater than 15.

    $ sudo bpftool map create /sys/fs/bpf/12345678901234567890 \
        type array key 4 value 4 entries 5 name 12345678901234567890

Users will think that 12345678901234567890 is legal, but this name cannot
be used to index a map.

    $ sudo bpftool map show name 12345678901234567890
    Error: can't parse name

    $ sudo bpftool map show
    ...
    1249: array  name 123456789012345  flags 0x0
    	key 4B  value 4B  max_entries 5  memlock 304B

    $ sudo bpftool map show name 123456789012345
    1249: array  name 123456789012345  flags 0x0
    	key 4B  value 4B  max_entries 5  memlock 304B

The map name provided in the command line is truncated, but no warning is
reported. This submission checks the length of the map name.

Reviewed-by: Quentin Monnet &lt;qmo@kernel.org&gt;
Signed-off-by: Rong Tao &lt;rongtao@cestc.cn&gt;
Link: https://lore.kernel.org/r/tencent_B44B3A95F0D7C2512DC40D831DA1FA2C9907@qq.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpftool: Using the right format specifiers</title>
<updated>2025-02-11T00:08:13+00:00</updated>
<author>
<name>Jiayuan Chen</name>
<email>mrpre@163.com</email>
</author>
<published>2025-02-07T12:37:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=17c3dc50294ba445ddc7d50020df6452e93d38b2'/>
<id>urn:sha1:17c3dc50294ba445ddc7d50020df6452e93d38b2</id>
<content type='text'>
Fixed some formatting specifiers errors, such as using %d for int and %u
for unsigned int, as well as other byte-length types.

Signed-off-by: Jiayuan Chen &lt;mrpre@163.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Reviewed-by: Quentin Monnet &lt;qmo@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20250207123706.727928-2-mrpre@163.com
</content>
</entry>
<entry>
<title>bpftool: Recognize arena map type</title>
<updated>2024-03-11T22:37:24+00:00</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@kernel.org</email>
</author>
<published>2024-03-08T01:08:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=eed512e8ac64339cfc69da1a6a4b60982cb502ca'/>
<id>urn:sha1:eed512e8ac64339cfc69da1a6a4b60982cb502ca</id>
<content type='text'>
Teach bpftool to recognize arena map type.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Link: https://lore.kernel.org/bpf/20240308010812.89848-10-alexei.starovoitov@gmail.com
</content>
</entry>
<entry>
<title>bpftool: Specify XDP Hints ifname when loading program</title>
<updated>2023-05-23T14:55:06+00:00</updated>
<author>
<name>Larysa Zaremba</name>
<email>larysa.zaremba@intel.com</email>
</author>
<published>2023-05-17T16:01:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f46392ee3dec24066e5fb260d9bd497b4cd4d191'/>
<id>urn:sha1:f46392ee3dec24066e5fb260d9bd497b4cd4d191</id>
<content type='text'>
Add ability to specify a network interface used to resolve XDP hints
kfuncs when loading program through bpftool.

Usage:

  bpftool prog load [...] xdpmeta_dev &lt;ifname&gt;

Writing just 'dev &lt;ifname&gt;' instead of 'xdpmeta_dev' is a very probable
mistake that results in not very descriptive errors,
so 'bpftool prog load [...] dev &lt;ifname&gt;' syntax becomes deprecated,
followed by 'bpftool map create [...] dev &lt;ifname&gt;' for consistency.

Now, to offload program, execute:

  bpftool prog load [...] offload_dev &lt;ifname&gt;

To offload map:

  bpftool map create [...] offload_dev &lt;ifname&gt;

'dev &lt;ifname&gt;' still performs offloading in the commands above, but now
triggers a warning and is excluded from bash completion.

'xdpmeta_dev' and 'offload_dev' are mutually exclusive options, because
'xdpmeta_dev' basically makes a program device-bound without loading it
onto the said device. For now, offloaded programs cannot use XDP hints [0],
but if this changes, using 'offload_dev &lt;ifname&gt;' should cover this case.

  [0] https://lore.kernel.org/bpf/a5a636cc-5b03-686f-4be0-000383b05cfc@linux.dev

Signed-off-by: Larysa Zaremba &lt;larysa.zaremba@intel.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Reviewed-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Link: https://lore.kernel.org/bpf/20230517160103.1088185-1-larysa.zaremba@intel.com
</content>
</entry>
<entry>
<title>bpftool: Dump map id instead of value for map_of_maps types</title>
<updated>2023-04-27T20:26:34+00:00</updated>
<author>
<name>Xueming Feng</name>
<email>kuro@kuroa.me</email>
</author>
<published>2023-04-27T12:03:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=bf06c9393493a2862d4670beda2928423c774ff3'/>
<id>urn:sha1:bf06c9393493a2862d4670beda2928423c774ff3</id>
<content type='text'>
When using `bpftool map dump` with map_of_maps, it is usually
more convenient to show the inner map id instead of raw value.

We are changing the plain print behavior to show inner_map_id
instead of hex value, this would help with quick look up of
inner map with `bpftool map dump id &lt;inner_map_id&gt;`.
To avoid disrupting scripted behavior, we will add a new
`inner_map_id` field to json output instead of replacing value.

plain print:
```
$ bpftool map dump id 138

Without Patch:
key:
fc 00 00 00 00 00 00 00  00 00 00 00 00 00 00 05
27 16 06 00
value:
8b 00 00 00
Found 1 element

With Patch:
key:
fc 00 00 00 00 00 00 00  00 00 00 00 00 00 00 05
27 16 06 00
inner_map_id:
139
Found 1 element
```

json print:
```
$ bpftool -p map dump id 567

Without Patch:
[{
        "key": ["0xc0","0x00","0x02","0x05","0x27","0x16","0x06","0x00"
        ],
        "value": ["0x38","0x02","0x00","0x00"
        ]
    }
]

With Patch:
[{
        "key": ["0xc0","0x00","0x02","0x05","0x27","0x16","0x06","0x00"
        ],
        "value": ["0x38","0x02","0x00","0x00"
        ],
        "inner_map_id": 568
    }
]
```

Signed-off-by: Xueming Feng &lt;kuro@kuroa.me&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/r/20230427120313.43574-1-kuro@kuroa.me
Signed-off-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd()</title>
<updated>2023-02-16T23:32:45+00:00</updated>
<author>
<name>Ilya Leoshkevich</name>
<email>iii@linux.ibm.com</email>
</author>
<published>2023-02-14T23:12:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=38f0408ef756e738387f7d8f62b8d58ca5938da4'/>
<id>urn:sha1:38f0408ef756e738387f7d8f62b8d58ca5938da4</id>
<content type='text'>
Use the new type-safe wrappers around bpf_obj_get_info_by_fd().

Split the bpf_obj_get_info_by_fd() call in build_btf_type_table() in
two, since knowing the type helps with the Memory Sanitizer.

Improve map_parse_fd_and_info() type safety by using
struct bpf_map_info * instead of void * for info.

Signed-off-by: Ilya Leoshkevich &lt;iii@linux.ibm.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Reviewed-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Link: https://lore.kernel.org/bpf/20230214231221.249277-4-iii@linux.ibm.com
</content>
</entry>
<entry>
<title>bpftool: remove function free_btf_vmlinux()</title>
<updated>2022-11-21T00:17:46+00:00</updated>
<author>
<name>Sahid Orentino Ferdjaoui</name>
<email>sahid.ferdjaoui@industrialdiscipline.com</email>
</author>
<published>2022-11-20T11:26:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=52df1a8aabadeba1e4c2fe157784637ddec76301'/>
<id>urn:sha1:52df1a8aabadeba1e4c2fe157784637ddec76301</id>
<content type='text'>
The function contains a single btf__free() call which can be
inlined. Credits to Yonghong Song.

Signed-off-by: Sahid Orentino Ferdjaoui &lt;sahid.ferdjaoui@industrialdiscipline.com&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Suggested-by: Yonghong Song &lt;yhs@fb.com&gt;
Reviewed-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Link: https://lore.kernel.org/r/20221120112515.38165-6-sahid.ferdjaoui@industrialdiscipline.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpftool: clean-up usage of libbpf_get_error()</title>
<updated>2022-11-21T00:17:46+00:00</updated>
<author>
<name>Sahid Orentino Ferdjaoui</name>
<email>sahid.ferdjaoui@industrialdiscipline.com</email>
</author>
<published>2022-11-20T11:26:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d1313e01271d2d8f33d6c82f1afb77e820a3540d'/>
<id>urn:sha1:d1313e01271d2d8f33d6c82f1afb77e820a3540d</id>
<content type='text'>
bpftool is now totally compliant with libbpf 1.0 mode and is not
expected to be compiled with pre-1.0, let's clean-up the usage of
libbpf_get_error().

The changes stay aligned with returned errors always negative.

- In tools/bpf/bpftool/btf.c This fixes an uninitialized local
variable `err` in function do_dump() because it may now be returned
without having been set.
- This also removes the checks on NULL pointers before calling
btf__free() because that function already does the check.

Signed-off-by: Sahid Orentino Ferdjaoui &lt;sahid.ferdjaoui@industrialdiscipline.com&gt;
Link: https://lore.kernel.org/r/20221120112515.38165-5-sahid.ferdjaoui@industrialdiscipline.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
</feed>
