Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/net: Add coverage for UDP GSO with IPv6 extension headers

After enabling UDP GSO for devices not offering checksum offload, we have
hit a regression where a bad offload warning can be triggered when sending
a datagram with IPv6 extension headers.

Extend the UDP GSO IPv6 tests to cover this scenario.

Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://patch.msgid.link/20240808-udp-gso-egress-from-tunnel-v4-3-f5c5b4149ab9@cloudflare.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jakub Sitnicki and committed by
Jakub Kicinski
1d2c46c1 30b03f2a

+24 -1
+24 -1
tools/testing/selftests/net/udpgso.c
··· 67 67 int gso_len; /* mss after applying gso */ 68 68 int r_num_mss; /* recv(): number of calls of full mss */ 69 69 int r_len_last; /* recv(): size of last non-mss dgram, if any */ 70 + bool v6_ext_hdr; /* send() dgrams with IPv6 extension headers */ 70 71 }; 71 72 72 73 const struct in6_addr addr6 = { ··· 77 76 const struct in_addr addr4 = { 78 77 __constant_htonl(0x0a000001), /* 10.0.0.1 */ 79 78 }; 79 + 80 + static const char ipv6_hopopts_pad1[8] = { 0 }; 80 81 81 82 struct testcase testcases_v4[] = { 82 83 { ··· 259 256 .r_num_mss = 2, 260 257 }, 261 258 { 259 + /* send 2 1B segments with extension headers */ 260 + .tlen = 2, 261 + .gso_len = 1, 262 + .r_num_mss = 2, 263 + .v6_ext_hdr = true, 264 + }, 265 + { 262 266 /* send 2B + 2B + 1B segments */ 263 267 .tlen = 5, 264 268 .gso_len = 2, ··· 406 396 int i, ret, val, mss; 407 397 bool sent; 408 398 409 - fprintf(stderr, "ipv%d tx:%d gso:%d %s\n", 399 + fprintf(stderr, "ipv%d tx:%d gso:%d %s%s\n", 410 400 addr->sa_family == AF_INET ? 4 : 6, 411 401 test->tlen, test->gso_len, 402 + test->v6_ext_hdr ? "ext-hdr " : "", 412 403 test->tfail ? "(fail)" : ""); 404 + 405 + if (test->v6_ext_hdr) { 406 + if (setsockopt(fdt, IPPROTO_IPV6, IPV6_HOPOPTS, 407 + ipv6_hopopts_pad1, sizeof(ipv6_hopopts_pad1))) 408 + error(1, errno, "setsockopt ipv6 hopopts"); 409 + } 413 410 414 411 val = test->gso_len; 415 412 if (cfg_do_setsockopt) { ··· 429 412 error(1, 0, "send succeeded while expecting failure"); 430 413 if (!sent && !test->tfail) 431 414 error(1, 0, "send failed while expecting success"); 415 + 416 + if (test->v6_ext_hdr) { 417 + if (setsockopt(fdt, IPPROTO_IPV6, IPV6_HOPOPTS, NULL, 0)) 418 + error(1, errno, "setsockopt ipv6 hopopts clear"); 419 + } 420 + 432 421 if (!sent) 433 422 return; 434 423