[PATCH bpf-next 0/2] cleanups for sockmap_listen

2023-09-28 Thread Geliang Tang
Two cleanups for sockmap_listen selftests: enable a kconfig and add a new helper. Geliang Tang (2): selftests/bpf: Enable CONFIG_VSOCKETS in config selftests/bpf: Add pair_redir_to_connected helper tools/testing/selftests/bpf/config| 1 + .../selftests/bpf/prog_tests

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

2023-09-28 Thread Geliang Tang
: vsock_socketpair_connectible() failed vsock_unix_redir_connectible:FAIL:1496 So this patch enables it in tools/testing/selftests/bpf/config. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/config | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next 2/2] selftests/bpf: Add pair_redir_to_connected helper

2023-09-28 Thread Geliang Tang
socketpair infos to the new common helper to do the connections. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sockmap_listen.c | 149 -- 1 file changed, 30 insertions(+), 119 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing

[PATCH bpf-next v2 2/2] selftests/bpf: Add pairs_redir_to_connected helper

2023-10-05 Thread Geliang Tang
socketpairs info to the new common helper to do the connections. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sockmap_listen.c | 159 -- 1 file changed, 35 insertions(+), 124 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools

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

2023-10-05 Thread Geliang Tang
: vsock_socketpair_connectible() failed vsock_unix_redir_connectible:FAIL:1496 So this patch enables it in tools/testing/selftests/bpf/config. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/config | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next v2 0/2] cleanups for sockmap_listen

2023-10-05 Thread Geliang Tang
v2: - rename c0/c1 to cli0/cli1, p0/p1 to peer0/perr1 as Daniel suggested. Two cleanups for sockmap_listen selftests: enable a kconfig and add a new helper. Geliang Tang (2): selftests/bpf: Enable CONFIG_VSOCKETS in config selftests/bpf: Add pairs_redir_to_connected helper tools/testing

[PATCH bpf-next v3] selftests/bpf: Add pairs_redir_to_connected helper

2023-10-06 Thread Geliang Tang
socketpairs info to the new common helper to do the connections. Signed-off-by: Geliang Tang --- v3: - move xclose() out of pairs_redir_to_connected. v2: - rename c0/c1 to cli0/cli1, p0/p1 to peer0/perr1 as Daniel suggested. --- .../selftests/bpf/prog_tests/sockmap_listen.c | 146

[bpf-next] selftests/bpf: Drop return in bpf_testmod_exit

2024-01-27 Thread Geliang Tang
From: Geliang Tang bpf_testmod_exit() should not have a return value, so this patch drops this useless 'return' in it. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/too

[PATCH bpf-next v2] selftests/bpf: Drop return in bpf_testmod_exit

2024-01-28 Thread Geliang Tang
From: Geliang Tang bpf_testmod_exit() should not have a return value, so this patch drops this useless 'return' in it. Acked-by: Jiri Olsa Signed-off-by: Geliang Tang --- v2: - rebase on top of latest bpf-next/master. --- tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 2

[PATCH bpf-next] selftests/bpf: Add F_SETFL for fcntl

2024-04-03 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

Re: [PATCH bpf-next] selftests/bpf: Add F_SETFL for fcntl

2024-04-03 Thread Geliang Tang
Hi Jakub, On Wed, 2024-04-03 at 15:29 -0700, John Fastabend wrote: > Jakub Sitnicki wrote: > > Hi Geliang, > > > > On Wed, Apr 03, 2024 at 04:32 PM +08, Geliang Tang wrote: > > > From: Geliang Tang > > > > > > Incorrect arguments are passed

Re: [PATCH bpf-next] selftests/bpf: Add F_SETFL for fcntl

2024-04-07 Thread Geliang Tang
On Thu, 2024-04-04 at 21:47 -0700, John Fastabend wrote: > Geliang Tang wrote: > > Hi Jakub, > >   > > On Wed, 2024-04-03 at 15:29 -0700, John Fastabend wrote: > > > Jakub Sitnicki wrote: > > > > Hi Geliang, > > > > > > > > On Wed

[PATCH bpf-next v2 0/2] export send_byte and send_recv_data

2024-04-07 Thread Geliang Tang
From: Geliang Tang Address Martin's comments for v1 (thanks.) - drop patch 1, "export send_byte helper". - drop "WRITE_ONCE(arg.stop, 0)". - rebased. send_recv_data will be re-used in MPTCP bpf tests, but not included in this set because it depends on other patches

