From patchwork Thu Dec 1 11:01:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 2881 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director14.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id kIM8Cs+JiGNAdAAAIUCqbw (envelope-from ) for ; Thu, 01 Dec 2022 06:02:39 -0500 Received: from proxy15.mail.iad3b.rsapps.net ([172.31.255.6]) by director14.mail.ord1d.rsapps.net with LMTP id 8LwbCs+JiGMKaAAAeJ7fFg (envelope-from ) for ; Thu, 01 Dec 2022 06:02:39 -0500 Received: from smtp36.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.iad3b.rsapps.net with LMTPS id cIeCA8+JiGOzcQAAhyf7VQ (envelope-from ) for ; Thu, 01 Dec 2022 06:02:39 -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: smtp36.gate.iad3b.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=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: aac100f8-7167-11ed-8429-5254003a7283-1-1 Received: from [216.105.38.7] ([216.105.38.7:41526] helo=lists.sourceforge.net) by smtp36.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id E2/04-24015-EC988836; Thu, 01 Dec 2022 06:02:38 -0500 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 1p0hK3-0001yw-Tf; Thu, 01 Dec 2022 11:01:43 +0000 Received: from [172.30.20.202] (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 1p0hJx-0001yN-Gg for openvpn-devel@lists.sourceforge.net; Thu, 01 Dec 2022 11:01:37 +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=3SpfYzhi5h14tmSbScoKyfinIAqQ847Wn9NZEI6Pz3o=; b=KTS6CVx7c6AXiO6yGX3VW71WL0 t8qc5nT5nX6NWZEG1nD9wydL9u4FfcZmXNVo3W0NpkYi1ZWxAcVyXkr+YxoW5OYaBcvYxGZnrxDLO o2vUXhxqzw90sS8du1hMaac8OthbxlEGpsTnWFWk/6aQteCJ7GS7mbHVqN/54qO4CE3Q=; 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=3SpfYzhi5h14tmSbScoKyfinIAqQ847Wn9NZEI6Pz3o=; b=l poHcK8xoU3gYQGY5JLphN+8xy4MdGXkOXTnGcTxGsrL1PHtxmrfOybp4ziEqx9EYRGR9uYTpEDXAa 06HmxyAvL7FcJiB5FPY0nyM5KmkqYar/Ws6G7A1Inq1yPFg7LRnLru6GMOjO1FSEt4FXdvLJ4exQ1 A2tZ7y+QU1Gm4wFA=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1p0hJv-0005Cc-CM for openvpn-devel@lists.sourceforge.net; Thu, 01 Dec 2022 11:01:37 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1p0hJo-000Coo-PT for openvpn-devel@lists.sourceforge.net; Thu, 01 Dec 2022 12:01:28 +0100 Received: (nullmailer pid 271110 invoked by uid 10006); Thu, 01 Dec 2022 11:01:28 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Thu, 1 Dec 2022 12:01:28 +0100 Message-Id: <20221201110128.271064-1-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 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: This commit consists of two parts. - explicitly removing an existing peer in p2p mode - ignoring the ping timeout notification that is generated by the first part Signed-off-by: Arne Schwabe --- src/openvpn/dco.c | 9 +++++++++ src/openvpn/dco_freebsd.c | 2 ++ src/openvpn/forward.c | 13 +++++++++++++ 3 files changed, 24 insertions(+) Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-Headers-End: 1p0hJv-0005Cc-CM Subject: [Openvpn-devel] [PATCH] Allow reconnecting in p2p mode work under FreeBSD 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 This commit consists of two parts. - explicitly removing an existing peer in p2p mode - ignoring the ping timeout notification that is generated by the first part Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/dco.c | 9 +++++++++ src/openvpn/dco_freebsd.c | 2 ++ src/openvpn/forward.c | 13 +++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 03ac8438a..cbd834194 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -459,6 +459,15 @@ dco_p2p_add_new_peer(struct context *c) struct sockaddr *remoteaddr = &ls->info.lsa->actual.dest.addr.sa; struct tls_multi *multi = c->c2.tls_multi; +#ifdef TARGET_FREEBSD + /* In Linux in P2P mode the kernel automatically removes an existing peer + * when adding a new peer. FreeBSD needs to explicitly be told to do that */ + if (c->c2.tls_multi->dco_peer_id != -1) + { + dco_del_peer(&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id); + c->c2.tls_multi->dco_peer_id = -1; + } +#endif int ret = dco_new_peer(&c->c1.tuntap->dco, multi->peer_id, c->c2.link_socket->sd, NULL, remoteaddr, NULL, NULL); if (ret < 0) diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 4e03f52e9..a52ac8c1b 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -312,6 +312,8 @@ dco_del_peer(dco_context_t *dco, unsigned int peerid) nvlist_t *nvl; int ret; + msg(D_DCO_DEBUG, "%s: peer-id %d", __func__, peerid); + nvl = nvlist_create(0); nvlist_add_number(nvl, "peerid", peerid); diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 1b418b1bc..958bf0b56 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1174,9 +1174,22 @@ process_incoming_dco(struct context *c) dco_do_read(dco); + /* FreeBSD currently sends us removal notifcation with the old peer-id in + * p2p mode with the ping timeout reason, so ignore that one to not shout + * ourselves in the foot and removing the just established session */ + if (dco->dco_message_peer_id != c->c2.tls_multi->dco_peer_id) + { + msg(D_DCO_DEBUG, "%s: received message for mismatching peer-id %d, " + "expected %d", __func__, dco->dco_message_peer_id, + c->c2.tls_multi->dco_peer_id); + return; + } + if ((dco->dco_message_type == OVPN_CMD_DEL_PEER) && (dco->dco_del_peer_reason == OVPN_DEL_PEER_REASON_EXPIRED)) { + msg(D_DCO_DEBUG, "%s: received peer expired notification of for peer-id " + "%d", __func__, dco->dco_message_peer_id); trigger_ping_timeout_signal(c); return; }