From: "stipa (Code Review)" Date: Tue, 14 Jan 2025 12:38:04 +0000 In-Reply-To: References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <840bd7732576dd0875fd7ff819fb320e796a0c28-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="1Du3MwN/4AM="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: dco-win: support for iroutes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --1Du3MwN/4AM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/857?usp=3Demail to look at the new patch set (#2). Change subject: dco-win: support for iroutes ...................................................................... dco-win: support for iroutes Unlike Linux/FreeBSD, dco-win doesn't have access to a system routing table, so we have to maintain internal routing table in the driver. For that, we have 4 ioctls to add/delete IPv4/IPv6 iroutes. When adding iroute, we pass peer-id, so that the driver is able to associate a subnet with a peer context. Change-Id: I36a5442c0a5667628f419bc64efe5fb562ad3b57 Signed-off-by: Lev Stipakov --- M src/openvpn/dco.c M src/openvpn/dco_win.c M src/openvpn/dco_win.h M src/openvpn/multi.c M src/openvpn/ovpn_dco_win.h 5 files changed, 132 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/857/2 diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index b5a2136..55fe40a 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -637,7 +637,7 @@ dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr) { -#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) +#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) if (!dco_enabled(&m->top.options)) { return; @@ -653,28 +653,34 @@ } struct context *c =3D &mi->context; - const char *dev =3D c->c1.tuntap->actual_name; - if (addrtype =3D=3D MR_ADDR_IPV6) { +#if defined(_WIN32) + dco_win_add_iroute_ipv6(&c->c1.tuntap->dco, addr->v6.addr, addr->n= etbits, c->c2.tls_multi->peer_id); +#else net_route_v6_add(&m->top.net_ctx, &addr->v6.addr, addr->netbits, - &mi->context.c2.push_ifconfig_ipv6_local, dev, 0, + &mi->context.c2.push_ifconfig_ipv6_local, c->c1.t= untap->actual_name, 0, DCO_IROUTE_METRIC); +#endif } else if (addrtype =3D=3D MR_ADDR_IPV4) { +#if defined(_WIN32) + dco_win_add_iroute_ipv4(&c->c1.tuntap->dco, addr->v4.addr, addr->n= etbits, c->c2.tls_multi->peer_id); +#else in_addr_t dest =3D htonl(addr->v4.addr); net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, - &mi->context.c2.push_ifconfig_local, dev, 0, + &mi->context.c2.push_ifconfig_local, c->c1.tuntap= ->actual_name, 0, DCO_IROUTE_METRIC); +#endif } -#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) */ +#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_= WIN32) */ } void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi) { -#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) +#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) if (!dco_enabled(&m->top.options)) { return; @@ -682,7 +688,6 @@ ASSERT(TUNNEL_TYPE(mi->context.c1.tuntap) =3D=3D DEV_TYPE_TUN); struct context *c =3D &mi->context; - const char *dev =3D c->c1.tuntap->actual_name; if (mi->context.c2.push_ifconfig_defined) { @@ -690,9 +695,13 @@ ir; ir =3D ir->next) { +#if defined(_WIN32) + dco_win_del_iroute_ipv4(&c->c1.tuntap->dco, htonl(ir->network)= , ir->netbits); +#else net_route_v4_del(&m->top.net_ctx, &ir->network, ir->netbits, - &mi->context.c2.push_ifconfig_local, dev, + &mi->context.c2.push_ifconfig_local, c->c1.tu= ntap->actual_name, 0, DCO_IROUTE_METRIC); +#endif } } @@ -702,12 +711,16 @@ ir6; ir6 =3D ir6->next) { +#if defined(_WIN32) + dco_win_del_iroute_ipv6(&c->c1.tuntap->dco, ir6->network, ir6-= >netbits); +#else net_route_v6_del(&m->top.net_ctx, &ir6->network, ir6->netbits, - &mi->context.c2.push_ifconfig_ipv6_local, dev, + &mi->context.c2.push_ifconfig_ipv6_local, c->= c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC); +#endif } } -#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) */ +#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_= WIN32) */ } #endif /* defined(ENABLE_DCO) */ diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index 14220b6..db2adac 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -873,4 +873,80 @@ return dco_get_version(&ver) && ver.Major >=3D 2; } +void +dco_win_add_iroute_ipv4(dco_context_t *dco, in_addr_t dst, unsigned int ne= tbits, unsigned int peer_id) +{ + struct gc_arena gc =3D gc_new(); + + OVPN_MP_IROUTE route =3D {.Addr.Addr4.S_un.S_addr =3D dst, .Netbits = =3D netbits, .PeerId =3D peer_id, .IPv6 =3D 0}; + + msg(D_DCO_DEBUG, "%s: %s/%d -> peer %d", __func__, print_in_addr_t(dst= , IA_NET_ORDER, &gc), netbits, peer_id); + + DWORD bytes_returned =3D 0; + if (!DeviceIoControl(dco->tt->hand, OVPN_IOCTL_MP_ADD_IROUTE, &route, + sizeof(route), NULL, 0, &bytes_returned, NULL)) + { + msg(M_WARN | M_ERRNO, "DeviceIoControl(OVPN_IOCTL_MP_ADD_IROUTE) f= ailed"); + } + + gc_free(&gc); +} + +void +dco_win_add_iroute_ipv6(dco_context_t *dco, struct in6_addr dst, unsigned = int netbits, unsigned int peer_id) +{ + struct gc_arena gc =3D gc_new(); + + OVPN_MP_IROUTE route =3D { .Addr.Addr6 =3D dst, .Netbits =3D netbits, = .PeerId =3D peer_id, .IPv6 =3D 1 }; + + msg(D_DCO_DEBUG, "%s: %s/%d -> peer %d", __func__, print_in6_addr(dst,= IA_NET_ORDER, &gc), netbits, peer_id); + + DWORD bytes_returned =3D 0; + if (!DeviceIoControl(dco->tt->hand, OVPN_IOCTL_MP_ADD_IROUTE, &route, + sizeof(route), NULL, 0, &bytes_returned, NULL)) + { + msg(M_WARN | M_ERRNO, "DeviceIoControl(OVPN_IOCTL_MP_ADD_IROUTE) f= ailed"); + } + + gc_free(&gc); +} + +void +dco_win_del_iroute_ipv4(dco_context_t *dco, in_addr_t dst, unsigned int ne= tbits) +{ + struct gc_arena gc =3D gc_new(); + + OVPN_MP_IROUTE route =3D { .Addr.Addr4.S_un.S_addr =3D dst, .Netbits = =3D netbits, .PeerId =3D -1, .IPv6 =3D 0 }; + + msg(D_DCO_DEBUG, "%s: %s/%d", __func__, print_in_addr_t(dst, IA_NET_OR= DER, &gc), netbits); + + DWORD bytes_returned =3D 0; + if (!DeviceIoControl(dco->tt->hand, OVPN_IOCTL_MP_DEL_IROUTE, &route, + sizeof(route), NULL, 0, &bytes_returned, NULL)) + { + msg(M_WARN | M_ERRNO, "DeviceIoControl(OVPN_IOCTL_MP_DEL_IROUTE) f= ailed"); + } + + gc_free(&gc); +} + +void +dco_win_del_iroute_ipv6(dco_context_t *dco, struct in6_addr dst, unsigned = int netbits) +{ + struct gc_arena gc =3D gc_new(); + + OVPN_MP_IROUTE route =3D { .Addr.Addr6 =3D dst, .Netbits =3D netbits, = .PeerId =3D -1, .IPv6 =3D 1 }; + + msg(D_DCO_DEBUG, "%s: %s/%d", __func__, print_in6_addr(dst, IA_NET_ORD= ER, &gc), netbits); + + DWORD bytes_returned =3D 0; + if (!DeviceIoControl(dco->tt->hand, OVPN_IOCTL_MP_DEL_IROUTE, &route, + sizeof(route), NULL, 0, &bytes_returned, NULL)) + { + msg(M_WARN | M_ERRNO, "DeviceIoControl(OVPN_IOCTL_MP_DEL_IROUTE) f= ailed"); + } + + gc_free(&gc); +} + #endif /* defined(_WIN32) */ diff --git a/src/openvpn/dco_win.h b/src/openvpn/dco_win.h index 2c2309f..21cb1de 100644 --- a/src/openvpn/dco_win.h +++ b/src/openvpn/dco_win.h @@ -24,6 +24,8 @@ #if defined(ENABLE_DCO) && defined(_WIN32) +#include + #include "buffer.h" #include "ovpn_dco_win.h" #include "sig.h" @@ -72,6 +74,18 @@ bool dco_win_supports_multipeer(void); +void +dco_win_add_iroute_ipv4(dco_context_t *dco, in_addr_t dst, unsigned int ne= tbits, unsigned int peer_id); + +void +dco_win_add_iroute_ipv6(dco_context_t *dco, struct in6_addr dst, unsigned = int netbits, unsigned int peer_id); + +void +dco_win_del_iroute_ipv4(dco_context_t *dco, in_addr_t dst, unsigned int ne= tbits); + +void +dco_win_del_iroute_ipv6(dco_context_t *dco, struct in6_addr dst, unsigned = int netbits); + #else /* if defined(ENABLE_DCO) && defined(_WIN32) */ static inline void diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 196174c..82fcf17 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -2448,6 +2448,9 @@ /* set context-level authentication flag */ mi->context.c2.tls_multi->multi_state =3D CAS_CONNECT_DONE; + /* Since dco-win maintains iroute routing table (subnet -> peer), + * peer must be added before iroutes. For other platforms it doesn't m= atter. */ + /* authentication complete, calculate dynamic client specific options = */ if (!multi_client_set_protocol_options(&mi->context)) { @@ -2465,6 +2468,8 @@ mi->context.c2.tls_multi->multi_state =3D CAS_FAILED; } + /* dco peer has been added, it is now safe for Windows to add iroutes = */ + /* * For routed tunnels, set up internal route to endpoint * plus add all iroute routes. diff --git a/src/openvpn/ovpn_dco_win.h b/src/openvpn/ovpn_dco_win.h index 8003ace..f798c5a 100644 --- a/src/openvpn/ovpn_dco_win.h +++ b/src/openvpn/ovpn_dco_win.h @@ -182,6 +182,16 @@ int PeerId; } OVPN_MP_SWAP_KEYS, * POVPN_MP_SWAP_KEYS; +typedef struct _OVPN_MP_IROUTE { + union { + IN_ADDR Addr4; + IN6_ADDR Addr6; + } Addr; + int Netbits; + int PeerId; + int IPv6; +} OVPN_MP_IROUTE, * POVPN_MP_IROUTE; + #define OVPN_IOCTL_NEW_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_BU= FFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_GET_STATS CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BU= FFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_NEW_KEY CTL_CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BU= FFERED, FILE_ANY_ACCESS) @@ -201,3 +211,6 @@ #define OVPN_IOCTL_MP_DEL_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 15, METHOD= _BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_MP_SWAP_KEYS CTL_CODE(FILE_DEVICE_UNKNOWN, 16, METHOD= _BUFFERED, FILE_ANY_ACCESS) + +#define OVPN_IOCTL_MP_ADD_IROUTE CTL_CODE(FILE_DEVICE_UNKNOWN, 17, METHOD_= BUFFERED, FILE_ANY_ACCESS) +#define OVPN_IOCTL_MP_DEL_IROUTE CTL_CODE(FILE_DEVICE_UNKNOWN, 18, METHOD_= BUFFERED, FILE_ANY_ACCESS) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/857?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I36a5442c0a5667628f419bc64efe5fb562ad3b57 Gerrit-Change-Number: 857 Gerrit-PatchSet: 2 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --1Du3MwN/4AM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

stipa uploaded patch set #2 to this change.

View Change

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/857/2
=
diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c
in= dex b5a2136..55fe40a 100644
--- a/src/openvpn/dco.c<= br>+++ b/src/openvpn/dco.c
@@ -637,7 +637,7 @@=
dco_install_iroute(struct multi_context *m, struct multi_instanc= e *mi,
struct mroute_addr *addr)=
{
-#if defin= ed(TARGET_LINUX) || defined(TARGET_FREEBSD)
+#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD= ) || defined(_WIN32)
if (!dco_enabled(&m->top.o= ptions))
{
return;
= @@ -653,28 +653,34 @@
}
=
struct context *c =3D &mi->context;
- const char *dev =3D c->c1.tuntap= ->actual_name;
-
if (addrtype =3D=3D MR_ADDR_IPV6)
{<= /span>
+#if defined(_WIN32)<= /span>
+ dco_win_add_= iroute_ipv6(&c->c1.tuntap->dco, addr->v6.addr, addr->netbit= s, c->c2.tls_multi->peer_id);
+#else
net_route_v6_add(&m->= top.net_ctx, &addr->v6.addr, addr->netbits,
- &mi->contex= t.c2.push_ifconfig_ipv6_local, dev, 0,
+ &mi->context.c2.push_ifc= onfig_ipv6_local, c->c1.tuntap->actual_name, 0,
= DCO_IROUTE_METRIC);
+#endif
}
els= e if (addrtype =3D=3D MR_ADDR_IPV4)
{
+#if defined(_WIN32)
+ dco_win_add_iroute_ipv4(&= ;c->c1.tuntap->dco, addr->v4.addr, addr->netbits, c->c2.tls_= multi->peer_id);
+= #else
in_addr_t dest =3D htonl(addr->v4.addr);<= /span>
net_route_v4_add(&m->top.net_ctx, &dest= , addr->netbits,
- = &mi->context.c2.push_ifconfig_local, dev, 0,<= /span>
+ = &mi->context.c2.push_ifconfig_local, c->c1.tuntap->actual= _name, 0,
DCO_IROUTE_METRIC);
+#endif
= }
-#endif /* if de= fined(TARGET_LINUX) || defined(TARGET_FREEBSD) */
+#endif /* if defined(TARGET_LINUX) || defined= (TARGET_FREEBSD) || defined(_WIN32) */
}
=
void
dco_delete_iroutes(struct multi_con= text *m, struct multi_instance *mi)
{
-#if defined(TARGET_LINUX) || defined(TARGE= T_FREEBSD)
+#if defin= ed(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32)
if (!dco_enabled(&m->top.options))

{
return;
@@ -682,7 +688,6 @@<= br> ASSERT(TUNNEL_TYPE(mi->context.c1.tuntap) =3D=3D DEV_TYPE_= TUN);

struct context *c =3D &mi-= >context;
- const= char *dev =3D c->c1.tuntap->actual_name;
if (mi->context.c2.push_ifconfig_defined)
= {
@@ -690,9 +695,13 @@
ir;=
ir =3D ir->next)
= {
+#if defined(_WIN3= 2)
+ dco_w= in_del_iroute_ipv4(&c->c1.tuntap->dco, htonl(ir->network), ir-= >netbits);
+#else<= /span>
net_route_v4_del(&m->top.net_ctx, &= ir->network, ir->netbits,
- &mi->context.c2.push_ifconfig= _local, dev,
+ = &mi->context.c2.push_ifconfig_local, c->c1.= tuntap->actual_name,
0, DC= O_IROUTE_METRIC);
+#e= ndif
}
}

@@ -702,12 +711,16 @@
ir6;
ir6 =3D ir6->next)
{<= /span>
+#if defined(_WIN32)<= /span>
+ dco_win_= del_iroute_ipv6(&c->c1.tuntap->dco, ir6->network, ir6->netb= its);
+#else net_route_v6_del(&m->top.net_ctx, &ir6->= network, ir6->netbits,
- &mi->context.c2.push_ifconfig_ipv6_= local, dev,
+ = &mi->context.c2.push_ifconfig_ipv6_local, c->= ;c1.tuntap->actual_name,
0= , DCO_IROUTE_METRIC);
+#endif
}
}
-#endif /* if defined(TARGET_LINUX) || = defined(TARGET_FREEBSD) */
+#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || def= ined(_WIN32) */
}

