selftests: net: retry when bind returns EBUSY in xdp_helper

When binding the XDP socket, we may get EBUSY because the deferred
destructor of XDP socket in previous test has not been executed yet. If
that is the case, just sleep and retry some times.

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://patch.msgid.link/20250425071018.36078-4-minhquangbui99@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Bui Quang Minh
2025-04-28 15:49:10 -07:00
committed by Jakub Kicinski
parent 5d346179e7
commit b2b4555cf2
+15 -5
View File
@@ -38,6 +38,7 @@ int main(int argc, char **argv)
struct sockaddr_xdp sxdp = { 0 };
int num_desc = NUM_DESC;
void *umem_area;
int retry = 0;
int ifindex;
int sock_fd;
int queue;
@@ -102,11 +103,20 @@ int main(int argc, char **argv)
}
}
if (bind(sock_fd, (struct sockaddr *)&sxdp, sizeof(sxdp)) != 0) {
munmap(umem_area, UMEM_SZ);
perror("bind failed");
close(sock_fd);
return 1;
while (1) {
if (bind(sock_fd, (struct sockaddr *)&sxdp, sizeof(sxdp)) == 0)
break;
if (errno == EBUSY && retry < 3) {
retry++;
sleep(1);
continue;
} else {
perror("bind failed");
munmap(umem_area, UMEM_SZ);
close(sock_fd);
return 1;
}
}
ksft_ready();