mirror of
https://github.com/OpenVPN/openvpn.git
synced 2025-05-09 21:51:05 +08:00
Added --route-metric option to set a default route metric
for --route (Roy Marples). git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1011 e7ae566f-a301-0410-adde-c780ea21d3b5
This commit is contained in:
parent
151ea252ee
commit
40ac3d7ac1
@ -7,10 +7,15 @@ $Id$
|
|||||||
|
|
||||||
* Fixed Windows server bug in time backtrack handling code which
|
* Fixed Windows server bug in time backtrack handling code which
|
||||||
could cause TLS negotiation failures on legitimate clients.
|
could cause TLS negotiation failures on legitimate clients.
|
||||||
|
|
||||||
* Rewrote gettimeofday function for Windows to be
|
* Rewrote gettimeofday function for Windows to be
|
||||||
simpler and more efficient.
|
simpler and more efficient.
|
||||||
|
|
||||||
* Merged PKCS#11 extensions to easy-rsa/2.0 (Alon Bar-Lev).
|
* 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
|
2006.04.12 -- Version 2.1-beta13
|
||||||
|
|
||||||
* Code added in 2.1-beta7 and 2.0.6-rc1 to extend byte counters
|
* Code added in 2.1-beta7 and 2.0.6-rc1 to extend byte counters
|
||||||
|
4
init.c
4
init.c
@ -634,15 +634,19 @@ do_init_route_list (const struct options *options,
|
|||||||
{
|
{
|
||||||
const char *gw = NULL;
|
const char *gw = NULL;
|
||||||
int dev = dev_type_enum (options->dev, options->dev_type);
|
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))
|
if (dev == DEV_TYPE_TUN && (options->topology == TOP_NET30 || options->topology == TOP_P2P))
|
||||||
gw = options->ifconfig_remote_netmask;
|
gw = options->ifconfig_remote_netmask;
|
||||||
if (options->route_default_gateway)
|
if (options->route_default_gateway)
|
||||||
gw = 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,
|
if (!init_route_list (route_list,
|
||||||
options->routes,
|
options->routes,
|
||||||
gw,
|
gw,
|
||||||
|
metric,
|
||||||
link_socket_current_remote (link_socket_info),
|
link_socket_current_remote (link_socket_info),
|
||||||
es))
|
es))
|
||||||
{
|
{
|
||||||
|
12
openvpn.8
12
openvpn.8
@ -240,6 +240,7 @@ openvpn \- secure IP tunnel daemon.
|
|||||||
[\ \fB\-\-route\-delay\fR\ \fI[n]\ [w]\fR\ ]
|
[\ \fB\-\-route\-delay\fR\ \fI[n]\ [w]\fR\ ]
|
||||||
[\ \fB\-\-route\-gateway\fR\ \fIgw\fR\ ]
|
[\ \fB\-\-route\-gateway\fR\ \fIgw\fR\ ]
|
||||||
[\ \fB\-\-route\-method\fR\ \fIm\fR\ ]
|
[\ \fB\-\-route\-method\fR\ \fIm\fR\ ]
|
||||||
|
[\ \fB\-\-route\-metric\fR\ \fIm\fR\ ]
|
||||||
[\ \fB\-\-route\-noexec\fR\ ]
|
[\ \fB\-\-route\-noexec\fR\ ]
|
||||||
[\ \fB\-\-route\-nopull\fR\ ]
|
[\ \fB\-\-route\-nopull\fR\ ]
|
||||||
[\ \fB\-\-route\-up\fR\ \fIcmd\fR\ ]
|
[\ \fB\-\-route\-up\fR\ \fIcmd\fR\ ]
|
||||||
@ -1037,6 +1038,11 @@ when
|
|||||||
.B --dev tun
|
.B --dev tun
|
||||||
is specified.
|
is specified.
|
||||||
|
|
||||||
|
.B metric
|
||||||
|
default -- taken from
|
||||||
|
.B --route-metric
|
||||||
|
otherwise 0.
|
||||||
|
|
||||||
The default can be specified by leaving an option blank or setting
|
The default can be specified by leaving an option blank or setting
|
||||||
it to "default".
|
it to "default".
|
||||||
|
|
||||||
@ -1073,6 +1079,12 @@ Specify a default gateway
|
|||||||
.B gw
|
.B gw
|
||||||
for use with
|
for use with
|
||||||
.B --route.
|
.B --route.
|
||||||
|
.TP
|
||||||
|
.B --route-metric m
|
||||||
|
Specify a default metric
|
||||||
|
.B m
|
||||||
|
for use with
|
||||||
|
.B --route.
|
||||||
.\"*********************************************************
|
.\"*********************************************************
|
||||||
.TP
|
.TP
|
||||||
.B --route-delay [n] [w]
|
.B --route-delay [n] [w]
|
||||||
|
@ -166,6 +166,7 @@ static const char usage_message[] =
|
|||||||
" gateway default: taken from --route-gateway or --ifconfig\n"
|
" gateway default: taken from --route-gateway or --ifconfig\n"
|
||||||
" Specify default by leaving blank or setting to \"nil\".\n"
|
" Specify default by leaving blank or setting to \"nil\".\n"
|
||||||
"--route-gateway gw : Specify a default gateway for use with --route.\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"
|
"--route-delay n [w] : Delay n seconds after connection initiation before\n"
|
||||||
" adding routes (may be 0). If not specified, routes will\n"
|
" adding routes (may be 0). If not specified, routes will\n"
|
||||||
" be added immediately after tun/tap open. On Windows, wait\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_script);
|
||||||
SHOW_STR (route_default_gateway);
|
SHOW_STR (route_default_gateway);
|
||||||
|
SHOW_INT (route_default_metric);
|
||||||
SHOW_BOOL (route_noexec);
|
SHOW_BOOL (route_noexec);
|
||||||
SHOW_INT (route_delay);
|
SHOW_INT (route_delay);
|
||||||
SHOW_INT (route_delay_window);
|
SHOW_INT (route_delay_window);
|
||||||
@ -3938,6 +3940,11 @@ add_option (struct options *options,
|
|||||||
VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
|
VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
|
||||||
options->route_default_gateway = p[1];
|
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"))
|
else if (streq (p[0], "route-delay"))
|
||||||
{
|
{
|
||||||
VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
|
VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
|
||||||
|
@ -243,6 +243,7 @@ struct options
|
|||||||
/* route management */
|
/* route management */
|
||||||
const char *route_script;
|
const char *route_script;
|
||||||
const char *route_default_gateway;
|
const char *route_default_gateway;
|
||||||
|
int route_default_metric;
|
||||||
bool route_noexec;
|
bool route_noexec;
|
||||||
int route_delay;
|
int route_delay;
|
||||||
int route_delay_window;
|
int route_delay_window;
|
||||||
|
13
route.c
13
route.c
@ -276,10 +276,10 @@ init_route (struct route *r,
|
|||||||
}
|
}
|
||||||
r->metric_defined = true;
|
r->metric_defined = true;
|
||||||
}
|
}
|
||||||
else
|
else if (spec->default_metric_defined)
|
||||||
{
|
{
|
||||||
r->metric = 0;
|
r->metric = spec->default_metric;
|
||||||
r->metric_defined = false;
|
r->metric_defined = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->defined = true;
|
r->defined = true;
|
||||||
@ -322,6 +322,7 @@ bool
|
|||||||
init_route_list (struct route_list *rl,
|
init_route_list (struct route_list *rl,
|
||||||
const struct route_option_list *opt,
|
const struct route_option_list *opt,
|
||||||
const char *remote_endpoint,
|
const char *remote_endpoint,
|
||||||
|
int default_metric,
|
||||||
in_addr_t remote_host,
|
in_addr_t remote_host,
|
||||||
struct env_set *es)
|
struct env_set *es)
|
||||||
{
|
{
|
||||||
@ -338,6 +339,12 @@ init_route_list (struct route_list *rl,
|
|||||||
rl->spec.remote_host_defined = true;
|
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);
|
rl->spec.net_gateway_defined = get_default_gateway (&rl->spec.net_gateway);
|
||||||
if (rl->spec.net_gateway_defined)
|
if (rl->spec.net_gateway_defined)
|
||||||
{
|
{
|
||||||
|
3
route.h
3
route.h
@ -65,6 +65,8 @@ struct route_special_addr
|
|||||||
in_addr_t remote_host;
|
in_addr_t remote_host;
|
||||||
bool remote_host_defined;
|
bool remote_host_defined;
|
||||||
struct route_bypass bypass;
|
struct route_bypass bypass;
|
||||||
|
int default_metric;
|
||||||
|
bool default_metric_defined;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct route_option {
|
struct route_option {
|
||||||
@ -132,6 +134,7 @@ void clear_route_list (struct route_list *rl);
|
|||||||
bool init_route_list (struct route_list *rl,
|
bool init_route_list (struct route_list *rl,
|
||||||
const struct route_option_list *opt,
|
const struct route_option_list *opt,
|
||||||
const char *remote_endpoint,
|
const char *remote_endpoint,
|
||||||
|
int default_metric,
|
||||||
in_addr_t remote_host,
|
in_addr_t remote_host,
|
||||||
struct env_set *es);
|
struct env_set *es);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user