From patchwork Thu Aug 8 09:56:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 13757166 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 AFB8578274 for ; Thu, 8 Aug 2024 09:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723111001; cv=none; b=Iv5L7n2GircICd+PSOO6/Qu6mIKx1/Eb0jc0vHvfvtorsjyvX27er10JD1gO6zlh5VcWSd+3O8G2NnWVmy+qBFRLtMEu3lhuV0Q8m+9vBOfi6pBeAT7ffczdk0EylYLeDyJoQ2PAei6dFC5pXEeZfF7ZO38iUuEFib/xxc0mcqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723111001; c=relaxed/simple; bh=IesTJSlpzunGzqUhDiLb2/aTmTP8Z/4m62dDm1ScgbQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t6Uhwi4QMT2Rvrs6eHtiXB/FTlhYRtaTfuQzQbTNOnw/hJXOCW7EcKwVfbgH59h3VC4hzbKtRR7L76BT1tr7veZfHzcqLsVgFiRwc/LSrmAs2hKnx6XBk/wEKdSxLhAdpZw+dW01gxAldBxhi9V3Qs4uYOw9kb8f59mXeAk9fcw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=XP3Rbl+8; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="XP3Rbl+8" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5a1337cfbb5so969756a12.3 for ; Thu, 08 Aug 2024 02:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1723110997; x=1723715797; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pjmg7XmZ9J2NGEjY7Od9fvedwGn3CBQ0UvYKrnNEzGk=; b=XP3Rbl+8OBiXYqVsTMRuycvCtUG1yIdP3/NNjE/hW7zLVUBR8+Ba9TSBzmLE6piMRa gaiKOD/aZZs1DQOM3Y/8BcHBybD0zLA0PBBUz8uMGHbs2JEIAbr21kj2dtFq4RJG5hqT smmNeDs+bpOJ2CPaoNbgrj3Y5ZI1V1LiHYN3KG0Z8rT+d/F6/wSAoToekMzBCP2FRsqT 2lYL9mstuMkqJANHgw+gSXcxr1HNWixZ7pK9eqOWuc6fLxDds1h/rS/MINpPBpCbtqPA 5/Y7sEthqt5FOjTaE2HzEmUKLDKka27z8WhqS6haokTer1wLGGm4cHo2ZKOgkFNFquTw /8Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723110997; x=1723715797; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pjmg7XmZ9J2NGEjY7Od9fvedwGn3CBQ0UvYKrnNEzGk=; b=oxzESZQgzSrLuidhHEDJrmmWWzJK3AKgKwDPuKxUlLF578R7QXdWoLx5kE30XZyBCU JyHgWVo65/EH7+P2YTgpif0fgEo4u6HFLb0TIOhUWENdphSGhyX94sLJbm0M88t7yXTv kiItleF+gCkYUL0WvpEIuNfsfBd7XS5zUQ1XLYXdIYUb9L1p90Ks3SOx4MDh89z/bTU/ cmU3mkwYTJXXYeM4/OG6+GS1ft7JiIDkBgKTNC08FHq+sUQqVcoUa3o3/jd7TedkXfHm VNa8tC+szHP0nwt/gUF44agKvCfymmyau3suJ/23xsmeQRp2I9OYraIjw9gCfW7mDYa5 /dyA== X-Gm-Message-State: AOJu0Yxfsdw9jq08dZvkSuR6tay04cwuF+RfunGvG4fBROqkTt9NJ4dK iuDaNXpKDNsoa5jyYm70kNGR9jvoqfTZMSrat1tvdqWmroKwpq2Qv3EODbVcBQP01JIpzuiPsP4 t X-Google-Smtp-Source: AGHT+IEHpd4x6DntDYbd75DeSaFwzZ2xaP+OtonlPRRk4Sp3fKCzz8y3ShIBABl/tHyV0+9w/GblxQ== X-Received: by 2002:a17:907:9619:b0:a77:e48d:bc8 with SMTP id a640c23a62f3a-a8090c849afmr121649466b.21.1723110997657; Thu, 08 Aug 2024 02:56:37 -0700 (PDT) Received: from cloudflare.com ([2a09:bac5:5063:2387::38a:2f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9bc9da0sm722834666b.29.2024.08.08.02.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 02:56:37 -0700 (PDT) From: Jakub Sitnicki Date: Thu, 08 Aug 2024 11:56:21 +0200 Subject: [PATCH net v4 1/3] net: Make USO depend on CSUM offload Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240808-udp-gso-egress-from-tunnel-v4-1-f5c5b4149ab9@cloudflare.com> References: <20240808-udp-gso-egress-from-tunnel-v4-0-f5c5b4149ab9@cloudflare.com> In-Reply-To: <20240808-udp-gso-egress-from-tunnel-v4-0-f5c5b4149ab9@cloudflare.com> To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , kernel-team@cloudflare.com X-Mailer: b4 0.14.1 X-Patchwork-Delegate: kuba@kernel.org UDP segmentation offload inherently depends on checksum offload. It should not be possible to disable checksum offload while leaving USO enabled. Enforce this dependency in code. There is a single tx-udp-segmentation feature flag to indicate support for both IPv4/6, hence the devices wishing to support USO must offer checksum offload for both IP versions. Fixes: 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") Suggested-by: Willem de Bruijn Signed-off-by: Jakub Sitnicki Reviewed-by: Willem de Bruijn --- net/core/dev.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 751d9b70e6ad..f66e61407883 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9912,6 +9912,15 @@ static void netdev_sync_lower_features(struct net_device *upper, } } +static bool netdev_has_ip_or_hw_csum(netdev_features_t features) +{ + netdev_features_t ip_csum_mask = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; + bool ip_csum = (features & ip_csum_mask) == ip_csum_mask; + bool hw_csum = features & NETIF_F_HW_CSUM; + + return ip_csum || hw_csum; +} + static netdev_features_t netdev_fix_features(struct net_device *dev, netdev_features_t features) { @@ -9993,15 +10002,9 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, features &= ~NETIF_F_LRO; } - if (features & NETIF_F_HW_TLS_TX) { - bool ip_csum = (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) == - (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); - bool hw_csum = features & NETIF_F_HW_CSUM; - - if (!ip_csum && !hw_csum) { - netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); - features &= ~NETIF_F_HW_TLS_TX; - } + if ((features & NETIF_F_HW_TLS_TX) && !netdev_has_ip_or_hw_csum(features)) { + netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); + features &= ~NETIF_F_HW_TLS_TX; } if ((features & NETIF_F_HW_TLS_RX) && !(features & NETIF_F_RXCSUM)) { @@ -10009,6 +10012,11 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, features &= ~NETIF_F_HW_TLS_RX; } + if ((features & NETIF_F_GSO_UDP_L4) && !netdev_has_ip_or_hw_csum(features)) { + netdev_dbg(dev, "Dropping USO feature since no CSUM feature.\n"); + features &= ~NETIF_F_GSO_UDP_L4; + } + return features; } From patchwork Thu Aug 8 09:56:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 13757167 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 C2BC4189BBA for ; Thu, 8 Aug 2024 09:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723111003; cv=none; b=Wqihd4u+8bLGbyldwY40pg+ZF5SuRKrZ5JNSK6fbIhso/ThKxVBXDhvtPYl0bUbtGaLEWiymVkc/iWZiO0Rf/chTMAqVBmpuYmqL8WjquoIkwV8dMosKzUqYplhGmCXTMjl5iSNMle5XN8hoB44Nm+yvz/nt+3TJ8mUxwCPf4Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723111003; c=relaxed/simple; bh=ofYrxRiFhAJ70TVaiyriyzdb+syk1ls6MOJtx+2Po5g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AU8QZLvHyZDsHoJMNmPM9Rn8XRASHt8DjuAFSSUI5CtpBmWYMCEFOAhISx+R89AYtiQT2pNctmFwuPTPx5seO9rHA8jRllwvCaAi0nWndB0dD9Ex8hJQsmrCHkuseolA1OFYMk4QgKwm7xfROZ4uZSdADZCVlq2oNuFZwZyP0Zc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=Spm4v1ZT; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="Spm4v1ZT" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a7a9e25008aso93887066b.0 for ; Thu, 08 Aug 2024 02:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1723111000; x=1723715800; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=T/p599qWvyrM2c1Jt+DzFLji+41+NVKxZDoSr/2/IUk=; b=Spm4v1ZTb+MZ1iud5PEOilsqg7hKUUpWsib4l5j5tuv26hljJdBO7MbmGJovg9XAMK y6s8L/fFdRqdXx8A5Ii08RX8dur25P6ql0FNbZmB44VXVnGGHTLC+sp40Q3bieVD47pD bFX3Y5450RvhKyv2yLg0xJ3vN7qU4JnOK/JfY2vgyBQ2fPzIeAWGSamt8ZhXJSgXUCWK i1NPXb3sCl8CQu0OssvXSlx3122iLhX6roeobcQyfCLC7YUKtbKeYFFjBreqctQnoC7u htDCI0rtsSfBTojRSzZKVXPfAOCUw1MEX38LRqpYyjKFMZOOm/7AuyxZyrAh731Jhbyv 568A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723111000; x=1723715800; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T/p599qWvyrM2c1Jt+DzFLji+41+NVKxZDoSr/2/IUk=; b=bKpxWnk0mpvl/JdNGH2Y7r1cQxbnKswpXO3I0AapLMEFMyz3FNUkLvqTVG43E7dJcu NEKC2efC2FLSJV1SdJE3urQ8HRew+IgcF0vsSWvCV2kRGhpA1cAYg0nwhDdgRQsZnVBu kGHXTYswpgqdq/cPMCeZrnnHBitdq4q8Jg2gM9tKWcgcgxXMOT7ljp/oIiesWEi0F+CV Vx65pNVuFi+5FxhpXmknl8C1Io9Rn4rGO21Hhl//3Ki8x53+RWqRY9QQyfd1D4a9soFp CubdsZMEOt+u24l5xQSpzwwBq6D2EPMcQI7qzSFZb4GybnvHD6wFU6w6v0+7Z6DjD/Az +pqw== X-Gm-Message-State: AOJu0YyeT9ArutC2bOHjRkIzOtZLlnVazzc5pWFLY1AlC7DPagfbGQuK H0UnAYEGBQVInwHxIYAZCzZW0PeFL3XWCLKwjaxhd6YZ4LFmHjjPYlRDEISKXiUGr6EKX6UThu5 m X-Google-Smtp-Source: AGHT+IHuSQ+h3WttOIeZug8k0eSMiyMkYw4Yre4VeI/PSqUtXaOITRLh4J2SUa3/5JG9zR9Hj20vSQ== X-Received: by 2002:a17:907:f764:b0:a7a:1d35:4106 with SMTP id a640c23a62f3a-a8090beb83cmr97479266b.5.1723110999734; Thu, 08 Aug 2024 02:56:39 -0700 (PDT) Received: from cloudflare.com ([2a09:bac5:5063:2387::38a:2f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9e8c732sm723103166b.187.2024.08.08.02.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 02:56:38 -0700 (PDT) From: Jakub Sitnicki Date: Thu, 08 Aug 2024 11:56:22 +0200 Subject: [PATCH net v4 2/3] udp: Fall back to software USO if IPv6 extension headers are present Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240808-udp-gso-egress-from-tunnel-v4-2-f5c5b4149ab9@cloudflare.com> References: <20240808-udp-gso-egress-from-tunnel-v4-0-f5c5b4149ab9@cloudflare.com> In-Reply-To: <20240808-udp-gso-egress-from-tunnel-v4-0-f5c5b4149ab9@cloudflare.com> To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , kernel-team@cloudflare.com, syzbot+e15b7e15b8a751a91d9a@syzkaller.appspotmail.com, Willem de Bruijn X-Mailer: b4 0.14.1 X-Patchwork-Delegate: kuba@kernel.org In commit 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") we have intentionally allowed UDP GSO packets marked CHECKSUM_NONE to pass to the GSO stack, so that they can be segmented and checksummed by a software fallback when the egress device lacks these features. What was not taken into consideration is that a CHECKSUM_NONE skb can be handed over to the GSO stack also when the egress device advertises the tx-udp-segmentation / NETIF_F_GSO_UDP_L4 feature. This will happen when there are IPv6 extension headers present, which we check for in __ip6_append_data(). Syzbot has discovered this scenario, producing a warning as below: ip6tnl0: caps=(0x00000006401d7869, 0x00000006401d7869) WARNING: CPU: 0 PID: 5112 at net/core/dev.c:3293 skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 Modules linked in: CPU: 0 PID: 5112 Comm: syz-executor391 Not tainted 6.10.0-rc7-syzkaller-01603-g80ab5445da62 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 RIP: 0010:skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 [...] Call Trace: __skb_gso_segment+0x3be/0x4c0 net/core/gso.c:127 skb_gso_segment include/net/gso.h:83 [inline] validate_xmit_skb+0x585/0x1120 net/core/dev.c:3661 __dev_queue_xmit+0x17a4/0x3e90 net/core/dev.c:4415 neigh_output include/net/neighbour.h:542 [inline] ip6_finish_output2+0xffa/0x1680 net/ipv6/ip6_output.c:137 ip6_finish_output+0x41e/0x810 net/ipv6/ip6_output.c:222 ip6_send_skb+0x112/0x230 net/ipv6/ip6_output.c:1958 udp_v6_send_skb+0xbf5/0x1870 net/ipv6/udp.c:1292 udpv6_sendmsg+0x23b3/0x3270 net/ipv6/udp.c:1588 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0xef/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2585 ___sys_sendmsg net/socket.c:2639 [inline] __sys_sendmmsg+0x3b2/0x740 net/socket.c:2725 __do_sys_sendmmsg net/socket.c:2754 [inline] __se_sys_sendmmsg net/socket.c:2751 [inline] __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2751 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f [...] We are hitting the bad offload warning because when an egress device is capable of handling segmentation offload requested by skb_shinfo(skb)->gso_type, the chain of gso_segment callbacks won't produce any segment skbs and return NULL. See the skb_gso_ok() branch in {__udp,tcp,sctp}_gso_segment helpers. To fix it, force a fallback to software USO when processing a packet with IPv6 extension headers, since we don't know if these can checksummed by all devices which offer USO. Fixes: 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") Reported-by: syzbot+e15b7e15b8a751a91d9a@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/000000000000e1609a061d5330ce@google.com/ Reviewed-by: Willem de Bruijn Signed-off-by: Jakub Sitnicki --- net/ipv4/udp_offload.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index bc8a9da750fe..b254a5dadfcf 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -282,6 +282,12 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, skb_transport_header(gso_skb))) return ERR_PTR(-EINVAL); + /* We don't know if egress device can segment and checksum the packet + * when IPv6 extension headers are present. Fall back to software GSO. + */ + if (gso_skb->ip_summed != CHECKSUM_PARTIAL) + features &= ~(NETIF_F_GSO_UDP_L4 | NETIF_F_CSUM_MASK); + if (skb_gso_ok(gso_skb, features | NETIF_F_GSO_ROBUST)) { /* Packet is from an untrusted source, reset gso_segs. */ skb_shinfo(gso_skb)->gso_segs = DIV_ROUND_UP(gso_skb->len - sizeof(*uh), From patchwork Thu Aug 8 09:56:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 13757168 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 2A309189F45 for ; Thu, 8 Aug 2024 09:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723111005; cv=none; b=n8soyrUa73hNOARniJOc5EX3ktW315PN6T+rvouqggZvADPFK+frmEdu9nYVHVOoUwDJ/o3hJf4w3uUuhhiBCFM+yG/GgGE+CBX5GXKwCS57jkklKm8bpPGwzHuG0HNtTiGI+gqFOOuDHURytf6cqVspnZusF0l/MagiOvFYLTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723111005; c=relaxed/simple; bh=8BjMynsZaaj57fS5DI7aS9+ZN6eNmRHZXtcj7EopA0U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eH59eduryZ5G1XqOTjhj312fp4nzO6GKnLJ/upkUaQiV5beH7dHcX4mrKdH++8gFrahKNgs2RKmrh0mFExNw4pdZBsHjdUudqhLNDUcTL16OxdToVc4ZbSbByPWuEvR4E/nzmFxQtKhrgrXi/OZ9Yk/9ju5+oD3P9CKwUyyRCEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=DweI1Z/I; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="DweI1Z/I" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52efdf02d13so1407703e87.2 for ; Thu, 08 Aug 2024 02:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1723111002; x=1723715802; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7vouzriBAMAKjajYgG7l6gvwiTRC39rAAvH0plnTP8A=; b=DweI1Z/IJ/607FBg8uU/oCDCxS5CQH/olfppAq7BvPLL6AQSr9M4iJt5J0rU8qNASd p3pVdqv1haxNmO8QeaubXWk05DBFDqasbD90C25LXRw81/JB2XDaga9iAw4hsTy84p80 6CYHL6xQi1zCtXrNvxNqk84pLe+nDxo7K7oL6kznkFyF/yd3s4HOExZZglo3xVW/C5l+ x+mzsBTeXiNd0VFAVOnxgUM8o1yfk24QUgivdpreZn+j9Yz+hrF9HF7pgHbOAR5ZXGVh jginHLNTd/spzCKjFbh9cYGcXGDWucDoTMnSCVxKqjc27gXfizJe0GTn/sQKz/Ua+jmC 9nRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723111002; x=1723715802; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7vouzriBAMAKjajYgG7l6gvwiTRC39rAAvH0plnTP8A=; b=xLmjac5/YwsKQsRpZhw1UqvNfZY54/J4Xn0EvtvMiyU1Xezy/DhkYE6WyKkiPS99s5 GSVZHzTxqY3etwikhv99VMfRMi0xc+rQtOu44WGSuh5Gvv6/zc6pfaTee39q9hicNd9T IOB+1roUpOa16BfWXMzE4PN2LR9vFagn+Ff6uIE23W6SBFQ92wEExD+hEFpeVRA3j4bI xaMgm9YhptRy29D9mWMdKocr9+qEvHCRJitrOzdQpZ9BuJL6D0zowoEZ6lSONirnuR/d j6pJdMc/i2kXvtFz0Eu+7AtVjOIpWmCvgfDXci4jhtCO/50Fr12fkbpPaYVfakzwpafZ RPtQ== X-Gm-Message-State: AOJu0Yx69Qpnk5dvfDgnSGn6vLIfCXchanrxXQtW0e483OOyaykBspf1 1MYqe/6AXnoKzjhknCJraPQae3NlvaHUp8fzV1vvXnmVKN1GOzyGC+e420gYca+5HNC1A/OyOh6 J X-Google-Smtp-Source: AGHT+IHhfQZ/HL5WMZatt0cvM7cD5/mZYPamjME+qzJzm9uhTX19KgvTPZWfSC741/LWItVbKWNm4g== X-Received: by 2002:a05:6512:3b1f:b0:52c:8b69:e039 with SMTP id 2adb3069b0e04-530e581224cmr1195510e87.4.1723111001632; Thu, 08 Aug 2024 02:56:41 -0700 (PDT) Received: from cloudflare.com ([2a09:bac5:5063:2387::38a:2f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9c129e2sm718398266b.82.2024.08.08.02.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 02:56:40 -0700 (PDT) From: Jakub Sitnicki Date: Thu, 08 Aug 2024 11:56:23 +0200 Subject: [PATCH net v4 3/3] selftests/net: Add coverage for UDP GSO with IPv6 extension headers Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240808-udp-gso-egress-from-tunnel-v4-3-f5c5b4149ab9@cloudflare.com> References: <20240808-udp-gso-egress-from-tunnel-v4-0-f5c5b4149ab9@cloudflare.com> In-Reply-To: <20240808-udp-gso-egress-from-tunnel-v4-0-f5c5b4149ab9@cloudflare.com> To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , kernel-team@cloudflare.com, Willem de Bruijn X-Mailer: b4 0.14.1 X-Patchwork-Delegate: kuba@kernel.org 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 Signed-off-by: Jakub Sitnicki --- tools/testing/selftests/net/udpgso.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/udpgso.c b/tools/testing/selftests/net/udpgso.c index 3e74cfa1a2bf..3f2fca02fec5 100644 --- a/tools/testing/selftests/net/udpgso.c +++ b/tools/testing/selftests/net/udpgso.c @@ -67,6 +67,7 @@ struct testcase { int gso_len; /* mss after applying gso */ int r_num_mss; /* recv(): number of calls of full mss */ 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 = { @@ -77,6 +78,8 @@ const struct in_addr addr4 = { __constant_htonl(0x0a000001), /* 10.0.0.1 */ }; +static const char ipv6_hopopts_pad1[8] = { 0 }; + struct testcase testcases_v4[] = { { /* no GSO: send a single byte */ @@ -255,6 +258,13 @@ struct testcase testcases_v6[] = { .gso_len = 1, .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 */ .tlen = 5, @@ -396,11 +406,18 @@ static void run_one(struct testcase *test, int fdt, int fdr, int i, ret, val, mss; 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, test->tlen, test->gso_len, + test->v6_ext_hdr ? "ext-hdr " : "", 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; if (cfg_do_setsockopt) { 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, error(1, 0, "send succeeded while expecting failure"); if (!sent && !test->tfail) 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) return;