diff mbox series

[net-next,v3,4/7] vsock/test: Adapt send_byte()/recv_byte() to handle MSG_ZEROCOPY

Message ID 20241218-test-vsock-leaks-v3-4-f1a4dcef9228@rbox.co (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series vsock/test: Tests for memory leaks | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 0 (+23) this patch: 0 (+23)
netdev/cc_maintainers warning 1 maintainers not CCed: virtualization@lists.linux.dev
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-12-18--18-00 (tests: 880)

Commit Message

Michal Luczaj Dec. 18, 2024, 2:32 p.m. UTC
For a zercopy 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.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 tools/testing/vsock/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefano Garzarella Dec. 18, 2024, 5:55 p.m. UTC | #1
On Wed, Dec 18, 2024 at 03:32:37PM +0100, Michal Luczaj wrote:
>For a zercopy 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.
>
>Signed-off-by: Michal Luczaj <mhal@rbox.co>
>---
> tools/testing/vsock/util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
>index 81b9a31059d8173a47ea87324da50e7aedd7308a..7058dc614c25f546fc3219d6b9ade2dcef21a9bd 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);
> 	}
> }
>
>-- 
>2.47.1
>
diff mbox series

Patch

diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
index 81b9a31059d8173a47ea87324da50e7aedd7308a..7058dc614c25f546fc3219d6b9ade2dcef21a9bd 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);
 	}
 }