All of lore.kernel.org
 help / color / mirror / Atom feed
From: <yang.yang29@zte.com.cn>
To: <davem@davemloft.net>, <willemdebruijn.kernel@gmail.com>
Cc: <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<shuah@kernel.org>, <netdev@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<zhang.yunkai@zte.com.cn>, <yang.yang29@zte.com.cn>,
	<xu.xin16@zte.com.cn>
Subject: [PATCH linux-next v3] selftests: net: udpgso_bench_rx: Fix verifty exceptions
Date: Mon, 24 Apr 2023 13:55:46 +0800 (CST)	[thread overview]
Message-ID: <202304241355464262541@zte.com.cn> (raw)

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. The problem is easily
reproducible in the latest kernel.

Environment A, the sender:
bash# udpgso_bench_tx -l 4 -4 -D "$IP_B"
udpgso_bench_tx: write: Connection refused

Environment B, the receiver:
bash# udpgso_bench_rx -4 -G -S 1472 -v
udpgso_bench_rx: data[1472]: len 17664, a(97) != q(113)

If the packet is captured, you will see:
Environment A, the sender:
bash# tcpdump -i eth0 host "$IP_B" &
IP $IP_A.41025 > $IP_B.8000: UDP, length 1472
IP $IP_A.41025 > $IP_B.8000: UDP, length 1472
IP $IP_B > $IP_A: ICMP $IP_B udp port 8000 unreachable, length 556

Environment B, the receiver:
bash# tcpdump -i eth0 host "$IP_B" &
IP $IP_A.41025 > $IP_B.8000: UDP, length 7360
IP $IP_A.41025 > $IP_B.8000: UDP, length 14720
IP $IP_B > $IP_A: ICMP $IP_B udp port 8000 unreachable, length 556

In one test, the verification data is printed as follows:
abcd...xyz           | 1...
..                  |
abcd...xyz           |
abcd...opabcd...xyz  | ...1472... Not xyzabcd, messages are merged
..                  |

The issue is that the test on receive for expected payload pattern 
{AB..Z}+ fail for GRO packets if segment payload does not end on a Z.

The issue still exists when using the GRO with -G, but not using the -S
to obtain gsosize. Therefore, a print has been added to remind users.

Changes in v3:
- Simplify description and adjust judgment order.

Changes in v2:
- Fix confusing descriptions.

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 | 34 +++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c
index f35a924d4a30..3ad18cbc570d 100644
--- a/tools/testing/selftests/net/udpgso_bench_rx.c
+++ b/tools/testing/selftests/net/udpgso_bench_rx.c
@@ -189,26 +189,45 @@ 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
 			cur++;

-		if (data[i] != cur)
+		if (data[i] != cur) {
+			if (cfg_gro_segment && !cfg_expected_gso_size)
+				error(0, 0, "Use -S to obtain gsosize to guide "
+					"splitting and verification.");
+
 			error(1, 0, "data[%d]: len %d, %c(%hhu) != %c(%hhu)\n",
 			      i, len,
 			      sanitized_char(data[i]), data[i],
 			      sanitized_char(cur), cur);
+		}
+	}
+}
+
+static void do_verify_udp_gro(const char *data, int len, int segment_size)
+{
+	int start = 0;
+
+	while (len - start > 0) {
+		if (len - start > segment_size)
+			do_verify_udp(data, start, segment_size);
+		else
+			do_verify_udp(data, start, len - start);
+
+		start += segment_size;
 	}
 }

@@ -268,7 +287,12 @@ static void do_flush_udp(int fd)
 			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 "
-- 
2.15.2

             reply	other threads:[~2023-04-24  5:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  5:55 yang.yang29 [this message]
2023-04-24 14:10 ` [PATCH linux-next v3] selftests: net: udpgso_bench_rx: Fix verifty exceptions 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=202304241355464262541@zte.com.cn \
    --to=yang.yang29@zte.com.cn \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.