<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c, branch linux-5.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2023-07-27T06:43:37Z</updated>
<entry>
<title>bpf: Remove extra lock_sock for TCP_ZEROCOPY_RECEIVE</title>
<updated>2023-07-27T06:43:37Z</updated>
<author>
<name>Stanislav Fomichev</name>
</author>
<published>2021-01-15T16:34:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=08f61a34913558e06576e7b6318bf583f273c1be'/>
<id>urn:sha1:08f61a34913558e06576e7b6318bf583f273c1be</id>
<content type='text'>
[ Upstream commit 9cacf81f8161111db25f98e78a7a0e32ae142b3f ]

Add custom implementation of getsockopt hook for TCP_ZEROCOPY_RECEIVE.
We skip generic hooks for TCP_ZEROCOPY_RECEIVE and have a custom
call in do_tcp_getsockopt using the on-stack data. This removes
3% overhead for locking/unlocking the socket.

Without this patch:
     3.38%     0.07%  tcp_mmap  [kernel.kallsyms]  [k] __cgroup_bpf_run_filter_getsockopt
            |
             --3.30%--__cgroup_bpf_run_filter_getsockopt
                       |
                        --0.81%--__kmalloc

With the patch applied:
     0.52%     0.12%  tcp_mmap  [kernel.kallsyms]  [k] __cgroup_bpf_run_filter_getsockopt_kern

Note, exporting uapi/tcp.h requires removing netinet/tcp.h
from test_progs.h because those headers have confliciting
definitions.

Signed-off-by: Stanislav Fomichev &lt;sdf@google.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Link: https://lore.kernel.org/bpf/20210115163501.805133-2-sdf@google.com
Stable-dep-of: 2598619e012c ("sctp: add bpf_bypass_getsockopt proto callback")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Properly initialize linfo in sockmap_basic</title>
<updated>2020-10-02T14:47:32Z</updated>
<author>
<name>Stanislav Fomichev</name>
</author>
<published>2020-10-02T00:04:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=48ca6243c6adf1a3d7e7a0fd519ba918eb7b00ca'/>
<id>urn:sha1:48ca6243c6adf1a3d7e7a0fd519ba918eb7b00ca</id>
<content type='text'>
When using -Werror=missing-braces, compiler complains about missing braces.
Let's use use ={} initialization which should do the job:

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: In function 'test_sockmap_iter':
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: missing braces around initializer [-Werror=missing-braces]
  union bpf_iter_link_info linfo = {0};
        ^
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: (near initialization for 'linfo.map') [-Werror=missing-braces]
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: At top level:

Signed-off-by: Stanislav Fomichev &lt;sdf@google.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20201002000451.1794044-1-sdf@google.com
</content>
</entry>
<entry>
<title>selftest: bpf: Test copying a sockmap and sockhash</title>
<updated>2020-09-28T23:48:02Z</updated>
<author>
<name>Lorenz Bauer</name>
</author>
<published>2020-09-28T09:08:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5b87adc3ceee3c3131e24e9bc9ef92dd41db089f'/>
<id>urn:sha1:5b87adc3ceee3c3131e24e9bc9ef92dd41db089f</id>
<content type='text'>
Since we can now call map_update_elem(sockmap) from bpf_iter context
it's possible to copy a sockmap or sockhash in the kernel. Add a
selftest which exercises this.

Signed-off-by: Lorenz Bauer &lt;lmb@cloudflare.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200928090805.23343-5-lmb@cloudflare.com
</content>
</entry>
<entry>
<title>selftests: bpf: Remove shared header from sockmap iter test</title>
<updated>2020-09-28T23:48:02Z</updated>
<author>
<name>Lorenz Bauer</name>
</author>
<published>2020-09-28T09:08:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=27870317337a6c24af503304620de8064c8d2e4a'/>
<id>urn:sha1:27870317337a6c24af503304620de8064c8d2e4a</id>
<content type='text'>
The shared header to define SOCKMAP_MAX_ENTRIES is a bit overkill.
Dynamically allocate the sock_fd array based on bpf_map__max_entries
instead.

Suggested-by: Yonghong Song &lt;yhs@fb.com&gt;
Signed-off-by: Lorenz Bauer &lt;lmb@cloudflare.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200928090805.23343-4-lmb@cloudflare.com
</content>
</entry>
<entry>
<title>selftests: bpf: Add helper to compare socket cookies</title>
<updated>2020-09-28T23:47:58Z</updated>
<author>
<name>Lorenz Bauer</name>
</author>
<published>2020-09-28T09:08:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=26c3270ddb4955be358c888766ad1a6105dd7469'/>
<id>urn:sha1:26c3270ddb4955be358c888766ad1a6105dd7469</id>
<content type='text'>
We compare socket cookies to ensure that insertion into a sockmap worked.
Pull this out into a helper function for use in other tests.

