From patchwork Thu Sep 8 20:41:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 2742 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id YGjwKHHgGmNdCgAAIUCqbw (envelope-from ) for ; Fri, 09 Sep 2022 02:42:57 -0400 Received: from proxy7.mail.ord1d.rsapps.net ([172.30.191.6]) by director13.mail.ord1d.rsapps.net with LMTP id ELPDKHHgGmP5ZQAA91zNiA (envelope-from ) for ; Fri, 09 Sep 2022 02:42:57 -0400 Received: from smtp19.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.ord1d.rsapps.net with LMTPS id CP9/KHHgGmPcTwAAMe1Fpw (envelope-from ) for ; Fri, 09 Sep 2022 02:42:57 -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: smtp19.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; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: a3560d7a-300a-11ed-805e-bc305bf036e4-1-1 Received: from [216.105.38.7] ([216.105.38.7:49696] helo=lists.sourceforge.net) by smtp19.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id D5/77-02726-170EA136; Fri, 09 Sep 2022 02:42:57 -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.95) (envelope-from ) id 1oWXhw-00023e-W6; Fri, 09 Sep 2022 06:41:57 +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.95) (envelope-from ) id 1oWXhn-00023P-Hd for openvpn-devel@lists.sourceforge.net; Fri, 09 Sep 2022 06:41:48 +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=rUdWzcWsRGwfRwnD9p3aEi9tBW20RidaP2TwYg4U9BU=; b=JhSOfoRpGBz7H6SzZRqM3qs6MR 8X8dD+qlCkxfMCNOYWYHIiIbRFjlJzBsbxAxtAE0c8KuqCSrdm74uHYoi2vJM4O98b2C2YfFxSXNE 7Vu8JgAMIrxerr4RHDvnPdK9GIRmAo+3glfOoI/SWCu+nWfQRBqgmpwK0IWrdLdEFOYg=; 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=rUdWzcWsRGwfRwnD9p3aEi9tBW20RidaP2TwYg4U9BU=; b=V xV2aiJLkxG7iSuJfAd+tduarjrJVo1l15tGpszwJ7lxPyKHzDiJnm4WEMXm5aqP8WLmyuwD1lyJ/U hBpmPbOJi4aigA93ySGHgRPglzNW6ylpd0FUmjLr3kW/b9q2+tDPVb6zrS1150SX8zRPCaoY1RaAP 2ZM2Xsn6YRsNb8V0=; Received: from mail-lf1-f54.google.com ([209.85.167.54]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1oWXhy-0000GB-VS for openvpn-devel@lists.sourceforge.net; Fri, 09 Sep 2022 06:41:48 +0000 Received: by mail-lf1-f54.google.com with SMTP id u18so1071674lfo.8 for ; Thu, 08 Sep 2022 23:41:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=rUdWzcWsRGwfRwnD9p3aEi9tBW20RidaP2TwYg4U9BU=; b=FHsMGxyY3Onz9j553OB/VgS+D8s9P3OrLfQX/z+JKFJadfUV9wSYiXuZcV5AayqgtR 9S3KwiRF07li1sJLf30zi3k8bTkoTlAtdT9wKkJcSYq2qufWn2+NqAE33ZC6k10QiPFJ q4xrRalEjujokRAiPGha70cE4OZh8+L3SREy8OmwvgYW/zGjcvr57sxce+zB2Be1cemp HLBA4IjxA5O9GnvglXkTyQV1H3mEUSryRiRixpGcWAeykHkVD19iyKPJLJgoPnrUNlwu PqnBegM9nncFNP5LABOWbNMYUfnhGl5Ej/hjVNs9q9yo3QDqwzioq6fMqO9R39kAvyyB WFug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=rUdWzcWsRGwfRwnD9p3aEi9tBW20RidaP2TwYg4U9BU=; b=5k1BlpxOFJlxBY3D0LQXbfFixcZsiLzblD0ZH7Wn6sfb3MPWnlGah2oHCaDw7YsbyX BCc6ABS//RbBC2I0I72+Va5Ji24JUJdNO+omIuK1//7tf3joL9VLXW61JoowxuO1tlFO vVGzwRcTnDkg4/niutmX+8e7dLC+4sxt6Ix03no4rryiyPuDxlqu4SWItX82pVQiEYA5 gV+We3I+m89enmCikO9+950mJ7LwtLS4USX3FQuS2riXVwl68RGORkDp8HUbqzbqEYJ/ x0gzM9wWglNBwrZTjWTaGom0L3SlpBMeZGcQw3MkeKYtoqwBlTSB+JGsZE65MNDCK4rJ ufNA== X-Gm-Message-State: ACgBeo1YFMtmYcA30BXs/F9SEngkspiS+FwNatuRFTd6/KcRpXoGkwh/ z8oo6G+a92QZ4a+lO8mZvBpqemmLWle+Tw== X-Google-Smtp-Source: AA6agR5RnUqNd/VWr6lXX7Uh7dIh78Guji1IHD9oZqPVtL8L4RDXraeyFacDo4KyQDpnnkP5Kyy/vQ== X-Received: by 2002:ac2:5bc3:0:b0:498:ff9:1cd1 with SMTP id u3-20020ac25bc3000000b004980ff91cd1mr2522925lfn.479.1662705699943; Thu, 08 Sep 2022 23:41:39 -0700 (PDT) Received: from LAPTOP-4L3N7KFS.localdomain (nat4.panoulu.net. [185.38.2.4]) by smtp.gmail.com with ESMTPSA id c10-20020ac25f6a000000b004948f583e6bsm147186lfc.138.2022.09.08.23.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 23:41:39 -0700 (PDT) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Fri, 9 Sep 2022 09:41:26 +0300 Message-Id: <20220909064126.482-1-lstipakov@gmail.com> X-Mailer: git-send-email 2.34.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: From: Lev Stipakov Reverse if condition - this allows us to get rid of indentation level, which makes code easier to read. Signed-off-by: Lev Stipakov --- src/openvpn/init.c | 88 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+), 43 deletions(-) Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.54 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [lstipakov[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.54 listed in list.dnswl.org] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1oWXhy-0000GB-VS Subject: [Openvpn-devel] [PATCH] do_persist_tuntap: remove indentation level 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: Lev Stipakov Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov Reverse if condition - this allows us to get rid of indentation level, which makes code easier to read. Signed-off-by: Lev Stipakov Acked-by: Antonio Quartulli --- src/openvpn/init.c | 88 ++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 84d95c21..d94b781e 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1057,57 +1057,59 @@ do_genkey(const struct options *options) bool do_persist_tuntap(struct options *options, openvpn_net_ctx_t *ctx) { - if (options->persist_config) - { - /* sanity check on options for --mktun or --rmtun */ - notnull(options->dev, "TUN/TAP device (--dev)"); - if (options->ce.remote || options->ifconfig_local - || options->ifconfig_remote_netmask - || options->shared_secret_file - || options->tls_server || options->tls_client - ) - { - msg(M_FATAL|M_OPTERR, - "options --mktun or --rmtun should only be used together with --dev"); - } + if (!options->persist_config) + { + return false; + } -#if defined(ENABLE_DCO) - if (dco_enabled(options)) - { - /* creating a DCO interface via --mktun is not supported as it does not - * make much sense. Since DCO is enabled by default, people may run into - * this without knowing, therefore this case should be properly handled. - * - * Disable DCO if --mktun was provided and print a message to let - * user know. - */ - if (dev_type_enum(options->dev, options->dev_type) == DEV_TYPE_TUN) - { - msg(M_WARN, "Note: --mktun does not support DCO. Creating TUN interface."); - } + /* sanity check on options for --mktun or --rmtun */ + notnull(options->dev, "TUN/TAP device (--dev)"); + if (options->ce.remote || options->ifconfig_local + || options->ifconfig_remote_netmask + || options->shared_secret_file + || options->tls_server || options->tls_client + ) + { + msg(M_FATAL|M_OPTERR, + "options --mktun or --rmtun should only be used together with --dev"); + } - options->tuntap_options.disable_dco = true; +#if defined(ENABLE_DCO) + if (dco_enabled(options)) + { + /* creating a DCO interface via --mktun is not supported as it does not + * make much sense. Since DCO is enabled by default, people may run into + * this without knowing, therefore this case should be properly handled. + * + * Disable DCO if --mktun was provided and print a message to let + * user know. + */ + if (dev_type_enum(options->dev, options->dev_type) == DEV_TYPE_TUN) + { + msg(M_WARN, "Note: --mktun does not support DCO. Creating TUN interface."); } + + options->tuntap_options.disable_dco = true; + } #endif #ifdef ENABLE_FEATURE_TUN_PERSIST - tuncfg(options->dev, options->dev_type, options->dev_node, - options->persist_mode, - options->username, options->groupname, &options->tuntap_options, - ctx); - if (options->persist_mode && options->lladdr) - { - set_lladdr(ctx, options->dev, options->lladdr, NULL); - } - return true; + tuncfg(options->dev, options->dev_type, options->dev_node, + options->persist_mode, + options->username, options->groupname, &options->tuntap_options, + ctx); + if (options->persist_mode && options->lladdr) + { + set_lladdr(ctx, options->dev, options->lladdr, NULL); + } + return true; #else /* ifdef ENABLE_FEATURE_TUN_PERSIST */ - msg( M_FATAL|M_OPTERR, - "options --mktun and --rmtun are not available on your operating " - "system. Please check 'man tun' (or 'tap'), whether your system " - "supports using 'ifconfig %s create' / 'destroy' to create/remove " - "persistent tunnel interfaces.", options->dev ); + msg(M_FATAL|M_OPTERR, + "options --mktun and --rmtun are not available on your operating " + "system. Please check 'man tun' (or 'tap'), whether your system " + "supports using 'ifconfig %s create' / 'destroy' to create/remove " + "persistent tunnel interfaces.", options->dev ); #endif - } return false; }