diff options
author | Michal Luczaj <mhal@rbox.co> | 2024-12-19 10:49:31 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-12-23 10:28:01 -0800 |
commit | f52e7f593b49344b9497c289cbb2ada213f60a7a (patch) | |
tree | 1398afcaf8e3fb73a72a8dff09625414ee6a4854 | |
parent | 50f9434463a0be5b972ee442ba6a9704c9afb02a (diff) |
vsock/test: Adapt send_byte()/recv_byte() to handle MSG_ZEROCOPY
For a zerocopy send(), buffer (always byte 'A') needs to be preserved (thus
it can not be on the stack) or the data recv()ed check in recv_byte() might
fail.
While there, change the printf format to 0x%02x so the '\0' bytes can be
seen.
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://patch.msgid.link/20241219-test-vsock-leaks-v4-4-a416e554d9d7@rbox.co
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | tools/testing/vsock/util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c index 81b9a31059d8..7058dc614c25 100644 --- a/tools/testing/vsock/util.c +++ b/tools/testing/vsock/util.c @@ -401,7 +401,7 @@ void recv_buf(int fd, void *buf, size_t len, int flags, ssize_t expected_ret) */ void send_byte(int fd, int expected_ret, int flags) { - const uint8_t byte = 'A'; + static const uint8_t byte = 'A'; send_buf(fd, &byte, sizeof(byte), flags, expected_ret); } @@ -420,7 +420,7 @@ void recv_byte(int fd, int expected_ret, int flags) recv_buf(fd, &byte, sizeof(byte), flags, expected_ret); if (byte != 'A') { - fprintf(stderr, "unexpected byte read %c\n", byte); + fprintf(stderr, "unexpected byte read 0x%02x\n", byte); exit(EXIT_FAILURE); } } |