From patchwork Sun Aug 4 23:25:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 793 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id gF85AKr2R13tZgAAIUCqbw for ; Mon, 05 Aug 2019 05:28:10 -0400 Received: from proxy15.mail.ord1d.rsapps.net ([172.30.191.6]) by director12.mail.ord1d.rsapps.net with LMTP id KOcJAKr2R12jPwAAIasKDg ; Mon, 05 Aug 2019 05:28:10 -0400 Received: from smtp8.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.ord1d.rsapps.net with LMTP id uEhzO6n2R10iRQAAAY1PeQ ; Mon, 05 Aug 2019 05:28:10 -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: smtp8.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 565a452c-b763-11e9-8f9d-782bcb03304b-1-1 Received: from [216.105.38.7] ([216.105.38.7:34278] helo=lists.sourceforge.net) by smtp8.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 71/BD-31452-9A6F74D5; Mon, 05 Aug 2019 05:28:09 -0400 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 1huZHB-00006B-9X; Mon, 05 Aug 2019 09:27:33 +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 1huZHA-000063-Mv for openvpn-devel@lists.sourceforge.net; Mon, 05 Aug 2019 09:27:32 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7jqR1HwdQZlS33FltKAg5Cycw56ExUVqIOQjTxhvmNQ=; b=CK17f4H6GPTqkHw1B87VBOOO6m GMS8bX1i8LY3AjRohVSH3+Ft3jQUwS8ifhju7reM+l0wltVqyV2lkIf3YCCccmymZKxior17HBm4H 4awPg4gg4Hl8POlRsJqhj1MbYhG+NL0yFAzeBsYvxlONCh3GcX+GaYX0wKQfDmWE8CNs=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7jqR1HwdQZlS33FltKAg5Cycw56ExUVqIOQjTxhvmNQ=; b=TzKmBBsvk4ZjwRXOo6qtewkbFS tqZdgH4MGnMetX6vBez4fXyQGFXr6p+ccb4JAzufh9Fguz64KwmG8hUlJN2LHOM4qzxziO5r45IbT 8DNtgjdjjID+hItr/KUWJuIwccJLq/6UFjqrElEURaWrlftSAf2yxKCXvuY3n89Zt3Q4=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1huZH9-00B3WD-7u for openvpn-devel@lists.sourceforge.net; Mon, 05 Aug 2019 09:27:32 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Mon, 5 Aug 2019 11:25:29 +0200 Message-Id: <20190805092529.9467-7-a@unstable.cc> In-Reply-To: <20190805092529.9467-1-a@unstable.cc> References: <20190805092529.9467-1-a@unstable.cc> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1huZH9-00B3WD-7u Subject: [Openvpn-devel] [PATCH 6/6] route.c: simplify ifdef logic 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 , Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox With the introduction of the new networking API layer on linux, some ifdefs can be pruned or simplified. While at it move some variable to improve readability. Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- src/openvpn/route.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 2d53c459..3ad87e26 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1554,13 +1554,10 @@ add_route(struct route_ipv4 *r, struct argv argv = argv_new(); #if !defined(TARGET_LINUX) const char *network; -#if !defined(ENABLE_IPROUTE) && !defined(TARGET_AIX) +#if !defined(TARGET_AIX) const char *netmask; #endif const char *gateway; -#else - const char *iface; - int metric; #endif bool status = false; int is_local_route; @@ -1574,7 +1571,7 @@ add_route(struct route_ipv4 *r, #if !defined(TARGET_LINUX) network = print_in_addr_t(r->network, 0, &gc); -#if !defined(ENABLE_IPROUTE) && !defined(TARGET_AIX) +#if !defined(TARGET_AIX) netmask = print_in_addr_t(r->netmask, 0, &gc); #endif gateway = print_in_addr_t(r->gateway, 0, &gc); @@ -1587,13 +1584,14 @@ add_route(struct route_ipv4 *r, } #if defined(TARGET_LINUX) - iface = NULL; + const char *iface = NULL; + int metric = -1; + if (is_on_link(is_local_route, flags, rgi)) { iface = rgi->iface; } - metric = -1; if (r->flags & RT_METRIC_DEFINED) { metric = r->metric; @@ -2148,10 +2146,10 @@ delete_route(struct route_ipv4 *r, struct argv argv = argv_new(); #if !defined(TARGET_LINUX) const char *network; -#if !defined(ENABLE_IPROUTE) && !defined(TARGET_AIX) +#if !defined(TARGET_AIX) const char *netmask; #endif -#if !defined(TARGET_LINUX) && !defined(TARGET_ANDROID) +#if !defined(TARGET_ANDROID) const char *gateway; #endif #else @@ -2168,10 +2166,10 @@ delete_route(struct route_ipv4 *r, #if !defined(TARGET_LINUX) network = print_in_addr_t(r->network, 0, &gc); -#if !defined(ENABLE_IPROUTE) && !defined(TARGET_AIX) +#if !defined(TARGET_AIX) netmask = print_in_addr_t(r->netmask, 0, &gc); #endif -#if !defined(TARGET_LINUX) && !defined(TARGET_ANDROID) +#if !defined(TARGET_ANDROID) gateway = print_in_addr_t(r->gateway, 0, &gc); #endif #endif