[PATCH bpf-next v2 4/4] selftests/bpf: Use start_server_str in test_tcp_check_syncookie_user

2024-06-12 Thread Geliang Tang
From: Geliang Tang Since start_server_str() is added now, it can be used in script test_tcp_check_syncookie_user.c instead of start_server_addr() to simplify the code. Signed-off-by: Geliang Tang Acked-by: Eduard Zingerman --- .../bpf/test_tcp_check_syncookie_user.c | 29

[PATCH bpf-next v2 3/4] selftests/bpf: Use start_server_str in mptcp

2024-06-12 Thread Geliang Tang
From: Geliang Tang Since start_server_str() is added now, it can be used in mptcp.c in start_mptcp_server() instead of using helpers make_sockaddr() and start_server_addr() to simplify the code. Signed-off-by: Geliang Tang Acked-by: Eduard Zingerman --- tools/testing/selftests/bpf/prog_tests

[PATCH bpf-next v2 1/4] selftests/bpf: Drop type from network_helper_opts

2024-06-12 Thread Geliang Tang
From: Geliang Tang The opts.{type, noconnect, must_fail} is at least a bit non intuitive or unnecessary. The only use case now is in test_bpf_ip_check_defrag_ok which ends up bypassing most (or at least some) of the connect_to_fd_opts() logic. It's much better that test should have its own

[PATCH bpf-next v2 2/4] selftests/bpf: Drop noconnect from network_helper_opts

2024-06-12 Thread Geliang Tang
From: Geliang Tang This patch extracts a new helper start_client() from connect_to_fd_opts() to create the client socket, but don't connect to the server. Then connect_to_fd_opts() can be implemented using start_client() and connect_fd_to_addr(). In test_bpf_ip_check_defrag_ok(), the new helper

[PATCH bpf-next v2 0/4] use network helpers, part 7

2024-06-12 Thread Geliang Tang
From: Geliang Tang v2: - update patch 2, extract a new helper start_client. - drop patch 3, keep must_fail in network_helper_opts. Drop type and noconnect from network_helper_opts. And use start_server_str in mptcp and test_tcp_check_syncookie_user. Patches 1-2 address Martin's comments

[PATCH net-next v7 2/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap

2024-06-12 Thread Geliang Tang
From: Geliang Tang Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking it to set file status flags. If O_NONBLOCK is used as 2nd argument and passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c). The correct approach is to use F_SETFL as 2nd argument

[PATCH net-next v7 1/2] tls: receive msg again for sk_redirect

2024-06-12 Thread Geliang Tang
From: Geliang Tang tls_sw doesn't work for sk_redirect in nonblock mode, sk_msg_recvmsg() returns 0 in that case in tls_sw_recvmsg(). This patch fixes this by using "continue" to receive msg again instead of ending it if strp isn't ready and rx_list is empty. Signed-off-by: Ge

[PATCH net-next v7 0/2] Add F_SETFL for fcntl in test_sockmap

2024-06-12 Thread Geliang Tang
From: Geliang Tang v7: - a better fix for tls_sw_recvmsg. v6: - add a fix for tls_sw_recvmsg(). v5: - add a new patch "Check recv lengths in test_sockmap" instead of using "continue" in msg_loop. v4: - address Martin's comments for v3. (thanks.) - add Yongho

Re: [PATCH bpf-next 1/5] selftests/bpf: Drop type from network_helper_opts

2024-06-11 Thread Geliang Tang
On Tue, 2024-06-11 at 14:20 -0700, Eduard Zingerman wrote: > On Tue, 2024-06-11 at 09:59 +0800, Geliang Tang wrote: > > From: Geliang Tang > > > > The opts.{type, noconnect, must_fail} is at least a bit non > > intuitive or > > u

[PATCH net-next v6 2/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap

2024-06-11 Thread Geliang Tang
From: Geliang Tang Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking it to set file status flags. If O_NONBLOCK is used as 2nd argument and passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c). The correct approach is to use F_SETFL as 2nd argument

[PATCH net-next v6 1/2] tls: wait for receiving next skb for sk_redirect

2024-06-11 Thread Geliang Tang
From: Geliang Tang tls_sw_recvmsg() doesn't work in nonblock mode, it returns -EAGAIN in that case. This patch fixes it, always wait for receiving the next skb for sk_redirect. Signed-off-by: Geliang Tang --- net/tls/tls_sw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tls

[PATCH net-next v6 0/2] Add F_SETFL for fcntl in test_sockmap

2024-06-11 Thread Geliang Tang
From: Geliang Tang v6: - add a fix for tls_sw_recvmsg(). v5: - add a new patch "Check recv lengths in test_sockmap" instead of using "continue" in msg_loop. v4: - address Martin's comments for v3. (thanks.) - add Yonghong's "Acked-by" tags. (thanks.) - u

[PATCH bpf-next v2 2/2] selftests/bpf: Close netns in error paths in test_tunnel

