From patchwork Tue Nov 10 17:06:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5657 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:20a6:b0:11a:a05e:cb97 with SMTP id 38csp1374128lad; Tue, 10 Nov 2026 09:06:51 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHZWDeBwNMZROcGosm5+Uunn9GiHogekpucPV1HmhbxOzAl3wr/pegZooT1RtA4SLXxtrb9ibKf0cY=@openvpn.net X-Received: by 2002:a05:7301:d0f:b0:36a:15cb:30bf with SMTP id 5a478bee46e88-3751eb8c42emr5719325eec.13.1794330411509; Tue, 10 Nov 2026 09:06:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794330411; cv=none; d=google.com; s=arc-20260327; b=hRRzZwM1+huViAvDOQRuRNCe3+v4dYBnZ9DruJkJ8zAhJ8tva8YxS9ybnp9P3SDy6/ aBwRdjrjUfJ4+Tuws2BdftAnmL4MOvftHado/vazMcs8mB53DqBmebmLqmZyWGwMOn7M JLA2+t8bxq+JMrmsixHvUnwKcxQ1mBCitGhpRXyR5xX7cTcpOzNhUbSWzh/FniRblYRO jOMrU8iVW1UePId4xIATTjbPdlvwqlYkOd+vESsDuSvQzfnxg++ThU7+Nyj6S7Gs0CoN 3PFH3aLC9jr6xYmpteKOY4r8k5n02DBH7Wa85OUURiorXK3bGYgQK/Lz7ZpiYYkYkpF0 rOJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=+wx3t3/lC5NeUsFr1934jc8yDlJ7DNawQad3DLVc0jo=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=bpLGsSUqZKyJ4VNAFkQTG6B4ANuHqGpkJ5UA5ZaLi8p9h7bR6+iEYxB6lYJRaazgOz z4gpJtlXdb9wAHM0ttgcpOJ0GfHa5QLiD86AFLIDDk0NnIThW+ig+LZEVZ7O4WmnDJoF 7vfo5jH96rIziydpCkoHqj+huP6H3VvAqvJPWbGMuZlHMg5fUeKWKw6WTlNeTMFuCbil hHaXKMrZcM4uZj14DsBjnBzQThVJTcl7nEUftOXT5hX7W7u1Qv5/e0aW+EUQuXMsoURq 9MXEpR34kDc+K9oWu0ynhtQ6gDyskywS9CASK9gRnT0B/1+WxnSnHeJoBr5yZUuHqlOI 9AAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=LyHQs+yb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Y3m3y8NX; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=M8l85xSf; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=uubRhmAX; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-3751dce4b46si9150221eec.4.2026.11.10.09.06.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 09:06:51 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=LyHQs+yb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Y3m3y8NX; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=M8l85xSf; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=uubRhmAX; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=+wx3t3/lC5NeUsFr1934jc8yDlJ7DNawQad3DLVc0jo=; b=LyHQs+ybYEfPBF rCfTSFbaYdstASQwzYP+wF8tSH2ByMaNWq5BbvjOL1l9MMgw8eN6YIxTT+ZoMZ44cZJdQmiwZLyAa PCzdPc1RNXOhe6QfDEfUJAJ44Jm8Xv/QTY4cJ7CS8a+Sqy1I0i2BRClKR083HXVKBlAptsmTyuZ/A eA4=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQpJ1-000000000UD-3CRR; Tue, 10 Nov 2026 17:06:47 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQpIz-000000000Ty-2hPh for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FryoE4zi1jnEKEsQMhRNYjywwDtpHiX1aBX470mv/f4=; b=Y3m3y8NXL7Gj+QAR4G9OJqAlk4 mNk0+R+/wYJNknk7GnvM4tvr8bk/wcrc+pxcMF+qw6is5KrPPqhQZMI74rxYSyzbC+oOsQELAorlU OCYC3I6F05dFx/KwdPDDxhBTTOb4rleyzywPymzbYNasJDD+gkI8mtN/qRpTLyVNlR20=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FryoE4zi1jnEKEsQMhRNYjywwDtpHiX1aBX470mv/f4=; b=M8l85xSfcY11jps8cgmoKaO++e LCKZJZ+Zw3nb54oc29qKW1QcsNnzny/9IDCIOb8LNWlrcg3wZ7tyDV+dw05QVsUvjKqd99h1TPxDz dVVevxuW6LkCyQeJs8C4pYuMGUf13T7KEnA3n4wNT+NFldfSz8WOM/A07sHesdJGwB8Q=; Received: from mout-b-112.mailbox.org ([195.10.208.42]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xQpIw-000000003wR-2PPX for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:45 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-112.mailbox.org (Postfix) with ESMTPS id 4jPCjk33Kpz5wwm for ; Tue, 10 Nov 2026 18:06:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1794330394; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FryoE4zi1jnEKEsQMhRNYjywwDtpHiX1aBX470mv/f4=; b=uubRhmAXWX5PcdS4mcT4PLQHzof4BMtA699txJf5unDyPLO/oACs+uAdnEYuwmiAWSsUm6 NfdDYaWiqZ4bJb0BM/YDC6z/kWS/UFXH+KbjGqQGoUjJC/hmBMLZLzpJz3vgMoAUx1YvuQ PuOYUL/0RDNtm9rfRzNAjhFmi/mSzGdS4SJUj6Yeh6F0Dlc3nDqHjbpf5d+ZZAYg4c0MAg hbIfk6EiEIpzPCQ9MXhtt9ckywAUux6xi601VMQNwZfSevbC2BBqblkf3HwCNIhtdEeapa PxOTpHetm6I/nyEKpNQx5q1rywqmEzc+/W7f4+tQ0W2oYrF6CjhN4h0GVIazcQ== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Nov 2026 18:06:17 +0100 Message-ID: <86994f75fd7d92f745f06e4392f89ff2ee12c3d8.1794329430.git.ralf@mandelbit.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jPCjk33Kpz5wwm X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Frag-list GRO validates the UDP checksum of every datagram before linking it into an aggregate. Completion records that verdict by turning a CHECKSUM_NONE head into CHECKSUM_UNNECESSARY, but leaves a [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1xQpIw-000000003wR-2PPX Subject: [Openvpn-devel] [PATCH ovpn net-next v2 1/6] udp: keep the GRO checksum verdict for CHECKSUM_COMPLETE frag-lists X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881491805462451391 X-GMAIL-MSGID: 1881491805462451391 Frag-list GRO validates the UDP checksum of every datagram before linking it into an aggregate. Completion records that verdict by turning a CHECKSUM_NONE head into CHECKSUM_UNNECESSARY, but leaves a CHECKSUM_COMPLETE head untouched. Its checksum then covers only the first datagram, while uh->len spans the whole aggregate. Any later validation of such an aggregate fails. udp4_csum_init and udp6_csum_init compute the complete checksum of an aggregate no longer than CHECKSUM_BREAK and drop it as a checksum error. For a larger aggregate, conntrack's nf_checksum in PRE_ROUTING falls back to a software checksum of the whole skb, which fails, marks the packet invalid and sets csum_complete_sw, so UDP drops the aggregate too. Record the verdict for a CHECKSUM_COMPLETE head as for a device which validated the checksums itself, so that completion yields the same CHECKSUM_UNNECESSARY state in every receive checksum mode. With rx-gro-list enabled on an mlx5 port, which reports CHECKSUM_COMPLETE, a 100 Mbit/s flow of 30-byte UDP datagrams to a local socket raised UdpInCsumErrors by 3880 in five seconds and lost exactly twice as many datagrams, one pair per dropped aggregate. With rx-gro-list disabled, the counter stayed at zero. TCP frag-list completion follows the same pattern and is not changed here. Sashiko reported the issue while reviewing an ovpn series which uses frag-list GRO. Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.") Signed-off-by: Ralf Lici --- New in v2. net/ipv4/udp_offload.c | 8 ++++++++ net/ipv6/udp_offload.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index cf07c3c6611a..572a65cd8977 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -965,6 +965,14 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; + /* GRO validated every datagram, but a CHECKSUM_COMPLETE value + * covers only the first one: keep the verdict instead, as for + * a device which validated the checksums itself + */ + if (skb->ip_summed == CHECKSUM_COMPLETE) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + skb->csum_level = 0; + } __skb_incr_checksum_unnecessary(skb); return 0; diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c index 7370bcb80332..0b7ced2b5394 100644 --- a/net/ipv6/udp_offload.c +++ b/net/ipv6/udp_offload.c @@ -176,6 +176,14 @@ int udp6_gro_complete(struct sk_buff *skb, int nhoff) skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; + /* GRO validated every datagram, but a CHECKSUM_COMPLETE value + * covers only the first one: keep the verdict instead, as for + * a device which validated the checksums itself + */ + if (skb->ip_summed == CHECKSUM_COMPLETE) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + skb->csum_level = 0; + } __skb_incr_checksum_unnecessary(skb); return 0; From patchwork Tue Nov 10 17:06:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5658 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:20a6:b0:11a:a05e:cb97 with SMTP id 38csp1374130lad; Tue, 10 Nov 2026 09:06:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErEIy9xpp71lWZrg2q5cWTuVEStzvIDrrkVyXEoxM4c/FPqDOWXGqVqdvdRNTVIAJNphJzdwDHzABk0=@openvpn.net X-Received: by 2002:a05:7022:ea8b:b0:1b3:a05f:892d with SMTP id a92af1059eb24-1b3b6052719mr4026180c88.40.1794330411525; Tue, 10 Nov 2026 09:06:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794330411; cv=none; d=google.com; s=arc-20260327; b=Z3z6Z9lneHwnPey/1norqC+sdKfKucSIVuzObTIpChvZNOSgEykoiNGRz6D/EJBG95 MPAIaH/z/5OYWfmaS+4wfL74x3vk6gSWj5ku+SMlVAhmJLIVvOQ5SESVkhfKlLHTHHbr /4IDBG+ff4WgBz0xlDDVJ/14bm4ENSy3fVAfy4O61tCmJBLwZkHUHmsLW9MSLchsH3VR CKXT7U7ylYncUUUHS8fSSSsgZNa0u8biBKM3SNzMTCdnL0EdBAafO/LviBbQ7xrLYgMB YaxmWreHZQ4P3JnXAKz3puwEBJUoS8xVXQ+KC3eQFb7ISXtKexHSeN5LR8zUvF/jUtx3 qVpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=viPqeIand2LhmtUuCj6jk52AlY57BTiKxnP87Xtxnw4=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=OiRlSFDYFVFbhmuzfjf+IK6yJfk55JsLh5lDKNAqZDgW/qhSy1onk8pudUtX1ld3ko /EzMQo5vcctvJbzPo830EeeoQWXncl7S+lvkive9dD5841nVDspfVwauD7x4+oKm919D EGpH+zS0RtypRGTdi43L8FNWABLPA/L3OxifmNlqGWPoIdiAzkpmQaqu1bKaM9RxRMO5 QFNoMvBf6QWh7I46qM4jG/HDSIXcumeax4dCf8lZCllNczrSDWaZYFiLk9Sx+DecZGAe JuCnCIaWajpU3eM9Wdy9cn9Wd8dBNAkl4OtdD5tLm2aRKoNHuXAwZvDu37ONb2+Ay2s7 KWHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=YfDikyJ8; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=mncE5kSD; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=jSonR02G; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=qCzoMVc8; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a92af1059eb24-1b3b5dd5ffesi8273020c88.94.2026.11.10.09.06.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 09:06:51 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=YfDikyJ8; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=mncE5kSD; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=jSonR02G; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=qCzoMVc8; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=viPqeIand2LhmtUuCj6jk52AlY57BTiKxnP87Xtxnw4=; b=YfDikyJ886v+6D 8cUScKvjTYFi0vbL0qtPAYAmuiYcytuqZhTl2MJaGRVpho9uVmw5P4axjzhFJjFavPHOiyBo1qtuA AhilR4wr6GHmYu7d/X7nKYZPmylzWPk79TmF99AZ4CM3Kv1sLs1tMKxS541uYjTZ4cZtuL49itbOS zvU=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQpJ4-000000006Pw-09oN; Tue, 10 Nov 2026 17:06:50 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQpJ1-000000006Pb-2SYH for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=O/7Xb03YejSulFw8+oLFVK7IuD3OLEu7pg5vMQZwhjs=; b=mncE5kSDVvLdCsB1IqXvQuEK+N itnqncdN9nVYk+4/vYs+xMnEuD/4M06OEfN3c8Pccca4ObhzDSfksdnmvu26WogOB0qA5rUXmt+OM ei+Hg6rkU8cmoWbLntitSRsquRt7i6iLzz1aMpFk1azugYH8K51RIdWpbD9HhWeQ4Y5I=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=O/7Xb03YejSulFw8+oLFVK7IuD3OLEu7pg5vMQZwhjs=; b=jSonR02Gjk1C+L9OZPz4ODdi2s Rqo0wmHMyIJ1yULbxRxY8Ms8GPMIddK4d92p3W39Lckq/7axSh9tgCsFqlfzY2BTbqcMlp3cjh+hB Y2MrcnJ0QrXRGDDIx5aDPqHnq6mMdfFfu/QgLaC2CVMvc6KbvAk7DjBBfseIhtARnOfM=; Received: from mout-b-201.mailbox.org ([195.10.208.61]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xQpIw-000000004PT-3yXx for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:46 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-201.mailbox.org (Postfix) with ESMTPS id 4jPCjk6YtgzLm11 for ; Tue, 10 Nov 2026 18:06:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1794330394; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O/7Xb03YejSulFw8+oLFVK7IuD3OLEu7pg5vMQZwhjs=; b=qCzoMVc8RWCu71Y9pIznZTIILzbhcmPqD4JoPe9A8zKRCHRhvN/fHcJJ1iQDMfdK3G4s+9 IZZU3CUHrDG0PWgFrw8TyrcZNMf+RJQiYsNnYU9fTGWFnk2buDYOJ7tmnAPkfAn7uyZakk VJCd/f6zUFxbL+GfC0Kw5evOXrC8n8Tf8sm28pUZdbS3VzsayJa3qvttPzy2A2R5UrcJBc I2oxhSPebuWoeKw1Uf8OZpF8GVFWNnZI9VZeYcKRjut+Zjnn3MWp+lv7ELEeUaLQmHCrow zTIAZqDuKcDN3M7xvBneKKv+1luyAegQuOfo7Ouw7qSVZkxdOdbQ74+y4pKT2w== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Nov 2026 18:06:18 +0100 Message-ID: <22dd867c764497525c4544c90fe08b23dbb6616e.1794329430.git.ralf@mandelbit.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jPCjk6YtgzLm11 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Since commit 3d010c8031e3 ("udp: do not accept non-tunnel GSO skbs landing in a tunnel"), udp_unexpected_gso segments generic UDP L4 and frag-list GSO before passing packets to an encapsulation callba [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [195.10.208.61 listed in wl.mailspike.net] X-Headers-End: 1xQpIw-000000004PT-3yXx Subject: [Openvpn-devel] [PATCH ovpn net-next v2 2/6] udp: let encapsulation callbacks consume UDP frag-list GSO X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881491805490519479 X-GMAIL-MSGID: 1881491805490519479 Since commit 3d010c8031e3 ("udp: do not accept non-tunnel GSO skbs landing in a tunnel"), udp_unexpected_gso segments generic UDP L4 and frag-list GSO before passing packets to an encapsulation callback, because GRO socket lookup cannot prove that such an aggregate will not later reach a tunnel. This protects callbacks which only understand UDP tunnel GSO packets, but also prevents an encapsulator from deliberately batching independent outer UDP records as a standard frag-list aggregate. Add an explicit per-socket opt-in for an encap_rcv callback which accepts the exact SKB_GSO_UDP_L4 | SKB_GSO_FRAGLIST representation. Publish acceptance only after the callbacks which consume that representation, and read it with acquire ordering. Treat the opt-in as provisional: segment the aggregate and process every datagram normally if the callback is absent or declines it. A declining callback must leave the aggregate unmodified. This keeps the combined representation away from the UDP socket and leaves callbacks which do not opt in protected as before. Check the inbound XFRM policy and reset conntrack state once for an aggregate passed to such a callback. Its datagrams share the verdict, and a check after a fallback would lack the state which the first one consumed. Preserve the sampled acceptance decision across concurrent callback changes and account every consumed datagram in UDP statistics. Consuming the aggregate whole avoids rebuilding every datagram only for the encapsulator to discard its outer headers, and lets the callback amortize per-batch work and look ahead across records. With this series and the ovpn UDP GSO transmit series applied, five interleaved 60-second iperf3 -Z single-flow AES-128-GCM runs in each direction over two directly connected 100-Gbit/s mlx5 ports, after a 10-second warm-up, compared direct consumption by the ovpn GRO callback with the same kernel in which ovpn declines every aggregate: Forward Reverse UDP segmentation 20.561 Gbit/s 20.498 Gbit/s Direct consumption 25.741 Gbit/s 25.150 Gbit/s Direct consumption improved throughput by 25.2% forward and 22.7% reverse, and reduced mean cycles per byte across the monitored data-path CPUs by 10.6% and 8.2%, respectively. Export skb_gro_receive_list, already shared by the core UDP and TCP frag-list GRO paths, so modular encapsulators can construct the same standard representation. Signed-off-by: Ralf Lici --- Changes since v1 https://lore.kernel.org/openvpn-devel/19426aa5f9a5805f925014be8b057dc2fba335d7.1794314969.git.ralf@mandelbit.com/ - Drop the pre-encapsulation checksum bypass, made redundant by the previous patch. (Sashiko) - Check the inbound XFRM policy and reset conntrack state once for an accepted aggregate, and count all its datagrams on a drop. (Sashiko) - Read frag-list acceptance with acquire ordering and warn when setting up a socket which still accepts frag-lists. (Sashiko) - Require a declined aggregate to be left unmodified, without the allowance for layout-only pulls. include/linux/udp.h | 17 ++++++++++ include/net/udp_tunnel.h | 1 + net/core/gro.c | 1 + net/ipv4/udp.c | 65 +++++++++++++++++++++++++++++++------- net/ipv4/udp_tunnel_core.c | 12 +++++++ net/ipv6/udp.c | 65 +++++++++++++++++++++++++++++++------- 6 files changed, 139 insertions(+), 22 deletions(-) diff --git a/include/linux/udp.h b/include/linux/udp.h index 998906ec3b32..cb3fd34d56f6 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h @@ -67,6 +67,10 @@ enum { UDP_FLAGS_ACCEPT_FRAGLIST, UDP_FLAGS_ACCEPT_L4, UDP_FLAGS_ENCAP_ENABLED, /* This socket enabled encap */ + /* encap_rcv accepts UDP L4 frag-list GSO. If it does not consume such + * an aggregate, it must leave it unmodified. + */ + UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST, }; /* per NUMA structure for lockless producer usage. */ @@ -211,6 +215,19 @@ static inline bool udp_encap_needed(void) return false; } +static inline bool udp_encap_accepts_fraglist(struct sock *sk, + struct sk_buff *skb) +{ + /* pairs with set_mask_bits in setup_udp_tunnel_sock, so the callbacks + * published before acceptance are visible once it is observed + */ + return skb_is_gso(skb) && + skb_shinfo(skb)->gso_type == + (SKB_GSO_UDP_L4 | SKB_GSO_FRAGLIST) && + test_bit_acquire(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST, + &udp_sk(sk)->udp_flags); +} + static inline bool udp_unexpected_gso(struct sock *sk, struct sk_buff *skb) { if (!skb_is_gso(skb)) diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h index 498b7b262fa9..a540e86d5f84 100644 --- a/include/net/udp_tunnel.h +++ b/include/net/udp_tunnel.h @@ -85,6 +85,7 @@ struct udp_tunnel_sock_cfg { void *sk_user_data; /* user data used by encap_rcv call back */ /* Used for setting up udp_sock fields, see udp.h for details */ __u8 encap_type; + unsigned long udp_flags; udp_tunnel_encap_rcv_t encap_rcv; udp_tunnel_encap_err_lookup_t encap_err_lookup; udp_tunnel_encap_err_rcv_t encap_err_rcv; diff --git a/net/core/gro.c b/net/core/gro.c index ff828a3dce3c..069df5d96075 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -266,6 +266,7 @@ int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb) return 0; } +EXPORT_SYMBOL(skb_gro_receive_list); static void gro_complete(struct gro_node *gro, struct sk_buff *skb) { diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 303d0102519a..d62452c0f663 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2383,6 +2383,29 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) return 0; } +/* Check the inbound policy and reset conntrack state, dropping the skb on + * failure. An accepted frag-list aggregate is checked once: its datagrams + * share the verdict, and a check after a fallback would lack the state which + * the first one consumed. + */ +static bool udp_queue_rcv_policy(struct sock *sk, struct sk_buff *skb, + bool encap_fraglist) +{ + if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { + unsigned int segs = encap_fraglist ? + skb_shinfo(skb)->gso_segs : 1; + + __SNMP_ADD_STATS(sock_net(sk)->mib.udp_statistics, + UDP_MIB_INERRORS, segs); + numa_drop_add(&udp_sk(sk)->drop_counters, segs); + sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_XFRM_POLICY); + return false; + } + nf_reset_ct(skb); + + return true; +} + /* returns: * -1: error * 0: success @@ -2391,7 +2414,8 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) * Note that in the success and error cases, the skb is assumed to * have either been requeued or freed. */ -static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) +static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb, + bool encap_fraglist) { enum skb_drop_reason drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; struct udp_sock *up = udp_sk(sk); @@ -2400,12 +2424,6 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) /* * Charge it to the socket, dropping if the queue is full. */ - if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { - drop_reason = SKB_DROP_REASON_XFRM_POLICY; - goto drop; - } - nf_reset_ct(skb); - if (static_branch_unlikely(&udp_encap_needed_key) && READ_ONCE(up->encap_type)) { int (*encap_rcv)(struct sock *sk, struct sk_buff *skb); @@ -2424,6 +2442,8 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) /* if we're overly short, let UDP handle it */ encap_rcv = READ_ONCE(up->encap_rcv); if (encap_rcv) { + unsigned int segs = encap_fraglist ? + skb_shinfo(skb)->gso_segs : 1; int ret; /* Verify checksum before giving to encap */ @@ -2431,7 +2451,12 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) goto csum_error; ret = encap_rcv(sk, skb); - if (ret <= 0) { + if (!ret) { + __SNMP_ADD_STATS(net->mib.udp_statistics, + UDP_MIB_INDATAGRAMS, segs); + return 0; + } + if (ret < 0 && !encap_fraglist) { __UDP_INC_STATS(net, UDP_MIB_INDATAGRAMS); return -ret; } @@ -2440,6 +2465,13 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) /* FALLTHROUGH -- it's a UDP Packet */ } + /* The encapsulator did not consume an aggregate it had opted into so + * we ask udp_queue_rcv_skb to retry after segmentation rather than + * exposing multiple datagrams to the socket as one. + */ + if (encap_fraglist) + return -EAGAIN; + prefetch(&sk->sk_rmem_alloc); if (rcu_access_pointer(sk->sk_filter) && udp_lib_checksum_complete(skb)) @@ -2466,11 +2498,18 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) static int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) { + bool encap_fraglist = udp_encap_accepts_fraglist(sk, skb); struct sk_buff *next, *segs; int ret; - if (likely(!udp_unexpected_gso(sk, skb))) - return udp_queue_rcv_one_skb(sk, skb); + if (likely(encap_fraglist || !udp_unexpected_gso(sk, skb))) { + if (!udp_queue_rcv_policy(sk, skb, encap_fraglist)) + return -1; + + ret = udp_queue_rcv_one_skb(sk, skb, encap_fraglist); + if (likely(ret != -EAGAIN)) + return ret; + } BUILD_BUG_ON(sizeof(struct udp_skb_cb) > SKB_GSO_CB_OFFSET); __skb_push(skb, -skb_mac_offset(skb)); @@ -2479,7 +2518,11 @@ static int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) __skb_pull(skb, skb_transport_offset(skb)); udp_post_segment_fix_csum(skb); - ret = udp_queue_rcv_one_skb(sk, skb); + /* datagrams of a declined aggregate share its verdict */ + if (!encap_fraglist && !udp_queue_rcv_policy(sk, skb, false)) + continue; + + ret = udp_queue_rcv_one_skb(sk, skb, false); if (ret > 0) ip_protocol_deliver_rcu(dev_net(skb->dev), skb, ret); } diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c index a128fe85620d..c023344891a2 100644 --- a/net/ipv4/udp_tunnel_core.c +++ b/net/ipv4/udp_tunnel_core.c @@ -71,6 +71,13 @@ static bool sk_saddr_any(struct sock *sk) void setup_udp_tunnel_sock(struct net *net, struct sock *sk, struct udp_tunnel_sock_cfg *cfg) { + const unsigned long allowed = BIT(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST); + unsigned long flags = cfg->udp_flags & allowed; + + WARN_ON_ONCE(cfg->udp_flags & ~allowed); + /* a socket must stop accepting frag-lists before it is set up again */ + WARN_ON_ONCE(udp_test_bit(ENCAP_ACCEPT_FRAGLIST, sk)); + /* Disable multicast loopback */ inet_clear_bit(MC_LOOP, sk); @@ -87,6 +94,11 @@ void setup_udp_tunnel_sock(struct net *net, struct sock *sk, udp_sk(sk)->gro_receive = cfg->gro_receive; udp_sk(sk)->gro_complete = cfg->gro_complete; + /* Publish frag-list acceptance only after the callbacks which consume + * that representation + */ + set_mask_bits(&udp_sk(sk)->udp_flags, allowed, flags); + udp_tunnel_encap_enable(sk); udp_tunnel_update_gro_rcv(sk, true); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 59f9872c3552..8c8a51508eb0 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -810,18 +810,36 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) return 0; } -static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) +/* Check the inbound policy and reset conntrack state, dropping the skb on + * failure. An accepted frag-list aggregate is checked once: its datagrams + * share the verdict, and a check after a fallback would lack the state which + * the first one consumed. + */ +static bool udpv6_queue_rcv_policy(struct sock *sk, struct sk_buff *skb, + bool encap_fraglist) { - enum skb_drop_reason drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; - struct udp_sock *up = udp_sk(sk); - struct net *net = sock_net(sk); - if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { - drop_reason = SKB_DROP_REASON_XFRM_POLICY; - goto drop; + unsigned int segs = encap_fraglist ? + skb_shinfo(skb)->gso_segs : 1; + + __SNMP_ADD_STATS(sock_net(sk)->mib.udp_stats_in6, + UDP_MIB_INERRORS, segs); + numa_drop_add(&udp_sk(sk)->drop_counters, segs); + sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_XFRM_POLICY); + return false; } nf_reset_ct(skb); + return true; +} + +static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb, + bool encap_fraglist) +{ + enum skb_drop_reason drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; + struct udp_sock *up = udp_sk(sk); + struct net *net = sock_net(sk); + if (static_branch_unlikely(&udpv6_encap_needed_key) && READ_ONCE(up->encap_type)) { int (*encap_rcv)(struct sock *sk, struct sk_buff *skb); @@ -840,6 +858,8 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) /* if we're overly short, let UDP handle it */ encap_rcv = READ_ONCE(up->encap_rcv); if (encap_rcv) { + unsigned int segs = encap_fraglist ? + skb_shinfo(skb)->gso_segs : 1; int ret; /* Verify checksum before giving to encap */ @@ -847,7 +867,12 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) goto csum_error; ret = encap_rcv(sk, skb); - if (ret <= 0) { + if (!ret) { + __SNMP_ADD_STATS(net->mib.udp_stats_in6, + UDP_MIB_INDATAGRAMS, segs); + return 0; + } + if (ret < 0 && !encap_fraglist) { __UDP6_INC_STATS(net, UDP_MIB_INDATAGRAMS); return -ret; } @@ -856,6 +881,13 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) /* FALLTHROUGH -- it's a UDP Packet */ } + /* The encapsulator did not consume an aggregate it had opted into so + * we ask udpv6_queue_rcv_skb to retry after segmentation rather than + * exposing multiple datagrams to the socket as one. + */ + if (encap_fraglist) + return -EAGAIN; + prefetch(&sk->sk_rmem_alloc); if (rcu_access_pointer(sk->sk_filter) && udp_lib_checksum_complete(skb)) @@ -883,11 +915,18 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) static int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) { + bool encap_fraglist = udp_encap_accepts_fraglist(sk, skb); struct sk_buff *next, *segs; int ret; - if (likely(!udp_unexpected_gso(sk, skb))) - return udpv6_queue_rcv_one_skb(sk, skb); + if (likely(encap_fraglist || !udp_unexpected_gso(sk, skb))) { + if (!udpv6_queue_rcv_policy(sk, skb, encap_fraglist)) + return -1; + + ret = udpv6_queue_rcv_one_skb(sk, skb, encap_fraglist); + if (likely(ret != -EAGAIN)) + return ret; + } __skb_push(skb, -skb_mac_offset(skb)); segs = udp_rcv_segment(sk, skb, false); @@ -895,7 +934,11 @@ static int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) __skb_pull(skb, skb_transport_offset(skb)); udp_post_segment_fix_csum(skb); - ret = udpv6_queue_rcv_one_skb(sk, skb); + /* datagrams of a declined aggregate share its verdict */ + if (!encap_fraglist && !udpv6_queue_rcv_policy(sk, skb, false)) + continue; + + ret = udpv6_queue_rcv_one_skb(sk, skb, false); if (ret > 0) ip6_protocol_deliver_rcu(dev_net(skb->dev), skb, ret, true); From patchwork Tue Nov 10 17:06:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5662 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:20a6:b0:11a:a05e:cb97 with SMTP id 38csp1374542lad; Tue, 10 Nov 2026 09:07:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErErlJUl1UmMzcafNw7Yy8g3WuFMKcNEP+Q4rx0g4F74fXwbaNljywmjtycNiwJkMtq0Q14/2MUvvRI=@openvpn.net X-Received: by 2002:a05:7301:618c:10b0:36d:3c0f:cc6f with SMTP id 5a478bee46e88-3751c536520mr3993083eec.3.1794330427628; Tue, 10 Nov 2026 09:07:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794330427; cv=none; d=google.com; s=arc-20260327; b=fDuggCCNh9cF1kY/kv01/zZJ2BXNx/eAE9rAF3YRwlTU0MlckG+RDM8mESHN/5ukbR h0cU6Wc7C2SPCvZetFJtU83bZBDutNNa9Sxr42DtyvCfHNKj7FehZb9PQXXXCfuFjJYm nMvbABOcf7ekfuCP9dhYpzXK7QJfRNbsCgCpzNFdDXjwX+x+l0i+XF2391mZONXy3oBT 23QyNhR0U/EI97XfcrZUJBA/yyZiIhFZ9FvBf6uzZEEFUTRPpCgf+Tp/59tOmXwNBMvY XMncLNc1HJjWjrEa7OUfYEoNp8tH4Dh1zm167lOdfoJx3V2HB7p+fF2/FsJA3RxzfWCT cp3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=IEAia5BQ5irQSywuIKyNLq03DjjE7P3v1DOYaF6lLIw=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=SoGj2OZVjBETr9gc1k1E3BlYE3p5O/DuY3XhithVBxNzIUgCDRQUcje+ozyxY4/Idm 7G6kcH55BJY0f7Nns7pHIhKCEaOLHoKpv/2WANdM/g4FVs7IQW6QUIBqNUMR3brzCI09 5lb1bL8Z8SO8GSEtQIhKPJa6+q5Ky6v3nalNmbjh0DGuUF7qsZkoGSZs4o1x3tL3wmCZ 6Qe2BfEJR55YRohEA4kdAP6isatXgxJ7jKBQAEJMTS/fDER6n9O0nvjIqWjfHhpE2amu glJj7C2TRO1LqAY+iL9VJGi5yZuflBfrqhkEPP70YCOlMukSc/kb71CYdLN/aZg45KIR drgg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=NPib6y+O; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=McTFTwqz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gxSqUmKE; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=1fL8JEY8; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-3752229422asi7022385eec.87.2026.11.10.09.07.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 09:07:07 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=NPib6y+O; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=McTFTwqz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gxSqUmKE; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=1fL8JEY8; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=IEAia5BQ5irQSywuIKyNLq03DjjE7P3v1DOYaF6lLIw=; b=NPib6y+OPmgWNF deovUS9xEFgok2TvXwgg72FAFDwfcvY7wIwb5AIDla7FFY2tke2DEQXvBWB7cwfeqkR2Ih6G/5m0W w6G6YY3+ypfVEIic+NNzhF0OnjL8sOhaWPSi2Me77qFGaDjRnxmT4qf8ImNruxYNlh+6iywOBhJb0 IYc=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQpJ4-000000001QZ-3ZPw; Tue, 10 Nov 2026 17:06:50 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQpJ0-000000001Q5-1VBs for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7T+J4+WlOB2IxlaIc1AotJlP4U892h0v4xRYK4YTHUA=; b=McTFTwqzAZjD6vQ8lUZsywTigE jBAUdy6YVOx44yKRL69Ge0GCj41Kcz9yTDR69ON64nmVgDqKGtwo+p6bM6Z6W0NO/5WnM6q1Se/f9 6hBhxzKqxc4MQADlrrLlleQTdtt9feXeTZsl6rdTvXEegewdgXwzOskN1DU98ooewnSw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7T+J4+WlOB2IxlaIc1AotJlP4U892h0v4xRYK4YTHUA=; b=gxSqUmKEwcwSMW50qZTpgVorua tKVXFVq2sDTCef77Nj4v0tehgSbBXP5u7ntPDKcD7nKUTMmkSU3v3OFAxtBDeP72VGMvBwcF2Xtv1 zfaPrY7W4iAnIGDvQNd13UZnGUPgVEFEy9ik9thHJHI4DC5YbYWnVsIZUxgXYsaBp6rs=; Received: from mout-b-206.mailbox.org ([195.10.208.51]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xQpIx-000000003wS-1rGl for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:46 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-206.mailbox.org (Postfix) with ESMTPS id 4jPCjl2QC1zQm for ; Tue, 10 Nov 2026 18:06:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1794330395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7T+J4+WlOB2IxlaIc1AotJlP4U892h0v4xRYK4YTHUA=; b=1fL8JEY8lU6uafjO//C9fBJLZrIAe1QEaMaSBfDRlkj/tHSE26uktC6jSaLTjl8f9t+bYJ PRrxSmqywM5NtXwlryqwvxF02r+G5v9j0129nMzbkbTzEYLN3cdRr+4rI+Yal7bPlIGmxd /NNMoJNa+Emxcwxj2e/KQ7QYrSBB1Vs+U0fR2fjthwT/0Co3Uk0LqPbmdPjzls16VrAKrM GdGvZ6XEEWhzO5hlKtSZ3Il3+EvNoCiJrfIU0lpZyPrejGTnniVmDTxm4ZWCjjnYfrGsvM jcsTWcu3YlETQ5JX63v+xZcYqx56Rs5momMx75DEr2JL1d3bKhDEqMmNz56SnQ== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Nov 2026 18:06:19 +0100 Message-ID: X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jPCjl2QC1zQm X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: UDP tunnel GRO callbacks normally remain installed until their socket is destroyed. This permits the tunnel callback registry to use one callback as a global static-call target when only one tunnel ty [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Headers-End: 1xQpIx-000000003wS-1rGl Subject: [Openvpn-devel] [PATCH ovpn net-next v2 3/6] udp_tunnel: support detachable GRO receive callbacks X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881491822233791429 X-GMAIL-MSGID: 1881491822233791429 UDP tunnel GRO callbacks normally remain installed until their socket is destroyed. This permits the tunnel callback registry to use one callback as a global static-call target when only one tunnel type is active. A userspace-owned socket can instead outlive its association with an encapsulator. Allow a receive callback which produces only standard UDP frag-list GSO to opt out of the callback registry and be detached while the socket remains live. Such aggregates need no tunnel completion callback and remain valid after detach. The socket must not already have a GRO callback, which would stay pinned in the registry. Publish the detachable dispatch mode before the callback, then publish frag-list acceptance only after all callbacks which consume that representation. Load each callback once before invocation. Provide a helper which removes the socket from GRO lookup, clears its callbacks and frag-list acceptance, and waits for in-flight network readers before retiring detachable dispatch mode. Keep the helper in udp_offload.c, which is built into the UDP stack even when NET_UDP_TUNNEL is a module, so built-in callers do not gain a dependency on udp_tunnel.ko. Existing tunnel sockets retain the static-call path and semantics. Signed-off-by: Ralf Lici --- Changes since v1 https://lore.kernel.org/openvpn-devel/a648e3aea95cdd32b6411a2a920ada54905ba293.1794314969.git.ralf@mandelbit.com/ - Warn if a detachable socket already has a GRO callback, which would stay pinned in the registry. (Sashiko) include/linux/udp.h | 1 + include/net/udp_tunnel.h | 2 ++ net/ipv4/udp_offload.c | 59 +++++++++++++++++++++++++++++++++----- net/ipv4/udp_tunnel_core.c | 29 ++++++++++++++++--- 4 files changed, 80 insertions(+), 11 deletions(-) diff --git a/include/linux/udp.h b/include/linux/udp.h index cb3fd34d56f6..3ae7ef796abb 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h @@ -71,6 +71,7 @@ enum { * an aggregate, it must leave it unmodified. */ UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST, + UDP_FLAGS_GRO_RCV_DETACHABLE, /* gro_receive may be detached */ }; /* per NUMA structure for lockless producer usage. */ diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h index a540e86d5f84..3a137901c88b 100644 --- a/include/net/udp_tunnel.h +++ b/include/net/udp_tunnel.h @@ -211,10 +211,12 @@ static inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum) #if IS_ENABLED(CONFIG_NET_UDP_TUNNEL) void udp_tunnel_update_gro_lookup(struct net *net, struct sock *sk, bool add); void udp_tunnel_update_gro_rcv(struct sock *sk, bool add); +void udp_tunnel_detach_gro(struct sock *sk); #else static inline void udp_tunnel_update_gro_lookup(struct net *net, struct sock *sk, bool add) {} static inline void udp_tunnel_update_gro_rcv(struct sock *sk, bool add) {} +static inline void udp_tunnel_detach_gro(struct sock *sk) {} #endif static inline void udp_tunnel_cleanup_gro(struct sock *sk) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index 572a65cd8977..61b4e226d091 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -82,6 +82,10 @@ void udp_tunnel_update_gro_rcv(struct sock *sk, bool add) struct udp_sock *up = udp_sk(sk); int i, old_gro_type_nr; + /* Dynamically detached callbacks cannot be static-call targets. */ + if (udp_test_bit(GRO_RCV_DETACHABLE, sk)) + return; + if (!UDP_MAX_TUNNEL_TYPES || !up->gro_receive) return; @@ -144,10 +148,45 @@ void udp_tunnel_update_gro_rcv(struct sock *sk, bool add) } EXPORT_SYMBOL_GPL(udp_tunnel_update_gro_rcv); +/** + * udp_tunnel_detach_gro - detach GRO callbacks from a live UDP socket + * @sk: UDP tunnel socket + * + * The caller must hold the socket lock and keep callback state alive until + * this function returns. + */ +void udp_tunnel_detach_gro(struct sock *sk) +{ + sock_owned_by_me(sk); + + if (WARN_ON_ONCE(!udp_test_bit(GRO_RCV_DETACHABLE, sk))) + return; + + udp_tunnel_update_gro_lookup(sock_net(sk), sk, false); + WRITE_ONCE(udp_sk(sk)->gro_receive, NULL); + WRITE_ONCE(udp_sk(sk)->gro_complete, NULL); + /* No new frag-list aggregates can be formed after gro_receive is + * cleared. Any aggregate already held by GRO may safely be segmented + * before encap_rcv. + */ + udp_clear_bit(ENCAP_ACCEPT_FRAGLIST, sk); + + /* Readers which captured a callback before it was cleared must keep + * bypassing the static-call path until they have completed. + */ + synchronize_net(); + udp_clear_bit(GRO_RCV_DETACHABLE, sk); +} +EXPORT_SYMBOL_GPL(udp_tunnel_detach_gro); + static struct sk_buff *udp_tunnel_gro_rcv(struct sock *sk, + udp_tunnel_gro_receive_t gro_receive, struct list_head *head, struct sk_buff *skb) { + if (unlikely(udp_test_bit(GRO_RCV_DETACHABLE, sk))) + return call_gro_receive_sk(gro_receive, sk, head, skb); + if (static_branch_likely(&udp_tunnel_static_call)) { if (unlikely(gro_recursion_inc_test(skb))) { NAPI_GRO_CB(skb)->flush |= 1; @@ -155,16 +194,17 @@ static struct sk_buff *udp_tunnel_gro_rcv(struct sock *sk, } return static_call(udp_tunnel_gro_rcv)(sk, head, skb); } - return call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb); + return call_gro_receive_sk(gro_receive, sk, head, skb); } #else static struct sk_buff *udp_tunnel_gro_rcv(struct sock *sk, + udp_tunnel_gro_receive_t gro_receive, struct list_head *head, struct sk_buff *skb) { - return call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb); + return call_gro_receive_sk(gro_receive, sk, head, skb); } #endif @@ -776,6 +816,7 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head, struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, struct udphdr *uh, struct sock *sk) { + udp_tunnel_gro_receive_t gro_receive = NULL; struct sk_buff *pp = NULL; struct sk_buff *p; struct udphdr *uh2; @@ -794,7 +835,9 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, * cases. Such packets should be caught in udp_unexpected_gso later. */ NAPI_GRO_CB(skb)->is_flist = 0; - if (!sk || !udp_sk(sk)->gro_receive) { + if (sk) + gro_receive = READ_ONCE(udp_sk(sk)->gro_receive); + if (!gro_receive) { /* If the packet was locally encapsulated in a UDP tunnel that * wasn't detected above, do not GRO. */ @@ -841,7 +884,7 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */ skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr)); - pp = udp_tunnel_gro_rcv(sk, head, skb); + pp = udp_tunnel_gro_rcv(sk, gro_receive, head, skb); out: skb_gro_flush_final(skb, pp, flush); @@ -920,6 +963,7 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff, { struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); unsigned int newlen = skb->len - nhoff; + udp_tunnel_gro_complete_t gro_complete = NULL; struct sock *sk; int err; @@ -927,7 +971,9 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff, sk = INDIRECT_CALL_INET(lookup, udp6_lib_lookup_skb, udp4_lib_lookup_skb, skb, uh->source, uh->dest); - if (sk && udp_sk(sk)->gro_complete) { + if (sk) + gro_complete = READ_ONCE(udp_sk(sk)->gro_complete); + if (gro_complete) { skb_shinfo(skb)->gso_type = uh->check ? SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL; @@ -940,8 +986,7 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff, * functions to make them set up the inner offsets. */ skb->encapsulation = 1; - err = udp_sk(sk)->gro_complete(sk, skb, - nhoff + sizeof(struct udphdr)); + err = gro_complete(sk, skb, nhoff + sizeof(struct udphdr)); } else { err = udp_gro_complete_segment(skb); } diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c index c023344891a2..426c5e4ac583 100644 --- a/net/ipv4/udp_tunnel_core.c +++ b/net/ipv4/udp_tunnel_core.c @@ -71,12 +71,28 @@ static bool sk_saddr_any(struct sock *sk) void setup_udp_tunnel_sock(struct net *net, struct sock *sk, struct udp_tunnel_sock_cfg *cfg) { - const unsigned long allowed = BIT(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST); + const unsigned long allowed = BIT(UDP_FLAGS_GRO_RCV_DETACHABLE) | + BIT(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST); unsigned long flags = cfg->udp_flags & allowed; WARN_ON_ONCE(cfg->udp_flags & ~allowed); /* a socket must stop accepting frag-lists before it is set up again */ WARN_ON_ONCE(udp_test_bit(ENCAP_ACCEPT_FRAGLIST, sk)); + set_mask_bits(&udp_sk(sk)->udp_flags, BIT(UDP_FLAGS_GRO_RCV_DETACHABLE), + flags & BIT(UDP_FLAGS_GRO_RCV_DETACHABLE)); + if (flags & BIT(UDP_FLAGS_GRO_RCV_DETACHABLE)) { + WARN_ON_ONCE(cfg->gro_complete || + !(flags & BIT(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST))); + /* the registry ignores detachable sockets, so a callback which + * is already registered there would stay pinned + */ + WARN_ON_ONCE(udp_sk(sk)->gro_receive); + /* The socket may already be receiving packets so drain readers + * which could have observed the old dispatch mode before + * publishing the detachable callback. + */ + synchronize_net(); + } /* Disable multicast loopback */ inet_clear_bit(MC_LOOP, sk); @@ -91,13 +107,18 @@ void setup_udp_tunnel_sock(struct net *net, struct sock *sk, udp_sk(sk)->encap_err_rcv = cfg->encap_err_rcv; udp_sk(sk)->encap_err_lookup = cfg->encap_err_lookup; udp_sk(sk)->encap_destroy = cfg->encap_destroy; - udp_sk(sk)->gro_receive = cfg->gro_receive; - udp_sk(sk)->gro_complete = cfg->gro_complete; + WRITE_ONCE(udp_sk(sk)->gro_complete, cfg->gro_complete); + /* Publish receive after the completion callback which its aggregates + * may later require + */ + WRITE_ONCE(udp_sk(sk)->gro_receive, cfg->gro_receive); /* Publish frag-list acceptance only after the callbacks which consume * that representation */ - set_mask_bits(&udp_sk(sk)->udp_flags, allowed, flags); + set_mask_bits(&udp_sk(sk)->udp_flags, + BIT(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST), + flags & BIT(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST)); udp_tunnel_encap_enable(sk); From patchwork Tue Nov 10 17:06:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5661 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:20a6:b0:11a:a05e:cb97 with SMTP id 38csp1374543lad; Tue, 10 Nov 2026 09:07:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHZ5jTVrFazjMEJpq4+EsAYsgiDWgFkJGg7fGX2/eXiGxT+jXuokuUiGQYq9fMgwlFUpET7MCGiPGE=@openvpn.net X-Received: by 2002:a05:7300:b088:b0:36a:2289:c599 with SMTP id 5a478bee46e88-3751f560fb2mr3875087eec.29.1794330412802; Tue, 10 Nov 2026 09:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794330412; cv=none; d=google.com; s=arc-20260327; b=f7psQgnV9hZfcJuuUamPzuu0Gsa17v7BDV1j2zgbMq/ek+V91XzX4PuzBMih1RkyzV YcgrvmAAG1zLNG021luM9gdwWjXloHeToRjeVLTjwP9p0JUkD92OYg1HlIJ88q+JWoqS 3bKym25r/yMbmHz59fU3hyIVBqQ7zKnFntP61DVlA6JsNG0FgyaBozQWkq2BcJI1hfNj ymlRPNdGTdruBQoQWOg1S5WBRHrfotJZUsHVLEUrULX9D627P4+1SJ8Y7/ll+aNAuE4U W8EfkWK7hHSuXquPhl4NmobHGhuioTVx4NFtR2sBCFAjIkK/VVXwEI7mcdpWCM4UppEy +xLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=D8/VcxK/emqD0ajxYonZQkqro+3Tm19wk10BOBk1SYQ=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=HAWYj9mJmrz86o44WLqBcobktmvM6eUXTKFZdRDVU92l7jgKnLkA1MtSz3j1MVBry1 IeTQklrXFmo3ZWe73B0y4qAdonePrZX/Ymat92XpwwSxoqTjFasxM3VW4/jwVzhfruUn nRtbAqcqYZvJR+tEAw1/lXxGZnpoRjjnrSUXjZqhowlvv11sTM83VBU/ZjpBcND6hNKV Py9uVbiwcEobCVedNPqxm4CLSQTx+XQVEntUC1jUajLuMjBkswChG24yaMmucbTFFD3f Mjk78cKRx3qcLwCcPbwJ6cu5Lwj14vAgoChlXrDTfL9iXhV1StMeXeAqXaDp5PpPopAs dcJw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=Tw+PUrzY; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="ZUXhx/C6"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=XkPJK8mD; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=sWtZZjqw; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-3751dce49a5si8959065eec.10.2026.11.10.09.06.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 09:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=Tw+PUrzY; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="ZUXhx/C6"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=XkPJK8mD; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=sWtZZjqw; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=D8/VcxK/emqD0ajxYonZQkqro+3Tm19wk10BOBk1SYQ=; b=Tw+PUrzYzPFeje yIhiVQ+89nvFpUdV4Z6NwsOwHhHgqMlLxdoLenGHwUWjkC7SRhvDKnM8Zi7dAo+GNa2LZMmLM2+YE eeO3xd37EUeB+m866817PEII+1mGup50GjYCiSsAtWT0vSea4tyxExgdKz8vxEHZPWlChlP9Jjxzm CEo=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQpJ4-000000007gL-3yS2; Tue, 10 Nov 2026 17:06:50 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQpJ0-000000007g9-0mXe for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cXcyzr/XZayzcoifNZLbAB0Ma50LPnREs4z0RZ3grpY=; b=ZUXhx/C6SKI3KsLnqw5Dre7SRG haQAbz4rxh7nta8cOnHnBoeqdZuZbmY0rSF+DCVQrgYxQVDHUVPNXIcGtOq6ts/XG/VHcy6dV09Fx VqCFaVa8sDIY2YDfyJJlOzQgAhLddq4FJKtisKXrMSmCUyGcB+HCW9AmJGDGte5yEst0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=cXcyzr/XZayzcoifNZLbAB0Ma50LPnREs4z0RZ3grpY=; b=XkPJK8mDt7Hb7OsSbMxcEZkfEg H5UrGWc1ZcLWFRysf5d5Xz01iSd60i6ojQT1JObs8z4tvI49uCJbxXxt2W7mkxdYB4w2Gufr5pI21 +PRhmZJB7JROo87Is95301seDlTsZpUgX2A8+7Z2mIkERsQgDlugHPdAv04uSLZxxNn4=; Received: from mout-b-210.mailbox.org ([195.10.208.40]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xQpIy-000000004PW-3Rea for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:46 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-210.mailbox.org (Postfix) with ESMTPS id 4jPCjl5qZwzFqsV for ; Tue, 10 Nov 2026 18:06:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1794330395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cXcyzr/XZayzcoifNZLbAB0Ma50LPnREs4z0RZ3grpY=; b=sWtZZjqwaHK10hdxtKQlHFgXnw33NSbmxlapSFM4X6zqIzThjOevX2Te9dJr8NCIa1jTyV MAyfkH2Mojql8syBJsKrWuGnHKdGM9iUQgBcvSCTg29CfrpkngorDJe+KiYFF1sAaahx0V fmOSgiSIq6ZHnzuqSDUC8gHS013BWOxm32MLJ6aPzGEuEFHq2PnMcCxN1MoBIovMv0f/eK 73bzwYAoMArQLDx4GaOhr+DnckYmjTs0GOZizagGpphWJfOyCXeypHPo5nESRnvAjC3/gD t2c2EHaTV1wmOwfweqZAL0Yj0j9iUj2mr9zKXIsGNDpHo2Jm2RxbPc88ihg4yQ== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Nov 2026 18:06:20 +0100 Message-ID: <26279b0076d6ad26368041341247897fc1e95f08.1794329430.git.ralf@mandelbit.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jPCjl5qZwzFqsV X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: A UDP socket may retain a detachable tunnel GRO callback while it remains visible to userspace. If userspace subsequently changes UDP_ENCAP, replacing the encapsulation callbacks without first retirin [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1xQpIy-000000004PW-3Rea Subject: [Openvpn-devel] [PATCH ovpn net-next v2 4/6] udp: detach tunnel GRO before changing UDP encapsulation X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881491806810981672 X-GMAIL-MSGID: 1881491806810981672 A UDP socket may retain a detachable tunnel GRO callback while it remains visible to userspace. If userspace subsequently changes UDP_ENCAP, replacing the encapsulation callbacks without first retiring GRO leaves the old callback lifetime and frag-list acceptance state active. Validate the requested encapsulation type, then detach such a GRO callback before installing the new encapsulation implementation. Existing sockets are unaffected because no current user enables detachable GRO callbacks. UDP_ENCAP already permits userspace to change the encapsulation type of a live socket even when driver state remains attached to it. Resolving that pre-existing ownership issue is outside the scope of this change. This only keeps detachable GRO state and callback lifetimes consistent when the existing transition occurs; it does not make cross-encapsulator ownership handoff supported. Signed-off-by: Ralf Lici --- No changes since v1 https://lore.kernel.org/openvpn-devel/99b9cccf9845899bc36e92165d9443499fe8a284.1794314969.git.ralf@mandelbit.com/ net/ipv4/udp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index d62452c0f663..2d16a220c42d 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -3019,6 +3019,9 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, case 0: #ifdef CONFIG_XFRM case UDP_ENCAP_ESPINUDP: + if (udp_test_bit(GRO_RCV_DETACHABLE, sk)) + udp_tunnel_detach_gro(sk); + set_xfrm_gro_udp_encap_rcv(val, sk->sk_family, sk); #if IS_ENABLED(CONFIG_IPV6) if (sk->sk_family == AF_INET6) @@ -3031,6 +3034,9 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, #endif fallthrough; case UDP_ENCAP_L2TPINUDP: + if (udp_test_bit(GRO_RCV_DETACHABLE, sk)) + udp_tunnel_detach_gro(sk); + WRITE_ONCE(up->encap_type, val); udp_tunnel_encap_enable(sk); break; From patchwork Tue Nov 10 17:06:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5659 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:20a6:b0:11a:a05e:cb97 with SMTP id 38csp1374271lad; Tue, 10 Nov 2026 09:06:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHow9aeAhWK3qKT5EgRj8l36xKKYR0mY8+lizrVo89ARPftdzezwpYVZw0hzUXCVw+BXZABO7OyM3Y=@openvpn.net X-Received: by 2002:a05:7300:8804:b0:36f:2e77:93e2 with SMTP id 5a478bee46e88-3751fc3a36dmr4810362eec.28.1794330417363; Tue, 10 Nov 2026 09:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794330417; cv=none; d=google.com; s=arc-20260327; b=eDU4IEEGHRzeiiHGXF+s9yqypXfQ6SN4uL1MmOlaUxgWF944DpK3prwLATYEhLlQb6 9Q1HaSAlpIzlyvdop7l+v/nX2WDOi5RmR/xEaH4eOkaPtUr8s+ZshsR/sh1GXvFEWL5G 8ygFk068Ky0BL+Ar9bH05ItrVsu9JJ4ileV3SvIs3jJO/5XqpXiI4CAn+3cxIHVgOAy9 12RSNvVIqGuFuUiIdUF/oJ5iAQEkKgf916571Ahe9n1969Ji8ua80Lgk8zGBFHLoeLQh EPqKqFlvHxN4A9U2j38xzInaUzaN9koLr/GUZCd3pT2L97L5Je8VxXfu/+l1hqAo+Oll tVVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=054ExcMcuhUj3mS+Pr/FJB7oOycgijTJyMkGEUxNLXY=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=Od7CTG2Br1fGxgCB1HcGnUL2JLrOpkRs1D1rwF59hBV850YHoO9eXqbMj3pjAylxAa 5E9gMFfEjihpbQ1ZWJNHDno7FQp6XR5cD2gHKsOL/PaSVhk7uHx1xlCaDHHQh8oxL/g0 60NDrfPqy0K1mb8kFis+Rt8qUeB0wo5KVJBIWPiM40kybaeBD1vhjORncNIf6tDckByc /ORE+/ly7BE1Ss15p3CIuQlkgbUkqjd5gEaHutqAYmwtpIskHgbV/lQVi8ORw9vYwOp+ QegPHT1N3ZWtoMyTbdWFkmZhGgfULyf4flOc3Sb2EfT7tP4+3tG2QT3uTiMHNu+WUZbY E3xA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="mSDfoO9/"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=RCFeAhNN; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=JaOXHCDu; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=wyUsXB9x; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-3752209cd1esi9432102eec.83.2026.11.10.09.06.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 09:06:57 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="mSDfoO9/"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=RCFeAhNN; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=JaOXHCDu; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=wyUsXB9x; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=054ExcMcuhUj3mS+Pr/FJB7oOycgijTJyMkGEUxNLXY=; b=mSDfoO9/KCuepS OrLWd8hq0CTZaExCG570PZdDo6NOaR4DxcNHwOQKKTBOjJl6/ZSBqzGw4s0uZ+Kczr2pgOfkAgsxe ZN7cFpfm/AwQCCroub5r07xr8s2QvNa7BlYm+lPUp7OPb6X4tIADxIofTxL5Qs2gQ0odH4ThVBGgP new=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQpJ9-000000000V1-3nu8; Tue, 10 Nov 2026 17:06:55 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQpJ1-000000000U7-2St4 for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XasjfT8UaxuVL+wBkYQNjWq9PAhbzmdO7oehnAWWRDU=; b=RCFeAhNNEyOLuGHR7/z8KlOoc7 VwNCOv0iDPJqNY6+Tjq8vPvzU2i8eJk0UtoagrCAX1z06ZWOMId2zoaBL33XIGdv5zNC6vHe9pbSr /i6RssZ/lgU0HP5C6otvW4e78tS+9BLbt8TTE1DuNiPfj+mLIj+mITyqJ686oMyiyoB8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=XasjfT8UaxuVL+wBkYQNjWq9PAhbzmdO7oehnAWWRDU=; b=JaOXHCDuwlvfRgK07DcCFdJ/xY Px9e8Jqr+1scGdXsodhIRABtMad/8y0B/HD1zWk3C2lnQwGLd3RL5D0vA6Nt5de2CfZG6WcVEredU CKBpIzNgKIcA8jqfkP416gLk+hiD33wf7zT0yjNdj6TMD7aNJ/niq7dWcrvMHrNtUBJc=; Received: from mout-b-105.mailbox.org ([195.10.208.50]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xQpIz-000000003wV-1iIs for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:47 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-105.mailbox.org (Postfix) with ESMTPS id 4jPCjm1vGtz9s5q for ; Tue, 10 Nov 2026 18:06:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1794330396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XasjfT8UaxuVL+wBkYQNjWq9PAhbzmdO7oehnAWWRDU=; b=wyUsXB9xf1+/Vf4EQz39mVrXyOTOzEjFKUj419ibm7V1vlzIYoC6QMZbAHjjapevlT2pmx 1cuhN8IEgSlKdqZh4x4eE6WR25nS0+z/4D+eDXFLAOky5fH6f/GsPNgc23pTTNrKqtDTqY Znf/8e6S9RIVfYJxmpdYpbgMWxlgcgEGqaugTOYqUjXp/Lw/6Kh6nqixWEp9A9KplRIpFD +9ziLTaUK5qEY+X+2vwaAuD8NJYq866fiQJC4hGDAa52DmHRuRi1FDfHkIPW4H+zVTzFlM xqmf5GSQAr2syPqF1TazZKN+Zk4WJ812CKEoHl9pv+uBJXxTFfPFJeWorjSi3Q== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Nov 2026 18:06:21 +0100 Message-ID: <3f88e036a4684c371956d26962e2ce6d02d61ab1.1794329430.git.ralf@mandelbit.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jPCjm1vGtz9s5q X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Register a UDP tunnel GRO receive callback for ovpn data sockets and coalesce compatible DATA_V2 records from one transport flow. Keep every encrypted record as a separate frag-list entry so the recei [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1xQpIz-000000003wV-1iIs Subject: [Openvpn-devel] [PATCH ovpn net-next v2 5/6] ovpn: coalesce UDP data records with GRO X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881491812003295356 X-GMAIL-MSGID: 1881491812003295356 Register a UDP tunnel GRO receive callback for ovpn data sockets and coalesce compatible DATA_V2 records from one transport flow. Keep every encrypted record as a separate frag-list entry so the receive path can authenticate it independently. Match the complete opcode, key and peer header and require compatible outer-network and checksum state. Flush on short records, differing segment geometry, existing GSO input, or the 64-record limit. Complete a held aggregate before an incompatible record from the same transport flow, preventing the new record from overtaking it. GRO socket lookup is not authoritative, so a generic UDP frag-list aggregate may later land on an ovpn socket, for example after DNAT. Consume only aggregates with standard, unmodified geometry, private head and child skbs, linear and uniform OpenVPN headers, and an outer tuple unchanged since GRO. Decline every other aggregate so UDP segments it and retries delivery one datagram at a time. Inspect aggregates without pulling, since a declined one must reach UDP unmodified. Detach compatible frag lists directly instead of rebuilding standalone UDP packets whose outer headers would be discarded after decryption. Repair the aggregate head accounting, retain the outer headers needed for authenticated endpoint updates, propagate post-GRO protocol, ingress interface, priority, security mark and tc index metadata to every record. Clear the outer VLAN tag, redirect and classification flags and delivery time, which the receive stack consumed on the head only. The socket also opts into the detachable GRO receive contract, since it's owned by userspace. Refuse a socket which another encapsulation, such as ESP-in-UDP, has configured without setting sk_user_data, since its GRO callback could not be replaced. Teardown removes callbacks only while they remain owned by ovpn and waits for readers which may already have captured one. This keeps ovpn detachable GRO state and callback lifetimes consistent if UDP_ENCAP changes the socket configuration. The GRO implementation does not depend on the linked ovpn UDP GSO transmit series, but the measurement kernel carried it so that transmit did not limit throughput. On two directly connected 100-Gbit/s mlx5 ports, five interleaved 60-second iperf3 -Z single-flow AES-128-GCM runs in each direction, after a 10-second warm-up, produced the following mean throughput: Forward Reverse Without GRO 18.721 Gbit/s 18.777 Gbit/s With GRO 21.542 Gbit/s 21.366 Gbit/s GRO improved throughput by 15.1% forward and 13.8% reverse. Mean cycles and instructions per byte across the monitored data-path CPUs fell from 4.535 to 4.207 (7.2%) and from 10.913 to 9.417 (13.7%), respectively. Link: https://lore.kernel.org/openvpn-devel/cover.1794244231.git.ralf@mandelbit.com/ Signed-off-by: Ralf Lici --- Changes since v1 https://lore.kernel.org/openvpn-devel/36b08ba627b885149ef45de3b6a26c52f857387d.1794314969.git.ralf@mandelbit.com/ - Refuse a socket which another encapsulation has configured without setting sk_user_data (Sashiko) - Read a held aggregate's header without pulling it (Sashiko) - Check aggregates in the encap callback without pulling them (Sashiko) - Clear the redirect, classification and delivery time state which the receive stack consumed on the aggregate head only (Sashiko) - Test skb_is_gso before pulling a new record's header drivers/net/ovpn/udp.c | 326 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 315 insertions(+), 11 deletions(-) diff --git a/drivers/net/ovpn/udp.c b/drivers/net/ovpn/udp.c index 055cdb1bee13..f2deec4b44fb 100644 --- a/drivers/net/ovpn/udp.c +++ b/drivers/net/ovpn/udp.c @@ -8,11 +8,14 @@ #include #include +#include #include #include #include +#include #include #include +#include #include #include #include @@ -27,6 +30,242 @@ #include "socket.h" #include "udp.h" +/* like UDP and TCP frag-list GRO */ +#define OVPN_UDP_GRO_CNT_MAX 64 + +static bool ovpn_udp_gro_header(struct sk_buff *skb, u32 *header) +{ + const unsigned int offset = skb_gro_offset(skb); + + /* GRO replaces its frag0 pointer after holding an skb, so keep the + * openvpn header linear for later candidate comparisons + */ + if (!pskb_may_pull(skb, offset + OVPN_OPCODE_SIZE)) + return false; + + *header = get_unaligned_be32(skb->data + offset); + return true; +} + +static struct sk_buff *ovpn_udp_gro_receive_fraglist(struct sock *sk, + struct list_head *head, + struct sk_buff *skb) +{ + const unsigned int gso_size = skb_gro_len(skb); + struct sk_buff *p, *pp = NULL; + int ret = 0, nhoff; + bool flush; + u32 header; + + /* A packet which cannot join an aggregate must not overtake records of + * the same flow which GRO is still holding. Complete those first, as + * the other GRO handlers do. + */ + if (NAPI_GRO_CB(skb)->flush || skb->encapsulation || skb_is_gso(skb) || + !ovpn_udp_gro_header(skb, &header) || + FIELD_GET(OVPN_OPCODE_PKTTYPE_MASK, header) != OVPN_DATA_V2) { + NAPI_GRO_CB(skb)->flush = 1; + list_for_each_entry(p, head, list) + if (NAPI_GRO_CB(p)->same_flow) + return p; + return NULL; + } + + /* udp_gro_receive sets encap_mark before invoking a tunnel callback, + * normally because the callback recurses into an inner protocol. ovpn + * retains complete outer UDP records instead, so clear it and use + * ordinary UDP frag-list completion. + */ + NAPI_GRO_CB(skb)->encap_mark = 0; + NAPI_GRO_CB(skb)->is_flist = 1; + + list_for_each_entry(p, head, list) { + if (!NAPI_GRO_CB(p)->same_flow) + continue; + + /* A different representation, opcode, key or peer ID completes + * the held aggregate; this record can start the next one. + * Read the held header without pulling which might change the + * skb shape. + */ + if (NAPI_GRO_CB(p)->encap_mark || !NAPI_GRO_CB(p)->is_flist || + skb_headlen(p) < skb_gro_offset(p) + OVPN_OPCODE_SIZE || + get_unaligned_be32(p->data + skb_gro_offset(p)) != header) + return p; + + /* GRO has already matched the outer addresses and UDP ports; + * check the remaining outer IP fields + */ + flush = gro_receive_network_flush(udp_hdr(skb), udp_hdr(p), p); + + /* The first record determines the nominal GSO size. A shorter + * final record may follow it, but a larger record cannot. + * Checksum metadata must also be uniform because the aggregate + * exposes only one checksum state. + */ + if (gso_size > skb_shinfo(p)->gso_size || flush || + skb->ip_summed != p->ip_summed || + skb->csum_level != p->csum_level) { + pp = p; + } else { + /* skb_gro_receive_list pulls the headers already + * processed by GRO before linking this skb to the + * record list so we have to manually preserve the + * outer network header location for later handling + */ + nhoff = NAPI_GRO_CB(skb)->network_offset; + skb_set_network_header(skb, nhoff); + ret = skb_gro_receive_list(p, skb); + } + + /* complete the aggregate if the append failed, or after + * appending a shorter final record, or after reaching the + * record-count limit + */ + if (ret || gso_size != skb_shinfo(p)->gso_size || + NAPI_GRO_CB(p)->count >= OVPN_UDP_GRO_CNT_MAX) + pp = p; + + return pp; + } + + return NULL; +} + +static bool ovpn_udp_outer_match(const struct sk_buff *head, + const struct sk_buff *frag) +{ + const struct udphdr *uhf = udp_hdr(frag); + const struct udphdr *uhh = udp_hdr(head); + + /* NAT might have rewritten endpoints after GRO */ + if (unlikely(uhh->source != uhf->source || uhh->dest != uhf->dest)) + return false; + + switch (head->protocol) { + case htons(ETH_P_IP): + return ip_hdr(head)->saddr == ip_hdr(frag)->saddr && + ip_hdr(head)->daddr == ip_hdr(frag)->daddr; + case htons(ETH_P_IPV6): + return ipv6_addr_equal(&ipv6_hdr(head)->saddr, + &ipv6_hdr(frag)->saddr) && + ipv6_addr_equal(&ipv6_hdr(head)->daddr, + &ipv6_hdr(frag)->daddr); + default: + return false; + } +} + +/* validate an skb and turn it into a list of uniform OpenVPN records or return + * NULL without modifying an aggregate which UDP must segment + */ +static struct sk_buff *ovpn_udp_gso_prepare(struct sk_buff *skb, u32 header) +{ + unsigned int len = 0, truesize = 0; + struct sk_buff *list, *record; + + if (!skb_is_gso(skb)) { + skb_mark_not_on_list(skb); + goto out; + } + + list = skb_shinfo(skb)->frag_list; + if (unlikely(!list)) + return NULL; + + /* if any of the skbs is not private, ask the stack to segment */ + if (unlikely(skb_shared(skb) || skb_cloned(skb))) + return NULL; + + /* transformations after GRO only update the aggregate head: if its + * outer tuple changed, ask UDP to propagate it while segmenting + */ + if (unlikely(skb_pagelen(skb) != sizeof(struct udphdr) + + skb_shinfo(skb)->gso_size || + !ovpn_udp_outer_match(skb, list))) + return NULL; + + skb_walk_frags(skb, record) { + /* if the OpenVPN header is not uniform (batch created by + * generic GRO by coalescing unrelated packets) ask the stack + * to segment and handle each segment independently + */ + if (unlikely(skb_shared(record) || skb_cloned(record) || + skb_headlen(record) < OVPN_OPCODE_SIZE || + get_unaligned_be32(record->data) != header)) + return NULL; + + len += record->len; + truesize += record->truesize; + } + + if (unlikely(skb->data_len < len || skb->len < len || + skb->truesize < truesize)) + return NULL; + + /* detach the exclusively owned fraglist */ + skb_shinfo(skb)->frag_list = NULL; + skb->data_len -= len; + skb->truesize -= truesize; + skb->len -= len; + skb->next = list; + skb_gso_reset(skb); + +out: + /* skb_gro_receive_list has already pulled the UDP headers from child + * records, while the aggregate head still starts at UDP, so pull its + * header too before returning the list + */ + __skb_pull(skb, sizeof(struct udphdr)); + return skb; +} + +static void ovpn_udp_recv(struct ovpn_peer *peer, struct sk_buff *list) +{ + const __be16 proto = list->protocol; + const u32 priority = list->priority; +#ifdef CONFIG_NET_SCHED + const u16 tc_index = list->tc_index; +#endif +#ifdef CONFIG_NETWORK_SECMARK + const u32 secmark = list->secmark; +#endif + const int skb_iif = list->skb_iif; + struct sk_buff *skb, *next; + + skb_list_walk_safe(list, skb, next) { + /* propagate post-GRO metadata from the list head, and clear + * the state which the receive stack consumed on the head only + */ + skb->protocol = proto; + skb->skb_iif = skb_iif; + skb->priority = priority; +#ifdef CONFIG_NETWORK_SECMARK + skb->secmark = secmark; +#endif +#ifdef CONFIG_NET_SCHED + skb->tc_index = tc_index; +#endif + __vlan_hwaccel_clear_tag(skb); + skb_reset_redirect(skb); +#ifdef CONFIG_NET_XGRESS + skb->tc_skip_classify = 0; +#endif + skb_clear_delivery_time(skb); + skb_mark_not_on_list(skb); + + /* keep the current reference alive for the next record before + * handing this one to crypto + */ + if (next && unlikely(!ovpn_peer_hold(peer))) { + DEBUG_NET_WARN_ON_ONCE(1); + kfree_skb_list(next); + next = NULL; + } + ovpn_recv(peer, skb); + } +} + /* Retrieve the corresponding ovpn object from a UDP socket * rcu_read_lock must be held on entry */ @@ -69,7 +308,9 @@ static int ovpn_udp_encap_recv(struct sock *sk, struct sk_buff *skb) struct ovpn_socket *ovpn_sock; struct ovpn_priv *ovpn; struct ovpn_peer *peer; - u32 peer_id; + bool aggregate = false; + struct sk_buff *list; + u32 header, peer_id; u8 opcode; ovpn_sock = ovpn_socket_from_udp_sock(sk); @@ -89,14 +330,28 @@ static int ovpn_udp_encap_recv(struct sock *sk, struct sk_buff *skb) * header are accessible. * They are required to fetch the OP code, the key ID and the peer ID. */ - if (unlikely(!pskb_may_pull(skb, sizeof(struct udphdr) + - OVPN_OPCODE_SIZE))) { + if (skb_is_gso(skb)) { + /* Only an accepted frag-list aggregate can carry OpenVPN + * records. It is checked without pulling, since one which we + * decline must reach UDP unmodified so that it can segment it. + */ + if (unlikely(skb_shinfo(skb)->gso_type != + (SKB_GSO_UDP_L4 | SKB_GSO_FRAGLIST))) + goto drop; + aggregate = true; + + if (unlikely(skb_headlen(skb) < + sizeof(struct udphdr) + OVPN_OPCODE_SIZE)) + goto drop; + } else if (unlikely(!pskb_may_pull(skb, sizeof(struct udphdr) + + OVPN_OPCODE_SIZE))) { net_dbg_ratelimited("%s: packet too small from UDP socket\n", netdev_name(ovpn->dev)); goto drop; } - opcode = ovpn_opcode_from_skb(skb, sizeof(struct udphdr)); + header = get_unaligned_be32(skb->data + sizeof(struct udphdr)); + opcode = FIELD_GET(OVPN_OPCODE_PKTTYPE_MASK, header); if (unlikely(opcode != OVPN_DATA_V2)) { /* DATA_V1 is not supported */ if (opcode == OVPN_DATA_V1) @@ -106,7 +361,7 @@ static int ovpn_udp_encap_recv(struct sock *sk, struct sk_buff *skb) return 1; } - peer_id = ovpn_peer_id_from_skb(skb, sizeof(struct udphdr)); + peer_id = FIELD_GET(OVPN_OPCODE_PEERID_MASK, header); /* some OpenVPN server implementations send data packets with the * peer-id set to UNDEF. In this case we skip the peer lookup by peer-id * and we try with the transport address @@ -119,12 +374,27 @@ static int ovpn_udp_encap_recv(struct sock *sk, struct sk_buff *skb) if (unlikely(!peer)) goto drop; - /* pop off outer UDP header */ - __skb_pull(skb, sizeof(struct udphdr)); - ovpn_recv(peer, skb); + /* A generic aggregate may contain records for different consumers and + * post-GRO transformations may have changed only its head. Prepare + * only a private, unmodified aggregate with uniform opcode, key ID and + * peer ID; otherwise return it to UDP for segmentation. + */ + list = ovpn_udp_gso_prepare(skb, header); + if (unlikely(!list)) { + ovpn_peer_put(peer); + return 1; + } + + ovpn_udp_recv(peer, list); return 0; drop: + /* let UDP segment an accepted aggregate so that every datagram gets + * its own verdict + */ + if (aggregate) + return 1; + ovpn_dev_dstats_rx_dropped(ovpn->dev); drop_noovpn: kfree_skb(skb); @@ -512,8 +782,11 @@ int ovpn_udp_socket_attach(struct ovpn_socket *ovpn_sock, struct socket *sock, struct udp_tunnel_sock_cfg cfg = { .sk_user_data = ovpn_sock, .encap_type = UDP_ENCAP_OVPNINUDP, + .udp_flags = BIT(UDP_FLAGS_GRO_RCV_DETACHABLE) | + BIT(UDP_FLAGS_ENCAP_ACCEPT_FRAGLIST), .encap_rcv = ovpn_udp_encap_recv, .encap_destroy = ovpn_udp_encap_destroy, + .gro_receive = ovpn_udp_gro_receive_fraglist, }; struct ovpn_socket *old_data; int ret; @@ -522,6 +795,18 @@ int ovpn_udp_socket_attach(struct ovpn_socket *ovpn_sock, struct socket *sock, rcu_read_lock(); old_data = rcu_dereference_sk_user_data(ovpn_sock->sk); if (!old_data) { + /* another encapsulation (such as ESP-in-UDP) may own the + * socket without setting sk_user_data, and the GRO callback + * which it may have registered cannot be replaced + */ + if (READ_ONCE(udp_sk(ovpn_sock->sk)->encap_type) || + READ_ONCE(udp_sk(ovpn_sock->sk)->gro_receive)) { + rcu_read_unlock(); + netdev_dbg(ovpn->dev, + "provided socket already taken by other user\n"); + return -EBUSY; + } + /* socket is currently unused - we can take it */ rcu_read_unlock(); setup_udp_tunnel_sock(sock_net(ovpn_sock->sk), sock->sk, &cfg); @@ -558,16 +843,35 @@ int ovpn_udp_socket_attach(struct ovpn_socket *ovpn_sock, struct socket *sock, */ void ovpn_udp_socket_detach(struct ovpn_socket *ovpn_sock) { + struct udp_sock *up = udp_sk(ovpn_sock->sk); struct sock *sk = ovpn_sock->sk; + /* Stop accepting aggregates while encap_rcv is still available. A + * reader which sampled acceptance before it was cleared can either be + * consumed by ovpn or fall back to UDP segmentation. + */ + if (udp_test_bit(GRO_RCV_DETACHABLE, sk) && + READ_ONCE(up->gro_receive) == ovpn_udp_gro_receive_fraglist) + udp_tunnel_detach_gro(sk); + + /* UDP_ENCAP may have replaced encap_rcv while leaving other ovpn state + * attached. Clear only callbacks still owned by ovpn. The final RCU + * grace period in ovpn_socket_release drains readers which captured + * encap_rcv before this point. + */ + if (READ_ONCE(up->encap_rcv) == ovpn_udp_encap_recv) + WRITE_ONCE(up->encap_rcv, NULL); + if (READ_ONCE(up->encap_destroy) == ovpn_udp_encap_destroy) + WRITE_ONCE(up->encap_destroy, NULL); + /* Re-enable multicast loopback */ inet_set_bit(MC_LOOP, sk); /* Disable CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE conversion */ inet_dec_convert_csum(sk); - WRITE_ONCE(udp_sk(sk)->encap_type, 0); - WRITE_ONCE(udp_sk(sk)->encap_rcv, NULL); - WRITE_ONCE(udp_sk(sk)->encap_destroy, NULL); + /* UDP_ENCAP might have rewritten the encap_type */ + if (READ_ONCE(up->encap_type) == UDP_ENCAP_OVPNINUDP) + WRITE_ONCE(up->encap_type, 0); rcu_assign_sk_user_data(sk, NULL); } From patchwork Tue Nov 10 17:06:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5660 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:20a6:b0:11a:a05e:cb97 with SMTP id 38csp1374410lad; Tue, 10 Nov 2026 09:07:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFpnIARh2CL1Lw/A9RhqZDLN36BktamOVoU56elnhYNdmMRD+3IiqKVyMY0JaDwhhyDqAgJ9qs/rBc=@openvpn.net X-Received: by 2002:a05:7022:3f0e:b0:1af:2ba7:e44b with SMTP id a92af1059eb24-1b3ba7b2e9amr2297848c88.3.1794330422782; Tue, 10 Nov 2026 09:07:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794330422; cv=none; d=google.com; s=arc-20260327; b=CvvGyGBXTKVuxesv/gYW3zXGP/Yfib2jhTI5XqcqY5xi+3CGeypzSUf/nADWgFSQ/l fQqERaCPSO9s3QBbXV/PMo/tLu73f/ceIA/EcX1DrByzu5qg8oU40G4hiLkFke6rtI9r Zu5+fDv6dCr+qpCH8ApYDIN9dpMwDRA1FB8PPHzfMwMfR2DLWqTLUU8w5PT+fAygHidP w7YEn9Y5PLLRy2d4Z/qLEjw/6rvp5S+S0WiSRIpj5kzZUWP3wEN1YCpktNgayc6G3kww CeYwoO0fEL3fc/KreemFny00gzdKhsvrFlFCYxShEoQ+DoP4AnxSF/E8CNwqnLs2EnL3 r/9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=Bp95uYWXJha+x9ghBz+gZJaIznCZzVkn0Uc46vDqex4=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=s3ET2pgKEjeURHwvMfkfsHD/wOSkF50uWojcXEbUyafumx3YUYo8AMSKTRQiZGvSr6 a2dDsfa7h+qrIoyzcb3Jp+X6Q5TYM2k6EzdZM4Nt4WN4hXz3YyrebLUv3ztGpVFuKMA6 BIWGs+YaCxu4kGwy6S6Gd+VFBnEr8yPO9EMWPbEIA9kx1FJqY8DKMszn4V2uZH23lmsC EeJ7hadvuSqWzSNxiP2FNLQJbo18LR70UYccuk2hLV0YIrgXr8PQzZTku5N99PXGe8RS VfmMc1ubbbW3H0MlE4KSjaxsZswOvH5rXoaOyWhURx/nyN2Kahw+PsiQtF3grmajcJej ejww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=el1Mn4KA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=byvkR9eT; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=jp5cfHsE; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=1A99VqT3; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a92af1059eb24-1b3b5bac88bsi8675728c88.65.2026.11.10.09.07.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 09:07:02 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=el1Mn4KA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=byvkR9eT; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=jp5cfHsE; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=1A99VqT3; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=Bp95uYWXJha+x9ghBz+gZJaIznCZzVkn0Uc46vDqex4=; b=el1Mn4KAsAyMSB GT/K6VBOPOGJ6DO9N8Vbpf/eF2raQF5uWp9D2oLE+bLRwR3CyMD8pB7Xn4WPcND+hqDGUsjGwr8Fu c5uVHr3bPE/jGzOM5hzS2Ll0JkNes2hWXPj52lvY5tv3viA3kJ9sSlyb1Z2COMyYvEowxbcmhfJPi CBk=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQpJ3-000000006Pj-3e09; Tue, 10 Nov 2026 17:06:49 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQpIz-000000006PT-1R9b for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5UhDqJjli9Vr0oBWUDnMuBVQH1Ti5Wc4FeLnJLMYwlo=; b=byvkR9eTkcIPvdD5BS/nu92cqo wtuCswW07KegEq+3whinFyKQEA/owSL83Rgrn7TVWM95YVUIR8FWq1ftnl04nUUW573eF+oYxHap+ R3pU1iUYdZUzr02ywgEZYtFAUpuNVLaovuUmA9FWO4hfIDry2fk5gTvyK+fHa0PTUul0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5UhDqJjli9Vr0oBWUDnMuBVQH1Ti5Wc4FeLnJLMYwlo=; b=jp5cfHsEGGN1HWklhL+sRZR7wy RMBCt/M24dpMUjwVvPA4wgRD47a0/ofgUaoSrchiIZvYcxSPY94Wp3jSuvJh96/Fw7GGcjwRKtorV U/blLRcCuLfmHm3kzk8ozrwl2Dt501R4Oltmv3xvKYty59aOS9ZYjZ9mCShvoE7zGzkg=; Received: from mout-b-107.mailbox.org ([195.10.208.47]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xQpIy-000000003wT-2UF3 for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 17:06:45 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-107.mailbox.org (Postfix) with ESMTPS id 4jPCjm4kHhz3y1n for ; Tue, 10 Nov 2026 18:06:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1794330396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5UhDqJjli9Vr0oBWUDnMuBVQH1Ti5Wc4FeLnJLMYwlo=; b=1A99VqT3JaoJgLzQumgv8rSujwmpRJTPX+A8Xv7BUlmXiAfPe4PWk3xtfxQ2LhSQq0CAJW G7Pp4nLdP1dubhZ0xv65/KF7mpngkhl4nkI7/ocxPnb6aU7uA+BCUg5Pg860nyIHzmK93s VJGAzJxyrnK9uTVsP9WX0MgkzXMEj8EghYIFxJmGygYw+GIUx4osukO30Lb1F3E1W4X9wb ThXUi1d7nF0r2eGz86xVyDEuzOtkgO1h/HMfbp18xgYgcY9TDKnD9MB5AQWF7d0ipd6v0Z Bo3FriVHIVWbewlzWlp60puwHjyWTZno8RmxifKcyhfAsqnScpWjyAZA8yQCrQ== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Nov 2026 18:06:22 +0100 Message-ID: X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jPCjm4kHhz3y1n X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Frag-list GRO exposes later encrypted records before the receive path decrypts the current one. Use this lookahead to request write ownership of linear ciphertext cache lines two records in advance, a [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Headers-End: 1xQpIy-000000003wT-2UF3 Subject: [Openvpn-devel] [PATCH ovpn net-next v2 6/6] ovpn: prefetch encrypted records before GRO batch decryption X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881491817047604295 X-GMAIL-MSGID: 1881491817047604295 Frag-list GRO exposes later encrypted records before the receive path decrypts the current one. Use this lookahead to request write ownership of linear ciphertext cache lines two records in advance, and maintain the same distance throughout the batch, overlapping their memory access latency with the current AEAD operation. An ordinary single-record UDP receive has no later record and therefore skips the prefetch path. Only prefetch the linear part of each skb. Walking non-linear fragments here would duplicate the scatterlist walk performed by crypto and could cost more than the cache hint saves. This optimization primarily targets synchronous software AEAD, where the CPU which issues the hint subsequently overwrites the prefetched lines. An asynchronous accelerator may instead access them through DMA and is not expected to benefit in the same way; the cache hint remains correctness-neutral. With the ovpn UDP GSO transmit series also applied, five interleaved 60-second iperf3 -Z single-flow AES-128-GCM runs in each direction over two directly connected 100-Gbit/s mlx5 ports, after a 10-second warm-up, produced the following mean throughput: Forward Reverse Without RX prefetch 21.542 Gbit/s 21.366 Gbit/s With RX prefetch 25.741 Gbit/s 25.150 Gbit/s RX prefetch improved throughput by 19.5% forward and 17.7% reverse. Mean cycles per byte across the monitored data-path CPUs fell from 4.207 to 3.896, a 7.4% reduction. A same-binary comparison using the aforementioned setup found distances one and two effectively tied forward, while distance two was 3.3% faster reverse and less variable. Signed-off-by: Ralf Lici --- No changes since v1 https://lore.kernel.org/openvpn-devel/e18ef3363a3d5167cddb8b0528d447ba1d5aa2ed.1794314969.git.ralf@mandelbit.com/ drivers/net/ovpn/udp.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/net/ovpn/udp.c b/drivers/net/ovpn/udp.c index f2deec4b44fb..5d3d4cd11988 100644 --- a/drivers/net/ovpn/udp.c +++ b/drivers/net/ovpn/udp.c @@ -6,9 +6,11 @@ * Author: Antonio Quartulli */ +#include #include #include #include +#include #include #include #include @@ -33,6 +35,21 @@ /* like UDP and TCP frag-list GRO */ #define OVPN_UDP_GRO_CNT_MAX 64 +/* leave enough work between a cache hint and the record which consumes it */ +#define OVPN_UDP_GRO_PREFETCH_DISTANCE 2 + +static void ovpn_udp_prefetchw_linear(const struct sk_buff *skb) +{ + unsigned long addr = (unsigned long)skb->data; + unsigned long end = addr + skb_headlen(skb); + + /* crypto overwrites data in place, so request write ownership of each + * linear cache line before the AEAD implementation reaches it + */ + for (; addr < end; addr = ALIGN(addr + 1, L1_CACHE_BYTES)) + prefetchw((void *)addr); +} + static bool ovpn_udp_gro_header(struct sk_buff *skb, u32 *header) { const unsigned int offset = skb_gro_offset(skb); @@ -222,6 +239,7 @@ static struct sk_buff *ovpn_udp_gso_prepare(struct sk_buff *skb, u32 header) static void ovpn_udp_recv(struct ovpn_peer *peer, struct sk_buff *list) { + struct sk_buff *skb, *next, *prefetch; const __be16 proto = list->protocol; const u32 priority = list->priority; #ifdef CONFIG_NET_SCHED @@ -231,9 +249,23 @@ static void ovpn_udp_recv(struct ovpn_peer *peer, struct sk_buff *list) const u32 secmark = list->secmark; #endif const int skb_iif = list->skb_iif; - struct sk_buff *skb, *next; + int i; + + /* a fraglist GRO aggregate makes later ciphertext visible before the + * current record is decrypted, so we prime the first two records, then + * keep the cache hints the same distance ahead while draining the list + */ + prefetch = list->next ? list : NULL; + for (i = 0; i < OVPN_UDP_GRO_PREFETCH_DISTANCE && prefetch; i++) { + ovpn_udp_prefetchw_linear(prefetch); + prefetch = prefetch->next; + } skb_list_walk_safe(list, skb, next) { + if (prefetch) { + ovpn_udp_prefetchw_linear(prefetch); + prefetch = prefetch->next; + } /* propagate post-GRO metadata from the list head, and clear * the state which the receive stack consumed on the head only */