From patchwork Tue Feb 22 03:35:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 2318 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.28.255.1]) by backend41.mail.ord1d.rsapps.net with LMTP id 4E4XHuT0FGKMdwAAqwncew (envelope-from ) for ; Tue, 22 Feb 2022 09:36:20 -0500 Received: from proxy1.mail.ord1c.rsapps.net ([172.28.255.1]) by director11.mail.ord1d.rsapps.net with LMTP id gI1rJ+T0FGL9dQAAvGGmqA (envelope-from ) for ; Tue, 22 Feb 2022 09:36:20 -0500 Received: from smtp27.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.ord1c.rsapps.net with LMTPS id aGnkDeX0FGLMOwAA2VeTtA (envelope-from ) for ; Tue, 22 Feb 2022 09:36:21 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp27.gate.ord1c.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: cc8862c0-93ec-11ec-9e95-b8ca3a655ab8-1-1 Received: from [216.105.38.7] ([216.105.38.7:42132] helo=lists.sourceforge.net) by smtp27.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id ED/AB-23229-3E4F4126; Tue, 22 Feb 2022 09:36:20 -0500 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.94.2) (envelope-from ) id 1nMWGJ-0002Ht-Ct; Tue, 22 Feb 2022 14:35:30 +0000 Received: from [172.30.20.202] (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.94.2) (envelope-from ) id 1nMWGH-0002HV-O7 for openvpn-devel@lists.sourceforge.net; Tue, 22 Feb 2022 14:35:28 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=j/JmB66PSFrZslhUbInc4W3FlfqtwUa5sKxJN8AIthE=; b=OV0Pq2DpBMDmL+5VEB83GoF5MM PqpCuwDjzuA1gMfWJdlyrgInQTiEbS0fbBRro5gv613qOu5Vi2Z+otXtlXBYqcDtbXVv8vmsmc2J6 e1fKKi7Ao0bCmL1EYtvFB6HVQdyabUMe1XKRHhm8Tfw8PrFMJA8H+42+hWyf9DUCluZM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=j/JmB66PSFrZslhUbInc4W3FlfqtwUa5sKxJN8AIthE=; b=W SUQEjTMdZ5sGPwItj9PxyXHmJ8usoXcPdeNOy/oSAWJZJv7iCh784ahHnPxZB23qYfakPWG1ijYAA JxnskIP6gXi6g7PR5dH8X8+Cx5C5Cc8pLjckqFumXavQEfxkbcZrkiKhAJOEIJ+PuMBM+mtSsYQfc RGPee+rZ/aEYyO3E=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1nMWGF-0002rm-0I for openvpn-devel@lists.sourceforge.net; Tue, 22 Feb 2022 14:35:27 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.15.2/8.14.9) with ESMTP id 21MEZGJB003574 for ; Tue, 22 Feb 2022 15:35:16 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.15.2/8.14.9/Submit) id 21MEZFiO003572 for openvpn-devel@lists.sourceforge.net; Tue, 22 Feb 2022 15:35:15 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 22 Feb 2022 15:35:14 +0100 Message-Id: <20220222143514.3480-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", 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: Commit 4225114b96 repaired "--mtu-disc yes" brokenness for IPv4 UDP sockets (caused by autoconf/ifdef issues). This patch adds new functionality to do --mtu-disc for IPv6 sockets as well. Half of it (setsockopt(IPV6_MTU_DISCOVER)) was already there, but receiving of detailed socket errors was missing the enablement of setsockopt(IPV6_RECVERR) and parsing of IPPROTO_IPV6/IPV6_RECVERR me [...] Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1nMWGF-0002rm-0I Subject: [Openvpn-devel] [PATCH] Implement --mtu-disc for IPv6 UDP sockets. 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 Commit 4225114b96 repaired "--mtu-disc yes" brokenness for IPv4 UDP sockets (caused by autoconf/ifdef issues). This patch adds new functionality to do --mtu-disc for IPv6 sockets as well. Half of it (setsockopt(IPV6_MTU_DISCOVER)) was already there, but receiving of detailed socket errors was missing the enablement of setsockopt(IPV6_RECVERR) and parsing of IPPROTO_IPV6/IPV6_RECVERR messages received. With that, we now get (sending over a route with "mtu 1300"): 2022-02-22 15:28:07 write UDPv6 [EMSGSIZE Path-MTU=1300]: Message too long (fd=3,code=90) 2022-02-22 15:28:07 Note adjusting 'mssfix 1400 mtu' to 'mssfix 1300 mtu' according to path MTU discovery 2022-02-22 15:28:07 Note adjusting 'fragment 1400 mtu' to 'fragment 1300 mtu' according to path MTU discovery Signed-off-by: Gert Doering Acked-By: Arne Schwabe --- src/openvpn/mtu.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/openvpn/mtu.c b/src/openvpn/mtu.c index aa810f1c..51eeaa64 100644 --- a/src/openvpn/mtu.c +++ b/src/openvpn/mtu.c @@ -352,6 +352,17 @@ format_extended_socket_error(int fd, int *mtu, struct gc_arena *gc) buf_printf(&out,"CMSG=%d|", cmsg->cmsg_type); } } + else if (cmsg->cmsg_level == IPPROTO_IPV6) + { + if (cmsg->cmsg_type == IPV6_RECVERR) + { + e = (struct sock_extended_err *) CMSG_DATA(cmsg); + } + else + { + buf_printf(&out,"CMSG=%d|", cmsg->cmsg_type); + } + } } if (e == NULL) { @@ -405,11 +416,18 @@ void set_sock_extended_error_passing(int sd) { int on = 1; - if (setsockopt(sd, SOL_IP, IP_RECVERR, (void *) &on, sizeof(on))) + /* see "man 7 ip" (on Linux) */ + if (setsockopt(sd, SOL_IP, IP_RECVERR, (void *) &on, sizeof(on)) != 0) { msg(M_WARN | M_ERRNO, "Note: enable extended error passing on TCP/UDP socket failed (IP_RECVERR)"); } + /* see "man 7 ipv6" (on Linux) */ + if (setsockopt(sd, IPPROTO_IPV6, IPV6_RECVERR, (void *) &on, sizeof(on)) != 0) + { + msg(M_WARN | M_ERRNO, + "Note: enable extended error passing on TCP/UDP socket failed (IPV6_RECVERR)"); + } } #endif /* if EXTENDED_SOCKET_ERROR_CAPABILITY */