<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/testing/selftests/bpf/prog_tests/sock_fields.c, branch master</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=master</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-06-23T17:52:12Z</updated>
<entry>
<title>selftests/bpf: Fix rare segfault in sock_fields prog test</title>
<updated>2022-06-23T17:52:12Z</updated>
<author>
<name>Jörn-Thorben Hinz</name>
</author>
<published>2022-06-21T07:01:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6dc7a0baf1a70b7d22662d38481824c14ddd80c5'/>
<id>urn:sha1:6dc7a0baf1a70b7d22662d38481824c14ddd80c5</id>
<content type='text'>
test_sock_fields__detach() got called with a null pointer here when one
of the CHECKs or ASSERTs up to the test_sock_fields__open_and_load()
call resulted in a jump to the "done" label.

A skeletons *__detach() is not safe to call with a null pointer, though.
This led to a segfault.

Go the easy route and only call test_sock_fields__destroy() which is
null-pointer safe and includes detaching.

Came across this while looking[1] to introduce the usage of
bpf_tcp_helpers.h (included in progs/test_sock_fields.c) together with
vmlinux.h.

[1] https://lore.kernel.org/bpf/629bc069dd807d7ac646f836e9dca28bbc1108e2.camel@mailbox.tu-berlin.de/

Fixes: 8f50f16ff39d ("selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads")
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: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Reviewed-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Acked-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Link: https://lore.kernel.org/bpf/20220621070116.307221-1-jthinz@mailbox.tu-berlin.de
</content>
</entry>
<entry>
<title>selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads</title>
<updated>2022-01-31T20:39:12Z</updated>
<author>
<name>Jakub Sitnicki</name>
</author>
<published>2022-01-30T11:55:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8f50f16ff39dd4e2d43d1548ca66925652f8aff7'/>
<id>urn:sha1:8f50f16ff39dd4e2d43d1548ca66925652f8aff7</id>
<content type='text'>
Add coverage to the verifier tests and tests for reading bpf_sock fields to
ensure that 32-bit, 16-bit, and 8-bit loads from dst_port field are allowed
only at intended offsets and produce expected values.

While 16-bit and 8-bit access to dst_port field is straight-forward, 32-bit
wide loads need be allowed and produce a zero-padded 16-bit value for
backward compatibility.

Signed-off-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Link: https://lore.kernel.org/r/20220130115518.213259-3-jakub@cloudflare.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Remove explicit setrlimit(RLIMIT_MEMLOCK) in main selftests</title>
<updated>2021-12-14T21:16:54Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2021-12-14T19:59:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c164b8b40422ef5c643d08bbc63280e1e1610573'/>
<id>urn:sha1:c164b8b40422ef5c643d08bbc63280e1e1610573</id>
<content type='text'>
As libbpf now is able to automatically take care of RLIMIT_MEMLOCK
increase (or skip it altogether on recent enough kernels), remove
explicit setrlimit() invocations in bench, test_maps, test_verifier, and
test_progs.

Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20211214195904.1785155-3-andrii@kernel.org
</content>
</entry>
<entry>
<title>selfetest/bpf: Make some tests serial</title>
<updated>2021-10-08T22:17:00Z</updated>
<author>
<name>Yucong Sun</name>
</author>
<published>2021-10-06T18:56:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d3f7b1664d3ebd69751327f45f5cd4adfb29f620'/>
<id>urn:sha1:d3f7b1664d3ebd69751327f45f5cd4adfb29f620</id>
<content type='text'>
Change tests that often fails in parallel execution mode to serial.

Signed-off-by: Yucong Sun &lt;sunyucong@gmail.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20211006185619.364369-15-fallentree@fb.com
</content>
</entry>
<entry>
<title>selftests/bpf: Turn on libbpf 1.0 mode and fix all IS_ERR checks</title>
<updated>2021-05-26T00:32:35Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2021-05-25T03:59:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bad2e478af3b4df9fd84b4db7779ea91bd618c16'/>
<id>urn:sha1:bad2e478af3b4df9fd84b4db7779ea91bd618c16</id>
<content type='text'>
Turn ony libbpf 1.0 mode. Fix all the explicit IS_ERR checks that now will be
broken because libbpf returns NULL on error (and sets errno). Fix
ASSERT_OK_PTR and ASSERT_ERR_PTR to work for both old mode and new modes and
use them throughout selftests. This is trivial to do by using
libbpf_get_error() API that all libbpf users are supposed to use, instead of
IS_ERR checks.

A bunch of checks also did explicit -1 comparison for various fd-returning
APIs. Such checks are replaced with &gt;= 0 or &lt; 0 cases.

