<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/samples/bpf, branch v5.9-rc7</title>
<subtitle>Linux Kernel (branches are rebased on master from time to time)</subtitle>
<id>https://sre.ring0.de/linux/atom?h=v5.9-rc7</id>
<link rel='self' href='https://sre.ring0.de/linux/atom?h=v5.9-rc7'/>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/'/>
<updated>2020-08-23T22:36:59Z</updated>
<entry>
<title>treewide: Use fallthrough pseudo-keyword</title>
<updated>2020-08-23T22:36:59Z</updated>
<author>
<name>Gustavo A. R. Silva</name>
<email>gustavoars@kernel.org</email>
</author>
<published>2020-08-23T22:36:59Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=df561f6688fef775baa341a0f5d960becd248b11'/>
<id>urn:sha1:df561f6688fef775baa341a0f5d960becd248b11</id>
<content type='text'>
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva &lt;gustavoars@kernel.org&gt;
</content>
</entry>
<entry>
<title>samples/bpf, selftests/bpf: Use bpf_probe_read_kernel</title>
<updated>2020-07-21T20:26:26Z</updated>
<author>
<name>Ilya Leoshkevich</name>
<email>iii@linux.ibm.com</email>
</author>
<published>2020-07-20T11:48:06Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=e4d9c2320716ea0e9ef59f503ddd8f253a642ddd'/>
<id>urn:sha1:e4d9c2320716ea0e9ef59f503ddd8f253a642ddd</id>
<content type='text'>
A handful of samples and selftests fail to build on s390, because
after commit 0ebeea8ca8a4 ("bpf: Restrict bpf_probe_read{, str}()
only to archs where they work") bpf_probe_read is not available
anymore.

Fix by using bpf_probe_read_kernel.

Signed-off-by: Ilya Leoshkevich &lt;iii@linux.ibm.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200720114806.88823-1-iii@linux.ibm.com
</content>
</entry>
<entry>
<title>samples/bpf: xdp_redirect_cpu: Load a eBPF program on cpumap</title>
<updated>2020-07-16T15:00:32Z</updated>
<author>
<name>Lorenzo Bianconi</name>
<email>lorenzo@kernel.org</email>
</author>
<published>2020-07-14T13:56:41Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=ce4dade7f12a8f3e7918184ac851d992f551805d'/>
<id>urn:sha1:ce4dade7f12a8f3e7918184ac851d992f551805d</id>
<content type='text'>
Extend xdp_redirect_cpu_{usr,kern}.c adding the possibility to load
a XDP program on cpumap entries. The following options have been added:
- mprog-name: cpumap entry program name
- mprog-filename: cpumap entry program filename
- redirect-device: output interface if the cpumap program performs a
  XDP_REDIRECT to an egress interface
- redirect-map: bpf map used to perform XDP_REDIRECT to an egress
  interface
- mprog-disable: disable loading XDP program on cpumap entries

Add xdp_pass, xdp_drop, xdp_redirect stats accounting

Co-developed-by: Jesper Dangaard Brouer &lt;brouer@redhat.com&gt;
Signed-off-by: Jesper Dangaard Brouer &lt;brouer@redhat.com&gt;
Signed-off-by: Lorenzo Bianconi &lt;lorenzo@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/aa5a9a281b9dac425620fdabe82670ffb6bbdb92.1594734381.git.lorenzo@kernel.org
</content>
</entry>
<entry>
<title>samples/bpf: xdp_redirect_cpu_user: Do not update bpf maps in option loop</title>
<updated>2020-07-16T15:00:31Z</updated>
<author>
<name>Lorenzo Bianconi</name>
<email>lorenzo@kernel.org</email>
</author>
<published>2020-07-14T13:56:36Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=a4e76f1bda8e7b358dc21f0f925b8a2c4c98e733'/>
<id>urn:sha1:a4e76f1bda8e7b358dc21f0f925b8a2c4c98e733</id>
<content type='text'>
Do not update xdp_redirect_cpu maps running while option loop but
defer it after all available options have been parsed. This is a
preliminary patch to pass the program name we want to attach to the
map entries as a user option

Signed-off-by: Lorenzo Bianconi &lt;lorenzo@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Jesper Dangaard Brouer &lt;brouer@redhat.com&gt;
Link: https://lore.kernel.org/bpf/95dc46286fd2c609042948e04bb7ae1f5b425538.1594734381.git.lorenzo@kernel.org
</content>
</entry>
<entry>
<title>samples: bpf: Add an option for printing extra statistics in xdpsock</title>
<updated>2020-07-13T22:32:56Z</updated>
<author>
<name>Ciara Loftus</name>
<email>ciara.loftus@intel.com</email>
</author>
<published>2020-07-08T07:28:34Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=b36c3206f9ef3ea2844e9092c12d29c0d1f56c54'/>
<id>urn:sha1:b36c3206f9ef3ea2844e9092c12d29c0d1f56c54</id>
<content type='text'>
Introduce the --extra-stats (or simply -x) flag to the xdpsock application
which prints additional statistics alongside the regular rx and tx
counters. The new statistics printed report error conditions eg. rx ring
full, invalid descriptors, etc.

Signed-off-by: Ciara Loftus &lt;ciara.loftus@intel.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200708072835.4427-3-ciara.loftus@intel.com
</content>
</entry>
<entry>
<title>bpf: Fix fds_example SIGSEGV error</title>
<updated>2020-07-10T21:25:25Z</updated>
<author>
<name>Wenbo Zhang</name>
<email>ethercflow@gmail.com</email>
</author>
<published>2020-07-10T09:20:35Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=eef8a42d6ce087d1c81c960ae0d14f955b742feb'/>
<id>urn:sha1:eef8a42d6ce087d1c81c960ae0d14f955b742feb</id>
<content type='text'>
The `BPF_LOG_BUF_SIZE`'s value is `UINT32_MAX &gt;&gt; 8`, so define an array
with it on stack caused an overflow.

Signed-off-by: Wenbo Zhang &lt;ethercflow@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200710092035.28919-1-ethercflow@gmail.com
</content>
</entry>
<entry>
<title>samples: bpf: Refactor BPF map performance test with libbpf</title>
<updated>2020-07-07T23:33:14Z</updated>
<author>
<name>Daniel T. Lee</name>
<email>danieltimlee@gmail.com</email>
</author>
<published>2020-07-07T18:48:54Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=cc7f641d637bef0b31194d28667553f77c4ef947'/>
<id>urn:sha1:cc7f641d637bef0b31194d28667553f77c4ef947</id>
<content type='text'>
Previously, in order to set the numa_node attribute at the time of map
creation using "libbpf", it was necessary to call bpf_create_map_node()
directly (bpf_load approach), instead of calling bpf_object_load()
that handles everything on its own, including map creation. And because
of this problem, this sample had problems with refactoring from bpf_load
to libbbpf.

However, by commit 1bdb6c9a1c43 ("libbpf: Add a bunch of attribute
getters/setters for map definitions") added the numa_node attribute and
allowed it to be set in the map.

By using libbpf instead of bpf_load, the inner map definition has
been explicitly declared with BTF-defined format. Also, the element of
ARRAY_OF_MAPS was also statically specified using the BTF format. And
for this reason some logic in fixup_map() was not needed and changed
or removed.

Signed-off-by: Daniel T. Lee &lt;danieltimlee@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200707184855.30968-4-danieltimlee@gmail.com
</content>
</entry>
<entry>
<title>samples: bpf: Refactor BPF map in map test with libbpf</title>
<updated>2020-07-07T23:33:10Z</updated>
<author>
<name>Daniel T. Lee</name>
<email>danieltimlee@gmail.com</email>
</author>
<published>2020-07-07T18:48:53Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=88795b4adb01a30fbfd75ef1c1ef73b4442e38b2'/>
<id>urn:sha1:88795b4adb01a30fbfd75ef1c1ef73b4442e38b2</id>
<content type='text'>
From commit 646f02ffdd49 ("libbpf: Add BTF-defined map-in-map
support"), a way to define internal map in BTF-defined map has been
added.

Instead of using previous 'inner_map_idx' definition, the structure to
be used for the inner map can be directly defined using array directive.

    __array(values, struct inner_map)

This commit refactors map in map test program with libbpf by explicitly
defining inner map with BTF-defined format.

Signed-off-by: Daniel T. Lee &lt;danieltimlee@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200707184855.30968-3-danieltimlee@gmail.com
</content>
</entry>
<entry>
<title>samples: bpf: Fix bpf programs with kprobe/sys_connect event</title>
<updated>2020-07-07T23:32:14Z</updated>
<author>
<name>Daniel T. Lee</name>
<email>danieltimlee@gmail.com</email>
</author>
<published>2020-07-07T18:48:52Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=af9bd3e3331b8af42b6606c75797d041ab39380c'/>
<id>urn:sha1:af9bd3e3331b8af42b6606c75797d041ab39380c</id>
<content type='text'>
Currently, BPF programs with kprobe/sys_connect does not work properly.

Commit 34745aed515c ("samples/bpf: fix kprobe attachment issue on x64")
This commit modifies the bpf_load behavior of kprobe events in the x64
architecture. If the current kprobe event target starts with "sys_*",
add the prefix "__x64_" to the front of the event.

Appending "__x64_" prefix with kprobe/sys_* event was appropriate as a
solution to most of the problems caused by the commit below.

    commit d5a00528b58c ("syscalls/core, syscalls/x86: Rename struct
    pt_regs-based sys_*() to __x64_sys_*()")

However, there is a problem with the sys_connect kprobe event that does
not work properly. For __sys_connect event, parameters can be fetched
normally, but for __x64_sys_connect, parameters cannot be fetched.

    ffffffff818d3520 &lt;__x64_sys_connect&gt;:
    ffffffff818d3520: e8 fb df 32 00        callq   0xffffffff81c01520
    &lt;__fentry__&gt;
    ffffffff818d3525: 48 8b 57 60           movq    96(%rdi), %rdx
    ffffffff818d3529: 48 8b 77 68           movq    104(%rdi), %rsi
    ffffffff818d352d: 48 8b 7f 70           movq    112(%rdi), %rdi
    ffffffff818d3531: e8 1a ff ff ff        callq   0xffffffff818d3450
    &lt;__sys_connect&gt;
    ffffffff818d3536: 48 98                 cltq
    ffffffff818d3538: c3                    retq
    ffffffff818d3539: 0f 1f 80 00 00 00 00  nopl    (%rax)

As the assembly code for __x64_sys_connect shows, parameters should be
fetched and set into rdi, rsi, rdx registers prior to calling
__sys_connect.

Because of this problem, this commit fixes the sys_connect event by
first getting the value of the rdi register and then the value of the
rdi, rsi, and rdx register through an offset based on that value.

Fixes: 34745aed515c ("samples/bpf: fix kprobe attachment issue on x64")
Signed-off-by: Daniel T. Lee &lt;danieltimlee@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200707184855.30968-2-danieltimlee@gmail.com
</content>
</entry>
<entry>
<title>bpf, xdp, samples: Fix null pointer dereference in *_user code</title>
<updated>2020-06-16T12:55:35Z</updated>
<author>
<name>Gaurav Singh</name>
<email>gaurav1086@gmail.com</email>
</author>
<published>2020-06-12T18:53:27Z</published>
<link rel='alternate' type='text/html' href='https://sre.ring0.de/linux/commit/?id=6903cdae9f9f08d61e49c16cbef11c293e33a615'/>
<id>urn:sha1:6903cdae9f9f08d61e49c16cbef11c293e33a615</id>
<content type='text'>
Memset on the pointer right after malloc can cause a NULL pointer
deference if it failed to allocate memory. A simple fix is to
replace malloc()/memset() pair with a simple call to calloc().

Fixes: 0fca931a6f21 ("samples/bpf: program demonstrating access to xdp_rxq_info")
Signed-off-by: Gaurav Singh &lt;gaurav1086@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Jesper Dangaard Brouer &lt;brouer@redhat.com&gt;
Acked-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
</content>
</entry>
</feed>
