From patchwork Wed Sep 30 03:13:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1497 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id CGnTMxSLdF/SRwAAIUCqbw (envelope-from ) for ; Wed, 30 Sep 2020 09:41:40 -0400 Received: from proxy15.mail.ord1d.rsapps.net ([172.30.191.6]) by director7.mail.ord1d.rsapps.net with LMTP id 0D25MxSLdF+/FAAAovjBpQ (envelope-from ) for ; Wed, 30 Sep 2020 09:41:40 -0400 Received: from smtp6.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.ord1d.rsapps.net with LMTPS id sChxMxSLdF84LAAAAY1PeQ (envelope-from ) for ; Wed, 30 Sep 2020 09:41:40 -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: smtp6.gate.ord1d.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: aac031ce-0322-11eb-a7d9-52540050e3e0-1-1 Received: from [216.105.38.7] ([216.105.38.7:48528] helo=lists.sourceforge.net) by smtp6.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 7E/72-09530-31B847F5; Wed, 30 Sep 2020 09:41:39 -0400 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.90_1) (envelope-from ) id 1kNcLi-0000ia-QM; Wed, 30 Sep 2020 13:40:50 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNcLi-0000iQ-44 for openvpn-devel@lists.sourceforge.net; Wed, 30 Sep 2020 13:40:50 +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=C+sMPoyjejNeNGD9ZK/LV+xDLrtCX5EJFOZxsPiIWmU=; b=cfKO/q35TJ4/hkvRsSdfu2cbek WDNWu3F626iIkaPCAhUirOv0FFrTQj4zYd5utUydXWLs+XfeFpFrYju3drwYmOIOMO4SXGfwB8dOe rKxptiW466FW8YguzaUnDFMdPGc5Fm7ZK+wmGSQLUIBdZ5y4w6UHz7gbXpHP0gOn5q8M=; 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=C+sMPoyjejNeNGD9ZK/LV+xDLrtCX5EJFOZxsPiIWmU=; b=O1oRdNCz4/ipyA1yZgZTM1xkGI Jbfu+km8NAbF4tsAEp6qjdJayfB9vIDtCAWJ9SvCwojiK2PkBjP42AmZmqf22mPg+StsTsb9z4MsO e6tPqs/ydeMK8BJjSCjzN5xD4mWcULFXnPLQvKEzJwDVmj+8mIm6kz4WNYKmXd5VA0RQ=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kNcLd-00BPLc-LD for openvpn-devel@lists.sourceforge.net; Wed, 30 Sep 2020 13:40:50 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1kNbv4-0003o0-HO for openvpn-devel@lists.sourceforge.net; Wed, 30 Sep 2020 15:13:18 +0200 Received: (nullmailer pid 1367 invoked by uid 10006); Wed, 30 Sep 2020 13:13:18 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Wed, 30 Sep 2020 15:13:11 +0200 Message-Id: <20200930131317.1299-7-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930131317.1299-1-arne@rfc2549.org> References: <20200930131317.1299-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rfc2549.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1kNcLd-00BPLc-LD Subject: [Openvpn-devel] [PATCH 05/11] Change parameter of send_auth_pending_messages from context to tls_multi 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 This prepares send_auth_pending_messages to be used a in context that does not have context c available but also does not need to schedule an immediate sending of the message (auth plugin/script) Signed-off-by: Arne Schwabe Acked-by: Lev Stipakov --- src/openvpn/forward.c | 17 +++++++++-------- src/openvpn/forward.h | 9 +++++++++ src/openvpn/multi.c | 4 +++- src/openvpn/push.c | 9 ++++----- src/openvpn/push.h | 4 +++- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 7d559544..7c759a62 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -335,6 +335,14 @@ send_control_channel_string_dowork(struct tls_multi *multi, return stat; } +void reschedule_multi_process(struct context *c) +{ + + interval_action(&c->c2.tmp_int); + context_immediate_reschedule(c); /* ZERO-TIMEOUT */ +} + + bool send_control_channel_string(struct context *c, const char *str, int msglevel) { @@ -342,15 +350,8 @@ send_control_channel_string(struct context *c, const char *str, int msglevel) { bool ret = send_control_channel_string_dowork(c->c2.tls_multi, str, msglevel); - /* - * Reschedule tls_multi_process. - * NOTE: in multi-client mode, usually the below two statements are - * insufficient to reschedule the client instance object unless - * multi_schedule_context_wakeup(m, mi) is also called. - */ + reschedule_multi_process(c); - interval_action(&c->c2.tmp_int); - context_immediate_reschedule(c); /* ZERO-TIMEOUT */ return ret; } return true; diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index a8b19f69..4336db5a 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -317,6 +317,15 @@ bool send_control_channel_string_dowork(struct tls_multi *multi, const char *str, int msglevel); + +/** + * Reschedule tls_multi_process. + * NOTE: in multi-client mode, usually the below two statements are + * insufficient to reschedule the client instance object unless + * multi_schedule_context_wakeup(m, mi) is also called. + */ +void reschedule_multi_process(struct context *c); + #define PIPV4_PASSTOS (1<<0) #define PIP_MSSFIX (1<<1) /* v4 and v6 */ #define PIP_OUTGOING (1<<2) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 50e2e350..e2454753 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -3903,7 +3903,9 @@ management_client_pending_auth(void *arg, if (mi) { /* sends INFO_PRE and AUTH_PENDING messages to client */ - bool ret = send_auth_pending_messages(&mi->context, extra, timeout); + bool ret = send_auth_pending_messages(mi->context.c2.tls_multi, extra, + timeout); + reschedule_multi_process(&mi->context); multi_schedule_context_wakeup(m, mi); return ret; } diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 59f8f33c..58e20baa 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -367,14 +367,13 @@ send_auth_failed(struct context *c, const char *client_reason) bool -send_auth_pending_messages(struct context *c, const char *extra, +send_auth_pending_messages(struct tls_multi *tls_multi, const char *extra, unsigned int timeout) { struct key_state *ks = &tls_multi->session[TM_ACTIVE].key[KS_PRIMARY]; static const char info_pre[] = "INFO_PRE,"; - struct tls_multi *tls_multi = c->c2.tls_multi; const char *const peer_info = tls_multi->peer_info; unsigned int proto = extract_iv_proto(peer_info); @@ -388,7 +387,7 @@ send_auth_pending_messages(struct context *c, const char *extra, struct gc_arena gc = gc_new(); if ((proto & IV_PROTO_AUTH_PENDING_KW) == 0) { - send_control_channel_string(c, "AUTH_PENDING", D_PUSH); + send_control_channel_string_dowork(tls_multi, "AUTH_PENDING", D_PUSH); } else { @@ -399,7 +398,7 @@ send_auth_pending_messages(struct context *c, const char *extra, struct buffer buf = alloc_buf_gc(len, &gc); buf_printf(&buf, auth_pre); buf_printf(&buf, "%u", timeout); - send_control_channel_string(c, BSTR(&buf), D_PUSH); + send_control_channel_string_dowork(tls_multi, BSTR(&buf), D_PUSH); } @@ -413,7 +412,7 @@ send_auth_pending_messages(struct context *c, const char *extra, struct buffer buf = alloc_buf_gc(len, &gc); buf_printf(&buf, info_pre); buf_printf(&buf, "%s", extra); - send_control_channel_string(c, BSTR(&buf), D_PUSH); + send_control_channel_string_dowork(tls_multi, BSTR(&buf), D_PUSH); ks->auth_deferred_expire = now + timeout; diff --git a/src/openvpn/push.h b/src/openvpn/push.h index a2192114..377f94a6 100644 --- a/src/openvpn/push.h +++ b/src/openvpn/push.h @@ -77,7 +77,9 @@ void send_auth_failed(struct context *c, const char *client_reason); * doc/management-notes.txt under client-pending-auth for * more details on message format */ -bool send_auth_pending_messages(struct context *c, const char *extra); +bool +send_auth_pending_messages(struct tls_multi *tls_multi, const char *extra, + unsigned int timeout); void send_restart(struct context *c, const char *kill_msg);