"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>
... | ... |
@@ -1249,7 +1249,7 @@ do_init_route_ipv6_list (const struct options *options, |
1249 | 1249 |
{ |
1250 | 1250 |
const char *gw = NULL; |
1251 | 1251 |
int dev = dev_type_enum (options->dev, options->dev_type); |
1252 |
- int metric = 0; |
|
1252 |
+ int metric = -1; /* no metric set */ |
|
1253 | 1253 |
|
1254 | 1254 |
if (dev != DEV_TYPE_TUN ) |
1255 | 1255 |
msg( M_WARN, "IPv6 routes on TAP devices are going to fail on some platforms (need gateway spec)" ); /* TODO-GERT */ |
... | ... |
@@ -383,7 +383,6 @@ init_route_ipv6 (struct route_ipv6 *r6, |
383 | 383 |
const struct route_ipv6_option *r6o, |
384 | 384 |
const struct route_ipv6_list *rl6 ) |
385 | 385 |
{ |
386 |
- r6->option = r6o; |
|
387 | 386 |
r6->defined = false; |
388 | 387 |
|
389 | 388 |
if ( !get_ipv6_addr( r6o->prefix, &r6->network, &r6->netbits, NULL, M_WARN )) |
... | ... |
@@ -410,7 +409,7 @@ init_route_ipv6 (struct route_ipv6 *r6, |
410 | 410 |
/* metric */ |
411 | 411 |
|
412 | 412 |
r6->metric_defined = false; |
413 |
- r6->metric = 0; |
|
413 |
+ r6->metric = -1; |
|
414 | 414 |
if (is_route_parm_defined (r6o->metric)) |
415 | 415 |
{ |
416 | 416 |
r6->metric = atoi (r6o->metric); |
... | ... |
@@ -700,7 +699,7 @@ init_route_ipv6_list (struct route_ipv6_list *rl6, |
700 | 700 |
|
701 | 701 |
rl6->flags = opt6->flags; |
702 | 702 |
|
703 |
- if (default_metric) |
|
703 |
+ if (default_metric >= 0 ) |
|
704 | 704 |
{ |
705 | 705 |
rl6->default_metric = default_metric; |
706 | 706 |
rl6->default_metric_defined = true; |
... | ... |
@@ -1582,7 +1581,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla |
1582 | 1582 |
network, |
1583 | 1583 |
r6->netbits, |
1584 | 1584 |
device); |
1585 |
- if (r6->metric_defined) |
|
1585 |
+ if (r6->metric_defined && r6->metric > 0 ) |
|
1586 | 1586 |
argv_printf_cat (&argv, " metric %d", r6->metric); |
1587 | 1587 |
|
1588 | 1588 |
#else |
... | ... |
@@ -1591,7 +1590,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla |
1591 | 1591 |
network, |
1592 | 1592 |
r6->netbits, |
1593 | 1593 |
device); |
1594 |
- if (r6->metric_defined) |
|
1594 |
+ if (r6->metric_defined && r6->metric > 0 ) |
|
1595 | 1595 |
argv_printf_cat (&argv, " metric %d", r6->metric); |
1596 | 1596 |
#endif /*ENABLE_IPROUTE*/ |
1597 | 1597 |
argv_msg (D_ROUTE, &argv); |
... | ... |
@@ -600,6 +600,8 @@ void add_route_connected_v6_net(struct tuntap * tt, |
600 | 600 |
r6.network = tt->local_ipv6; |
601 | 601 |
r6.netbits = tt->netbits_ipv6; |
602 | 602 |
r6.gateway = tt->local_ipv6; |
603 |
+ r6.metric = 0; /* connected route */ |
|
604 |
+ r6.metric_defined = true; |
|
603 | 605 |
add_route_ipv6 (&r6, tt, 0, es); |
604 | 606 |
} |
605 | 607 |
|
... | ... |
@@ -612,6 +614,8 @@ void delete_route_connected_v6_net(struct tuntap * tt, |
612 | 612 |
r6.network = tt->local_ipv6; |
613 | 613 |
r6.netbits = tt->netbits_ipv6; |
614 | 614 |
r6.gateway = tt->local_ipv6; |
615 |
+ r6.metric = 0; /* connected route */ |
|
616 |
+ r6.metric_defined = true; |
|
615 | 617 |
delete_route_ipv6 (&r6, tt, 0, es); |
616 | 618 |
} |
617 | 619 |
#endif |