From patchwork Tue Dec 31 14:54:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4033 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:998b:b0:5e7:b9eb:58e8 with SMTP id d11csp8367532mav; Tue, 31 Dec 2024 06:54:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW/YIiQpMPwt2t3lZYvZpxP08Nn62LV0NAhMnl81SKw8DxOFkTqndin3kp6Uzzsn7QWdRglcze5gWc=@openvpn.net X-Google-Smtp-Source: AGHT+IEK63LQhd7raXZjMa9MfkAUCgfrraxSzXk6AxCF/QoBfaBi1iECGM0KExQcCfKrTdTCBnWs X-Received: by 2002:a05:6870:8185:b0:296:e481:8b4d with SMTP id 586e51a60fabf-2a7fb3128e8mr20560895fac.28.1735656878116; Tue, 31 Dec 2024 06:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735656878; cv=none; d=google.com; s=arc-20240605; b=Z9u9fBNX2p4RLpmxpevrN44VYQssMR7ICPKI7Lecd18fq16/MYqU0upPkGQ9Mtv79i Vd4LcWSWMjya94F8hC3vxKzQS1J9XNFrnagRQpWvV+zkQnznoPVXZFN9m/4w+qDt1cAa 7DmzAYSnY1Hk59IUXmccAXFT8dvlbfINgt1U7AmjGpzz2eWY35rRNYNaCmVmeaiizlo0 3cOVeWg2t9GUaWPvd3jV3MJoBjgTQ5usvnvP963rnUxkrjL30DK+VZcuZaRn+g/0q7Re m4gJ5uBd1j6/Jj4AcUi7F3gQJZNT4ds3aPXeIFVzJRn0EVq6DfheVajypDVuky6eg1BA fHDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=zPIgfEZUR6Ef/pYqtkpd6SMicVk8/qRSe7nDk7SdgzU=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=aL+UF4zBaWLGZHXgV7eizwxXdkrEmF3XCQoZm1Mj2Uamsqm2seVG0VbkQ+PH3t1OhY r308fnu5G8p0o69uAyrx3v7hIsUUb4mjOV36JVbNt2/HoUH87wQQVzKHXUSj0xQRH58Y kwNrM9FuR3OKWtXloDiK//p572RswXMg1M5P6sRDusQNpZnIxmdph6SsLJMF+XVPmq9d kT3YbHoIu8dPIQbn+XuXjWx7kN96ZHEruPYXIJYE2H/KMgoTsVstgmWQZeSyYK/E/NYs tBlC5dc+d+gO/PhXSTnur/yekIyt6Ct3GZ9l7O5x4Co3VcixI5DPqYc1dibu8MAjbiJ7 2PCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=MAdeiEmU; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ck0HLw7P; 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 586e51a60fabf-2a7d749a815si16348362fac.29.2024.12.31.06.54.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Dec 2024 06:54:37 -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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=MAdeiEmU; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ck0HLw7P; 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 [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tSddh-0001fp-0Z; Tue, 31 Dec 2024 14:54:33 +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.95) (envelope-from ) id 1tSdde-0001fh-FU for openvpn-devel@lists.sourceforge.net; Tue, 31 Dec 2024 14:54:31 +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-Subscribe:List-Post:List-Owner:List-Archive; bh=RjG38Rcg9jR1n2HY+3j1fqJ5YBH88Nu4MquGDQO1aMo=; b=MAdeiEmUdr8f7YUzB1sWRT6emw 5FqfUGsNk6479BQHbjfXULaBCRUK5pgdl0hDeh0SrmbCHi5sOM87UgkeV7CQyX+n3Gy8OZNhwIMzz Idhs89KmAj8mQgSc+9ZwLB4jkBT8RJKNFqLx+s/TYwrk6DHJWdqF8qqIhuU8RARHwVYw=; 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-Subscribe: List-Post:List-Owner:List-Archive; bh=RjG38Rcg9jR1n2HY+3j1fqJ5YBH88Nu4MquGDQO1aMo=; b=ck0HLw7PRCIfWItgqCWL3gvNG+ essFOdEE/hBd+vM+S2FJsMrqf0YC9yJiHAD0sVIO84HBfflJGnA1OYFDaknU1VCvR7Kjj+VkfWbPm T5mfxA4YXdnB5OqG7I2vWIRs5i5lStZZJRQv1eNPrWUesYRLogUf8dV4T9N+3OcVVNNM=; 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.95) id 1tSddd-0006bM-Si for openvpn-devel@lists.sourceforge.net; Tue, 31 Dec 2024 14:54:31 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 4BVEsIFb012138 for ; Tue, 31 Dec 2024 15:54:18 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 4BVEsINV012137 for openvpn-devel@lists.sourceforge.net; Tue, 31 Dec 2024 15:54:18 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 31 Dec 2024 15:54:17 +0100 Message-ID: <20241231145417.12128-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 0.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: From: Lev Stipakov c->c2.link_socket_owned is true in client mode and for the global context in the server mode - those are exactly the cases when we want to set sd to undefined when using dco-win. Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in bl.score.senderscore.com] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in sa-trusted.bondedsender.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1tSddd-0006bM-Si Subject: [Openvpn-devel] [PATCH v7] dco-win: simplify do_close_link_socket() 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: =?utf-8?q?1819968146979880578?= X-GMAIL-MSGID: =?utf-8?q?1819968146979880578?= From: Lev Stipakov c->c2.link_socket_owned is true in client mode and for the global context in the server mode - those are exactly the cases when we want to set sd to undefined when using dco-win. Change-Id: I3232dd8d855ca3f198b4ca3b2ef4f67cec49f3d4 Signed-off-by: Lev Stipakov Acked-by: Gert Doering --- 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/+/813 This mail reflects revision 7 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 850cd12..2bd5518 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -4018,21 +4018,18 @@ static void do_close_link_socket(struct context *c) { - /* in dco-win case, link socket is a tun handle which is - * closed in do_close_tun(). Set it to UNDEFINED so - * we won't use WinSock API to close it. */ - if (tuntap_is_dco_win(c->c1.tuntap) && c->c2.link_sockets) - { - for (int i = 0; i < c->c1.link_sockets_num; i++) - { - c->c2.link_sockets[i]->sd = SOCKET_UNDEFINED; - } - } - if (c->c2.link_sockets && c->c2.link_socket_owned) { for (int i = 0; i < c->c1.link_sockets_num; i++) { + /* in dco-win case, link socket is a tun handle which is + * closed in do_close_tun(). Set it to UNDEFINED so + * we won't use WinSock API to close it. */ + if (tuntap_is_dco_win(c->c1.tuntap)) + { + c->c2.link_sockets[i]->sd = SOCKET_UNDEFINED; + } + link_socket_close(c->c2.link_sockets[i]); } c->c2.link_sockets = NULL;