Patch "selftests/bpf: Fix a CI failure caused by vsock write" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    selftests/bpf: Fix a CI failure caused by vsock write

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     selftests-bpf-fix-a-ci-failure-caused-by-vsock-write.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 341b41264999a57e94288ff6194829f1bc65b554
Author: Xu Kuohai <xukuohai@xxxxxxxxxx>
Date:   Fri Sep 1 11:10:37 2023 +0800

    selftests/bpf: Fix a CI failure caused by vsock write
    
    [ Upstream commit c1970e26bdc1209974bb5cf31cc23f2b7ad6ce50 ]
    
    While commit 90f0074cd9f9 ("selftests/bpf: fix a CI failure caused by vsock sockmap test")
    fixes a receive failure of vsock sockmap test, there is still a write failure:
    
    Error: #211/79 sockmap_listen/sockmap VSOCK test_vsock_redir
    Error: #211/79 sockmap_listen/sockmap VSOCK test_vsock_redir
      ./test_progs:vsock_unix_redir_connectible:1501: egress: write: Transport endpoint is not connected
      vsock_unix_redir_connectible:FAIL:1501
      ./test_progs:vsock_unix_redir_connectible:1501: ingress: write: Transport endpoint is not connected
      vsock_unix_redir_connectible:FAIL:1501
      ./test_progs:vsock_unix_redir_connectible:1501: egress: write: Transport endpoint is not connected
      vsock_unix_redir_connectible:FAIL:1501
    
    The reason is that the vsock connection in the test is set to ESTABLISHED state
    by function virtio_transport_recv_pkt, which is executed in a workqueue thread,
    so when the user space test thread runs before the workqueue thread, this
    problem occurs.
    
    To fix it, before writing the connection, wait for it to be connected.
    
    Fixes: d61bd8c1fd02 ("selftests/bpf: add a test case for vsock sockmap")
    Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20230901031037.3314007-1-xukuohai@xxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h b/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h
index d12665490a905..36d829a65aa44 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h
@@ -179,6 +179,32 @@
 		__ret;                                                         \
 	})
 
+static inline int poll_connect(int fd, unsigned int timeout_sec)
+{
+	struct timeval timeout = { .tv_sec = timeout_sec };
+	fd_set wfds;
+	int r, eval;
+	socklen_t esize = sizeof(eval);
+
+	FD_ZERO(&wfds);
+	FD_SET(fd, &wfds);
+
+	r = select(fd + 1, NULL, &wfds, NULL, &timeout);
+	if (r == 0)
+		errno = ETIME;
+	if (r != 1)
+		return -1;
+
+	if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &eval, &esize) < 0)
+		return -1;
+	if (eval != 0) {
+		errno = eval;
+		return -1;
+	}
+
+	return 0;
+}
+
 static inline int poll_read(int fd, unsigned int timeout_sec)
 {
 	struct timeval timeout = { .tv_sec = timeout_sec };
diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
index 5674a9d0cacf0..8df8cbb447f10 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
@@ -1452,11 +1452,18 @@ static int vsock_socketpair_connectible(int sotype, int *v0, int *v1)
 	if (p < 0)
 		goto close_cli;
 
+	if (poll_connect(c, IO_TIMEOUT_SEC) < 0) {
+		FAIL_ERRNO("poll_connect");
+		goto close_acc;
+	}
+
 	*v0 = p;
 	*v1 = c;
 
 	return 0;
 
+close_acc:
+	close(p);
 close_cli:
 	close(c);
 close_srv:



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux