diff mbox series

[liburing,5/7] test/send: don't use SO_ZEROCOPY if not available

Message ID ecc68eb72d8aff9bd3b16a0f5a3ea005b25126c3.1676941370.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series test sends with huge pages | expand

Commit Message

Pavel Begunkov Feb. 21, 2023, 1:05 a.m. UTC
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/send-zerocopy.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index f1277fa..481aa28 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -197,11 +197,9 @@  static int create_socketpair_ip(struct sockaddr_storage *addr,
 				bool ipv6, bool client_connect,
 				bool msg_zc, bool tcp)
 {
-	int family;
 	socklen_t addr_size;
-	int ret, val;
-	int listen_sock = -1;
-	int sock;
+	int family, sock, listen_sock = -1;
+	int ret;
 
 	memset(addr, 0, sizeof(*addr));
 	if (ipv6) {
@@ -278,11 +276,17 @@  static int create_socketpair_ip(struct sockaddr_storage *addr,
 		}
 	}
 	if (msg_zc) {
-		val = 1;
+#ifdef SO_ZEROCOPY
+		int val = 1;
+
 		if (setsockopt(*sock_client, SOL_SOCKET, SO_ZEROCOPY, &val, sizeof(val))) {
 			perror("setsockopt zc");
 			return 1;
 		}
+#else
+		fprintf(stderr, "no SO_ZEROCOPY\n");
+		return 1;
+#endif
 	}
 	if (tcp) {
 		*sock_server = accept(listen_sock, NULL, NULL);
@@ -502,7 +506,10 @@  static int test_inet_send(struct io_uring *ring)
 			continue;
 		if (swap_sockets && !tcp)
 			continue;
-
+#ifndef SO_ZEROCOPY
+		if (msg_zc_set)
+			continue;
+#endif
 		ret = create_socketpair_ip(&addr, &sock_client, &sock_server, ipv6,
 				 client_connect, msg_zc_set, tcp);
 		if (ret) {