[PATCH bpf-next v2 1/2] selftests/bpf: Add struct send_recv_arg

2024-04-07 Thread Geliang Tang
From: Geliang Tang Avoid setting total_bytes and stop as global variables, this patch adds a new struct named send_recv_arg to pass arguments between threads. Put these two variables together with fd into this struct and pass it to server thread, so that server thread can access these two

[PATCH bpf-next v2 2/2] selftests/bpf: Export send_recv_data helper

2024-04-07 Thread Geliang Tang
From: Geliang Tang This patch extracts the code to send and receive data into a new helper named send_recv_data() in network_helpers.c and export it in network_helpers.h. This helper will be used for MPTCP BPF selftests. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf

Re: [PATCH bpf-next v2 2/2] selftests/bpf: Export send_recv_data helper

2024-04-08 Thread Geliang Tang
Hi Martin, On Mon, 2024-04-08 at 11:45 +0800, Geliang Tang wrote: > From: Geliang Tang > > This patch extracts the code to send and receive data into a new > helper named send_recv_data() in network_helpers.c and export it > in network_helpers.h. > > This helper will

[PATCH bpf-next v3 0/4] export send_recv_data

2024-04-09 Thread Geliang Tang
From: Geliang Tang v3: - add two more patches. - use log_err instead of ASSERT in v3. - let send_recv_data return int as Martin suggested. v2: Address Martin's comments for v1 (thanks.) - drop patch 1, "export send_byte helper". - drop "WRITE_ONCE(arg.s

[PATCH bpf-next v3 1/4] selftests/bpf: Use log_err in network_helpers

2024-04-09 Thread Geliang Tang
From: Geliang Tang The helpers ASSERT_OK/GE/OK_PTR should avoid using in public functions. This patch uses log_err() to replace them in network_helpers.c. And drop '#include "test_progs.h"' in it, include and instead. Signed-off-by: Geliang Tang --- tools/t

[PATCH bpf-next v3 2/4] selftests/bpf: Add struct send_recv_arg

2024-04-09 Thread Geliang Tang
From: Geliang Tang Avoid setting total_bytes and stop as global variables, this patch adds a new struct named send_recv_arg to pass arguments between threads. Put these two variables together with fd into this struct and pass it to server thread, so that server thread can access these two

[PATCH bpf-next v3 3/4] selftests/bpf: Export send_recv_data helper

2024-04-09 Thread Geliang Tang
From: Geliang Tang This patch extracts the code to send and receive data into a new helper named send_recv_data() in network_helpers.c and export it in network_helpers.h. This helper will be used for MPTCP BPF selftests. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf

[PATCH bpf-next v3 4/4] selftests/bpf: Support nonblock for send_recv_data

2024-04-09 Thread Geliang Tang
From: Geliang Tang Some tests, such as the MPTCP bpf tests, require send_recv_data helper to run in nonblock mode. This patch adds nonblock support for send_recv_data(). Check if it is currently in nonblock mode, and if so, ignore EWOULDBLOCK to continue sending and receiving. Signed-off-by

Re: [PATCH bpf-next v3 3/4] selftests/bpf: Export send_recv_data helper

2024-04-09 Thread Geliang Tang
On Tue, 2024-04-09 at 18:57 +0800, Geliang Tang wrote: > From: Geliang Tang > > This patch extracts the code to send and receive data into a new > helper named send_recv_data() in network_helpers.c and export it > in network_helpers.h. > > This helper will be used fo

[PATCH bpf-next v4 0/3] export send_recv_data

2024-04-09 Thread Geliang Tang
From: Geliang Tang v4: - fix a bug in v3, it should be 'if (err)', not 'if (!err)'. - move "selftests/bpf: Use log_err in network_helpers" out of this series. v3: - add two more patches. - use log_err instead of ASSERT in v3. - let send_recv_data retur

[PATCH bpf-next v4 1/3] selftests/bpf: Add struct send_recv_arg

2024-04-09 Thread Geliang Tang
From: Geliang Tang Avoid setting total_bytes and stop as global variables, this patch adds a new struct named send_recv_arg to pass arguments between threads. Put these two variables together with fd into this struct and pass it to server thread, so that server thread can access these two

[PATCH bpf-next v4 2/3] selftests/bpf: Export send_recv_data helper

2024-04-09 Thread Geliang Tang
From: Geliang Tang This patch extracts the code to send and receive data into a new helper named send_recv_data() in network_helpers.c and export it in network_helpers.h. This helper will be used for MPTCP BPF selftests. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf

[PATCH bpf-next v4 3/3] selftests/bpf: Support nonblock for send_recv_data

2024-04-09 Thread Geliang Tang
From: Geliang Tang Some tests, such as the MPTCP bpf tests, require send_recv_data helper to run in nonblock mode. This patch adds nonblock support for send_recv_data(). Check if it is currently in nonblock mode, and if so, ignore EWOULDBLOCK to continue sending and receiving. Signed-off-by

[PATCH bpf-next 00/14] use start_server and connect_to helpers

2024-04-10 Thread Geliang Tang
From: Geliang Tang This patchset uses public helpers start_server_* and connect_to_* defined in network_helpers.c to drop duplicate code. Geliang Tang (14): selftests/bpf: Add start_server_addr helper selftests/bpf: Use start_server_addr in cls_redirect selftests/bpf: Use connect_to_addr

[PATCH bpf-next 01/14] selftests/bpf: Add start_server_addr helper

2024-04-10 Thread Geliang Tang
From: Geliang Tang In order to pair up with connect_to addr(), this patch adds a new helper start_server_addr(), which is a wrapper of __start_server(), and accepts an argument 'addr' of 'struct sockaddr' type instead of a string type argument like start_server(). Signed-

[PATCH bpf-next 02/14] selftests/bpf: Use start_server_addr in cls_redirect

2024-04-10 Thread Geliang Tang
From: Geliang Tang Include network_helpers.h in prog_tests/cls_redirect.c, use the newly added public helper start_server_addr() instead of the local defined function start_server(). This can avoid duplicate code. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/cls_redirect.c

[PATCH bpf-next 03/14] selftests/bpf: Use connect_to_addr in cls_redirect

2024-04-10 Thread Geliang Tang
From: Geliang Tang This patch uses public helper connect_to_addr() exported in network_helpers.h instead of the local defined function connect_to_server() in prog_tests/cls_redirect.c. This can avoid duplicate code. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/cls_redirect.c

[PATCH bpf-next 04/14] selftests/bpf: Use start_server_addr in sk_assign

2024-04-10 Thread Geliang Tang
From: Geliang Tang Include network_helpers.h in prog_tests/sk_assign.c, use the newly added public helper start_server_addr() instead of the local defined function start_server(). This can avoid duplicate code. The code set SO_RCVTIMEO timeout as timeo_sec (3s) can be dropped, since

[PATCH bpf-next 05/14] selftests/bpf: Use connect_to_addr in sk_assign

2024-04-10 Thread Geliang Tang
From: Geliang Tang This patch uses public helper connect_to_addr() exported in network_helpers.h instead of the local defined function connect_to_server() in prog_tests/sk_assign.c. This can avoid duplicate code. The code set SO_SNDTIMEO timeout as timeo_sec (3s) can be dropped, since

[PATCH bpf-next 06/14] selftests/bpf: Use log_err in network_helpers

2024-04-10 Thread Geliang Tang
From: Geliang Tang The helpers ASSERT_OK/GE/OK_PTR should avoid using in public functions. This patch uses log_err() to replace them in network_helpers.c. And drop '#include "test_progs.h"' in it, include and instead. Signed-off-by: Geliang Tang --- tools/t

[PATCH bpf-next 07/14] selftests/bpf: Use start_server_addr in test_sock_addr

2024-04-10 Thread Geliang Tang
From: Geliang Tang Include network_helpers.h in test_sock_addr.c, use the newly added public helper start_server_addr() instead of the local defined function start_server(). This can avoid duplicate code. In order to use functions defined in network_helpers.c, Makefile needs to be updated and

[PATCH bpf-next 09/14] selftests/bpf: Add function pointer for __start_server

2024-04-10 Thread Geliang Tang
From: Geliang Tang __start_server() sets SO_REUSPORT through setsockopt() when the parameter 'reuseport' is set. This patch makes it more flexible by accepting a function pointer named setsockopt. Then the original start_reuseport_server() can be implemented by passing in a new

[PATCH bpf-next 08/14] selftests/bpf: Use connect_to_addr in test_sock_addr

2024-04-10 Thread Geliang Tang
From: Geliang Tang This patch uses public helper connect_to_addr() exported in network_helpers.h instead of the local defined function connect_to_server() in test_sock_addr.c. This can avoid duplicate code. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sock_addr.c | 36

[PATCH bpf-next 10/14] selftests/bpf: Add start_server_setsockopt helper

2024-04-10 Thread Geliang Tang
From: Geliang Tang This patch adds a new helper start_server_setsockopt(), which is a wrapper of __start_server(), and accepts a function pointer setsockopt as a parameter. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 6 ++ tools/testing/selftests/bpf

[PATCH bpf-next 11/14] selftests/bpf: Use start_server_setsockopt in sockopt_inherit

2024-04-10 Thread Geliang Tang
From: Geliang Tang Include network_helpers.h in prog_tests/sockopt_inherit.c, use public helpers make_sockaddr() and start_server_setsockopt() instead of the local defined function start_server(). This can avoid duplicate code. Signed-off-by: Geliang Tang --- .../bpf/prog_tests

[PATCH bpf-next 12/14] selftests/bpf: Use connect_to_fd in sockopt_inherit

2024-04-10 Thread Geliang Tang
From: Geliang Tang This patch uses public helper connect_to_fd() exported in network_helpers.h instead of the local defined function connect_to_server() in prog_tests/sockopt_inherit.c. This can avoid duplicate code. Signed-off-by: Geliang Tang --- .../bpf/prog_tests/sockopt_inherit.c

[PATCH bpf-next 13/14] selftests/bpf: Use start_server_* in test_tcp_check_syncookie

2024-04-10 Thread Geliang Tang
From: Geliang Tang Include network_helpers.h in test_tcp_check_syncookie_user.c, use public helpers start_server_addr() and start_server_setsockopt() in it instead of the local defined function start_server(). This can avoid duplicate code. In order to use functions defined in network_helpers.c

[PATCH bpf-next 14/14] selftests/bpf: Use connect_to_addr in test_tcp_check_syncookie

2024-04-10 Thread Geliang Tang
From: Geliang Tang This patch uses public helper connect_to_addr() exported in network_helpers.h instead of the local defined function connect_to_server() in test_tcp_check_syncookie_user.c. This can avoid duplicate code. Signed-off-by: Geliang Tang --- .../bpf/test_tcp_check_syncookie_user.c

Re: [PATCH bpf-next 06/14] selftests/bpf: Use log_err in network_helpers

2024-04-10 Thread Geliang Tang
On Wed, 2024-04-10 at 15:29 +0800, Geliang Tang wrote: > From: Geliang Tang > > The helpers ASSERT_OK/GE/OK_PTR should avoid using in public > functions. > This patch uses log_err() to replace them in network_helpers.c. > > And drop '#include "test_progs.h&q