2024-06-10 Thread Geliang Tang
From: Geliang Tang netns created by open_netns() should be closed in error paths in test_vxlan_tunnel(), test_ip6vxlan_tunnel() and test_ipip_tunnel(). Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/test_tunnel.c| 27 +-- 1 file changed, 19 insertions(+), 8

[PATCH bpf-next v2 1/2] selftests/bpf: Enable INET_XFRM_TUNNEL in config

2024-06-10 Thread Geliang Tang
From: Geliang Tang The kconfigs CONFIG_INET_XFRM_TUNNEL and CONFIG_INET6_XFRM_TUNNEL are needed by test_tunnel tests. This patch enables them together with the dependent kconfigs CONFIG_INET_IPCOMP and CONFIG_INET6_IPCOMP. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/config | 4

[PATCH bpf-next v2 0/2] Enable INET_XFRM_TUNNEL in config

2024-06-10 Thread Geliang Tang
From: Geliang Tang v2: - resend patch 1. - another fix for test_tunnel. Geliang Tang (2): selftests/bpf: Enable INET_XFRM_TUNNEL in config selftests/bpf: Close netns in error paths in test_tunnel tools/testing/selftests/bpf/config| 4 +++ .../selftests/bpf/prog_tests

Re: [PATCH bpf-next] selftests/bpf: Enable INET_XFRM_TUNNEL in config

2024-06-10 Thread Geliang Tang
On Wed, May 29, 2024 at 02:01:06AM +0200, Ilya Leoshkevich wrote: > On Fri, 2024-05-24 at 18:27 +0200, Daniel Borkmann wrote: > > On 5/16/24 3:41 AM, Geliang Tang wrote: > > > From: Geliang Tang > > > > > > The kconfigs CONFIG_INET_XFRM_TUNNEL and CONFIG_INET

[PATCH bpf-next 5/5] selftests/bpf: Use start_server_str in test_tcp_check_syncookie_user

2024-06-10 Thread Geliang Tang
From: Geliang Tang Since start_server_str() is added now, it can be used in script test_tcp_check_syncookie_user.c instead of start_server_addr() to simplify the code. Signed-off-by: Geliang Tang --- .../bpf/test_tcp_check_syncookie_user.c | 29 ++- 1 file changed, 3

[PATCH bpf-next 4/5] selftests/bpf: Use start_server_str in mptcp

2024-06-10 Thread Geliang Tang
From: Geliang Tang Since start_server_str() is added now, it can be used in mptcp.c in start_mptcp_server() instead of using helpers make_sockaddr() and start_server_addr() to simplify the code. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 7 +-- 1 file

[PATCH bpf-next 3/5] selftests/bpf: Drop must_fail from network_helper_opts

2024-06-10 Thread Geliang Tang
From: Geliang Tang This patch adds another new parameter "must_fail" for __connect_to_fd_opts, then opts->must_fail can be replaced by "must_fail" parameter in it. In run_test() of cgroup_v1v2, true is passed to it, while false is passed in other places. And the s

[PATCH bpf-next 2/5] selftests/bpf: Drop noconnect from network_helper_opts

2024-06-10 Thread Geliang Tang
From: Geliang Tang This patch adds another new parameter "noconnect" for __connect_to_fd_opts, then opts->noconnect can be replaced by "noconnect" parameter in it. In test_bpf_ip_check_defrag_ok(), true is passed to it. And the strcut member "noconnect" of netwo

[PATCH bpf-next 1/5] selftests/bpf: Drop type from network_helper_opts

2024-06-10 Thread Geliang Tang
From: Geliang Tang The opts.{type, noconnect, must_fail} is at least a bit non intuitive or unnecessary. The only use case now is in test_bpf_ip_check_defrag_ok which ends up bypassing most (or at least some) of the connect_to_fd_opts() logic. It's much better that test should have its own

[PATCH bpf-next 0/5] use network helpers, part 7

2024-06-10 Thread Geliang Tang
From: Geliang Tang Drop type, noconnect and must_fail from network_helper_opts. And use start_server_str in mptcp and test_tcp_check_syncookie_user. Patches 1-3 address Martin's comments in the previous series. Geliang Tang (5): selftests/bpf: Drop type from network_helper_opts selftests

Re: [PATCH bpf-next 3/8] selftests/bpf: Use bpf_link attachments in test_sockmap

2024-05-31 Thread Geliang Tang
On Fri, May 31, 2024 at 01:13:39PM +0200, Jakub Sitnicki wrote: > On Thu, May 30, 2024 at 04:45 PM -07, John Fastabend wrote: > > Geliang Tang wrote: > >> On Mon, 2024-05-27 at 21:36 +0200, Jakub Sitnicki wrote: > >> > On Mon, May 27, 2024 at 10:12 AM -07, John Fas

[PATCH bpf-next 5/5] selftests/bpf: Drop useless arguments of do_test in bpf_tcp_ca

