aboutsummaryrefslogtreecommitdiff
path: root/route.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2007-02-28 03:49:33 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2007-02-28 03:49:33 +0000
commit94a4350003492d140d6e2c8b9c979703fce81939 (patch)
treee649f05334c13ad9fb96e9c7a71a83c16b33f7fe /route.c
parentThe Windows version will now use a default route-delay (diff)
downloadopenvpn-94a4350003492d140d6e2c8b9c979703fce81939.tar.xz
Worked around an incompatibility in the Windows Vista
version of CreateIpForwardEntry as described in http://www.nynaeve.net/?p=59 This issue would cause route additions using the IP Helper API to fail on Vista. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1748 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to '')
-rw-r--r--route.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/route.c b/route.c
index 354a10c..36d41cd 100644
--- a/route.c
+++ b/route.c
@@ -1279,16 +1279,34 @@ add_route_ipapi (const struct route *r, const struct tuntap *tt)
ret = true;
else
{
- /* failed, try a different forward type (--redirect-gateway over RRAS seems to need this) */
- fr.dwForwardType = 3; /* the next hop is the final dest */
+ /* failed, try increasing the metric to work around Vista issue */
+ const unsigned int forward_metric_limit = 2048; /* iteratively retry higher metrics up to this limit */
- status = CreateIpForwardEntry (&fr);
+ for ( ; fr.dwForwardMetric1 <= forward_metric_limit; ++fr.dwForwardMetric1)
+ {
+ /* try a different forward type=3 ("the next hop is the final dest") in addition to 4.
+ --redirect-gateway over RRAS seems to need this. */
+ for (fr.dwForwardType = 4; fr.dwForwardType >= 3; --fr.dwForwardType)
+ {
+ status = CreateIpForwardEntry (&fr);
+ if (status == NO_ERROR)
+ {
+ msg (D_ROUTE, "ROUTE: CreateIpForwardEntry succeeded with dwForwardMetric1=%u and dwForwardType=%u",
+ (unsigned int)fr.dwForwardMetric1,
+ (unsigned int)fr.dwForwardType);
+ ret = true;
+ goto doublebreak;
+ }
+ else if (status != ERROR_BAD_ARGUMENTS)
+ goto doublebreak;
+ }
+ }
- if (status == NO_ERROR)
- ret = true;
- else
- msg (M_WARN, "ROUTE: route addition failed using CreateIpForwardEntry: %s [if_index=%u]",
+ doublebreak:
+ if (status != NO_ERROR)
+ msg (M_WARN, "ROUTE: route addition failed using CreateIpForwardEntry: %s [status=%u if_index=%u]",
strerror_win32 (status, &gc),
+ (unsigned int)status,
(unsigned int)if_index);
}
}