Use start_server and connect_fd_to_fd
Subsystems (4)
Geliang Tang
reviewerv3 cover Use start_server and connect_fd_to_fd
From: Geliang Tang <[email protected]>
v3:
- split v2 as two patches as Daniel suggested.
- The patch "selftests/bpf: Use start_server in bpf_tcp_ca" is merged by Daniel (thanks), but I forgot to drop 'settimeo(lfd, 0)' in it, so I send a squash-to patch to fix this.
Geliang Tang (2):
Squash to "selftests/bpf: Use start_server in bpf_tcp_ca" selftests/bpf: Use connect_fd_to_fd in bpf_tcp_ca
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v3 1/2 Squash to "selftests/bpf: Use start_server in bpf_tcp_ca"
From: Geliang Tang <[email protected]>
Please add these lines into commit log:
'''settimeo(lfd, 0) is invoked in start_server() already, drop the duplicate one.
'''
--- tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +1 -1
@@ -100,7 +100,7 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) }if (settcpca (lfd, tcp_ca) ||settcpca (fd, tcp_ca) || -settimeo (lfd,0 ) ||settimeo (fd,0 )) +settimeo (fd,0 )) goto done; err =getsockname (lfd, (struct sockaddr *)&sa6, &addrlen);
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v3 2/2 selftests/bpf: Use connect_fd_to_fd in bpf_tcp_ca
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
To simplify the code, use BPF selftests helper connect_fd_to_fd() in bpf_tcp_ca.c instead of open-coding it. This helper is defined in network_helpers.c, and exported in network_helpers.h, which is already included in bpf_tcp_ca.c.
settimeo(fd, 0) is invoked in connect_fd_to_fd() already, drop the duplicate one.
--- tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +2 -9
@@ -78,11 +78,9 @@ static void *server(void *arg)static void do_test (const char *tcp_ca,const struct bpf_map *sk_stg_map) { -struct sockaddr_in6 sa6 = {};ssize_t nr_recv =0 , bytes =0 ;int lfd =-1 , fd =-1 ;pthread_t srv_thread; -socklen_t addrlen =sizeof (sa6);void *thread_ret;char batch[1500 ];int err;
@@ -99,12 +97,7 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map)return ; } -if (settcpca (lfd, tcp_ca) ||settcpca (fd, tcp_ca) || -settimeo (fd,0 )) - goto done; - - err =getsockname (lfd, (struct sockaddr *)&sa6, &addrlen); -if (!ASSERT_NEQ (err,-1 ,"getsockname" )) +if (settcpca (lfd, tcp_ca) ||settcpca (fd, tcp_ca)) goto done;if (sk_stg_map) {
@@ -115,7 +108,7 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) }/* connect to server */ - err =connect (fd, (struct sockaddr *)&sa6, addrlen); + err =connect_fd_to_fd (fd, lfd,0 );if (!ASSERT_NEQ (err,-1 ,"connect" )) goto done;
Signature · 1 line
2.40.1