2024-05-30 Thread Geliang Tang
From: Geliang Tang bpf_map_lookup_elem() has been removed from do_test(), it makes the sk_stg_map argument of do_test() useless. In addition, two exactly the same opts are passed in all the places where do_test() is invoked, so cli_opts argument can be dropped too. This patch drops these two

[PATCH bpf-next 4/5] selftests/bpf: Use start_test in test_dctcp in bpf_tcp_ca

2024-05-30 Thread Geliang Tang
From: Geliang Tang The "if (sk_stg_map)" block in do_test() is only used by test_dctcp(), it makes sense to move it from do_test() into test_dctcp(). Then do_test() can be used by other tests except test_dctcp(). Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/bp

[PATCH bpf-next 3/5] selftests/bpf: Use start_test in test_dctcp_fallback in bpf_tcp_ca

2024-05-30 Thread Geliang Tang
From: Geliang Tang The newly added helper start_test() can be used in test_dctcp_fallback() too, to replace start_server_str() and connect_to_fd_opts(). In that way, two network_helper_opts srv_opts and cli_opts are used instead of the previously shared opts. Signed-off-by: Geliang Tang

[PATCH bpf-next 1/5] selftests/bpf: Use connect_to_fd_opts in do_test in bpf_tcp_ca

2024-05-30 Thread Geliang Tang
From: Geliang Tang This patch uses connect_to_fd_opts() instead of using connect_fd_to_fd() and settcpca() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument. Then define a dctcp dedicated post_socket_cb callback stg_post_socket_cb(), invoking both settcpca

[PATCH bpf-next 2/5] selftests/bpf: Add start_test helper in bpf_tcp_ca

2024-05-30 Thread Geliang Tang
From: Geliang Tang For moving the "if (sk_stg_map)" block out of do_test(), extract the code before this block as a new function start_test(). It creates server-side and client-side sockets and returns them to the caller. Signed-off-by: Geliang Tang --- .../selftests/bpf/

[PATCH bpf-next 0/5] use network helpers, part 6

2024-05-30 Thread Geliang Tang
From: Geliang Tang For moving dctcp test dedicated code out of do_test() into test_dctcp(). This patchset adds a new helper start_test() in bpf_tcp_ca.c to refactor do_test(). Address Martin's comments for the previous series. Geliang Tang (5): selftests/bpf: Use connect_to_fd_opts

Re: [PATCH net v2] selftests: hsr: Fix "File exists" errors for hsr_ping

2024-05-29 Thread Geliang Tang
Hi Lukasz, On Wed, 2024-05-29 at 14:43 +0200, Lukasz Majewski wrote: > Hi Geliang, > > First of all - thanks for spotting and fixing this error. > > > From: Geliang Tang > > > > The hsr_ping test reports the following errors: > > > >  INFO: preparin

Re: [PATCH bpf-next 3/8] selftests/bpf: Use bpf_link attachments in test_sockmap

2024-05-27 Thread Geliang Tang
On Mon, 2024-05-27 at 21:36 +0200, Jakub Sitnicki wrote: > On Mon, May 27, 2024 at 10:12 AM -07, John Fastabend wrote: > > Geliang Tang wrote: > > > From: Geliang Tang > > > > > > Switch attachments to bpf_link using > > > bpf_program__atta

[PATCH bpf-next v5 7/7] selftests/bpf: Add post_connect_cb callback

2024-05-25 Thread Geliang Tang
From: Geliang Tang For getting rid of the second parameter of do_test(), this patch adds a new callback post_connect_cb in struct network_helper_opts, it will be invoked after connect_fd_to_addr() in connect_to_fd_opts(). Then define a dctcp dedicated post_connect_cb callback, invoking

[PATCH bpf-next v5 6/7] selftests/bpf: Use connect_to_fd_opts in do_test in bpf_tcp_ca

2024-05-25 Thread Geliang Tang
From: Geliang Tang This patch uses connect_to_fd_opts() instead of using connect_fd_to_fd() and settcpca() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument. Then define a dctcp dedicated post_socket_cb callback stg_post_socket_cb(), invoking both cc_cb

[PATCH bpf-next v5 5/7] selftests/bpf: Use start_server_str in do_test in bpf_tcp_ca

2024-05-25 Thread Geliang Tang
From: Geliang Tang This patch uses new helper start_server_str() in do_test() in bpf_tcp_ca.c to accept a struct network_helper_opts argument instead of using start_server() and settcpca(). Then change the type of the first paramenter of do_test() into a struct network_helper_opts one. Define

[PATCH bpf-next v5 4/7] selftests/bpf: Use post_socket_cb in start_server_str

2024-05-25 Thread Geliang Tang
From: Geliang Tang This patch uses start_server_str() helper in test_dctcp_fallback() in bpf_tcp_ca.c, instead of using start_server() and settcpca(). For support opts in start_server_str() helper, opts->cb_opts needs to be passed to post_socket_cb() in __start_server(). Signed-off-by: Geli

[PATCH bpf-next v5 3/7] selftests/bpf: Use post_socket_cb in connect_to_fd_opts

2024-05-25 Thread Geliang Tang
From: Geliang Tang Since the post_socket_cb() callback is added in struct network_helper_opts, it's make sense to use it not only in __start_server(), but also in connect_to_fd_opts(). Then it can be used to set TCP_CONGESTION sockopt. Add a "void *" type member cb_opts i

[PATCH bpf-next v5 2/7] selftests/bpf: Add start_server_str helper

2024-05-25 Thread Geliang Tang
From: Geliang Tang It's a tech debt that start_server() does not take the "opts" argument. It's pretty handy to have start_server() as a helper that takes string address. So this patch creates a new helper start_server_str(). Then start_server() can be a wrapper of it. Signed-off-b

[PATCH bpf-next v5 1/7] selftests/bpf: Drop struct post_socket_opts

2024-05-25 Thread Geliang Tang
From: Geliang Tang It's not possible to have one generic/common "struct post_socket_opts" for all tests. It's better to have the individual test define its own callback opts struct. So this patch drops struct post_socket_opts, and changes the second parameter of post_socket_cb as &qu

[PATCH bpf-next v5 0/7] use network helpers, part 5

2024-05-25 Thread Geliang Tang
From: Geliang Tang This patchset uses post_socket_cb and post_connect_cb callbacks of struct network_helper_opts to refactor do_test() in bpf_tcp_ca.c to move dctcp test dedicated code out of do_test() into test_dctcp(). v5: - address Martin's comments in v4 (thanks) - add patch 4, use

[PATCH bpf-next v4 6/6] selftests/bpf: Add post_connect_cb callback

2024-05-23 Thread Geliang Tang
From: Geliang Tang For getting rid of the second parameter of do_test(), this patch adds a new callback post_connect_cb in struct network_helper_opts, it will be invoked after connect_fd_to_addr() in connect_to_fd_opts(). Then define a dctcp dedicated post_connect_cb callback, invoking

[PATCH bpf-next v4 5/6] selftests/bpf: Use connect_to_fd_opts in do_test in bpf_tcp_ca

2024-05-23 Thread Geliang Tang
From: Geliang Tang This patch uses connect_to_fd_opts() instead of using connect_fd_to_fd() and settcpca() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument. Then define a dctcp dedicated post_socket_cb callback stg_post_socket_cb(), invoking both cc_cb

[PATCH bpf-next v4 4/6] selftests/bpf: Use start_server_str in bpf_tcp_ca

2024-05-23 Thread Geliang Tang
From: Geliang Tang This patch uses new helper start_server_str() in do_test() in bpf_tcp_ca.c to accept a struct network_helper_opts argument instead of using start_server() and settcpca(). Then change the type of the first paramenter of do_test() into a struct network_helper_opts one. Define

[PATCH bpf-next v4 2/6] selftests/bpf: Add start_server_str helper

2024-05-23 Thread Geliang Tang
From: Geliang Tang It's a tech debt that start_server() does not take the "opts" argument. It's pretty handy to have start_server() as a helper that takes string address. So this patch creates a new helper start_server_str(). Then start_server() can be a wrapper of it. Signed-off-b

[PATCH bpf-next v4 3/6] selftests/bpf: Use post_socket_cb in connect_to_fd_opts

2024-05-23 Thread Geliang Tang
From: Geliang Tang Since the post_socket_cb() callback is added in struct network_helper_opts, it's make sense to use it not only in __start_server(), but also in connect_to_fd_opts(). Then it can be used to set TCP_CONGESTION sockopt. Add a "void *" type member cb_opts i

[PATCH bpf-next v4 1/6] selftests/bpf: Drop struct post_socket_opts

2024-05-23 Thread Geliang Tang
From: Geliang Tang It's not possible to have one generic/common "struct post_socket_opts" for all tests. It's better to have the individual test define its own callback opts struct. So this patch drops struct post_socket_opts, and changes the second parameter of post_socket_cb as &qu

[PATCH bpf-next v4 0/6] use network helpers, part 5

2024-05-23 Thread Geliang Tang
From: Geliang Tang This patchset uses post_socket_cb and post_connect_cb callbacks of struct network_helper_opts to refactor do_test() in bpf_tcp_ca.c to move dctcp test dedicated code out of do_test() into test_dctcp(). v4: - address Martin's comments in v3 (thanks). - drop 2 patches, keep

Re: [PATCH bpf-next] selftests/bpf: Use prog_attach_type to attach in test_sockmap

2024-05-23 Thread Geliang Tang
This patch is "Rejected", according to Jakub's comments: https://lore.kernel.org/bpf/87zfsiw3a3@cloudflare.com/ Thanks, -Geliang On Wed, 2024-05-22 at 18:08 +0800, Geliang Tang wrote: > From: Geliang Tang > > Since prog_attach_type[] array is defined, it makes sense

[PATCH bpf-next 8/8] selftests/bpf: Drop duplicate bpf_map_lookup_elem in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang bpf_map_lookup_elem is invoked in bpf_prog3() already, no need to invoke it again. This patch drops it. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/test_sockmap_kern.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next 7/8] selftests/bpf: Check length of recv in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang The value of recv in msg_loop may be negative, like EWOULDBLOCK, so it's necessary to check if it is positive before accumulating it to bytes_recvd. Fixes: 16962b2404ac ("bpf: sockmap, add selftests") Signed-off-by: Geliang Tang --- tools/testing/sel

[PATCH bpf-next 6/8] selftests/bpf: Fix size of map_fd in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang The array size of map_fd[] is 9, not 8. This patch changes it as a more general form: ARRAY_SIZE(map_fd). Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests

[PATCH bpf-next 5/8] selftests/bpf: Drop prog_fd array in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang The program fds can be got by using bpf_program__fd(progs[]), then prog_fd becomes useless. This patch drops it. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools

[PATCH bpf-next 4/8] selftests/bpf: Replace tx_prog_fd with tx_prog in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang bpf_program__attach_sockmap() needs to take a parameter of type bpf_program instead of an fd, so tx_prog_fd becomes useless. This patch uses a pointer tx_prog to point to an item in progs[] array. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c

[PATCH bpf-next 3/8] selftests/bpf: Use bpf_link attachments in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang Switch attachments to bpf_link using bpf_program__attach_sockmap() instead of bpf_prog_attach(). This patch adds a new array progs[] to replace prog_fd[] array, set in populate_progs() for each program in bpf object. And another new array links[] to save the attached

[PATCH bpf-next 2/8] selftests/bpf: Drop duplicate definition of i in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang There's already a definition of i in run_options() at the beginning, no need to define a new one in "if (tx_prog_fd > 0)" block. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-

[PATCH bpf-next 1/8] selftests/bpf: Fix tx_prog_fd values in test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang The values of tx_prog_fd in run_options() should not be 0, so set it as -1 in else branch, and test it using "if (tx_prog_fd > 0)" condition, not "if (tx_prog_fd)" or "if (tx_prog_fd >= 0)". Signed-off-by: Geliang Tang --- tools/test

[PATCH bpf-next 0/8] fixes for test_sockmap

2024-05-23 Thread Geliang Tang
From: Geliang Tang This patchset contains some fixes and improvements for test_sockmap. 3-5: switching attachments to bpf_link as Jakub suggested in [1]. 1-2, 6-8: Small fixes. [1] https://lore.kernel.org/bpf/87zfsiw3a3@cloudflare.com/ Geliang Tang (8): selftests/bpf: Fix tx_prog_fd

[PATCH net v2] selftests: hsr: Fix "File exists" errors for hsr_ping

2024-05-22 Thread Geliang Tang
From: Geliang Tang The hsr_ping test reports the following errors: INFO: preparing interfaces for HSRv0. INFO: Initial validation ping. INFO: Longer ping test. INFO: Cutting one link. INFO: Delay the link and drop a few packages. INFO: All good. INFO: preparing interfaces for HSRv1

Re: [PATCH net] selftests: hsr: Fix "File exists" errors for hsr_ping

2024-05-22 Thread Geliang Tang
On Wed, 2024-05-22 at 11:05 +0800, Hangbin Liu wrote: > On Tue, May 21, 2024 at 04:49:44PM +0800, Geliang Tang wrote: > > From: Geliang Tang > > > > The hsr_ping test reports the following errors: > > > >  INFO: preparing interfaces for HSRv0. > >  I

[PATCH bpf-next] selftests/bpf: Use prog_attach_type to attach in test_sockmap

2024-05-22 Thread Geliang Tang
From: Geliang Tang Since prog_attach_type[] array is defined, it makes sense to use it paired with prog_fd[] array for bpf_prog_attach() and bpf_prog_detach2() instead of open-coding. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c | 44 +++--- 1

[PATCH bpf-next v3 8/8] selftests/bpf: Add post_connect_cb callback

2024-05-22 Thread Geliang Tang
From: Geliang Tang For getting rid of the second parameter of do_test(), this patch adds a new callback post_connect_cb in struct network_helper_opts, it will be invoked after connect_fd_to_addr() in connect_to_fd_opts(). Then define a dctcp dedicated post_connect_cb callback, invoking

[PATCH bpf-next v3 7/8] selftests/bpf: Use connect_to_fd_opts in do_test in bpf_tcp_ca

2024-05-22 Thread Geliang Tang
From: Geliang Tang This patch uses connect_to_fd_opts() instead of using connect_fd_to_fd() and settcpca() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument. Then define a dctcp dedicated post_socket_cb callback stg_post_socket_cb(), invoking both cc_cb

[PATCH bpf-next v3 4/8] selftests/bpf: Add start_server_str helper

2024-05-22 Thread Geliang Tang
From: Geliang Tang It's a tech debt that start_server() does not take the "opts" argument. It's pretty handy to have start_server() as a helper that takes string address. So this patch creates a new helper start_server_str(). Then start_server() can be a wrapper of it. Signed-off-b

[PATCH bpf-next v3 6/8] selftests/bpf: Use start_server_str in bpf_tcp_ca

2024-05-22 Thread Geliang Tang
From: Geliang Tang This patch uses new helper start_server_str() in do_test() in bpf_tcp_ca.c to accept a struct network_helper_opts argument instead of using start_server() and settcpca(). Then change the type of the first paramenter of do_test() into a struct network_helper_opts one. Define

[PATCH bpf-next v3 5/8] selftests/bpf: Use post_socket_cb in connect_to_fd_opts

2024-05-22 Thread Geliang Tang
From: Geliang Tang Since the post_socket_cb() callback is added in struct network_helper_opts, it's make sense to use it not only in __start_server(), but also in connect_to_fd_opts(). Then it can be used to set TCP_CONGESTION sockopt. Add a "void *" type member cb_opts i

[PATCH bpf-next v3 3/8] selftests/bpf: Drop type parameter of connect_to_addr

2024-05-22 Thread Geliang Tang
From: Geliang Tang Since "type" is a struct member of network_helper_opts, it makes sense to drop the "type" parameter of connect_to_addr() helper, using opts->type instead in this helper. If no network_helper_opts is set, use SOCK_STREAM as default socket type. Sign

[PATCH bpf-next v3 2/8] selftests/bpf: Drop type parameter of start_server_addr

2024-05-22 Thread Geliang Tang
From: Geliang Tang Since "type" is a struct member of network_helper_opts, it makes sense to drop the "type" parameter of start_server_addr() and __start_server() helpers, using opts->type instead in the helpers. If no network_helper_opts is set, use SOCK_STREAM as defau

[PATCH bpf-next v3 1/8] selftests/bpf: Drop struct post_socket_opts

2024-05-22 Thread Geliang Tang
From: Geliang Tang It's not possible to have one generic/common "struct post_socket_opts" for all tests. It's better to have the individual test define its own callback opts struct. So this patch drops struct post_socket_opts, and changes the second parameter of post_socket_cb as &qu

[PATCH bpf-next v3 0/8] use network helpers, part 5

2024-05-22 Thread Geliang Tang
From: Geliang Tang This patchset uses post_socket_cb and post_connect_cb callbacks of struct network_helper_opts to refactor do_test() in bpf_tcp_ca.c to move dctcp test dedicated code out of do_test() into test_dctcp(). v3: - Add 4 new patches, 1-3 are cleanups. 4 adds a new helper

[PATCH net] selftests: hsr: Fix "File exists" errors for hsr_ping

2024-05-21 Thread Geliang Tang
From: Geliang Tang The hsr_ping test reports the following errors: INFO: preparing interfaces for HSRv0. INFO: Initial validation ping. INFO: Longer ping test. INFO: Cutting one link. INFO: Delay the link and drop a few packages. INFO: All good. INFO: preparing interfaces for HSRv1

[PATCH bpf-next] selftests/bpf: Fix prog numbers in test_sockmap

2024-05-17 Thread Geliang Tang
From: Geliang Tang bpf_prog5 and bpf_prog7 are removed from progs/test_sockmap_kern.h in commit d79a32129b21 ("bpf: Selftests, remove prints from sockmap tests"), now there are only 9 progs in it, not 11: SEC("sk_skb1") int bpf_prog1(struct __sk_buff *skb)

[PATCH bpf-next] selftests/bpf: Enable INET_XFRM_TUNNEL in config

2024-05-15 Thread Geliang Tang
From: Geliang Tang The kconfigs CONFIG_INET_XFRM_TUNNEL and CONFIG_INET6_XFRM_TUNNEL are needed by test_tunnel tests. This patch enables them together with the dependent kconfigs CONFIG_INET_IPCOMP and CONFIG_INET6_IPCOMP. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/config | 4

[PATCH bpf-next v2 8/8] selftests/bpf: Use netns helpers in lwt tests

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch uses netns helpers create_netns() and cleanup_netns() in lwt_helpers.h instead of using the local function netns_create() and netns_delete(). For using these helpers. network_helpers.h needs to be included in lwt_helpers.h. Then '#include "network_help

[PATCH bpf-next v2 7/8] selftests/bpf: Use cleanup_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch uses cleanup_netns() helper in BPF tests wide to replace close_netns() and "ip netns del", included assign_reuse.c, crypto_sanity.c, decap_sanity.c, fib_lookup.c, ns_current_pid_tgid.c, sock_destroy.c, sock_iter_batch.c, xdp_dev_bound_only.c and xdp_do_

