From patchwork Mon Aug 10 04:36:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1370 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id YAsPHN1bMV+KQQAAIUCqbw for ; Mon, 10 Aug 2020 10:38:21 -0400 Received: from proxy17.mail.ord1d.rsapps.net ([172.30.191.6]) by director8.mail.ord1d.rsapps.net with LMTP id wDnbG91bMV+TXwAAfY0hYg (envelope-from ) for ; Mon, 10 Aug 2020 10:38:21 -0400 Received: from smtp4.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy17.mail.ord1d.rsapps.net with LMTP id eAloG91bMV9IXwAAWC7mWg ; Mon, 10 Aug 2020 10:38:21 -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: smtp4.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; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 22a35e02-db17-11ea-b84f-0024e87f2f2c-1-1 Received: from [216.105.38.7] ([216.105.38.7:46616] helo=lists.sourceforge.net) by smtp4.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id C2/12-30428-CDB513F5; Mon, 10 Aug 2020 10:38:20 -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 1k58vf-0007HE-M5; Mon, 10 Aug 2020 14:37:35 +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 1k58vW-0007EE-EE for openvpn-devel@lists.sourceforge.net; Mon, 10 Aug 2020 14:37:26 +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=66dleLHQqOo7b4/SrvqMQZcbDRYeSe3ZEXOcAz+5T7k=; b=TEKvhxd8jchiuLq+PorOp2Sd/b 0hDDhdR9VB0nNAVM5m0hnH/NfhJbAT19hdHVOdP7K1TEi0I4tlDj/DOEWxrt0JxrBAwSkSHHQ+d+f Ug6g1zgSrzo1FQIm/Js70USW/jeM8hExWE38+uv1dmn4DcCTwAmygN4FsZ9G25mohYtE=; 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=66dleLHQqOo7b4/SrvqMQZcbDRYeSe3ZEXOcAz+5T7k=; b=QAvJRZXzYW1m2FUIFRIH0yicpF aRnnKh0KkO5IxWP843octLh0LkWhFe9kM4sj803IM15g1e1AnJl1mec9Vhw5gqaNplbZV8wEQyCGL bo77CTTBq8FEmMXaJdqStoJu6qnIXolklS0SuRhFuST2rih0hMgvuiFICVv1bVdKMCtY=; 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.92.2) id 1k58vU-00FaLY-N7 for openvpn-devel@lists.sourceforge.net; Mon, 10 Aug 2020 14:37:26 +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 1k58vE-000OS6-Ei for openvpn-devel@lists.sourceforge.net; Mon, 10 Aug 2020 16:37:08 +0200 Received: (nullmailer pid 5898 invoked by uid 10006); Mon, 10 Aug 2020 14:37:08 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 10 Aug 2020 16:36:56 +0200 Message-Id: <20200810143707.5834-7-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200810143707.5834-1-arne@rfc2549.org> References: <20200810143707.5834-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 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 0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1k58vU-00FaLY-N7 Subject: [Openvpn-devel] [PATCH 06/17] Remove a number of check/do_work wrapper calls from coarse_timers 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 indirection is not very helpful in understanding the code flow. Moving the check to process_coarse_timers and remove the check function and rename the do_work function to the drop the do_work as it does no longer serve a purpose Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/forward.c | 166 +++++++++++------------------------------- src/openvpn/forward.h | 12 +-- src/openvpn/status.c | 13 ---- src/openvpn/status.h | 2 - 4 files changed, 47 insertions(+), 146 deletions(-) diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 8a0d63f7..7ac878f9 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -138,84 +138,6 @@ check_incoming_control_channel(struct context *c) #endif } -/* - * Should we add routes? - */ -static inline void -check_add_routes(struct context *c) -{ - void check_add_routes_dowork(struct context *c); - - if (event_timeout_trigger(&c->c2.route_wakeup, &c->c2.timeval, ETT_DEFAULT)) - { - check_add_routes_dowork(c); - } -} - -/* - * Should we exit due to inactivity timeout? - */ -static inline void -check_inactivity_timeout(struct context *c) -{ - void check_inactivity_timeout_dowork(struct context *c); - - if (c->options.inactivity_timeout - && event_timeout_trigger(&c->c2.inactivity_interval, &c->c2.timeval, ETT_DEFAULT)) - { - check_inactivity_timeout_dowork(c); - } -} - -#if P2MP - -static inline void -check_server_poll_timeout(struct context *c) -{ - void check_server_poll_timeout_dowork(struct context *c); - - if (c->options.ce.connect_timeout - && event_timeout_trigger(&c->c2.server_poll_interval, &c->c2.timeval, ETT_DEFAULT)) - { - check_server_poll_timeout_dowork(c); - } -} - -/* - * Scheduled exit? - */ -static inline void -check_scheduled_exit(struct context *c) -{ - void check_scheduled_exit_dowork(struct context *c); - - if (event_timeout_defined(&c->c2.scheduled_exit)) - { - if (event_timeout_trigger(&c->c2.scheduled_exit, &c->c2.timeval, ETT_DEFAULT)) - { - check_scheduled_exit_dowork(c); - } - } -} -#endif /* if P2MP */ - -/* - * Should we write timer-triggered status file. - */ -static inline void -check_status_file(struct context *c) -{ - void check_status_file_dowork(struct context *c); - - if (c->c1.status_output) - { - if (status_trigger_tv(c->c1.status_output, &c->c2.timeval)) - { - check_status_file_dowork(c); - } - } -} - #ifdef ENABLE_FRAGMENT /* * Should we deliver a datagram fragment to remote? @@ -232,37 +154,6 @@ check_fragment(struct context *c) } #endif -#if P2MP - -/* - * see if we should send a push_request in response to --pull - */ -static inline void -check_push_request(struct context *c) -{ - void check_push_request_dowork(struct context *c); - - if (event_timeout_trigger(&c->c2.push_request_interval, &c->c2.timeval, ETT_DEFAULT)) - { - check_push_request_dowork(c); - } -} - -#endif - -/* - * Should we persist our anti-replay packet ID state to disk? - */ -static inline void -check_packet_id_persist_flush(struct context *c) -{ - if (packet_id_persist_enabled(&c->c1.pid_persist) - && event_timeout_trigger(&c->c2.packet_id_persist_interval, &c->c2.timeval, ETT_DEFAULT)) - { - packet_id_persist_save(&c->c1.pid_persist); - } -} - /* * Set our wakeup to 0 seconds, so we will be rescheduled * immediately. @@ -410,7 +301,7 @@ check_incoming_control_channel_dowork(struct context *c) * Periodically resend PUSH_REQUEST until PUSH message received */ void -check_push_request_dowork(struct context *c) +check_push_request(struct context *c) { send_push_request(c); @@ -521,7 +412,7 @@ check_add_routes_action(struct context *c, const bool errors) } void -check_add_routes_dowork(struct context *c) +check_add_routes(struct context *c) { if (test_routes(c->c1.route_list, c->c1.tuntap)) { @@ -559,7 +450,7 @@ check_add_routes_dowork(struct context *c) * Should we exit due to inactivity timeout? */ void -check_inactivity_timeout_dowork(struct context *c) +check_inactivity_timeout(struct context *c) { msg(M_INFO, "Inactivity timeout (--inactive), exiting"); register_signal(c, SIGTERM, "inactive"); @@ -575,7 +466,7 @@ get_server_poll_remaining_time(struct event_timeout *server_poll_timeout) #if P2MP void -check_server_poll_timeout_dowork(struct context *c) +check_server_poll_timeout(struct context *c) { event_timeout_reset(&c->c2.server_poll_interval); ASSERT(c->c2.tls_multi); @@ -605,7 +496,7 @@ schedule_exit(struct context *c, const int n_seconds, const int signal) * Scheduled exit? */ void -check_scheduled_exit_dowork(struct context *c) +check_scheduled_exit(struct context *c) { register_signal(c, c->c2.scheduled_exit_signal, "delayed-exit"); } @@ -616,7 +507,7 @@ check_scheduled_exit_dowork(struct context *c) * Should we write timer-triggered status file. */ void -check_status_file_dowork(struct context *c) +check_status_file(struct context *c) { if (c->c1.status_output) { @@ -761,10 +652,18 @@ process_coarse_timers(struct context *c) { /* flush current packet-id to file once per 60 * seconds if --replay-persist was specified */ - check_packet_id_persist_flush(c); + if (packet_id_persist_enabled(&c->c1.pid_persist) + && event_timeout_trigger(&c->c2.packet_id_persist_interval, &c->c2.timeval, ETT_DEFAULT)) + { + packet_id_persist_save(&c->c1.pid_persist); + } - /* should we update status file? */ - check_status_file(c); + /* Should we write timer-triggered status file */ + if (c->c1.status_output + && event_timeout_trigger(&c->c1.status_output->et, &c->c2.timeval, ETT_DEFAULT)) + { + check_status_file(c); + } /* process connection establishment items */ if (event_timeout_trigger(&c->c2.wait_for_connect, &c->c2.timeval, ETT_DEFAULT)) @@ -772,8 +671,11 @@ process_coarse_timers(struct context *c) check_connection_established(c); } #if P2MP - /* see if we should send a push_request in response to --pull */ - check_push_request(c); + /* see if we should send a push_request (option --pull) */ + if (event_timeout_trigger(&c->c2.push_request_interval, &c->c2.timeval, ETT_DEFAULT)) + { + check_push_request(c); + } #endif #ifdef PLUGIN_PF @@ -781,10 +683,18 @@ process_coarse_timers(struct context *c) #endif /* process --route options */ - check_add_routes(c); + if (event_timeout_trigger(&c->c2.route_wakeup, &c->c2.timeval, ETT_DEFAULT)) + { + check_add_routes(c); + } /* possibly exit due to --inactive */ - check_inactivity_timeout(c); + if (c->options.inactivity_timeout + && event_timeout_trigger(&c->c2.inactivity_interval, &c->c2.timeval, ETT_DEFAULT)) + { + check_inactivity_timeout(c); + } + if (c->sig->signal_received) { return; @@ -800,13 +710,19 @@ process_coarse_timers(struct context *c) #if P2MP if (c->c2.tls_multi) { - check_server_poll_timeout(c); + if (c->options.ce.connect_timeout + && event_timeout_trigger(&c->c2.server_poll_interval, &c->c2.timeval, ETT_DEFAULT)) + { + check_server_poll_timeout(c); + } if (c->sig->signal_received) { return; } - - check_scheduled_exit(c); + if (event_timeout_trigger(&c->c2.scheduled_exit, &c->c2.timeval, ETT_DEFAULT)) + { + check_scheduled_exit(c); + } if (c->sig->signal_received) { return; diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index 635e84ae..114a24e7 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -77,9 +77,9 @@ void check_tls_errors_nco(struct context *c); #if P2MP void check_incoming_control_channel_dowork(struct context *c); -void check_scheduled_exit_dowork(struct context *c); +void check_scheduled_exit(struct context *c); -void check_push_request_dowork(struct context *c); +void check_push_request(struct context *c); #endif /* P2MP */ @@ -90,13 +90,13 @@ void check_fragment_dowork(struct context *c); void check_connection_established(struct context *c); -void check_add_routes_dowork(struct context *c); +void check_add_routes(struct context *c); -void check_inactivity_timeout_dowork(struct context *c); +void check_inactivity_timeout(struct context *c); -void check_server_poll_timeout_dowork(struct context *c); +void check_server_poll_timeout(struct context *c); -void check_status_file_dowork(struct context *c); +void check_status_file(struct context *c); void io_wait_dowork(struct context *c, const unsigned int flags); diff --git a/src/openvpn/status.c b/src/openvpn/status.c index 91391d1a..e8dcf7cd 100644 --- a/src/openvpn/status.c +++ b/src/openvpn/status.c @@ -146,19 +146,6 @@ status_trigger(struct status_output *so) } } -bool -status_trigger_tv(struct status_output *so, struct timeval *tv) -{ - if (so) - { - return event_timeout_trigger(&so->et, tv, ETT_DEFAULT); - } - else - { - return false; - } -} - void status_reset(struct status_output *so) { diff --git a/src/openvpn/status.h b/src/openvpn/status.h index 2a399d7d..66e5bc53 100644 --- a/src/openvpn/status.h +++ b/src/openvpn/status.h @@ -69,8 +69,6 @@ struct status_output *status_open(const char *filename, const struct virtual_output *vout, const unsigned int flags); -bool status_trigger_tv(struct status_output *so, struct timeval *tv); - bool status_trigger(struct status_output *so); void status_reset(struct status_output *so);