#endi= f /* defined(ENABLE_DCO) */
diff --git a/src/openvpn/dco_wi= n.c b/src/openvpn/dco_win.c
index 14220b6..db2adac 100644
--- a/src/openvpn/dco_win.c
+++ b/src/openvp= n/dco_win.c
@@ -873,4 +873,80 @@
retur= n dco_get_version(&ver) && ver.Major >=3D 2;
}


+void
+dco_win_add_i= route_ipv4(dco_context_t *dco, in_addr_t dst, unsigned int netbits, unsigne= d int peer_id)
+{
+ struct gc_arena gc = =3D gc_new();
+
+ OVPN_MP_IROUTE route = =3D {.Addr.Addr4.S_un.S_addr =3D dst, .Netbits =3D netbits, .PeerId =3D pee= r_id, .IPv6 =3D 0};
+=
+ msg(D_DCO_DEBUG= , "%s: %s/%d -> peer %d", __func__, print_in_addr_t(dst, IA_NE= T_ORDER, &gc), netbits, peer_id);
+
+ = DWORD bytes_returned =3D 0;
+ if (!DeviceIoControl(dco->tt->hand, OVPN_IOCTL_MP_ADD_= IROUTE, &route,
+= sizeof(route), NULL, 0, &bytes_returned, NULL)= )
+ {
+ msg(M_WARN | M_ERRNO, &q= uot;DeviceIoControl(OVPN_IOCTL_MP_ADD_IROUTE) failed");

+ }

+
+ gc_free(&gc);
+}
+<= br>+void
+dco_win_add_iroute_ipv6(dco_context_t *dc= o, struct in6_addr dst, unsigned int netbits, unsigned int peer_id)<= br>+{
+ struct gc_arena gc =3D gc_new();+
+ OVPN_MP_IROUTE route =3D { .Addr.Addr6 =3D = dst, .Netbits =3D netbits, .PeerId =3D peer_id, .IPv6 =3D 1 };
+

+ msg(D_DCO_DEBUG, "%s: %s/%d -> peer %d&= quot;, __func__, print_in6_addr(dst, IA_NET_ORDER, &gc), netbits, peer_= id);
+
+ DWORD bytes_returned =3D 0;
+ if (!DeviceIoContr= ol(dco->tt->hand, OVPN_IOCTL_MP_ADD_IROUTE, &route,
+ sizeof(r= oute), NULL, 0, &bytes_returned, NULL))

+ {
+ msg(M_WARN | M_ERRNO, "DeviceIoControl(OVPN_IOCTL_MP= _ADD_IROUTE) failed");
+ }
+
+ gc_free(&gc);
+}
+
+void
+= dco_win_del_iroute_ipv4(dco_context_t *dco, in_addr_t dst, unsigned int net= bits)
+{
+ struct gc_arena gc =3D gc_ne= w();

+
+ OVPN_MP_IROUTE route =3D { .Ad= dr.Addr4.S_un.S_addr =3D dst, .Netbits =3D netbits, .PeerId =3D -1, .IPv6 = =3D 0 };

+
= + msg(D_DCO_DEBUG, "%s:= %s/%d", __func__, print_in_addr_t(dst, IA_NET_ORDER, &gc), netbit= s);
+
+ DWORD bytes_returned =3D 0;
+ if (!DeviceIoContro= l(dco->tt->hand, OVPN_IOCTL_MP_DEL_IROUTE, &route,
+ sizeof(ro= ute), NULL, 0, &bytes_returned, NULL))

+ {
+ msg(M_WARN | M_ERRNO, "DeviceIoControl(OVPN_IOCTL_MP_= DEL_IROUTE) failed");
+ }
+=
+ gc_free(&gc);
+}
+
+void
+= dco_win_del_iroute_ipv6(dco_context_t *dco, struct in6_addr dst, unsigned i= nt netbits)
+{=
+ struct gc_arena gc =3D= gc_new();
++ OVPN_MP_IROUTE route =3D= { .Addr.Addr6 =3D dst, .Netbits =3D netbits, .PeerId =3D -1, .IPv6 =3D 1 }= ;
+
+ msg(D_DCO_DEBUG, "%s: %s/%d&= quot;, __func__, print_in6_addr(dst, IA_NET_ORDER, &gc), netbits);
+
+ DWORD bytes_returned =3D 0;+ if (!DeviceIoControl(dco-= >tt->hand, OVPN_IOCTL_MP_DEL_IROUTE, &route,
+ sizeof(route), = NULL, 0, &bytes_returned, NULL))
+ {
= + }
+
+ gc_free(&gc);

= +}
+
#endif /* defined(_WIN32) */
diff --git a/src/openvpn/dco_win.h b/src/openvpn/dco_win.h
index 2c2309f..21cb1de 100644
--- a/src/open= vpn/dco_win.h
+++ b/src/openvpn/dco_win.h
@= @ -24,6 +24,8 @@

#if defined(ENABLE_DCO)= && defined(_WIN32)

+#include <in6addr.h>
+
#include "buffer.h= "
#include "ovpn_dco_win.h"
#include "sig.h"

@@ -72,6 +74,18 @@
<= span> bool

dco_win_supports_multipeer(void);

+void
= +dco_win_add_iroute_ipv4(dco_co= ntext_t *dco, in_addr_t dst, unsigned int netbits, unsigned int peer_id);
+
+void
+dco_win_add_iroute_ipv6(dco_context_t *dco, struct in6_= addr dst, unsigned int netbits, unsigned int peer_id);
+
+void
= +dco_win_del_iroute_ipv4(dco_context_t *dco, in_addr_t dst, unsigned int ne= tbits);
+
<= span style=3D"color: hsl(120, 100%, 40%);">+void

+dco_win_del_iroute_ipv6(dco_context_t *dco, st= ruct in6_addr dst, unsigned int netbits);
+
#else /* if defined(ENABLE_DCO) &am= p;& defined(_WIN32) */

static inline= void
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.= c
index 196174c..82fcf17 100644
--- a/src/o= penvpn/multi.c
+++ b/src/openvpn/multi.c
@@= -2448,6 +2448,9 @@
/* set context-level authenticatio= n flag */
mi->context.c2.tls_multi->multi_state = =3D CAS_CONNECT_DONE;

+ /* Since dco-win maintains iroute routing table (su= bnet -> peer),
+ = * peer must be added before iroutes. For other platforms it doesn't = matter. */
+ /* authentication complete, calculate dynamic client specific = options */
if (!multi_client_set_protocol_options(&= ;mi->context))
{
@@ -2465,6 +2468,8= @@
mi->context.c2.tls_multi->multi_state = =3D CAS_FAILED;
}

+ /* dco peer has been added, it is = now safe for Windows to add iroutes */
+
/*
* For rou= ted tunnels, set up internal route to endpoint
* plus= add all iroute routes.
diff --git a/src/openvpn/ovpn_dco_w= in.h b/src/openvpn/ovpn_dco_win.h
index 8003ace..f798c5a 10= 0644
--- a/src/openvpn/ovpn_dco_win.h
+++ b= /src/openvpn/ovpn_dco_win.h
@@ -182,6 +182,16 @@
= int PeerId;
} OVPN_MP_SWAP_KEYS, * POVPN_MP_SWA= P_KEYS;

+typedef struct _OVPN_MP_IROUTE {
+ union {
+ IN_ADDR Addr4;
+ IN6_ADDR Addr6;
+ } Addr;
+ int Netbits;
+ int PeerId;
+} O= VPN_MP_IROUTE, * POVPN_MP_IROUTE;
+
#define OVPN_IOCTL_NEW_PEER CTL_CODE(FI= LE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
#d= efine OVPN_IOCTL_GET_STATS CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BUFFE= RED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_NEW_KEY CTL_= CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
@@ -201,3 +211,6 @@


#define OVPN_IOC= TL_MP_DEL_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 15, METHOD_BUFFERED, FILE_A= NY_ACCESS)
#define OVPN_IOCTL_MP_SWAP_KEYS CTL_CODE(FILE= _DEVICE_UNKNOWN, 16, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+#define OVPN_IOCTL_MP_ADD_IROUTE CTL_CODE(FILE_DEVICE_UNKNO= WN, 17, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define OVPN_IOCTL_MP_DEL_IROUTE CTL_CODE(FILE_DEVICE= _UNKNOWN, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)

=

To view, visit change 857. To unsubscribe, or for help writing mail fil= ters, visit settings.

<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I36a5442c0a5667628f419bc64ef= e5fb562ad3b57
Gerrit-Change-Number: 857
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--1Du3MwN/4AM=--