From patchwork Sun Nov 29 17:16:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5814 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp11766851lad; Sun, 29 Nov 2026 09:16:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGm4oY1ihwN9B5fnt0+Txm1p1FvCc9rPbiQxFmT2/FNYUKBorudvTZBJ0PCXEn+RiPiYMJDBH5WI5k=@openvpn.net X-Received: by 2002:a05:7300:c7c4:b0:376:13e5:e8fe with SMTP id 5a478bee46e88-3856c4b839cmr29102568eec.3.1795972596956; Sun, 29 Nov 2026 09:16:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795972596; cv=none; d=google.com; s=arc-20260327; b=puZwfdUhxe2iHoNgHdQ/YyYVYXu8CnKyq1/4rUWvDqR3C6U+BxlyTatvOlWDSZBU4d cAWatzQMC2bniVt2wvNyGWiBdduJAQhFHTDNvjg+Fe8YYcmijXeJJY3oCVIL1kFFr3M2 K7rycZxoadrNmtkwyDTjZeCCwLN9ZP/V4wLZ3EHK6dHmSV+jR9Aw/LNfvxAgMm8mPB17 5jgNCBmSm9KDqetT+BWIkfz9Y3pGYeLUWIkX5B8+B/LdFgz4NcEvMc+4+dJtJe1uZkAV Xysp7BCapJKizW5IJPJqKM38phIWAuk8gQCI/btI+orMOpFqmhsZnEpNlO4v0b+/Qcln 9oSA== 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; bh=bwyrDjqfxLtp5QJOfd67LD1xJJxK0vNddpFnhqR1l3k=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=nrzp6USgv3bSM6/lwj+BbZLAtqUngTstcH15+G7erwC0WjoA3ZwIk2XM4LC0Y3lrBK c6JUoi21uDSQca7Zx7pzzjOzPgG20BIkdQZlb9TqxUkGAQdflymqwdowdo3cSYh75xmS s48uaY3HTtTDieZZt/etTun7/6OL6m8L78Jr0A0qfSpFI+g/IYIqm844hAWePZ/uvEJU 1JY5itguAE6NCxAkFq4jhBQj42UrJG8VRRu6JUonj7wj+YsEjY58BJTvlnPPfL23CFdG OaAgJkPKhzSzyrsDKWoSIIiLH+yHOdM5Jh3Cjn3ooh824/1JyGDTKln8DVfM7kCv0VlF jReA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=Kjni1jQW; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=gpooTplW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=XNSt6CaZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-38566fd31f8si119105141eec.25.2026.11.29.09.16.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Nov 2026 09:16:36 -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=Kjni1jQW; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=gpooTplW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=XNSt6CaZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de 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=bwyrDjqfxLtp5QJOfd67LD1xJJxK0vNddpFnhqR1l3k=; b=Kjni1jQW1wK0Rj Ly/lN4F048qD7TTNk2C+FBarPPcRkEDLTrkrWBawT+DVZdQxuJpDapDQm3lxhLp5vx+1Dphdbjeif vQI8ETobQknzpCwB5ZfbKxcPU7sxpkq80lUjDYiypwK6JVyvIu6IT3KSGeyUJk1zSaQBpYqrIbpDz NDQ=; 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 1xXiVu-000000002Yf-35vU; Sun, 29 Nov 2026 17:16:34 +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 1xXiVt-000000002YP-1tl4 for openvpn-devel@lists.sourceforge.net; Sun, 29 Nov 2026 17:16:33 +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=iSpRe6IgFzq8puksb3UdiDtAyTgzs6OPMFJTC897qmk=; b=gpooTplWKKSzWITj8rDH/bL9N0 Vqp3bOIVbiCPqauLrzLE3R7+nW2xLqo+hl2KlBDSEX99LZjqmUfc2YAJZ+YBc0P/z6uoh4kl/l5og XvJGk7cupN1X7u20ylCHkccKGvHnMU2+obGIXMyrdWNEfIzQcfVMzFf4QP1LLqW2AKew=; 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=iSpRe6IgFzq8puksb3UdiDtAyTgzs6OPMFJTC897qmk=; b=XNSt6CaZ/TFO5TV195ESw7BgN8 czf+tnf5nvDnNqyGze/itTBTzIcLeamcaGlEGJnxp3CAUU6uFCKenZ+69BMU2C8G3SOjYM2i4pk9J ziC70L8BR45EHqGkYWOXi3MsP9rBPfBvpZyCQ8UNOzEGv2G/pEO3+MpOfxGZIx5uVjeY=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xXiVs-000000003x8-0adS for openvpn-devel@lists.sourceforge.net; Sun, 29 Nov 2026 17:16:33 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6ATHGP8N015662 for ; Sun, 29 Nov 2026 18:16:25 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6ATHGPfH015661 for openvpn-devel@lists.sourceforge.net; Sun, 29 Nov 2026 18:16:25 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sun, 29 Nov 2026 18:16:19 +0100 Message-ID: <20261129171625.15648-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) 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: From: Razvan Cojocaru client_nat_transform() adjusted the TCP/UDP checksum at a fixed offset of 20 bytes. With IP options this rewrote the UDP destination port or the TCP data offset and flags instead, and for non-first fr [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xXiVs-000000003x8-0adS Subject: [Openvpn-devel] [PATCH v2] clinat: locate the TCP/UDP header via the IP header length 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: 1883213762123096064 X-GMAIL-MSGID: 1883213762123096064 From: Razvan Cojocaru client_nat_transform() adjusted the TCP/UDP checksum at a fixed offset of 20 bytes. With IP options this rewrote the UDP destination port or the TCP data offset and flags instead, and for non-first fragments it modified payload bytes. Use the header length from the IP header and skip the transport checksum for non-first fragments, as mss_fixup_ipv4() does. Change-Id: Ibd316e5c3e6a0fb600ec4817aa079554464fd942 Signed-off-by: Razvan Cojocaru Acked-by: Antonio Quartulli Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2208 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2208 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Antonio Quartulli diff --git a/src/openvpn/clinat.c b/src/openvpn/clinat.c index fc4acef..a046324 100644 --- a/src/openvpn/clinat.c +++ b/src/openvpn/clinat.c @@ -247,32 +247,45 @@ ADJUST_CHECKSUM(accumulate, h->ip.check); + /* The TCP/UDP header follows any IP options, and only the first + * fragment carries it. */ + const int hlen = OPENVPN_IPH_GET_LEN(h->ip.version_len); + struct buffer l4 = *ipbuf; + if ((ntohs(h->ip.frag_off) & OPENVPN_IP_OFFMASK) || hlen < (int)sizeof(struct openvpn_iphdr) + || !buf_advance(&l4, hlen)) + { + return; + } + if (h->ip.protocol == OPENVPN_IPPROTO_TCP) { - if (BLENZ(ipbuf) >= sizeof(struct openvpn_iphdr) + sizeof(struct openvpn_tcphdr)) + if (BLENZ(&l4) >= sizeof(struct openvpn_tcphdr)) { - ADJUST_CHECKSUM(accumulate, h->u.tcp.check); + struct openvpn_tcphdr *tcp = (struct openvpn_tcphdr *)BPTR(&l4); + ADJUST_CHECKSUM(accumulate, tcp->check); } } else if (h->ip.protocol == OPENVPN_IPPROTO_UDP) { - if (BLENZ(ipbuf) >= sizeof(struct openvpn_iphdr) + sizeof(struct openvpn_udphdr)) + if (BLENZ(&l4) >= sizeof(struct openvpn_udphdr)) { + struct openvpn_udphdr *udp = (struct openvpn_udphdr *)BPTR(&l4); + /* RFC 768: a UDP checksum of 0 means "no checksum computed". * Do not run the incremental adjustment over a non-checksum, * or we will write a bogus non-zero value into the field. */ - if (h->u.udp.check) + if (udp->check) { - ADJUST_CHECKSUM(accumulate, h->u.udp.check); + ADJUST_CHECKSUM(accumulate, udp->check); - if (!h->u.udp.check) + if (!udp->check) { /* RFC 768: a computed checksum of 0 must be transmitted * as 0xFFFF (one-complement), because 0 is reserved for * "no checksum computed" */ - h->u.udp.check = 0xFFFF; + udp->check = 0xFFFF; } } }