Signed-off-by: Lorenz Bauer &lt;lmb@cloudflare.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200928090805.23343-3-lmb@cloudflare.com
</content>
</entry>
<entry>
<title>selftests: bpf: Test iterating a sockmap</title>
<updated>2020-09-10T19:35:26Z</updated>
<author>
<name>Lorenz Bauer</name>
</author>
<published>2020-09-09T16:27:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2f7de9865ba3cbfcf8b504f07154fdb6124176a4'/>
<id>urn:sha1:2f7de9865ba3cbfcf8b504f07154fdb6124176a4</id>
<content type='text'>
Add a test that exercises a basic sockmap / sockhash iteration. For
now we simply count the number of elements seen. Once sockmap update
from iterators works we can extend this to perform a full copy.

Signed-off-by: Lorenz Bauer &lt;lmb@cloudflare.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200909162712.221874-4-lmb@cloudflare.com
</content>
</entry>
<entry>
<title>selftests: bpf: Fix sockmap update nits</title>
<updated>2020-08-24T21:51:46Z</updated>
<author>
<name>Lorenz Bauer</name>
</author>
<published>2020-08-24T08:45:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8c3b3d971f2e4d72d8768457c40b513ca5d1f906'/>
<id>urn:sha1:8c3b3d971f2e4d72d8768457c40b513ca5d1f906</id>
<content type='text'>
Address review by Yonghong, to bring the new tests in line with the
usual code style.

Signed-off-by: Lorenz Bauer &lt;lmb@cloudflare.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200824084523.13104-1-lmb@cloudflare.com
</content>
</entry>
<entry>
<title>selftests: bpf: Test sockmap update from BPF</title>
<updated>2020-08-21T22:16:12Z</updated>
<author>
<name>Lorenz Bauer</name>
</author>
<published>2020-08-21T10:29:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bb23c0e1c57f3b40c8d2713401c1b42df911d424'/>
<id>urn:sha1:bb23c0e1c57f3b40c8d2713401c1b42df911d424</id>
<content type='text'>
Add a test which copies a socket from a sockmap into another sockmap
or sockhash. This excercises bpf_map_update_elem support from BPF
context. Compare the socket cookies from source and destination to
ensure that the copy succeeded.

Also check that the verifier rejects map_update from unsafe contexts.

Signed-off-by: Lorenz Bauer &lt;lmb@cloudflare.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200821102948.21918-7-lmb@cloudflare.com
</content>
</entry>
<entry>
<title>bpf, selftests: Add sk_msg helpers load and attach test</title>
<updated>2020-06-01T21:38:20Z</updated>
<author>
<name>John Fastabend</name>
</author>
<published>2020-05-24T16:51:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1d9c037a898b3c0344cfe5064ba6c482bf9b46b0'/>
<id>urn:sha1:1d9c037a898b3c0344cfe5064ba6c482bf9b46b0</id>
<content type='text'>
The test itself is not particularly useful but it encodes a common
pattern we have.

Namely do a sk storage lookup then depending on data here decide if
we need to do more work or alternatively allow packet to PASS. Then
if we need to do more work consult task_struct for more information
about the running task. Finally based on this additional information
drop or pass the data. In this case the suspicious check is not so
realisitic but it encodes the general pattern and uses the helpers
so we test the workflow.

This is a load test to ensure verifier correctly handles this case.

Signed-off-by: John Fastabend &lt;john.fastabend@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/159033909665.12355.6166415847337547879.stgit@john-Precision-5820-Tower
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpf: Selftests build error in sockmap_basic.c</title>
<updated>2020-02-10T22:31:34Z</updated>
<author>
<name>John Fastabend</name>
</author>
<published>2020-02-10T05:44:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f2e97dc126b712c0d21219ed0c42710006c1cf52'/>
<id>urn:sha1:f2e97dc126b712c0d21219ed0c42710006c1cf52</id>
<content type='text'>
Fix following build error. We could push a tcp.h header into one of the
include paths, but I think its easy enough to simply pull in the three
defines we need here. If we end up using more of tcp.h at some point
we can pull it in later.

/home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: In function ‘connected_socket_v4’:
/home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:20:11: error: ‘TCP_REPAIR_ON’ undeclared (first use in this function)
  repair = TCP_REPAIR_ON;
           ^
/home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:20:11: note: each undeclared identifier is reported only once for each function it appears in
/home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:29:11: error: ‘TCP_REPAIR_OFF_NO_WP’ undeclared (first use in this function)
  repair = TCP_REPAIR_OFF_NO_WP;

Then with fix,

$ ./test_progs -n 44
#44/1 sockmap create_update_free:OK
#44/2 sockhash create_update_free:OK
#44 sockmap_basic:OK

Fixes: 5d3919a953c3c ("selftests/bpf: Test freeing sockmap/sockhash with a socket in it")
Signed-off-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Reviewed-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Link: https://lore.kernel.org/bpf/158131347731.21414.12120493483848386652.stgit@john-Precision-5820-Tower
</content>
</entry>
</feed>
