]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Merged add_bypass_address() and add_host_route_if_nonlocal()
authorDavid Sommerseth <dazo@users.sourceforge.net>
Mon, 15 Nov 2010 08:00:12 +0000 (09:00 +0100)
committerDavid Sommerseth <dazo@users.sourceforge.net>
Thu, 18 Nov 2010 17:54:49 +0000 (18:54 +0100)
The add_host_route_if_nonlocal() function is too simple to really
benefit from calling add_bypass_address() when this function is the
only caller to this function.

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: Peter Stuge <peter@stuge.se>
route.c

diff --git a/route.c b/route.c
index 612bcbef317d08f2d7c5a269cadc8def4c146242..f78893effbb86228fcb5d8006d7ab45b3c05b1ac 100644 (file)
--- a/route.c
+++ b/route.c
@@ -59,26 +59,6 @@ print_bypass_addresses (const struct route_bypass *rb)
 
 #endif
 
-static bool
-add_bypass_address (struct route_bypass *rb, const in_addr_t a)
-{
-  int i;
-  for (i = 0; i < rb->n_bypass; ++i)
-    {
-      if (a == rb->bypass[i]) /* avoid duplicates */
-       return true;
-    }
-  if (rb->n_bypass < N_ROUTE_BYPASS)
-    {
-      rb->bypass[rb->n_bypass++] = a;
-      return true;
-    }
-  else
-    {
-      return false;
-    }
-}
-
 struct route_option_list *
 new_route_option_list (const int max_routes, struct gc_arena *a)
 {
@@ -2124,8 +2104,18 @@ netmask_to_netbits (const in_addr_t network, const in_addr_t netmask, int *netbi
 static void
 add_host_route_if_nonlocal (struct route_bypass *rb, const in_addr_t addr)
 {
-  if (test_local_addr(addr) == TLA_NONLOCAL && addr != 0 && addr != ~0)
-    add_bypass_address (rb, addr);
+  if (test_local_addr(addr) == TLA_NONLOCAL && addr != 0 && addr != ~0) {
+    int i;
+    for (i = 0; i < rb->n_bypass; ++i)
+      {
+        if (addr == rb->bypass[i]) /* avoid duplicates */
+          return;
+      }
+    if (rb->n_bypass < N_ROUTE_BYPASS)
+      {
+        rb->bypass[rb->n_bypass++] = addr;
+      }
+  }
 }
 
 static void