[PATCH bpf-next v2 6/8] selftests/bpf: Export cleanup_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch adds a new struct member name in struct nstoken, to save the name of the given network namespace. It dups the name string in open_netns() and freed in close_netns(). Then move cleanup_netns() from mptcp.c into network_helpers.c as a public helper. In it the newly

[PATCH bpf-next v2 5/8] selftests/bpf: Use create_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang The newly added helper create_netns() can be used in assign_reuse.c, fib_lookup.c, ns_current_pid_tgid.c, sock_destroy.c and sock_iter_batch.c to simplify the code. It changes the behavior of test fib_lookup.c a little bit, but doesn't affect the results. Signed-off

[PATCH bpf-next v2 4/8] selftests/bpf: Export create_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch moves create_netns() from mptcp.c into network_helpers.c, and export it in network_helpers.h as a public helper. The new helper accepts a string parameter, and uses SYS_NOFAIL() instead of SYS() to execute the command, since SYS() deponds on test__fail() which

[PATCH bpf-next v2 3/8] selftests/bpf: Drop duplicate create_netns

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch drops the duplicate local functions create_netns() in bind_perm.c, bpf_iter_setsockopt.c, setget_sockopt.c, sock_fields.c and tcp_hdr_options.c and uses unshare_netns() instead. A new helper create_netns() will be added in network_helpers.c as a public one. Signed

[PATCH bpf-next v2 2/8] selftests/bpf: Use unshare_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang The newly added helper unshare_netns() can be used to replace unshare() and "ip link set dev lo up" in sk_assign.c, btf_skc_cls_ingress.c and tcp_custom_syncookie.c to simplify the code. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/

[PATCH bpf-next v2 1/8] selftests/bpf: Add unshare_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang Many BPF selftests create new test network namespaces by using CLONE_NEWNET flag to unshare the network namespace, so that the calling process is moved into a new network namespace which is not shared with any previously existing process. So this patch adds a new helper

[PATCH bpf-next v2 0/8] add netns helpers

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patchset addresses Alexei's comment for commit "Handle SIGINT when creating netns" [1]. Export local helpers create_netns() and cleanup_netns() defined in mptcp.c into network_helpers.c as generic ones. For this another helper unshare_netns() is added

Re: [PATCH bpf-next 9/9] selftests/bpf: Use netns helpers in test_tunnel

2024-05-15 Thread Geliang Tang
Sorry, this patch breaks CI. Changes Requested. -Geliang On Wed, 2024-05-15 at 13:59 +0800, Geliang Tang wrote: > From: Geliang Tang > > This patch uses netns helpers create_netns() and cleanup_netns() in > test_tunnel.c instead of using open_netns() and close_netns() > direct

[PATCH bpf-next 9/9] selftests/bpf: Use netns helpers in test_tunnel

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch uses netns helpers create_netns() and cleanup_netns() in test_tunnel.c instead of using open_netns() and close_netns() directly. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/test_tunnel.c| 19 +-- 1 file changed, 9 insertions

[PATCH bpf-next 8/9] selftests/bpf: Use netns helpers in lwt tests

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch uses netns helpers create_netns() and cleanup_netns() in lwt_helpers.h instead of using the local function netns_create() and netns_delete(). For using these helpers. network_helpers.h needs to be included in lwt_helpers.h. Then '#include "network_help

[PATCH bpf-next 7/9] selftests/bpf: Use cleanup_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch uses cleanup_netns() helper in BPF tests wide to replace close_netns() and "ip netns del", included assign_reuse.c, crypto_sanity.c, decap_sanity.c, fib_lookup.c, ns_current_pid_tgid.c, sock_destroy.c, sock_iter_batch.c, xdp_dev_bound_only.c and xdp_do_

[PATCH bpf-next 6/9] selftests/bpf: Export cleanup_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch adds a new struct member name in struct nstoken, to save the name of the given network namespace. It dups the name string in open_netns() and freed in close_netns(). Then move cleanup_netns() from mptcp.c into network_helpers.c as a public helper. In it the newly

[PATCH bpf-next 5/9] selftests/bpf: Use create_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang The newly added helper create_netns() can be used in assign_reuse.c, fib_lookup.c, ns_current_pid_tgid.c, sock_destroy.c and sock_iter_batch.c to simplify the code. It changes the behavior of test fib_lookup.c a little bit, but doesn't affect the results. Signed-off

[PATCH bpf-next 4/9] selftests/bpf: Export create_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch moves create_netns() from mptcp.c into network_helpers.c, and export it in network_helpers.h as a public helper. The new helper accepts a string parameter, and uses SYS_NOFAIL() instead of SYS() to execute the command, since SYS() deponds on test__fail() which

[PATCH bpf-next 3/9] selftests/bpf: Drop duplicate create_netns

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patch drops the duplicate local functions create_netns() in bind_perm.c, bpf_iter_setsockopt.c, setget_sockopt.c, sock_fields.c and tcp_hdr_options.c and uses unshare_netns() instead. A new helper create_netns() will be added in network_helpers.c as a public one. Signed

[PATCH bpf-next 2/9] selftests/bpf: Use unshare_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang The newly added helper unshare_netns() can be used to replace unshare() and "ip link set dev lo up" in sk_assign.c, btf_skc_cls_ingress.c and tcp_custom_syncookie.c to simplify the code. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/

[PATCH bpf-next 1/9] selftests/bpf: Add unshare_netns helper

2024-05-15 Thread Geliang Tang
From: Geliang Tang Many BPF selftests create new test network namespaces by using CLONE_NEWNET flag to unshare the network namespace, so that the calling process is moved into a new network namespace which is not shared with any previously existing process. So this patch adds a new helper

[PATCH bpf-next 0/9] add netns helpers

2024-05-15 Thread Geliang Tang
From: Geliang Tang This patchset addresses Alexei's comment for commit "Handle SIGINT when creating netns" [1]. Export local helpers create_netns() and cleanup_netns() defined in mptcp.c into network_helpers.c as generic ones. For this another helper unshare_netns() is added

[PATCH bpf-next v2 4/4] selftests/bpf: Add post_connect_cb callback

2024-05-14 Thread Geliang Tang
From: Geliang Tang For getting rid of the second parameter of do_test(), this patch adds a new callback post_connect_cb in struct network_helper_opts, it will be invoked after connect_fd_to_addr() in connect_to_fd_opts(). Then define a dctcp dedicated post_connect_cb callback, invoking

[PATCH bpf-next v2 3/4] selftests/bpf: Use connect_to_fd_opts in do_test in bpf_tcp_ca

2024-05-14 Thread Geliang Tang
From: Geliang Tang This patch uses connect_to_fd_opts() instead of using connect_fd_to_fd() and settcpca() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument. Then define a dctcp dedicated post_socket_cb callback stg_post_socket_cb(), invoking both cc_cb

[PATCH bpf-next v2 2/4] selftests/bpf: Use start_server_addr in bpf_tcp_ca

2024-05-14 Thread Geliang Tang
From: Geliang Tang This patch uses start_server_addr() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument instead of using start_server() and settcpca(). Then change the type of the first paramenter of do_test() into a struct network_helper_opts one. Define

[PATCH bpf-next v2 1/4] selftests/bpf: Use post_socket_cb in connect_to_fd_opts

2024-05-14 Thread Geliang Tang
From: Geliang Tang Since the post_socket_cb() callback is added in struct network_helper_opts, it's make sense to use it not only in __start_server(), but also in connect_to_fd_opts(). Then it can be used to set TCP_CONGESTION sockopt. Add a post_socket_opts type member cb_opts into struct

[PATCH bpf-next v2 0/4] use network helpers, part 5

2024-05-14 Thread Geliang Tang
From: Geliang Tang This patchset uses post_socket_cb and post_connect_cb callbacks of struct network_helper_opts to refactor do_test() in bpf_tcp_ca.c to move dctcp test dedicated code out of do_test() into test_dctcp(). Patch 3 adds a new member in post_socket_opts and patch 4 adds a new

[PATCH bpf-next] selftests/bpf: Free strdup memory in xdp_hw_metadata

2024-05-11 Thread Geliang Tang
From: Geliang Tang The strdup() function returns a pointer to a new string which is a duplicate of the string "ifname". Memory for the new string is obtained with malloc(), and need to be freed with free(). This patch adds this missing "free(saved_hwtstamp_ifname)" i

[PATCH bpf-next 3/4] selftests/bpf: Use connect_to_fd_opts in do_test in bpf_tcp_ca

2024-05-10 Thread Geliang Tang
From: Geliang Tang This patch uses connect_to_fd_opts() instead of using connect_fd_to_fd() and settcpca() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument. Then define a dctcp dedicated post_socket_cb callback stg_post_socket_cb(), invoking both cc_cb

[PATCH bpf-next 4/4] selftests/bpf: Add post_connect_cb callback

2024-05-10 Thread Geliang Tang
From: Geliang Tang For getting rid of the second parameter of do_test(), this patch adds a new callback post_connect_cb in struct network_helper_opts, it will be invoked after connect_fd_to_addr() in connect_to_fd_opts(). Then define a dctcp dedicated post_connect_cb callback, invoking

[PATCH bpf-next 2/4] selftests/bpf: Use start_server_addr in bpf_tcp_ca

2024-05-10 Thread Geliang Tang
From: Geliang Tang This patch uses start_server_addr() in do_test() in prog_tests/bpf_tcp_ca.c to accept a struct network_helper_opts argument instead of using start_server() and settcpca(). Then change the type of the first paramenter of do_test() into a struct network_helper_opts one. Define

  1   2   3   >