From nobody Thu Oct 2 16:32:29 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5028D2FF145 for ; Mon, 15 Sep 2025 11:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757936494; cv=none; b=UdEOTRkVplnDdBsCcDYVG6Ut2hi4HYNx80aYmLa549R7GAw1r3ha9WsPxy2XfBiJRcLjxLWTD140049vxuPak8j9Dt4U0ECmveKUR/ZqSa6HE7ILwyJlQMAGBMLe2YfFw1BEOjAFHlv5b5N+1qURGkYt30Q5YoKlHW6bQ8savJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757936494; c=relaxed/simple; bh=8MEzHqJEQ2aWHJMkJzMjK33JjxtCm1bYj3TNlfG4lVo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RKXNKRMjnyAPr0a/elHarSVhLCIKIeMezR4ywLhZeYc5ZGptiZzZwe1XiOsZFPf5TDz498AWhhp+WJqoUqD7O6QsGCGGGNGFSxLU77Jhcomh81SY9J3KoY8elZHgDZPFQVW4UXXjipw1QBsGfps1jtnScXYm3UZ5gUU7pEjfpI8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NbjMSBgJ; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NbjMSBgJ" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45df0cde41bso31343875e9.3 for ; Mon, 15 Sep 2025 04:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757936490; x=1758541290; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zcBD+Qv0ZPeDmK2bvIZ8tL4Dih4YYu9zRXXKcI28lv8=; b=NbjMSBgJlPPzyfiU+R3X/YFiXbOytOJ3U0k9hYXACgN/TzDvXGIe5i0lDEVHJmjJ7T HDzmgWRBQ/AP+3Ihkh2FEOpHYIU9NbYC2MxEIAv+olZ/K1z+n+TgLAnqwrqFMNT3O48W cmcebkH9Sfh8VUwZ+J+AhU++O2arADiNSTE5aSiA+JbzONovwwWwFFOq3qImAB4gIocX DXsLQAuWoskliqUeMK0FR5K5PePH1FJoZqLxw8aX8vHqrXyPRxhKW/WRfaiwEgIq3fmk RSKqLTdeweGDfxPP/x0vAvxSx1quFdlzC+md9DnPhVe8UEyIRoGggf5xihjddOpSH9kg cXcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757936490; x=1758541290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zcBD+Qv0ZPeDmK2bvIZ8tL4Dih4YYu9zRXXKcI28lv8=; b=DD+/xvlg+5zOsEafdnVRtIX9iCT7kAISmRAIbZXLBBBjXCLln07oE3R1qnMtGULclh v8sUbvFs5TxOu4k+rYNQDkLcR2I8Y9AXarP3cu5WXJsq6IPPrFoC2hgbc7LiwdftDBow 6EYbcgKe7b0guJAGqrVQfNFPmX/mR9QNQd2wJ6/KgXiyE6GdYBc7Ws/+RGcfi6jsO7a/ GPbTR+L+zTU26ZY+mt7j3as8eSh+g3unMTO+ntUM7owuqKwoeTRrQmvnp5P0klAgr98s hLaC9ZEVjo81ExFm6pS7yOBzG1DGwDsQ5n48558K0iBNCxJhfAh8xC+A0fKohkOkmtrz oIkw== X-Forwarded-Encrypted: i=1; AJvYcCXdxLwzxOi2MnhiontDHF5rdPymp5ezKA/eXmsrgARblgQ01EjXKb3X2cKq2lNDbNDJILNmUeW8TdhrUkg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1gEfRz+jope+zZZsVmNrTMh64zXmup0yWdoT8nm5ONioSYTx+ 6x/aTW+/Sa/c56Xe8j4hFk0ccoZlEYBi1YBOdMZ59LwbGmfbZwP18jeL X-Gm-Gg: ASbGncs9RRuBlwRfXu4V8r1zXP4XjNjQp411hqMKFtHMSZ2Z64WrtpVM5io4hgRBEW9 FlnHP68M01Yu7nh4qSxfkrMwqc3YXSVfjxoM2oZ4zZXx4L0tqUy7CcyxsqDDdYgbO8/qz+U7J0B T2HkM1l1WfoflvT5DLjzOUk+TlmRndULEDo+tPYul/kYECKFhHuphXDpIlmwYeqXbzitdyJ7bbG +HtWpO7sJo8rcoYRpy8h601XO7EsMfzcvONaj4ku4m6pxvqn6myS4XmasnlmmDHMqv250l4Ae6w 3W/H1Oc0QliO9BsRlVoM3aidN0lYRDADPnrHRzbMQXqWmXfZUT5qwNTGmFvpTdjuoQ3IQNPqGlB U2FCCQW6IO2RSDcLm4sC5th+HPwZ4XCROog== X-Google-Smtp-Source: AGHT+IEybk2FVYM0GPYM41odfQqYVDDvs/3s6JOJaYyRBYx9Z2H+EzWndEX4GODHUYF/31REBO66tQ== X-Received: by 2002:a05:600c:3511:b0:45f:2805:1d0 with SMTP id 5b1f17b1804b1-45f282562a2mr59040855e9.34.1757936490172; Mon, 15 Sep 2025 04:41:30 -0700 (PDT) Received: from localhost ([45.10.155.13]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45f28c193f9sm94955855e9.2.2025.09.15.04.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Sep 2025 04:41:29 -0700 (PDT) From: Richard Gobert To: netdev@vger.kernel.org, pabeni@redhat.com, ecree.xilinx@gmail.com, willemdebruijn.kernel@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, horms@kernel.org, corbet@lwn.net, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, shuah@kernel.org, sdf@fomichev.me, aleksander.lobakin@intel.com, florian.fainelli@broadcom.com, alexander.duyck@gmail.com, linux-kernel@vger.kernel.org, linux-net-drivers@amd.com, Richard Gobert Subject: [PATCH net-next v5 5/5] selftests/net: test ipip packets in gro.sh Date: Mon, 15 Sep 2025 13:39:33 +0200 Message-Id: <20250915113933.3293-6-richardbgobert@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250915113933.3293-1-richardbgobert@gmail.com> References: <20250915113933.3293-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add IPIP test-cases to the GRO selftest. This selftest already contains IP ID test-cases. They are now also tested for encapsulated packets. This commit also fixes ipip packet generation in the test. Signed-off-by: Richard Gobert Reviewed-by: Willem de Bruijn --- tools/testing/selftests/net/gro.c | 49 ++++++++++++++++++++++++------ tools/testing/selftests/net/gro.sh | 2 +- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/ne= t/gro.c index 3d4a82a2607c..2b1d9f2b3e9e 100644 --- a/tools/testing/selftests/net/gro.c +++ b/tools/testing/selftests/net/gro.c @@ -93,6 +93,7 @@ static bool tx_socket =3D true; static int tcp_offset =3D -1; static int total_hdr_len =3D -1; static int ethhdr_proto =3D -1; +static bool ipip; static const int num_flush_id_cases =3D 6; =20 static void vlog(const char *fmt, ...) @@ -114,7 +115,9 @@ static void setup_sock_filter(int fd) int ipproto_off, opt_ipproto_off; int next_off; =20 - if (proto =3D=3D PF_INET) + if (ipip) + next_off =3D sizeof(struct iphdr) + offsetof(struct iphdr, protocol); + else if (proto =3D=3D PF_INET) next_off =3D offsetof(struct iphdr, protocol); else next_off =3D offsetof(struct ipv6hdr, nexthdr); @@ -244,7 +247,7 @@ static void fill_datalinklayer(void *buf) eth->h_proto =3D ethhdr_proto; } =20 -static void fill_networklayer(void *buf, int payload_len) +static void fill_networklayer(void *buf, int payload_len, int protocol) { struct ipv6hdr *ip6h =3D buf; struct iphdr *iph =3D buf; @@ -254,7 +257,7 @@ static void fill_networklayer(void *buf, int payload_le= n) =20 ip6h->version =3D 6; ip6h->payload_len =3D htons(sizeof(struct tcphdr) + payload_len); - ip6h->nexthdr =3D IPPROTO_TCP; + ip6h->nexthdr =3D protocol; ip6h->hop_limit =3D 8; if (inet_pton(AF_INET6, addr6_src, &ip6h->saddr) !=3D 1) error(1, errno, "inet_pton source ip6"); @@ -266,7 +269,7 @@ static void fill_networklayer(void *buf, int payload_le= n) iph->version =3D 4; iph->ihl =3D 5; iph->ttl =3D 8; - iph->protocol =3D IPPROTO_TCP; + iph->protocol =3D protocol; iph->tot_len =3D htons(sizeof(struct tcphdr) + payload_len + sizeof(struct iphdr)); iph->frag_off =3D htons(0x4000); /* DF =3D 1, MF =3D 0 */ @@ -313,9 +316,19 @@ static void create_packet(void *buf, int seq_offset, i= nt ack_offset, { memset(buf, 0, total_hdr_len); memset(buf + total_hdr_len, 'a', payload_len); + fill_transportlayer(buf + tcp_offset, seq_offset, ack_offset, payload_len, fin); - fill_networklayer(buf + ETH_HLEN, payload_len); + + if (ipip) { + fill_networklayer(buf + ETH_HLEN, payload_len + sizeof(struct iphdr), + IPPROTO_IPIP); + fill_networklayer(buf + ETH_HLEN + sizeof(struct iphdr), + payload_len, IPPROTO_TCP); + } else { + fill_networklayer(buf + ETH_HLEN, payload_len, IPPROTO_TCP); + } + fill_datalinklayer(buf); } =20 @@ -416,6 +429,13 @@ static void recompute_packet(char *buf, char *no_ext, = int extlen) iph->tot_len =3D htons(ntohs(iph->tot_len) + extlen); iph->check =3D 0; iph->check =3D checksum_fold(iph, sizeof(struct iphdr), 0); + + if (ipip) { + iph +=3D 1; + iph->tot_len =3D htons(ntohs(iph->tot_len) + extlen); + iph->check =3D 0; + iph->check =3D checksum_fold(iph, sizeof(struct iphdr), 0); + } } else { ip6h->payload_len =3D htons(ntohs(ip6h->payload_len) + extlen); } @@ -777,7 +797,7 @@ static void send_fragment4(int fd, struct sockaddr_ll *= daddr) */ memset(buf + total_hdr_len, 'a', PAYLOAD_LEN * 2); fill_transportlayer(buf + tcp_offset, PAYLOAD_LEN, 0, PAYLOAD_LEN * 2, 0); - fill_networklayer(buf + ETH_HLEN, PAYLOAD_LEN); + fill_networklayer(buf + ETH_HLEN, PAYLOAD_LEN, IPPROTO_TCP); fill_datalinklayer(buf); =20 iph->frag_off =3D htons(0x6000); // DF =3D 1, MF =3D 1 @@ -1071,7 +1091,7 @@ static void gro_sender(void) * and min ipv6hdr size. Like MAX_HDR_SIZE, * MAX_PAYLOAD is defined with the larger header of the two. */ - int offset =3D proto =3D=3D PF_INET ? 20 : 0; + int offset =3D (proto =3D=3D PF_INET && !ipip) ? 20 : 0; int remainder =3D (MAX_PAYLOAD + offset) % MSS; =20 send_large(txfd, &daddr, remainder); @@ -1221,7 +1241,7 @@ static void gro_receiver(void) check_recv_pkts(rxfd, correct_payload, 2); } } else if (strcmp(testname, "large") =3D=3D 0) { - int offset =3D proto =3D=3D PF_INET ? 20 : 0; + int offset =3D (proto =3D=3D PF_INET && !ipip) ? 20 : 0; int remainder =3D (MAX_PAYLOAD + offset) % MSS; =20 correct_payload[0] =3D (MAX_PAYLOAD + offset); @@ -1250,6 +1270,7 @@ static void parse_args(int argc, char **argv) { "iface", required_argument, NULL, 'i' }, { "ipv4", no_argument, NULL, '4' }, { "ipv6", no_argument, NULL, '6' }, + { "ipip", no_argument, NULL, 'e' }, { "rx", no_argument, NULL, 'r' }, { "saddr", required_argument, NULL, 's' }, { "smac", required_argument, NULL, 'S' }, @@ -1259,7 +1280,7 @@ static void parse_args(int argc, char **argv) }; int c; =20 - while ((c =3D getopt_long(argc, argv, "46d:D:i:rs:S:t:v", opts, NULL)) != =3D -1) { + while ((c =3D getopt_long(argc, argv, "46d:D:ei:rs:S:t:v", opts, NULL)) != =3D -1) { switch (c) { case '4': proto =3D PF_INET; @@ -1269,6 +1290,11 @@ static void parse_args(int argc, char **argv) proto =3D PF_INET6; ethhdr_proto =3D htons(ETH_P_IPV6); break; + case 'e': + ipip =3D true; + proto =3D PF_INET; + ethhdr_proto =3D htons(ETH_P_IP); + break; case 'd': addr4_dst =3D addr6_dst =3D optarg; break; @@ -1304,7 +1330,10 @@ int main(int argc, char **argv) { parse_args(argc, argv); =20 - if (proto =3D=3D PF_INET) { + if (ipip) { + tcp_offset =3D ETH_HLEN + sizeof(struct iphdr) * 2; + total_hdr_len =3D tcp_offset + sizeof(struct tcphdr); + } else if (proto =3D=3D PF_INET) { tcp_offset =3D ETH_HLEN + sizeof(struct iphdr); total_hdr_len =3D tcp_offset + sizeof(struct tcphdr); } else if (proto =3D=3D PF_INET6) { diff --git a/tools/testing/selftests/net/gro.sh b/tools/testing/selftests/n= et/gro.sh index 9e3f186bc2a1..4c5144c6f652 100755 --- a/tools/testing/selftests/net/gro.sh +++ b/tools/testing/selftests/net/gro.sh @@ -4,7 +4,7 @@ readonly SERVER_MAC=3D"aa:00:00:00:00:02" readonly CLIENT_MAC=3D"aa:00:00:00:00:01" readonly TESTS=3D("data" "ack" "flags" "tcp" "ip" "large") -readonly PROTOS=3D("ipv4" "ipv6") +readonly PROTOS=3D("ipv4" "ipv6" "ipip") dev=3D"" test=3D"all" proto=3D"ipv4" --=20 2.36.1