[RFC PATCH bpf-next 08/14] selftests/bpf: Fix off by one error in remove_all_established

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

 



This test is meant to destroy all sockets left in the current bucket,
but currently destroys all sockets except the last one. This worked for
the normal TCP socket iterator tests, since the last socket was removed
from the bucket anyway when its counterpart was destroyed. However, with
socket hash iterators this doesn't work, since the last socket stays in
the bucket until it's closed or destroyed explicitly. Fix this before
the next patch which adds test coverage for socket hash iterators.

Signed-off-by: Jordan Rife <jordan@xxxxxxxx>
---
 tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c b/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c
index 27781df8f2fb..e6fc4fd994f9 100644
--- a/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c
+++ b/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c
@@ -463,7 +463,7 @@ static void remove_all_established(int family, int sock_type, const char *addr,
 	for (i = 0; i < established_socks_len - 1; i++) {
 		close_idx[i] = get_nth_socket(established_socks,
 					      established_socks_len, link,
-					      listen_socks_len + i);
+					      listen_socks_len + i + 1);
 		if (!ASSERT_GE(close_idx[i], 0, "close_idx"))
 			return;
 	}
-- 
2.43.0





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux