From patchwork Wed Sep 16 04:17:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Grishenko X-Patchwork-Id: 1456 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id 8JGUOfAeYl+RVAAAIUCqbw (envelope-from ) for ; Wed, 16 Sep 2020 10:19:28 -0400 Received: from proxy8.mail.ord1c.rsapps.net ([172.28.255.1]) by director8.mail.ord1d.rsapps.net with LMTP id SJduOfAeYl9FGQAAfY0hYg (envelope-from ) for ; Wed, 16 Sep 2020 10:19:28 -0400 Received: from smtp11.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy8.mail.ord1c.rsapps.net with LMTPS id YAgdOfAeYl87EQAAHz/atg (envelope-from ) for ; Wed, 16 Sep 2020 10:19:28 -0400 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: smtp11.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; dkim=fail (signature verification failed) header.d=yandex-team.ru; dmarc=fail (p=none; dis=none) header.from=yandex-team.ru X-Suspicious-Flag: YES X-Classification-ID: a0ecc974-f827-11ea-a813-bc305beffa54-1-1 Received: from [216.105.38.7] ([216.105.38.7:51824] helo=lists.sourceforge.net) by smtp11.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id F1/EE-27944-FEE126F5; Wed, 16 Sep 2020 10:19:28 -0400 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.90_1) (envelope-from ) id 1kIYGN-0002NM-8T; Wed, 16 Sep 2020 14:18:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIYGM-0002NF-3y for openvpn-devel@lists.sourceforge.net; Wed, 16 Sep 2020 14:18:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=joLfiWrSLCXGVMZ++BnQ/lmzme2yxakRgMDmzgvWcoA=; b=Ajg0FzgsTMNhNuj+MxfrnHDWCC /VBdDUAH7Jy7kKTsdSUBvnRZGrTT0e/8N6tWw+Nk0FeaIvhSXzPu6n2M/lb1UInFFna96j7Z2Fhwi fe1HOkXZaWxMNIgFdVXe84s6xdEU1/Whq5pTxC/3G/VJ6w+1hpX+d7lQLNfes5YQ8dsQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding: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=joLfiWrSLCXGVMZ++BnQ/lmzme2yxakRgMDmzgvWcoA=; b=AE97dS+OiOaNZ9NdE/HzW/Ig7n J0YmNKMLp3DoR5e7z7tmQ9JSjWuqT18BBijcTkf8lN2CwKrUeMWZGyjb/Pu6P2tl7zFoFCw0lBsod 8C6nQ5wC+qHjzLutBLgMtiWxDbnfFUMgYUlqzs/lcONcxOZ8ERwyAlrWJpX5FcJJpUqQ=; Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kIYGB-00CWc9-HE for openvpn-devel@lists.sourceforge.net; Wed, 16 Sep 2020 14:18:21 +0000 Received: from iva8-d077482f1536.qloud-c.yandex.net (iva8-d077482f1536.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2f26:0:640:d077:482f]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 183F22E1610 for ; Wed, 16 Sep 2020 17:18:01 +0300 (MSK) Received: from iva8-88b7aa9dc799.qloud-c.yandex.net (iva8-88b7aa9dc799.qloud-c.yandex.net [2a02:6b8:c0c:77a0:0:640:88b7:aa9d]) by iva8-d077482f1536.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id 9wD9jfCske-I0vimXIW; Wed, 16 Sep 2020 17:18:01 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1600265881; bh=joLfiWrSLCXGVMZ++BnQ/lmzme2yxakRgMDmzgvWcoA=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From; b=b2XZHjCPgNNG3NSphb+h+uxv5UoQJXx7fR7hnCr+uYui1ZoMkfktMNZnMNAaB+pDy /9bdxLO12Qjex2a+6/1K12KJsOxF3gn/xAfXPj1sHP4lJcFbUxzcDOlf9nVu7NgHTz UTYcM4tmP3YMT/0ljdYHqBnfgaJbQ/iXkhQVe2+k= Received: from 37.9.122.51-iva.dhcp.yndx.net (37.9.122.51-iva.dhcp.yndx.net [37.9.122.51]) by iva8-88b7aa9dc799.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id RB4ugRwZK4-I0l4WuSB; Wed, 16 Sep 2020 17:18:00 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) From: Vladislav Grishenko To: openvpn-devel@lists.sourceforge.net Date: Wed, 16 Sep 2020 19:17:55 +0500 Message-Id: <20200916141755.1923-1-themiron@yandex-team.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200916131349.27668-1-themiron@yandex-team.ru> References: <20200916131349.27668-1-themiron@yandex-team.ru> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1kIYGB-00CWc9-HE Subject: [Openvpn-devel] [PATCH v2] Fix fatal error at switching remotes (#629) 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox If remote server has been resolved to multiple addresses, at least one connection attemt has been made and connection to the last address was skipped by management - resolved earlier link socket addrinfo objects will not be cleared neither on instance close nor in the next connection entry loop. This causes fatal error assert: >REMOTE:openvpn.net,1194,udp remote ACCEPT SUCCESS: remote command succeeded >REMOTE:openvpn.net,1194,udp remote SKIP SUCCESS: remote command succeeded >FATAL:Assertion failed at init.c:504 (c->c1.link_socket_addr.current_remote == NULL) Fix this behaviour by cleaning stale addinfo objects. v2: better comment placement and too long length fix Signed-off-by: Vladislav Grishenko Acked-by: Lev Stipakov --- src/openvpn/init.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index a785934a..8fc79638 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -500,6 +500,17 @@ next_connection_entry(struct context *c) */ if (!c->options.persist_remote_ip) { + /* Connection entry addinfo objects might have been resolved + * earlier but the entry itself might have been skipped by + * management on the previous loop. + * If so, clear the addrinfo objects as close_instance does + */ + if (c->c1.link_socket_addr.remote_list) + { + clear_remote_addrlist(&c->c1.link_socket_addr, + !c->options.resolve_in_advance); + } + /* close_instance should have cleared the addrinfo objects */ ASSERT(c->c1.link_socket_addr.current_remote == NULL); ASSERT(c->c1.link_socket_addr.remote_list == NULL);