There were also few misuses of bpf_object__find_map_by_name() in test_maps.
Those are fixed in this patch as well.

Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Acked-by: Toke Høiland-Jørgensen &lt;toke@redhat.com&gt;
Link: https://lore.kernel.org/bpf/20210525035935.1461796-3-andrii@kernel.org
</content>
</entry>
<entry>
<title>selftests: Make sure all 'skel' variables are declared static</title>
<updated>2020-09-29T18:43:43Z</updated>
<author>
<name>Toke Høiland-Jørgensen</name>
</author>
<published>2020-09-29T12:30:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f970cbcdcdb5b3468a6c05332818d226fb60038f'/>
<id>urn:sha1:f970cbcdcdb5b3468a6c05332818d226fb60038f</id>
<content type='text'>
If programs in prog_tests using skeletons declare the 'skel' variable as
global but not static, that will lead to linker errors on the final link of
the prog_tests binary due to duplicate symbols. Fix a few instances of this.

Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
Fixes: 9a856cae2217 ("bpf: selftest: Add test_btf_skc_cls_ingress")
Signed-off-by: Toke Høiland-Jørgensen &lt;toke@redhat.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200929123026.46751-1-toke@redhat.com
</content>
</entry>
<entry>
<title>bpf: selftest: Use bpf_skc_to_tcp_sock() in the sock_fields test</title>
<updated>2020-09-25T20:58:02Z</updated>
<author>
<name>Martin KaFai Lau</name>
</author>
<published>2020-09-25T00:04:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=edc2d66ad1851db6bd89a611b4e46470f1a40ba9'/>
<id>urn:sha1:edc2d66ad1851db6bd89a611b4e46470f1a40ba9</id>
<content type='text'>
This test uses bpf_skc_to_tcp_sock() to get a kernel tcp_sock ptr "ktp".
Access the ktp-&gt;lsndtime and also pass ktp to bpf_sk_storage_get().

It also exercises the bpf_sk_cgroup_id() and bpf_sk_ancestor_cgroup_id()
with the "ktp".  To do that, a parent cgroup and a child cgroup are
created.  The bpf prog is attached to the child cgroup.

Signed-off-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200925000446.3858975-1-kafai@fb.com
</content>
</entry>
<entry>
<title>bpf: selftest: Use network_helpers in the sock_fields test</title>
<updated>2020-09-25T20:58:02Z</updated>
<author>
<name>Martin KaFai Lau</name>
</author>
<published>2020-09-25T00:04:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c40a565a04afd0429ecc8a1a2c9aff897796118f'/>
<id>urn:sha1:c40a565a04afd0429ecc8a1a2c9aff897796118f</id>
<content type='text'>
This patch uses start_server() and connect_to_fd() from network_helpers.h
to remove the network testing boiler plate codes.  epoll is no longer
needed also since the timeout has already been taken care of also.

Signed-off-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200925000440.3858639-1-kafai@fb.com
</content>
</entry>
<entry>
<title>bpf: selftest: Adapt sock_fields test to use skel and global variables</title>
<updated>2020-09-25T20:58:02Z</updated>
<author>
<name>Martin KaFai Lau</name>
</author>
<published>2020-09-25T00:04:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b18c1f0aa4775bf1ecfbe5942e4e7c6bffdeff6a'/>
<id>urn:sha1:b18c1f0aa4775bf1ecfbe5942e4e7c6bffdeff6a</id>
<content type='text'>
skel is used.

Global variables are used to store the result from bpf prog.
addr_map, sock_result_map, and tcp_sock_result_map are gone.
Instead, global variables listen_tp, srv_sa6, cli_tp,, srv_tp,
listen_sk, srv_sk, and cli_sk are added.
Because of that, bpf_addr_array_idx and bpf_result_array_idx are also
no longer needed.

CHECK() macro from test_progs.h is reused and bail as soon as
a CHECK failure.

shutdown() is used to ensure the previous data-ack is received.
The bytes_acked, bytes_received, and the pkt_out_cnt checks are
using "&lt;" to accommodate the final ack may not have been received/sent.
It is enough since it is not the focus of this test.

The sk local storage is all initialized to 0xeB9F now, so the
check_sk_pkt_out_cnt() always checks with the 0xeB9F base.  It is to
keep things simple.

The next patch will reuse helpers from network_helpers.h to simplify
things further.

Signed-off-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200925000434.3858204-1-kafai@fb.com
</content>
</entry>
<entry>
<title>bpf: selftest: Move sock_fields test into test_progs</title>
<updated>2020-09-25T20:58:02Z</updated>
<author>
<name>Martin KaFai Lau</name>
</author>
<published>2020-09-25T00:04:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6f521a2bd26870bcd14aac42ff2ce0b1a22ae477'/>
<id>urn:sha1:6f521a2bd26870bcd14aac42ff2ce0b1a22ae477</id>
<content type='text'>
This is a mechanical change to
1. move test_sock_fields.c to prog_tests/sock_fields.c
2. rename progs/test_sock_fields_kern.c to progs/test_sock_fields.c

Minimal change is made to the code itself.  Next patch will make
changes to use new ways of writing test, e.g. use skel and global
variables.

Signed-off-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200925000427.3857814-1-kafai@fb.com
</content>
</entry>
</feed>
