Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Yang Yang <yang.yang29@zte.com.cn>
To: davem@davemloft.net, edumazet@google.com,
	willemdebruijn.kernel@gmail.com
Cc: yang.yang29@zte.com.cn, kuba@kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	netdev@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org,
	zhang.yunkai@zte.com.cn, xu.xin16@zte.com.cn,
	Xuexin Jiang <jiang.xuexin@zte.com.cn>
Subject: [PATCH linux-next 1/3] selftests: net: udpgso_bench_rx: Fix verifty exceptions
Date: Mon, 17 Apr 2023 20:24:23 +0800	[thread overview]
Message-ID: <20230417122423.193237-1-yang.yang29@zte.com.cn> (raw)
In-Reply-To: <202304172017351308785@zte.com.cn>

From: Zhang Yunkai (CGEL ZTE) <zhang.yunkai@zte.com.cn>

The verification function of this test case is likely to encounter the
following error, which may confuse users.

Executing the following command fails:
bash# udpgso_bench_tx -l 4 -4 -D "$DST"
bash# udpgso_bench_tx -l 4 -4 -D "$DST" -S 0
bash# udpgso_bench_rx -4 -G -S 1472 -v
udpgso_bench_rx: data[1472]: len 2944, a(97) != q(113)

This is because the sending buffers are not aligned by 26 bytes, and the
GRO is not merged sequentially, and the receiver does not judge this
situation. We do the validation after the data is split at the receiving
end, just as the application actually uses this feature.

Signed-off-by: Zhang Yunkai (CGEL ZTE) <zhang.yunkai@zte.com.cn>
Reviewed-by: xu xin (CGEL ZTE) <xu.xin16@zte.com.cn>
Reviewed-by: Yang Yang (CGEL ZTE) <yang.yang29@zte.com.cn>
Cc: Xuexin Jiang (CGEL ZTE) <jiang.xuexin@zte.com.cn>
---
 tools/testing/selftests/net/udpgso_bench_rx.c | 38 +++++++++++++++++++++------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c
index f35a924d4a30..a5b7f30659a5 100644
--- a/tools/testing/selftests/net/udpgso_bench_rx.c
+++ b/tools/testing/selftests/net/udpgso_bench_rx.c
@@ -189,16 +189,16 @@ static char sanitized_char(char val)
 	return (val >= 'a' && val <= 'z') ? val : '.';
 }
 
-static void do_verify_udp(const char *data, int len)
+static void do_verify_udp(const char *data, int start, int len)
 {
-	char cur = data[0];
+	char cur = data[start];
 	int i;
 
 	/* verify contents */
 	if (cur < 'a' || cur > 'z')
 		error(1, 0, "data initial byte out of range");
 
-	for (i = 1; i < len; i++) {
+	for (i = start + 1; i < start + len; i++) {
 		if (cur == 'z')
 			cur = 'a';
 		else
@@ -212,6 +212,24 @@ static void do_verify_udp(const char *data, int len)
 	}
 }
 
+static void do_verify_udp_gro(const char *data, int len, int gso_size)
+{
+	int remaining = len;
+	int start = 0;
+
+	while (remaining) {
+		if (remaining < 0)
+			break;
+
+		if (remaining > gso_size)
+			do_verify_udp(data, start, gso_size);
+		else
+			do_verify_udp(data, start, remaining);
+		start += gso_size;
+		remaining -= gso_size;
+	}
+}
+
 static int recv_msg(int fd, char *buf, int len, int *gso_size)
 {
 	char control[CMSG_SPACE(sizeof(int))] = {0};
@@ -264,16 +282,20 @@ static void do_flush_udp(int fd)
 		if (cfg_expected_pkt_len && ret != cfg_expected_pkt_len)
 			error(1, 0, "recv: bad packet len, got %d,"
 			      " expected %d\n", ret, cfg_expected_pkt_len);
+		if (cfg_expected_gso_size && cfg_expected_gso_size != gso_size)
+			error(1, 0, "recv: bad gso size, got %d, expected %d %s",
+				gso_size, cfg_expected_gso_size, "(-1 == no gso cmsg))\n");
 		if (len && cfg_verify) {
 			if (ret == 0)
 				error(1, errno, "recv: 0 byte datagram\n");
 
-			do_verify_udp(rbuf, ret);
+			if (!cfg_gro_segment)
+				do_verify_udp(rbuf, 0, ret);
+			else if (gso_size > 0)
+				do_verify_udp_gro(rbuf, ret, gso_size);
+			else
+				do_verify_udp_gro(rbuf, ret, ret);
 		}
-		if (cfg_expected_gso_size && cfg_expected_gso_size != gso_size)
-			error(1, 0, "recv: bad gso size, got %d, expected %d "
-			      "(-1 == no gso cmsg))\n", gso_size,
-			      cfg_expected_gso_size);
 
 		packets++;
 		bytes += ret;
-- 
2.15.2

  reply	other threads:[~2023-04-17 12:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 12:17 [PATCH linux-next 0/3] selftests: net: udpgso_bench_rx: Fix verifty, gsosize, and packet number exceptions yang.yang29
2023-04-17 12:24 ` Yang Yang [this message]
2023-04-17 15:16   ` [PATCH linux-next 1/3] selftests: net: udpgso_bench_rx: Fix verifty exceptions Willem de Bruijn
2023-04-18  1:29     ` Yang Yang
2023-04-18 13:01       ` Willem de Bruijn
2023-04-18 14:20   ` Paolo Abeni
2023-04-17 12:24 ` [PATCH linux-next 2/3] selftests: net: udpgso_bench_rx: Fix gsosize exceptions Yang Yang
2023-04-17 12:25 ` [PATCH linux-next 3/3] selftests: net: udpgso_bench_rx: Fix packet number exceptions Yang Yang
2023-04-17 15:27   ` Willem de Bruijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230417122423.193237-1-yang.yang29@zte.com.cn \
    --to=yang.yang29@zte.com.cn \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiang.xuexin@zte.com.cn \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=xu.xin16@zte.com.cn \
    --cc=zhang.yunkai@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox