]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
cleanup and redefine metric handling for IPv6 routes
authorGert Doering <gert@greenie.muc.de>
Sun, 10 Jun 2012 15:41:27 +0000 (17:41 +0200)
committerDavid Sommerseth <davids@redhat.com>
Wed, 13 Jun 2012 10:20:01 +0000 (12:20 +0200)
"no metric set" is now stored as "-1"
"metric 0" means "on-link route" (what the BSDs do)
properly initialize metric value to "0" for on-link IPv6 net on BSDs

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: 1339342891-28443-2-git-send-email-gert@greenie.muc.de
URL: http://article.gmane.org/gmane.network.openvpn.devel/6710
Signed-off-by: David Sommerseth <davids@redhat.com>
src/openvpn/init.c
src/openvpn/route.c
src/openvpn/tun.c

index 30f5803e9baaab0d42d73ac23aff650da952ca28..bfd6cfa8a9cc7a44fd914fb77924d30f9fd9fa6d 100644 (file)
@@ -1249,7 +1249,7 @@ do_init_route_ipv6_list (const struct options *options,
 {
   const char *gw = NULL;
   int dev = dev_type_enum (options->dev, options->dev_type);
-  int metric = 0;
+  int metric = -1;             /* no metric set */
 
   if (dev != DEV_TYPE_TUN )
     msg( M_WARN, "IPv6 routes on TAP devices are going to fail on some platforms (need gateway spec)" );       /* TODO-GERT */
index 7c25c770d32a5d49747afea8da6d09df3fff8d61..aadbacce802c44bca931fbe926ecede8d451abc4 100644 (file)
@@ -383,7 +383,6 @@ init_route_ipv6 (struct route_ipv6 *r6,
                 const struct route_ipv6_option *r6o,
                 const struct route_ipv6_list *rl6 )
 {
-  r6->option = r6o;
   r6->defined = false;
 
   if ( !get_ipv6_addr( r6o->prefix, &r6->network, &r6->netbits, NULL, M_WARN ))
@@ -410,7 +409,7 @@ init_route_ipv6 (struct route_ipv6 *r6,
   /* metric */
 
   r6->metric_defined = false;
-  r6->metric = 0;
+  r6->metric = -1;
   if (is_route_parm_defined (r6o->metric))
     {
       r6->metric = atoi (r6o->metric);
@@ -700,7 +699,7 @@ init_route_ipv6_list (struct route_ipv6_list *rl6,
 
   rl6->flags = opt6->flags;
 
-  if (default_metric)
+  if (default_metric >= 0 )
     {
       rl6->default_metric = default_metric;
       rl6->default_metric_defined = true;
@@ -1582,7 +1581,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
              network,
              r6->netbits,
              device);
-  if (r6->metric_defined)
+  if (r6->metric_defined && r6->metric > 0 )
     argv_printf_cat (&argv, " metric %d", r6->metric);
 
 #else
@@ -1591,7 +1590,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
              network,
              r6->netbits,
              device);
-  if (r6->metric_defined)
+  if (r6->metric_defined && r6->metric > 0 )
     argv_printf_cat (&argv, " metric %d", r6->metric);
 #endif  /*ENABLE_IPROUTE*/
   argv_msg (D_ROUTE, &argv);
index c9edbb8e5738591f829d935df05d873c481d0512..6cef94254a3588932ac762f9992ce6c0a78c1d5d 100644 (file)
@@ -600,6 +600,8 @@ void add_route_connected_v6_net(struct tuntap * tt,
     r6.network = tt->local_ipv6;
     r6.netbits = tt->netbits_ipv6;
     r6.gateway = tt->local_ipv6;
+    r6.metric  = 0;                    /* connected route */
+    r6.metric_defined = true;
     add_route_ipv6 (&r6, tt, 0, es);
 }
 
@@ -612,6 +614,8 @@ void delete_route_connected_v6_net(struct tuntap * tt,
     r6.network = tt->local_ipv6;
     r6.netbits = tt->netbits_ipv6;
     r6.gateway = tt->local_ipv6;
+    r6.metric  = 0;                    /* connected route */
+    r6.metric_defined = true;
     delete_route_ipv6 (&r6, tt, 0, es);
 }
 #endif