[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 self

[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 it

[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 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 strcu

[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 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

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 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

[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 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 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. (tha

[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/ne

[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

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 > > unneces

[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 Y

[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-

[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 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 commen

[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 it

[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 h

[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 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

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

2024-06-13 Thread Geliang Tang
Superseded, will send a v3 soon. Thanks, -Geliang On Wed, 2024-06-12 at 22:41 +0800, Geliang Tang wrote: > From: Geliang Tang > > v2: >  - update patch 2, extract a new helper start_client. >  - drop patch 3, keep must_fail in network_helper_opts. > > Drop ty

[PATCH mptcp-next v3 0/6] use network helpers, part 7

2024-06-17 Thread Geliang Tang
From: Geliang Tang v3: - rename start_client to client_socket - Use connect_to_addr in connect_to_fd_opt 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

[PATCH mptcp-next v3 1/6] selftests/bpf: Drop type from network_helper_opts

2024-06-17 Thread Geliang Tang
From: Geliang Tang The opts.{type, noconnect} 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 it

[PATCH mptcp-next v3 2/6] selftests/bpf: Use connect_to_addr in connect_to_fd_opt

2024-06-17 Thread Geliang Tang
From: Geliang Tang This patch moves "post_socket_cb" and "noconnect" into connect_to_addr(), then connect_to_fd_opts() can be implemented by getsockname() and connect_to_addr(). This change makes connect_to_* interfaces more unified. Signed-off-by: Geliang Tang --- tools/t

[PATCH mptcp-next v3 3/6] selftests/bpf: Add client_socket helper

2024-06-17 Thread Geliang Tang
From: Geliang Tang This patch extracts a new helper client_socket() 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 client_socket() and connect_fd_to_addr(). This helper can be used in connect_to

[PATCH mptcp-next v3 4/6] selftests/bpf: Drop noconnect from network_helper_opts

2024-06-17 Thread Geliang Tang
From: Geliang Tang In test_bpf_ip_check_defrag_ok(), the new helper client_socket() can be used to replace connect_to_fd_opts() with "noconnect" opts, and the strcut member "noconnect" of network_helper_opts can be dropped now, always connect to server in connect_to_fd_op

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

2024-06-17 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 mptcp-next v3 6/6] selftests/bpf: Use start_server_str in test_tcp_check_syncookie_user

2024-06-17 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

Re: [PATCH mptcp-next v3 0/6] use network helpers, part 7

2024-06-17 Thread Geliang Tang
Sorry, v3 breaks the CI. Changes Requested. -Geliang On Mon, 2024-06-17 at 16:33 +0800, Geliang Tang wrote: > From: Geliang Tang > > v3: >  - rename start_client to client_socket >  - Use connect_to_addr in connect_to_fd_opt > > v2: >  - update patch 2, extract a

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

2024-06-17 Thread Geliang Tang
From: Geliang Tang v4: - fix errors reported by CI. v3: - rename start_client to client_socket - Use connect_to_addr in connect_to_fd_opt 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

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

2024-06-17 Thread Geliang Tang
From: Geliang Tang The opts.{type, noconnect} 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 it

[PATCH bpf-next v4 2/6] selftests/bpf: Use connect_to_addr in connect_to_fd_opt

2024-06-17 Thread Geliang Tang
From: Geliang Tang This patch moves "post_socket_cb" and "noconnect" into connect_to_addr(), then connect_to_fd_opts() can be implemented by getsockname() and connect_to_addr(). This change makes connect_to_* interfaces more unified. Signed-off-by: Geliang Tang --- tools/t

[PATCH bpf-next v4 3/6] selftests/bpf: Add client_socket helper

2024-06-17 Thread Geliang Tang
From: Geliang Tang This patch extracts a new helper client_socket() 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 client_socket() and connect_fd_to_addr(). This helper can be used in connect_to

[PATCH bpf-next v4 4/6] selftests/bpf: Drop noconnect from network_helper_opts

2024-06-17 Thread Geliang Tang
From: Geliang Tang In test_bpf_ip_check_defrag_ok(), the new helper client_socket() can be used to replace connect_to_fd_opts() with "noconnect" opts, and the strcut member "noconnect" of network_helper_opts can be dropped now, always connect to server in connect_to_fd_op

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

2024-06-17 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 v4 6/6] selftests/bpf: Use start_server_str in test_tcp_check_syncookie_user

2024-06-17 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 v5 0/6] use network helpers, part 7

2024-06-18 Thread Geliang Tang
From: Geliang Tang v5: - update patch 1, add getsockopt(SO_PROTOCOL) in connect_to_fd() to fix errors reported by CI. v4: - fix errors reported by CI. v3: - rename start_client to client_socket - Use connect_to_addr in connect_to_fd_opt v2: - update patch 2, extract a new helper

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

2024-06-18 Thread Geliang Tang
From: Geliang Tang The opts.{type, noconnect} 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 it

[PATCH bpf-next v5 2/6] selftests/bpf: Use connect_to_addr in connect_to_fd_opt

2024-06-18 Thread Geliang Tang
From: Geliang Tang This patch moves "post_socket_cb" and "noconnect" into connect_to_addr(), then connect_to_fd_opts() can be implemented by getsockname() and connect_to_addr(). This change makes connect_to_* interfaces more unified. Signed-off-by: Geliang Tang --- tools/t

[PATCH bpf-next v5 3/6] selftests/bpf: Add client_socket helper

2024-06-18 Thread Geliang Tang
From: Geliang Tang This patch extracts a new helper client_socket() 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 client_socket() and connect_fd_to_addr(). This helper can be used in connect_to

[PATCH bpf-next v5 4/6] selftests/bpf: Drop noconnect from network_helper_opts

2024-06-18 Thread Geliang Tang
From: Geliang Tang In test_bpf_ip_check_defrag_ok(), the new helper client_socket() can be used to replace connect_to_fd_opts() with "noconnect" opts, and the strcut member "noconnect" of network_helper_opts can be dropped now, always connect to server in connect_to_fd_op

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

2024-06-18 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 v5 6/6] selftests/bpf: Use start_server_str in test_tcp_check_syncookie_user

2024-06-18 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 v6 0/6] use network helpers, part 7

2024-06-20 Thread Geliang Tang
From: Geliang Tang v6: - update ASSERT strings in patch 4 as Eduard suggested. (thanks) v5: - update patch 1, add getsockopt(SO_PROTOCOL) in connect_to_fd() to fix errors reported by CI. v4: - fix errors reported by CI. v3: - rename start_client to client_socket - Use connect_to_addr in

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

2024-06-20 Thread Geliang Tang
From: Geliang Tang The opts.{type, noconnect} 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 it

[PATCH bpf-next v6 2/6] selftests/bpf: Use connect_to_addr in connect_to_fd_opt

2024-06-20 Thread Geliang Tang
From: Geliang Tang This patch moves "post_socket_cb" and "noconnect" into connect_to_addr(), then connect_to_fd_opts() can be implemented by getsockname() and connect_to_addr(). This change makes connect_to_* interfaces more unified. Acked-by: Eduard Zingerman Signed-

[PATCH bpf-next v6 3/6] selftests/bpf: Add client_socket helper

2024-06-20 Thread Geliang Tang
From: Geliang Tang This patch extracts a new helper client_socket() 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 client_socket() and connect_fd_to_addr(). This helper can be used in connect_to

[PATCH bpf-next v6 4/6] selftests/bpf: Drop noconnect from network_helper_opts

2024-06-20 Thread Geliang Tang
From: Geliang Tang In test_bpf_ip_check_defrag_ok(), the new helper client_socket() can be used to replace connect_to_fd_opts() with "noconnect" opts, and the strcut member "noconnect" of network_helper_opts can be dropped now, always connect to server in connect_to_fd_opts(

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

2024-06-20 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. Acked-by: Eduard Zingerman Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests

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

2024-06-20 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. Acked-by: Eduard Zingerman Signed-off-by: Geliang Tang --- .../bpf/test_tcp_check_syncookie_user.c | 29

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

2024-06-21 Thread Geliang Tang
From: Geliang Tang This patch set uses network helpers in sockmap_ktls and sk_lookup, and drop three local helpers tcp_server(), inetaddr_len() and make_socket() in them. Geliang Tang (6): selftests/bpf: Use start_server in sockmap_ktls selftests/bpf: Use connect_to_fd in sockmap_ktls

[PATCH bpf-next 1/6] selftests/bpf: Use start_server in sockmap_ktls

2024-06-21 Thread Geliang Tang
From: Geliang Tang Include network_helpers.h in prog_tests/sockmap_ktls.c, use public network helper start_server() instead of the local defined function tcp_server(). This can avoid duplicate code. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sockmap_ktls.c| 18

[PATCH bpf-next 2/6] selftests/bpf: Use connect_to_fd in sockmap_ktls

2024-06-21 Thread Geliang Tang
From: Geliang Tang Use public network helper connect_to_fd() instead of open-coding it in prog_tests/sockmap_ktls.c. This can avoid duplicate code. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sockmap_ktls.c| 14 ++ 1 file changed, 2 insertions(+), 12

[PATCH bpf-next 3/6] selftests/bpf: Use start_server_str in sk_lookup

2024-06-21 Thread Geliang Tang
From: Geliang Tang This patch uses public helper start_server_addr() in make_server() in prog_tests/sk_lookup.c to avoid duplicate code. Add a helper setsockopts() to set SOL_CUSTOM sockopt looply, set it to setsockopt pointer of struct network_helper_opts, and pass it to start_server_addr

[PATCH bpf-next 4/6] selftests/bpf: Drop inetaddr_len in sk_lookup

2024-06-21 Thread Geliang Tang
From: Geliang Tang This patch adds a new parameter "len" for make_socket() to get the length of the address by make_sockaddr(), then local helper inetaddr_len() can be dropped. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sk_lookup.c | 30 +

[PATCH bpf-next 5/6] selftests/bpf: Use connect_to_fd in sk_lookup

2024-06-21 Thread Geliang Tang
From: Geliang Tang This patch uses public helper connect_to_fd() exported in network_helpers.h instead of using make_socket() and connect() in prog_tests/sk_lookup.c. This can simplify the code. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/sk_lookup.c | 33

  1   2   3   4   5   >