From nobody Sat Jan 10 14:59:47 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 291A43191D0 for ; Tue, 6 Jan 2026 01:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767663375; cv=none; b=TodSVFp3AOEFMixHJ1EKmOzCv1lv3Vp6D8Bbfp24f37KfYfydRHM7Pw/y8FSzWWjEgX31QXqbTySF/xh5X6pn/uUwUv36BVOjv9Z07+xWujDByEveS4NKPxgk/P5JHhS0awX5yLaEH6r+TUpSmZtUuDW2e2M/NXll/zJ4UX5uIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767663375; c=relaxed/simple; bh=uL092dlJuSSJTGC3YnxkXxk3fogYnWG29PGHbQ5sLEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IWO0NoPyPmiemA3qMgCzT5KGKt26elRVH61Vz1YH/aidwMTZeAHIn29wz3l5oQKovU14yHcw0xLMd7LXzKpRWJUoHdo97VBQUL6wTaTE1ovk0gomw4V+of7rq8vv39vGRjwbFbI6tx9YSGJUxneYp4rsP6wfX2F0oDc3aUGapog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GiOWE3Qt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GiOWE3Qt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767663373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6zfvleqHF+vihvobQ9j/ZQshfIqfQXu1yeAQ6DhfoSA=; b=GiOWE3QtktKI/G3MTM1LFRe763oCTFV+3tSd6cPNbKC+795nECl7PH/WxeNHyG4BNNbJ8Q ufhCLUxftAF/etIW46xPxna947nu2029GZB67RTARLe/QHZQUzUO+3AQZr0J/fCNy2gUIF gWbmkxCUpPjPEaSB5UHHYovLGJnS4ro= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-ci2DhOxrNR6k4G63VYV6WQ-1; Mon, 05 Jan 2026 20:36:07 -0500 X-MC-Unique: ci2DhOxrNR6k4G63VYV6WQ-1 X-Mimecast-MFC-AGG-ID: ci2DhOxrNR6k4G63VYV6WQ_1767663366 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 16EF51800343; Tue, 6 Jan 2026 01:36:06 +0000 (UTC) Received: from xudu-thinkpadx1carbongen9.nay.csb (unknown [10.66.60.72]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 343F3180044F; Tue, 6 Jan 2026 01:36:01 +0000 (UTC) From: Xu Du To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 8/8] selftest: tun: Add test data for success and failure paths Date: Tue, 6 Jan 2026 09:35:21 +0800 Message-ID: <89100ed7d241df962e31ec84090c8b99d6fa7206.1767597114.git.xudu@redhat.com> In-Reply-To: References: 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" To improve the robustness and coverage of the TUN selftests, this patch expands the set of test data. Signed-off-by: Xu Du --- tools/testing/selftests/net/tun.c | 115 +++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/tun.c b/tools/testing/selftests/ne= t/tun.c index 3a90e7c4bc5b..1676996fbdd0 100644 --- a/tools/testing/selftests/net/tun.c +++ b/tools/testing/selftests/net/tun.c @@ -57,6 +57,10 @@ static struct in6_addr param_ipaddr6_inner_src =3D { { { 0x20, 0x02, 0x0d, 0xb8, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 } }, }; =20 +#ifndef BIT +#define BIT(nr) (1UL << (nr)) +#endif + #define VN_ID 1 #define VN_PORT 4789 #define UDP_SRC_PORT 22 @@ -72,6 +76,8 @@ static struct in6_addr param_ipaddr6_inner_src =3D { #define UDP_TUNNEL_VXLAN_4IN6 0x04 #define UDP_TUNNEL_VXLAN_6IN6 0x08 =20 +#define UDP_TUNNEL_MAX_SEGMENTS BIT(7) + #define UDP_TUNNEL_OUTER_IPV4 (UDP_TUNNEL_VXLAN_4IN4 | UDP_TUNNEL_VXLAN_6I= N4) #define UDP_TUNNEL_INNER_IPV4 (UDP_TUNNEL_VXLAN_4IN4 | UDP_TUNNEL_VXLAN_4I= N6) =20 @@ -547,6 +553,39 @@ FIXTURE_VARIANT(tun_vnet_udptnl) =20 /* clang-format off */ #define TUN_VNET_UDPTNL_VARIANT_ADD(type, desc) = \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_nogsosz_1byte) { \ + /* no GSO: send a single byte */ \ + .tunnel_type =3D type, \ + .data_size =3D 1, \ + .r_num_mss =3D 1, \ + .is_tap =3D true, \ + .no_gso =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_nogsosz_1mss) { \ + /* no GSO: send a single MSS, fall back to no GSO */ \ + .tunnel_type =3D type, \ + .data_size =3D UDP_TUNNEL_MSS(type), \ + .r_num_mss =3D 1, \ + .is_tap =3D true, \ + .no_gso =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_nogsosz_gtmss) { \ + /* no GSO: send a single MSS + 1B: fail */ \ + .tunnel_type =3D type, \ + .data_size =3D UDP_TUNNEL_MSS(type) + 1, \ + .r_num_mss =3D 1, \ + .is_tap =3D true, \ + .no_gso =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_1byte) { \ + /* GSO: send 1 byte, gso 1 byte, fall back to no GSO */ \ + .tunnel_type =3D type, \ + .gso_size =3D 1, \ + .data_size =3D 1, \ + .r_num_mss =3D 1, \ + .is_tap =3D true, \ + .no_gso =3D true, \ + }; \ FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_1mss) { \ /* send a single MSS: fall back to no GSO */ \ .tunnel_type =3D type, \ @@ -555,8 +594,65 @@ FIXTURE_VARIANT(tun_vnet_udptnl) .r_num_mss =3D 1, \ .is_tap =3D true, \ .no_gso =3D true, \ - }; -/* clang-format on */ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_ltgso) { \ + /* data <=3D MSS < gso: will fall back to no GSO */ \ + .tunnel_type =3D type, \ + .gso_size =3D UDP_TUNNEL_MSS(type) + 1, \ + .data_size =3D UDP_TUNNEL_MSS(type), \ + .r_num_mss =3D 1, \ + .is_tap =3D true, \ + .no_gso =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_gtgso) { \ + /* GSO: a single MSS + 1B */ \ + .tunnel_type =3D type, \ + .gso_size =3D UDP_TUNNEL_MSS(type), \ + .data_size =3D UDP_TUNNEL_MSS(type) + 1, \ + .r_num_mss =3D 2, \ + .is_tap =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_2mss) { \ + /* no GSO: send exactly 2 MSS */ \ + .tunnel_type =3D type, \ + .gso_size =3D UDP_TUNNEL_MSS(type), \ + .data_size =3D UDP_TUNNEL_MSS(type) * 2, \ + .r_num_mss =3D 2, \ + .is_tap =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_maxbytes) { \ + /* GSO: send max bytes */ \ + .tunnel_type =3D type, \ + .gso_size =3D UDP_TUNNEL_MSS(type), \ + .data_size =3D UDP_TUNNEL_MAX(type, true), \ + .r_num_mss =3D UDP_TUNNEL_MAX(type, true) / \ + UDP_TUNNEL_MSS(type) + 1, \ + .is_tap =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_over_maxbytes) { \ + /* GSO: send oversize max bytes: fail */ \ + .tunnel_type =3D type, \ + .gso_size =3D UDP_TUNNEL_MSS(type), \ + .data_size =3D ETH_MAX_MTU, \ + .r_num_mss =3D ETH_MAX_MTU / UDP_TUNNEL_MSS(type) + 1, \ + .is_tap =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_maxsegs) { \ + /* GSO: send max number of min sized segments */ \ + .tunnel_type =3D type, \ + .gso_size =3D 1, \ + .data_size =3D UDP_TUNNEL_MAX_SEGMENTS, \ + .r_num_mss =3D UDP_TUNNEL_MAX_SEGMENTS, \ + .is_tap =3D true, \ + }; \ + FIXTURE_VARIANT_ADD(tun_vnet_udptnl, desc##_5byte) { \ + /* GSO: send 5 bytes, gso 2 bytes */ \ + .tunnel_type =3D type, \ + .gso_size =3D 2, \ + .data_size =3D 5, \ + .r_num_mss =3D 3, \ + .is_tap =3D true, \ + } /* clang-format on */ =20 TUN_VNET_UDPTNL_VARIANT_ADD(UDP_TUNNEL_VXLAN_4IN4, 4in4); TUN_VNET_UDPTNL_VARIANT_ADD(UDP_TUNNEL_VXLAN_6IN4, 6in4); @@ -895,4 +991,19 @@ TEST_F(tun_vnet_udptnl, recv_gso_packet) } } =20 +XFAIL_ADD(tun_vnet_udptnl, 4in4_nogsosz_gtmss, recv_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 6in4_nogsosz_gtmss, recv_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 4in6_nogsosz_gtmss, recv_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 6in6_nogsosz_gtmss, recv_gso_packet); + +XFAIL_ADD(tun_vnet_udptnl, 4in4_over_maxbytes, send_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 6in4_over_maxbytes, send_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 4in6_over_maxbytes, send_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 6in6_over_maxbytes, send_gso_packet); + +XFAIL_ADD(tun_vnet_udptnl, 4in4_over_maxbytes, recv_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 6in4_over_maxbytes, recv_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 4in6_over_maxbytes, recv_gso_packet); +XFAIL_ADD(tun_vnet_udptnl, 6in6_over_maxbytes, recv_gso_packet); + TEST_HARNESS_MAIN --=20 2.49.0