<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/bpf/bpftool/gen.c, branch linux-6.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.1.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.1.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-09-30T22:40:46Z</updated>
<entry>
<title>bpftool: Fix error message of strerror</title>
<updated>2022-09-30T22:40:46Z</updated>
<author>
<name>Tianyi Liu</name>
</author>
<published>2022-09-28T08:09:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3ca2fb497440a3c8294f9df0ce7b2c3c9a1c5875'/>
<id>urn:sha1:3ca2fb497440a3c8294f9df0ce7b2c3c9a1c5875</id>
<content type='text'>
strerror() expects a positive errno, however variable err will never be
positive when an error occurs. This causes bpftool to output too many
"unknown error", even a simple "file not exist" error can not get an
accurate message.

This patch fixed all "strerror(err)" patterns in bpftool.
Specially in btf.c#L823, hashmap__append() is an internal function of
libbpf and will not change errno, so there's a little difference.
Some libbpf_get_error() calls are kept for return values.

Changes since v1: https://lore.kernel.org/bpf/SY4P282MB1084B61CD8671DFA395AA8579D539@SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM/
Check directly for NULL values instead of calling libbpf_get_error().

Signed-off-by: Tianyi Liu &lt;i.pear@outlook.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/SY4P282MB1084AD9CD84A920F08DF83E29D549@SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM
</content>
</entry>
<entry>
<title>bpftool: Don't try to return value from void function in skeleton</title>
<updated>2022-07-29T17:43:14Z</updated>
<author>
<name>Jörn-Thorben Hinz</name>
</author>
<published>2022-07-26T13:32:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a6df06744b2d0b953615e0d6ca8b5e84ae4019fc'/>
<id>urn:sha1:a6df06744b2d0b953615e0d6ca8b5e84ae4019fc</id>
<content type='text'>
A skeleton generated by bpftool previously contained a return followed
by an expression in OBJ_NAME__detach(), which has return type void. This
did not hurt, the bpf_object__detach_skeleton() called there returns
void itself anyway, but led to a warning when compiling with e.g.
-pedantic.

Signed-off-by: Jörn-Thorben Hinz &lt;jthinz@mailbox.tu-berlin.de&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/20220726133203.514087-1-jthinz@mailbox.tu-berlin.de
</content>
</entry>
<entry>
<title>bpftool: Add support for KIND_RESTRICT to gen min_core_btf command</title>
<updated>2022-07-08T12:26:39Z</updated>
<author>
<name>Daniel Müller</name>
</author>
<published>2022-07-06T21:28:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=aad53f17f0ad7485872d66fbcb53cc0c60e811f2'/>
<id>urn:sha1:aad53f17f0ad7485872d66fbcb53cc0c60e811f2</id>
<content type='text'>
This change adjusts bpftool's type marking logic, as used in conjunction
with TYPE_EXISTS relocations, to correctly recognize and handle the
RESTRICT BTF kind.

Suggested-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Daniel Müller &lt;deso@posteo.net&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Link: https://lore.kernel.org/bpf/20220623212205.2805002-1-deso@posteo.net/T/#m4c75205145701762a4b398e0cdb911d5b5305ffc
Link: https://lore.kernel.org/bpf/20220706212855.1700615-2-deso@posteo.net
</content>
</entry>
<entry>
<title>bpftool: Honor BPF_CORE_TYPE_MATCHES relocation</title>
<updated>2022-07-06T03:26:18Z</updated>
<author>
<name>Daniel Müller</name>
</author>
<published>2022-06-28T16:01:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=633e7ceb2cbbae9b2f5ca69106b0de65728c5988'/>
<id>urn:sha1:633e7ceb2cbbae9b2f5ca69106b0de65728c5988</id>
<content type='text'>
bpftool needs to know about the newly introduced BPF_CORE_TYPE_MATCHES
relocation for its 'gen min_core_btf' command to work properly in the
present of this relocation.
Specifically, we need to make sure to mark types and fields so that they
are present in the minimized BTF for "type match" checks to work out.
However, contrary to the existing btfgen_record_field_relo, we need to
rely on the BTF -- and not the spec -- to find fields. With this change
we handle this new variant correctly. The functionality will be tested
with follow on changes to BPF selftests, which already run against a
minimized BTF created with bpftool.

Signed-off-by: Daniel Müller &lt;deso@posteo.net&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/20220628160127.607834-3-deso@posteo.net
</content>
</entry>
<entry>
<title>bpftool: Add btf enum64 support</title>
<updated>2022-06-07T17:20:43Z</updated>
<author>
<name>Yonghong Song</name>
</author>
<published>2022-06-07T06:26:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=58a53978fdf65d12dae1798e44120efb992a3615'/>
<id>urn:sha1:58a53978fdf65d12dae1798e44120efb992a3615</id>
<content type='text'>
Add BTF_KIND_ENUM64 support.
For example, the following enum is defined in uapi bpf.h.
  $ cat core.c
  enum A {
        BPF_F_INDEX_MASK                = 0xffffffffULL,
        BPF_F_CURRENT_CPU               = BPF_F_INDEX_MASK,
        BPF_F_CTXLEN_MASK               = (0xfffffULL &lt;&lt; 32),
  } g;
Compiled with
  clang -target bpf -O2 -g -c core.c
Using bpftool to dump types and generate format C file:
  $ bpftool btf dump file core.o
  ...
  [1] ENUM64 'A' encoding=UNSIGNED size=8 vlen=3
        'BPF_F_INDEX_MASK' val=4294967295ULL
        'BPF_F_CURRENT_CPU' val=4294967295ULL
        'BPF_F_CTXLEN_MASK' val=4503595332403200ULL
  $ bpftool btf dump file core.o format c
  ...
  enum A {
        BPF_F_INDEX_MASK = 4294967295ULL,
        BPF_F_CURRENT_CPU = 4294967295ULL,
        BPF_F_CTXLEN_MASK = 4503595332403200ULL,
  };
  ...

Note that for raw btf output, the encoding (UNSIGNED or SIGNED)
is printed out as well. The 64bit value is also represented properly
in BTF and C dump.

Acked-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/r/20220607062652.3722649-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpftool: Check for NULL ptr of btf in codegen_asserts</title>
<updated>2022-06-02T23:26:43Z</updated>
<author>
<name>Michael Mullin</name>
</author>
<published>2022-05-23T19:49:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=de4b4b94fad90f876ab12e87999109e31a1871b4'/>
<id>urn:sha1:de4b4b94fad90f876ab12e87999109e31a1871b4</id>
<content type='text'>
bpf_object__btf() can return a NULL value.  If bpf_object__btf returns
null, do not progress through codegen_asserts(). This avoids a null ptr
dereference at the call btf__type_cnt() in the function find_type_for_map()

Signed-off-by: Michael Mullin &lt;masmullin@gmail.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220523194917.igkgorco42537arb@jup
</content>
</entry>
<entry>
<title>bpftool: bpf_link_get_from_fd support for LSM programs in lskel</title>
<updated>2022-05-10T17:42:08Z</updated>
<author>
<name>KP Singh</name>
</author>
<published>2022-05-09T21:49:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bd2331b3757f5b2ab4aafc591b55fa2a592abf7c'/>
<id>urn:sha1:bd2331b3757f5b2ab4aafc591b55fa2a592abf7c</id>
<content type='text'>
bpf_link_get_from_fd currently returns a NULL fd for LSM programs.
LSM programs are similar to tracing programs and can also use
skel_raw_tracepoint_open.

Signed-off-by: KP Singh &lt;kpsingh@kernel.org&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220509214905.3754984-1-kpsingh@kernel.org
</content>
</entry>
<entry>
<title>bpftool: Declare generator name</title>
<updated>2022-05-10T00:42:53Z</updated>
<author>
<name>Jason Wang</name>
</author>
<published>2022-05-09T09:02:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=56c3e749d08a041454f5d75273c24d16240f26dc'/>
<id>urn:sha1:56c3e749d08a041454f5d75273c24d16240f26dc</id>
<content type='text'>
Most code generators declare its name so did this for bfptool.

Signed-off-by: Jason Wang &lt;jasowang@redhat.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220509090247.5457-1-jasowang@redhat.com
</content>
</entry>
<entry>
<title>bpftool: Explicit errno handling in skeletons</title>
<updated>2022-03-30T12:06:59Z</updated>
<author>
<name>Delyan Kratunov</name>
</author>
<published>2022-03-21T23:29:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=522574fd7864e091d473765102e866414979b2ab'/>
<id>urn:sha1:522574fd7864e091d473765102e866414979b2ab</id>
<content type='text'>
Andrii noticed that since f97b8b9bd630 ("bpftool: Fix a bug in subskeleton
code generation") the subskeleton code allows bpf_object__destroy_subskeleton
to overwrite the errno that subskeleton__open would return with. While this
is not currently an issue, let's make it future-proof.

This patch explicitly tracks err in subskeleton__open and skeleton__create
(i.e. calloc failure is explicitly ENOMEM) and ensures that errno is -err on
the error return path. The skeleton code had to be changed since maps and
progs codegen is shared with subskeletons.

Fixes: f97b8b9bd630 ("bpftool: Fix a bug in subskeleton code generation")
Signed-off-by: Delyan Kratunov &lt;delyank@fb.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/3b6bfbb770c79ae64d8de26c1c1bd9d53a4b85f8.camel@fb.com
</content>
</entry>
<entry>
<title>bpftool: Fix generated code in codegen_asserts</title>
<updated>2022-03-29T02:10:25Z</updated>
<author>
<name>Jiri Olsa</name>
</author>
<published>2022-03-28T08:37:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ef8a257b4e499a979364b1f9caf25a325f6ee8b8'/>
<id>urn:sha1:ef8a257b4e499a979364b1f9caf25a325f6ee8b8</id>
<content type='text'>
Arnaldo reported perf compilation fail with:

  $ make -k BUILD_BPF_SKEL=1 CORESIGHT=1 PYTHON=python3
  ...
  In file included from util/bpf_counter.c:28:
  /tmp/build/perf//util/bpf_skel/bperf_leader.skel.h: In function ‘bperf_leader_bpf__assert’:
  /tmp/build/perf//util/bpf_skel/bperf_leader.skel.h:351:51: error: unused parameter ‘s’ [-Werror=unused-parameter]
    351 | bperf_leader_bpf__assert(struct bperf_leader_bpf *s)
        |                          ~~~~~~~~~~~~~~~~~~~~~~~~~^
  cc1: all warnings being treated as errors

If there's nothing to generate in the new assert function,
we will get unused 's' warn/error, adding 'unused' attribute to it.

Fixes: 08d4dba6ae77 ("bpftool: Bpf skeletons assert type sizes")
Reported-by: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Tested-by: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Link: https://lore.kernel.org/bpf/20220328083703.2880079-1-jolsa@kernel.org
</content>
</entry>
</feed>
