aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--init.c4
-rw-r--r--openvpn.812
-rw-r--r--options.c7
-rw-r--r--options.h1
-rw-r--r--route.c13
-rw-r--r--route.h3
7 files changed, 42 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index eb45c12..a83ae01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,9 +7,14 @@ $Id$
* Fixed Windows server bug in time backtrack handling code which
could cause TLS negotiation failures on legitimate clients.
+
* Rewrote gettimeofday function for Windows to be
simpler and more efficient.
+
* Merged PKCS#11 extensions to easy-rsa/2.0 (Alon Bar-Lev).
+
+* Added --route-metric option to set a default route metric
+ for --route (Roy Marples).
2006.04.12 -- Version 2.1-beta13
diff --git a/init.c b/init.c
index c0eeb1a..0bc5219 100644
--- a/init.c
+++ b/init.c
@@ -634,15 +634,19 @@ do_init_route_list (const struct options *options,
{
const char *gw = NULL;
int dev = dev_type_enum (options->dev, options->dev_type);
+ int metric = 0;
if (dev == DEV_TYPE_TUN && (options->topology == TOP_NET30 || options->topology == TOP_P2P))
gw = options->ifconfig_remote_netmask;
if (options->route_default_gateway)
gw = options->route_default_gateway;
+ if (options->route_default_metric)
+ metric = options->route_default_metric;
if (!init_route_list (route_list,
options->routes,
gw,
+ metric,
link_socket_current_remote (link_socket_info),
es))
{
diff --git a/openvpn.8 b/openvpn.8
index 499d802..7df156d 100644
--- a/openvpn.8
+++ b/openvpn.8
@@ -240,6 +240,7 @@ openvpn \- secure IP tunnel daemon.
[\ \fB\-\-route\-delay\fR\ \fI[n]\ [w]\fR\ ]
[\ \fB\-\-route\-gateway\fR\ \fIgw\fR\ ]
[\ \fB\-\-route\-method\fR\ \fIm\fR\ ]
+[\ \fB\-\-route\-metric\fR\ \fIm\fR\ ]
[\ \fB\-\-route\-noexec\fR\ ]
[\ \fB\-\-route\-nopull\fR\ ]
[\ \fB\-\-route\-up\fR\ \fIcmd\fR\ ]
@@ -1037,6 +1038,11 @@ when
.B --dev tun
is specified.
+.B metric
+default -- taken from
+.B --route-metric
+otherwise 0.
+
The default can be specified by leaving an option blank or setting
it to "default".
@@ -1073,6 +1079,12 @@ Specify a default gateway
.B gw
for use with
.B --route.
+.TP
+.B --route-metric m
+Specify a default metric
+.B m
+for use with
+.B --route.
.\"*********************************************************
.TP
.B --route-delay [n] [w]
diff --git a/options.c b/options.c
index 793ae66..effe1b1 100644
--- a/options.c
+++ b/options.c
@@ -166,6 +166,7 @@ static const char usage_message[] =
" gateway default: taken from --route-gateway or --ifconfig\n"
" Specify default by leaving blank or setting to \"nil\".\n"
"--route-gateway gw : Specify a default gateway for use with --route.\n"
+ "--route-metric m : Specify a default metric for use with --route.\n"
"--route-delay n [w] : Delay n seconds after connection initiation before\n"
" adding routes (may be 0). If not specified, routes will\n"
" be added immediately after tun/tap open. On Windows, wait\n"
@@ -1175,6 +1176,7 @@ show_settings (const struct options *o)
SHOW_STR (route_script);
SHOW_STR (route_default_gateway);
+ SHOW_INT (route_default_metric);
SHOW_BOOL (route_noexec);
SHOW_INT (route_delay);
SHOW_INT (route_delay_window);
@@ -3938,6 +3940,11 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
options->route_default_gateway = p[1];
}
+ else if (streq (p[0], "route-metric") && p[1])
+ {
+ VERIFY_PERMISSION (OPT_P_ROUTE);
+ options->route_default_metric = positive_atoi (p[1]);
+ }
else if (streq (p[0], "route-delay"))
{
VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
diff --git a/options.h b/options.h
index 4349f7d..b9dafe7 100644
--- a/options.h
+++ b/options.h
@@ -243,6 +243,7 @@ struct options
/* route management */
const char *route_script;
const char *route_default_gateway;
+ int route_default_metric;
bool route_noexec;
int route_delay;
int route_delay_window;
diff --git a/route.c b/route.c
index 0b9a78e..b041b3e 100644
--- a/route.c
+++ b/route.c
@@ -276,10 +276,10 @@ init_route (struct route *r,
}
r->metric_defined = true;
}
- else
+ else if (spec->default_metric_defined)
{
- r->metric = 0;
- r->metric_defined = false;
+ r->metric = spec->default_metric;
+ r->metric_defined = true;
}
r->defined = true;
@@ -322,6 +322,7 @@ bool
init_route_list (struct route_list *rl,
const struct route_option_list *opt,
const char *remote_endpoint,
+ int default_metric,
in_addr_t remote_host,
struct env_set *es)
{
@@ -338,6 +339,12 @@ init_route_list (struct route_list *rl,
rl->spec.remote_host_defined = true;
}
+ if (default_metric)
+ {
+ rl->spec.default_metric = default_metric;
+ rl->spec.default_metric_defined = true;
+ }
+
rl->spec.net_gateway_defined = get_default_gateway (&rl->spec.net_gateway);
if (rl->spec.net_gateway_defined)
{
diff --git a/route.h b/route.h
index 9cbc773..fc27a5a 100644
--- a/route.h
+++ b/route.h
@@ -65,6 +65,8 @@ struct route_special_addr
in_addr_t remote_host;
bool remote_host_defined;
struct route_bypass bypass;
+ int default_metric;
+ bool default_metric_defined;
};
struct route_option {
@@ -132,6 +134,7 @@ void clear_route_list (struct route_list *rl);
bool init_route_list (struct route_list *rl,
const struct route_option_list *opt,
const char *remote_endpoint,
+ int default_metric,
in_addr_t remote_host,
struct env_set *es);