From patchwork Mon Jan 14 04:48:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 661 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.27.255.54]) by backend30.mail.ord1d.rsapps.net with LMTP id CNhNJ3W5PFyeMwAAIUCqbw for ; Mon, 14 Jan 2019 11:31:49 -0500 Received: from proxy3.mail.iad3a.rsapps.net ([172.27.255.54]) by director11.mail.ord1d.rsapps.net with LMTP id MPIcJXW5PFxmPQAAvGGmqA ; Mon, 14 Jan 2019 11:31:49 -0500 Received: from smtp23.gate.iad3a ([172.27.255.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.iad3a.rsapps.net with LMTP id uAcRIHW5PFxOdwAAYaqY3Q ; Mon, 14 Jan 2019 11:31:49 -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: smtp23.gate.iad3a.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: e3cab8b8-1819-11e9-8b08-52540033eb40-1-1 Received: from [216.105.38.7] ([216.105.38.7:21847] helo=lists.sourceforge.net) by smtp23.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id F2/5F-32171-579BC3C5; Mon, 14 Jan 2019 11:31:49 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1gj58j-0004nF-Io; Mon, 14 Jan 2019 16:31:05 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gj58i-0004n0-0h for openvpn-devel@lists.sourceforge.NET; Mon, 14 Jan 2019 16:31:04 +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:Cc: To:From:Sender:Reply-To: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=aRIOdB8MJSldEbwkIkdwhvGQ/xtQ16UJISJ+xhUY/10=; b=hA176GmeqSS6+dTQSVlbkyTRok cQm6mnYvqG9tBoTiH3QX66doKnix6KBHd9SE+X000oiAnhRV9jDfm9CYuaTHxqknHUUfzR/vBLwDq oNuaWShqeAV1rlrns6jB5lpCBJVUhK+gdN1Slx3izjMaNxblO83bUePlTMgg6IKqDO4Q=; 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:Cc:To:From:Sender:Reply-To :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=aRIOdB8MJSldEbwkIkdwhvGQ/xtQ16UJISJ+xhUY/10=; b=S1y2ViwSoRWtHWf5In33IV+9cN SAB6XAC9LA1YJU6v6UhkLSAobiN9NT0LL50oMIkHXX737A6vvrr5gCbjJQQTNzpl4vTXtQ01kc8wD iyqmmKCv628NYz3KHmzH7d8V5z9zDcG4fVZvS5fSFEnj45mGapjlDOxdVF3PD338//z8=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1gj58g-0045JC-L1 for openvpn-devel@lists.sourceforge.NET; Mon, 14 Jan 2019 16:31:03 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.91 (FreeBSD)) (envelope-from ) id 1gj4TL-000MiS-KU; Mon, 14 Jan 2019 16:48:19 +0100 Received: (nullmailer pid 6114 invoked by uid 10006); Mon, 14 Jan 2019 15:48:19 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 14 Jan 2019 16:48:16 +0100 Message-Id: <20190114154819.6064-3-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190114154819.6064-1-arne@rfc2549.org> References: <20190114154819.6064-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-Headers-End: 1gj58g-0045JC-L1 Subject: [Openvpn-devel] [PATCH 3/6] Add send_control_channel_string_dowork variant 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: , Cc: Arne Schwabe MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Arne Schwabe The send_control_channel_string_dowork variant does not schedule the sending of the actual and can be used where struct context is not available. Acked-by: Gert Doering --- src/openvpn/forward.c | 43 +++++++++++++++++++++++-------------------- src/openvpn/forward.h | 31 ++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 0a90fff0..4076f647 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -464,42 +464,45 @@ check_connection_established_dowork(struct context *c) } } -/* - * Send a string to remote over the TLS control channel. - * Used for push/pull messages, passing username/password, - * etc. - */ +bool +send_control_channel_string_dowork(struct tls_multi *multi, + const char *str, int msglevel) +{ + struct gc_arena gc = gc_new(); + bool stat; + + /* buffered cleartext write onto TLS control channel */ + stat = tls_send_payload(multi, (uint8_t *) str, strlen(str) + 1); + + msg(msglevel, "SENT CONTROL [%s]: '%s' (status=%d)", + tls_common_name(multi, false), + sanitize_control_message(str, &gc), + (int) stat); + + gc_free(&gc); + return stat; +} + bool send_control_channel_string(struct context *c, const char *str, int msglevel) { if (c->c2.tls_multi) { - struct gc_arena gc = gc_new(); - bool stat; - - /* buffered cleartext write onto TLS control channel */ - stat = tls_send_payload(c->c2.tls_multi, (uint8_t *) str, strlen(str) + 1); - + 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. */ + interval_action(&c->c2.tmp_int); context_immediate_reschedule(c); /* ZERO-TIMEOUT */ - - msg(msglevel, "SENT CONTROL [%s]: '%s' (status=%d)", - tls_common_name(c->c2.tls_multi, false), - sanitize_control_message(str, &gc), - (int) stat); - - gc_free(&gc); - return stat; + return ret; } return true; } - /* * Add routes. */ diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index f97b0e2e..48202c07 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -286,7 +286,36 @@ void process_outgoing_tun(struct context *c); /**************************************************************************/ -bool send_control_channel_string(struct context *c, const char *str, int msglevel); +/* + * Send a string to remote over the TLS control channel. + * Used for push/pull messages, passing username/password, + * etc. + * @param c - The context structure of the VPN tunnel associated with + * the packet. + * @param str - The message to be sent + * @param msglevel - Message level to use for logging + */ +bool +send_control_channel_string(struct context *c, const char *str, int msglevel); + +/* + * Send a string to remote over the TLS control channel. + * Used for push/pull messages, passing username/password, + * etc. + * + * This variant does not schedule the actual sending of the message + * The caller needs to ensure that it is scheduled or call + * send_control_channel_string + * + * @param multi - The tls_multi structure of the VPN tunnel associated + * with the packet. + * @param str - The message to be sent + * @param msglevel - Message level to use for logging + */ + +bool +send_control_channel_string_dowork(struct tls_multi *multi, + const char *str, int msglevel); #define PIPV4_PASSTOS (1<<0) #define PIP_MSSFIX (1<<1) /* v4 and v6 */