mbox series

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

Message ID cover.1716520609.git.tanggeliang@kylinos.cn
Headers show
Series use network helpers, part 5 | expand

Message

Geliang Tang May 24, 2024, 3:21 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

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 "type" as the individual arg to start_server_addr,
   connect_to_addr and start_server_str.

v3:
 - Add 4 new patches, 1-3 are cleanups. 4 adds a new helper.
 - address Martin's comments in v2.

v2:
 - rebased on commit "selftests/bpf: Add test for the use of new args in
 cong_control"

Geliang Tang (6):
  selftests/bpf: Drop struct post_socket_opts
  selftests/bpf: Add start_server_str helper
  selftests/bpf: Use post_socket_cb in connect_to_fd_opts
  selftests/bpf: Use start_server_str in bpf_tcp_ca
  selftests/bpf: Use connect_to_fd_opts in do_test in bpf_tcp_ca
  selftests/bpf: Add post_connect_cb callback

 tools/testing/selftests/bpf/network_helpers.c |  39 +++--
 tools/testing/selftests/bpf/network_helpers.h |   9 +-
 .../selftests/bpf/prog_tests/bpf_tcp_ca.c     | 138 +++++++++++++-----
 .../bpf/prog_tests/sockopt_inherit.c          |   2 +-
 .../bpf/test_tcp_check_syncookie_user.c       |   4 +-
 5 files changed, 133 insertions(+), 59 deletions(-)

Comments

Martin KaFai Lau May 24, 2024, 11:16 p.m. UTC | #1
On 5/23/24 8:21 PM, Geliang Tang wrote:
> +static int cc_cb(int fd, void *opts)
> +{
> +	struct cb_opts *cb_opts = (struct cb_opts *)opts;
> +
> +	return setsockopt(fd, SOL_TCP, TCP_CONGESTION, cb_opts->cc,
> +			  strlen(cb_opts->cc) + 1);

Since this cc_cb is in the test itself, it should use ASSERT_* such that the 
error output will be more useful. The same (use ASSERT_* whenever makes sense) 
goes for all cb functions in this set. In particular for the cb that does more 
than setsockopt in patch 5.
Martin KaFai Lau May 24, 2024, 11:18 p.m. UTC | #2
On 5/23/24 8:21 PM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> 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().

Overall looks good. It needs another respin.

pw-bot: cr