Commit 1d2c46c1 authored by Jakub Sitnicki's avatar Jakub Sitnicki Committed by Jakub Kicinski

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: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Link: https://patch.msgid.link/20240808-udp-gso-egress-from-tunnel-v4-3-f5c5b4149ab9@cloudflare.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 30b03f2a
...@@ -67,6 +67,7 @@ struct testcase { ...@@ -67,6 +67,7 @@ struct testcase {
int gso_len; /* mss after applying gso */ int gso_len; /* mss after applying gso */
int r_num_mss; /* recv(): number of calls of full mss */ int r_num_mss; /* recv(): number of calls of full mss */
int r_len_last; /* recv(): size of last non-mss dgram, if any */ int r_len_last; /* recv(): size of last non-mss dgram, if any */
bool v6_ext_hdr; /* send() dgrams with IPv6 extension headers */
}; };
const struct in6_addr addr6 = { const struct in6_addr addr6 = {
...@@ -77,6 +78,8 @@ const struct in_addr addr4 = { ...@@ -77,6 +78,8 @@ const struct in_addr addr4 = {
__constant_htonl(0x0a000001), /* 10.0.0.1 */ __constant_htonl(0x0a000001), /* 10.0.0.1 */
}; };
static const char ipv6_hopopts_pad1[8] = { 0 };
struct testcase testcases_v4[] = { struct testcase testcases_v4[] = {
{ {
/* no GSO: send a single byte */ /* no GSO: send a single byte */
...@@ -255,6 +258,13 @@ struct testcase testcases_v6[] = { ...@@ -255,6 +258,13 @@ struct testcase testcases_v6[] = {
.gso_len = 1, .gso_len = 1,
.r_num_mss = 2, .r_num_mss = 2,
}, },
{
/* send 2 1B segments with extension headers */
.tlen = 2,
.gso_len = 1,
.r_num_mss = 2,
.v6_ext_hdr = true,
},
{ {
/* send 2B + 2B + 1B segments */ /* send 2B + 2B + 1B segments */
.tlen = 5, .tlen = 5,
...@@ -396,11 +406,18 @@ static void run_one(struct testcase *test, int fdt, int fdr, ...@@ -396,11 +406,18 @@ static void run_one(struct testcase *test, int fdt, int fdr,
int i, ret, val, mss; int i, ret, val, mss;
bool sent; bool sent;
fprintf(stderr, "ipv%d tx:%d gso:%d %s\n", fprintf(stderr, "ipv%d tx:%d gso:%d %s%s\n",
addr->sa_family == AF_INET ? 4 : 6, addr->sa_family == AF_INET ? 4 : 6,
test->tlen, test->gso_len, test->tlen, test->gso_len,
test->v6_ext_hdr ? "ext-hdr " : "",
test->tfail ? "(fail)" : ""); test->tfail ? "(fail)" : "");
if (test->v6_ext_hdr) {
if (setsockopt(fdt, IPPROTO_IPV6, IPV6_HOPOPTS,
ipv6_hopopts_pad1, sizeof(ipv6_hopopts_pad1)))
error(1, errno, "setsockopt ipv6 hopopts");
}
val = test->gso_len; val = test->gso_len;
if (cfg_do_setsockopt) { if (cfg_do_setsockopt) {
if (setsockopt(fdt, SOL_UDP, UDP_SEGMENT, &val, sizeof(val))) if (setsockopt(fdt, SOL_UDP, UDP_SEGMENT, &val, sizeof(val)))
...@@ -412,6 +429,12 @@ static void run_one(struct testcase *test, int fdt, int fdr, ...@@ -412,6 +429,12 @@ static void run_one(struct testcase *test, int fdt, int fdr,
error(1, 0, "send succeeded while expecting failure"); error(1, 0, "send succeeded while expecting failure");
if (!sent && !test->tfail) if (!sent && !test->tfail)
error(1, 0, "send failed while expecting success"); error(1, 0, "send failed while expecting success");
if (test->v6_ext_hdr) {
if (setsockopt(fdt, IPPROTO_IPV6, IPV6_HOPOPTS, NULL, 0))
error(1, errno, "setsockopt ipv6 hopopts clear");
}
if (!sent) if (!sent)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment