Skip to contentSkip to conversation

selftests: net: tcp_mmap: clear whole tcp_zerocopy_receive struct

PATCH Applied Eric Dumazet 3 participants 3 messages May 6, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: net: tcp_mmap: clear whole tcp_zerocopy_receive struct

We added fields in tcp_zerocopy_receive structure,
so make sure to clear all fields to not pass garbage to the kernel.

We were lucky because recent additions added 'out' parameters, still we need to clean our reference implementation, before folks copy/paste it.

Fixes c8856c051454 ("tcp-zerocopy: Return inq along with tcp receive zerocopy.")
Fixes 33946518d493 ("tcp-zerocopy: Return sk_err (if set) along with tcp receive zerocopy.")
Cc Arjun Roy <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>
---
 tools/testing/selftests/net/tcp_mmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/tcp_mmap.c +2 -1
index 35505b31e5cc092453ea7b72d9dba45bed2d6549..62171fd638c817dabe2d988f3cfae74522112584 100644
@@ -165,9 +165,10 @@ void *child_thread(void *arg)
 			socklen_t zc_len = sizeof(zc);
 			int res;
 
+			memset(&zc, 0, sizeof(zc));
 			zc.address = (__u64)((unsigned long)addr);
 			zc.length = chunk_size;
-			zc.recv_skip_hint = 0;
+
 			res = getsockopt(fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE,
 					 &zc, &zc_len);
 			if (res == -1)
Signature · 1 line
2.26.2.526.g744177e7f7-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Eric Dumazet

We added fields in tcp_zerocopy_receive structure,
so make sure to clear all fields to not pass garbage to the kernel.

We were lucky because recent additions added 'out' parameters, still we need to clean our reference implementation, before folks copy/paste it.

Quoted 5 lines
Fixes c8856c051454 ("tcp-zerocopy: Return inq along with tcp receive zerocopy.")
Fixes 33946518d493 ("tcp-zerocopy: Return sk_err (if set) along with tcp receive zerocopy.")
Cc Arjun Roy <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>

Thank you for fixing the self test!

Quoted 23 lines
---
 tools/testing/selftests/net/tcp_mmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/tcp_mmap.c +2 -2
index 35505b31e5cc092453ea7b72d9dba45bed2d6549..62171fd638c817dabe2d988f3cfae74522112584 100644
@@ -165,9 +165,10 @@ void *child_thread(void *arg)
                        socklen_t zc_len = sizeof(zc);
                        int res;
 
+                       memset(&zc, 0, sizeof(zc));
                        zc.address = (__u64)((unsigned long)addr);
                        zc.length = chunk_size;
-                       zc.recv_skip_hint = 0;
+
                        res = getsockopt(fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE,
                                         &zc, &zc_len);
                        if (res == -1)
--

2.26.2.526.g744177e7f7-goog

maintainer Applied
#2 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Tue, 5 May 2020 20:51:06 -0700

Quoted 7 lines

We added fields in tcp_zerocopy_receive structure,
so make sure to clear all fields to not pass garbage to the kernel.

We were lucky because recent additions added 'out' parameters, still we need to clean our reference implementation, before folks copy/paste it.

Quoted 5 lines
Fixes c8856c051454 ("tcp-zerocopy: Return inq along with tcp receive zerocopy.")
Fixes 33946518d493 ("tcp-zerocopy: Return sk_err (if set) along with tcp receive zerocopy.")
Cc Arjun Roy <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>

Applied, thanks Eric.