From patchwork Mon Jul 11 02:23:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2579 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.51]) by backend30.mail.ord1d.rsapps.net with LMTP id gCkqBJEWzGJsfgAAIUCqbw (envelope-from ) for ; Mon, 11 Jul 2022 08:24:49 -0400 Received: from proxy15.mail.iad3a.rsapps.net ([172.27.255.51]) by director9.mail.ord1d.rsapps.net with LMTP id GGYABJEWzGL9XgAAalYnBA (envelope-from ) for ; Mon, 11 Jul 2022 08:24:49 -0400 Received: from smtp3.gate.iad3a ([172.27.255.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.iad3a.rsapps.net with LMTPS id YI3yOJAWzGItDgAAHi9b9g (envelope-from ) for ; Mon, 11 Jul 2022 08:24:48 -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: smtp3.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 7435e986-0114-11ed-aa0b-525400af4d07-1-1 Received: from [216.105.38.7] ([216.105.38.7:57820] helo=lists.sourceforge.net) by smtp3.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id ED/9F-19614-0961CC26; Mon, 11 Jul 2022 08:24:48 -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.94.2) (envelope-from ) id 1oAsRt-0001zw-1A; Mon, 11 Jul 2022 12:23:35 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oAsRq-0001zq-Oy for openvpn-devel@lists.sourceforge.net; Mon, 11 Jul 2022 12:23:33 +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:Cc:To:From:Sender:Reply-To: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=xCOsbZ1EL66C0f06HhuojZr7H1O2/39jk91erveEYrk=; b=PWbRHUUQU/oeGU5dBrnaxFOacy hYUOEw7sqBGWUo0EvzZ+jN4c1jCjP2fZ5hjYi+9S+2tAIg90Ijvsiav6iUftzm23xrieMRQ0FaI0M brk6KyFWquq3rWRcmwhK88zFsUG+690er1ijvuydnMltxLOL7CA1pYOj+VUNuK1puhfc=; 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:Cc:To:From :Sender:Reply-To: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=xCOsbZ1EL66C0f06HhuojZr7H1O2/39jk91erveEYrk=; b=E 1O46rbtQziwHLsU3vzxRJHiOzMeJCtMqqF6XVbRSHNhRnjtxPxFzKKkenWPsqHs0p/P69GQrhzAhm /gxvMdenDmWdwp3cyXooQndUD1u6CQeoWDv5MhI2l9LOdcISBDepBSd7744ZOphDkdulSNHMlVP6m N8YT1H5elUE6nB5M=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1oAsRn-0002ZX-On for openvpn-devel@lists.sourceforge.net; Mon, 11 Jul 2022 12:23:33 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Mon, 11 Jul 2022 14:23:48 +0200 Message-Id: <20220711122348.8756-1-a@unstable.cc> MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.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: The pre_connect_save() function is not used outside of options.c, therefore it should not be exported. Make it static and move definition before its invocation. Move also pre_connect_restore() along with it in order to keep the two close to each other. Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1oAsRn-0002ZX-On Subject: [Openvpn-devel] [PATCH] options: don't export local function pre_connect_save() 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: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox The pre_connect_save() function is not used outside of options.c, therefore it should not be exported. Make it static and move definition before its invocation. Move also pre_connect_restore() along with it in order to keep the two close to each other. Cc: Arne Schwabe Signed-off-by: Antonio Quartulli Acked-by: Heiko Hund --- src/openvpn/options.c | 238 +++++++++++++++++++++--------------------- src/openvpn/options.h | 2 - 2 files changed, 119 insertions(+), 121 deletions(-) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index fa66b513..6f83406b 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3219,6 +3219,125 @@ remap_redirect_gateway_flags(struct options *opt) } #endif +/* + * Save/Restore certain option defaults before --pull is applied. + */ + +static void +pre_connect_save(struct options *o) +{ + ALLOC_OBJ_CLEAR_GC(o->pre_connect, struct options_pre_connect, &o->gc); + o->pre_connect->tuntap_options = o->tuntap_options; + o->pre_connect->tuntap_options_defined = true; + o->pre_connect->foreign_option_index = o->foreign_option_index; + + if (o->routes) + { + o->pre_connect->routes = clone_route_option_list(o->routes, &o->gc); + o->pre_connect->routes_defined = true; + } + if (o->routes_ipv6) + { + o->pre_connect->routes_ipv6 = clone_route_ipv6_option_list(o->routes_ipv6, &o->gc); + o->pre_connect->routes_ipv6_defined = true; + } + if (o->client_nat) + { + o->pre_connect->client_nat = clone_client_nat_option_list(o->client_nat, &o->gc); + o->pre_connect->client_nat_defined = true; + } + + o->pre_connect->route_default_gateway = o->route_default_gateway; + o->pre_connect->route_ipv6_default_gateway = o->route_ipv6_default_gateway; + + o->pre_connect->dns_options = clone_dns_options(o->dns_options, &o->gc); + + /* NCP related options that can be overwritten by a push */ + o->pre_connect->ciphername = o->ciphername; + o->pre_connect->authname = o->authname; + + /* Ping related options should be reset to the config values on reconnect */ + o->pre_connect->ping_rec_timeout = o->ping_rec_timeout; + o->pre_connect->ping_rec_timeout_action = o->ping_rec_timeout_action; + o->pre_connect->ping_send_timeout = o->ping_send_timeout; + + /* Miscellaneous Options */ +#ifdef USE_COMP + o->pre_connect->comp = o->comp; +#endif +} + +void +pre_connect_restore(struct options *o, struct gc_arena *gc) +{ + const struct options_pre_connect *pp = o->pre_connect; + if (pp) + { + CLEAR(o->tuntap_options); + if (pp->tuntap_options_defined) + { + o->tuntap_options = pp->tuntap_options; + } + + if (pp->routes_defined) + { + rol_check_alloc(o); + copy_route_option_list(o->routes, pp->routes, gc); + } + else + { + o->routes = NULL; + } + + if (pp->routes_ipv6_defined) + { + rol6_check_alloc(o); + copy_route_ipv6_option_list(o->routes_ipv6, pp->routes_ipv6, gc); + } + else + { + o->routes_ipv6 = NULL; + } + + o->route_default_gateway = pp->route_default_gateway; + o->route_ipv6_default_gateway = pp->route_ipv6_default_gateway; + + /* Free DNS options and reset them to pre-pull state */ + gc_free(&o->dns_options.gc); + struct gc_arena dns_gc = gc_new(); + o->dns_options = clone_dns_options(pp->dns_options, &dns_gc); + o->dns_options.gc = dns_gc; + + if (pp->client_nat_defined) + { + cnol_check_alloc(o); + copy_client_nat_option_list(o->client_nat, pp->client_nat); + } + else + { + o->client_nat = NULL; + } + + o->foreign_option_index = pp->foreign_option_index; + + o->ciphername = pp->ciphername; + o->authname = pp->authname; + + o->ping_rec_timeout = pp->ping_rec_timeout; + o->ping_rec_timeout_action = pp->ping_rec_timeout_action; + o->ping_send_timeout = pp->ping_send_timeout; + + /* Miscellaneous Options */ +#ifdef USE_COMP + o->comp = pp->comp; +#endif + } + + o->push_continuation = 0; + o->push_option_types_found = 0; + o->data_channel_crypto_flags = 0; +} + static void options_postprocess_mutate_invariant(struct options *options) { @@ -3946,125 +4065,6 @@ options_postprocess_pull(struct options *o, struct env_set *es) return success; } -/* - * Save/Restore certain option defaults before --pull is applied. - */ - -void -pre_connect_save(struct options *o) -{ - ALLOC_OBJ_CLEAR_GC(o->pre_connect, struct options_pre_connect, &o->gc); - o->pre_connect->tuntap_options = o->tuntap_options; - o->pre_connect->tuntap_options_defined = true; - o->pre_connect->foreign_option_index = o->foreign_option_index; - - if (o->routes) - { - o->pre_connect->routes = clone_route_option_list(o->routes, &o->gc); - o->pre_connect->routes_defined = true; - } - if (o->routes_ipv6) - { - o->pre_connect->routes_ipv6 = clone_route_ipv6_option_list(o->routes_ipv6, &o->gc); - o->pre_connect->routes_ipv6_defined = true; - } - if (o->client_nat) - { - o->pre_connect->client_nat = clone_client_nat_option_list(o->client_nat, &o->gc); - o->pre_connect->client_nat_defined = true; - } - - o->pre_connect->route_default_gateway = o->route_default_gateway; - o->pre_connect->route_ipv6_default_gateway = o->route_ipv6_default_gateway; - - o->pre_connect->dns_options = clone_dns_options(o->dns_options, &o->gc); - - /* NCP related options that can be overwritten by a push */ - o->pre_connect->ciphername = o->ciphername; - o->pre_connect->authname = o->authname; - - /* Ping related options should be reset to the config values on reconnect */ - o->pre_connect->ping_rec_timeout = o->ping_rec_timeout; - o->pre_connect->ping_rec_timeout_action = o->ping_rec_timeout_action; - o->pre_connect->ping_send_timeout = o->ping_send_timeout; - - /* Miscellaneous Options */ -#ifdef USE_COMP - o->pre_connect->comp = o->comp; -#endif -} - -void -pre_connect_restore(struct options *o, struct gc_arena *gc) -{ - const struct options_pre_connect *pp = o->pre_connect; - if (pp) - { - CLEAR(o->tuntap_options); - if (pp->tuntap_options_defined) - { - o->tuntap_options = pp->tuntap_options; - } - - if (pp->routes_defined) - { - rol_check_alloc(o); - copy_route_option_list(o->routes, pp->routes, gc); - } - else - { - o->routes = NULL; - } - - if (pp->routes_ipv6_defined) - { - rol6_check_alloc(o); - copy_route_ipv6_option_list(o->routes_ipv6, pp->routes_ipv6, gc); - } - else - { - o->routes_ipv6 = NULL; - } - - o->route_default_gateway = pp->route_default_gateway; - o->route_ipv6_default_gateway = pp->route_ipv6_default_gateway; - - /* Free DNS options and reset them to pre-pull state */ - gc_free(&o->dns_options.gc); - struct gc_arena dns_gc = gc_new(); - o->dns_options = clone_dns_options(pp->dns_options, &dns_gc); - o->dns_options.gc = dns_gc; - - if (pp->client_nat_defined) - { - cnol_check_alloc(o); - copy_client_nat_option_list(o->client_nat, pp->client_nat); - } - else - { - o->client_nat = NULL; - } - - o->foreign_option_index = pp->foreign_option_index; - - o->ciphername = pp->ciphername; - o->authname = pp->authname; - - o->ping_rec_timeout = pp->ping_rec_timeout; - o->ping_rec_timeout_action = pp->ping_rec_timeout_action; - o->ping_send_timeout = pp->ping_send_timeout; - - /* Miscellaneous Options */ -#ifdef USE_COMP - o->comp = pp->comp; -#endif - } - - o->push_continuation = 0; - o->push_option_types_found = 0; - o->data_channel_crypto_flags = 0; -} - /* * Build an options string to represent data channel encryption options. * This string must match exactly between peers. The keysize is checked diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 1b30cedd..7acffc3d 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -817,8 +817,6 @@ void options_postprocess(struct options *options, struct env_set *es); bool options_postprocess_pull(struct options *o, struct env_set *es); -void pre_connect_save(struct options *o); - void pre_connect_restore(struct options *o, struct gc_arena *gc); bool apply_push_options(struct options *options,