[Openvpn-devel,6/6] route.c: simplify ifdef logic
Commit Message
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 <antonio@openvpn.net>
---
src/openvpn/route.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
Comments
Acked-by: Gert Doering <gert@greenie.muc.de>
These look like reasonable simplifications - if we're not on linux,
we'll never have ENABLE_IPROUTE2, so no good testing for it. And so on.
Compile tested on Linux/sitnl, Linux/iproute2, FreeBSD. Buildbot will
see to the others (if it breaks AIX, I'll find out next time I play
around with that port, and complain to the dimwit who ACKed this :) ).
Your patch has been applied to the master branch.
commit d42f070c507592a80425fa45801bc2d4cb573789
Author: Antonio Quartulli
Date: Mon Aug 5 11:25:29 2019 +0200
route.c: simplify ifdef logic
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20190805092529.9467-7-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18724.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
@@ -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