Change in openvpn[master]: PUSH_UPDATE: add DCO and iroutes support on server
A message that is not in the archive (sent off-list or not yet received): gerrit.1766071205000.I88f37e47026a7d7ea0f7c6bde1d79d32c14e5297@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
to review the following change.
Change subject: PUSH_UPDATE: add DCO and iroutes support on server
......................................................................
PUSH_UPDATE: add DCO and iroutes support on server
Renamed update_vhash() to update_vaddr().
Moved the -ifconfig logic from send_single_push_update() to update_vaddr(). Changed canary logic to use the current value of ifconfig (if present) as canary. Added logic in the update_vaddr() to not unlearn and re-learn the same address.
Added logic to update the peer's virtual address(es) in the DCO to the current value(s) after sending a PUSH_UPDATE message on Linux.
Added dco_multi_update_peer_addr() and dco_update_peer_addr() to do so.
Added logic to update iroutes after changing the peer's virtual address(es). Divided dco_delete_iroutes() in _v4() and _v6() to better updating iroutes.
---
M src/openvpn/dco.c
M src/openvpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_linux.c
M src/openvpn/dco_win.c
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/push_util.c
M tests/unit_tests/openvpn/test_push_update_msg.c
9 files changed, 377 insertions(+), 142 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/1450/1
src/openvpn/dco.c +56 -7
@@ -658,6 +658,41 @@return 0 ; } +int +dco_multi_update_peer_addr (struct multi_context *m,struct multi_instance *mi,int flags) +{ +if (!flags) + { +return 0 ; + } + +struct context *c = &mi->context; +int peer_id = c->c2.tls_multi->dco_peer_id; + +/* In server mode we need to fetch the remote addresses from the push config */ +struct in_addr vpn_ip4 = {0 }; +struct in_addr *vpn_addr4 =NULL ; +if (c->c2.push_ifconfig_defined) + { + vpn_ip4.s_addr =htonl (c->c2.push_ifconfig_local); + vpn_addr4 = &vpn_ip4; + } + +struct in6_addr *vpn_addr6 =NULL ; +if (c->c2.push_ifconfig_ipv6_defined) + { + vpn_addr6 = &c->c2.push_ifconfig_ipv6_local; + } + +int ret =dco_update_peer_addr (&c->c1.tuntap->dco, peer_id, vpn_addr4, vpn_addr6, flags); +if (ret <0 ) + { +return ret; + } + +return 0 ; +} +void dco_install_iroute (struct multi_context *m,struct multi_instance *mi,struct mroute_addr *addr) {
@@ -723,7 +758,7 @@ }void -dco_delete_iroutes (struct multi_context *m,struct multi_instance *mi) +dco_delete_iroutes_v4 (struct multi_context *m,struct multi_instance *mi) {#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32)if (!dco_enabled (&m->top.options))
@@ -734,7 +769,7 @@struct context *c = &mi->context; -if (mi->context.c2.push_ifconfig_defined) +if (c->c2.push_ifconfig_defined) {for (const struct iroute *ir = c->options.iroutes; ir; ir = ir->next) {
@@ -742,7 +777,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -750,7 +785,7 @@#if !defined(_WIN32)/* Check if we added a host route as the assigned client IP address was * not in the on link scope defined by --ifconfig */ -in_addr_t ifconfig_local = mi->context.c2.push_ifconfig_local; +in_addr_t ifconfig_local = c->c2.push_ifconfig_local;if (multi_check_push_ifconfig_extra_route (mi,htonl (ifconfig_local))) {
@@ -761,8 +796,22 @@ }#endif } +#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */ +} -if (mi->context.c2.push_ifconfig_ipv6_defined) +void +dco_delete_iroutes_v6 (struct multi_context *m,struct multi_instance *mi) +{ +#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32) +if (!dco_enabled (&m->top.options)) + { +return ; + } +ASSERT (TUNNEL_TYPE (mi->context.c1.tuntap) ==DEV_TYPE_TUN ); + +struct context *c = &mi->context; + +if (c->c2.push_ifconfig_ipv6_defined) {for (const struct iroute_ipv6 *ir6 = c->options.iroutes_ipv6; ir6; ir6 = ir6->next) {
@@ -770,7 +819,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -778,7 +827,7 @@/* Checked if we added a host route as the assigned client IP address was * outside the --ifconfig-ipv6 tun interface config */ #if !defined(_WIN32) -struct in6_addr *dest = &mi->context.c2.push_ifconfig_ipv6_local; +struct in6_addr *dest = &c->c2.push_ifconfig_ipv6_local;if (multi_check_push_ifconfig_ipv6_extra_route (mi, dest)) {/* On windows we do not install these routes, so we also do not need to delete them */
src/openvpn/dco.h +40 -3
65 lines not on this page · raw message
src/openvpn/dco_freebsd.c +6 -0
@@ -559,6 +559,12 @@return ret; } +int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ + return 0 +} +static void dco_update_peer_stat (struct multi_context *m,uint32_t peerid,const nvlist_t *nvl) {
src/openvpn/dco_linux.c +44 -0
50 lines not on this page · raw message
src/openvpn/dco_win.c +6 -0
@@ -526,6 +526,12 @@ }int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ + return 0 +} + +int dco_new_key (dco_context_t *dco,unsigned int peerid,int keyid,dco_key_slot_t slot,const uint8_t *encrypt_key,const uint8_t *encrypt_iv,const uint8_t *decrypt_key,const uint8_t *decrypt_iv,const char *ciphername,bool epoch)
src/openvpn/multi.c +191 -87
345 lines not on this page · raw message
src/openvpn/multi.h +1 -3
@@ -714,8 +714,6 @@#endif void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6); -void unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi); -void unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi); +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6);#endif /* MULTI_H */
src/openvpn/push_util.c +32 -29
86 lines not on this page · raw message
tests/unit_tests/openvpn/test_push_update_msg.c +1 -13
@@ -31,19 +31,7 @@ }void -unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) {return ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88f37e47026a7d7ea0f7c6bde1d79d32c14e5297
Gerrit-Change-Number: 1450
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
to look at the new patch set (#3).
Change subject: PUSH_UPDATE: add DCO and iroutes support on server
......................................................................
PUSH_UPDATE: add DCO and iroutes support on server
Renamed update_vhash() to update_vaddr().
Moved the -ifconfig logic from send_single_push_update() to update_vaddr(). Changed canary logic to use the current value of ifconfig (if present) as canary. Added logic in the update_vaddr() to not unlearn and re-learn the same address.
Added logic to update the peer's virtual address(es) in the DCO to the current value(s) after sending a PUSH_UPDATE message on Linux.
Added dco_multi_update_peer_addr() and dco_update_peer_addr() to do so.
Added logic to update iroutes after changing the peer's virtual address(es). Divided dco_delete_iroutes() in _v4() and _v6() to better updating iroutes.
---
M src/openvpn/dco.c
M src/openvpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_linux.c
M src/openvpn/dco_win.c
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/push_util.c
M tests/unit_tests/openvpn/test_push_update_msg.c
9 files changed, 377 insertions(+), 142 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/1450/3
src/openvpn/dco.c +56 -7
@@ -658,6 +658,41 @@return 0 ; } +int +dco_multi_update_peer_addr (struct multi_context *m,struct multi_instance *mi,int flags) +{ +if (!flags) + { +return 0 ; + } + +struct context *c = &mi->context; +int peer_id = c->c2.tls_multi->dco_peer_id; + +/* In server mode we need to fetch the remote addresses from the push config */ +struct in_addr vpn_ip4 = {0 }; +struct in_addr *vpn_addr4 =NULL ; +if (c->c2.push_ifconfig_defined) + { + vpn_ip4.s_addr =htonl (c->c2.push_ifconfig_local); + vpn_addr4 = &vpn_ip4; + } + +struct in6_addr *vpn_addr6 =NULL ; +if (c->c2.push_ifconfig_ipv6_defined) + { + vpn_addr6 = &c->c2.push_ifconfig_ipv6_local; + } + +int ret =dco_update_peer_addr (&c->c1.tuntap->dco, peer_id, vpn_addr4, vpn_addr6, flags); +if (ret <0 ) + { +return ret; + } + +return 0 ; +} +void dco_install_iroute (struct multi_context *m,struct multi_instance *mi,struct mroute_addr *addr) {
@@ -723,7 +758,7 @@ }void -dco_delete_iroutes (struct multi_context *m,struct multi_instance *mi) +dco_delete_iroutes_v4 (struct multi_context *m,struct multi_instance *mi) {#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32)if (!dco_enabled (&m->top.options))
@@ -734,7 +769,7 @@struct context *c = &mi->context; -if (mi->context.c2.push_ifconfig_defined) +if (c->c2.push_ifconfig_defined) {for (const struct iroute *ir = c->options.iroutes; ir; ir = ir->next) {
@@ -742,7 +777,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -750,7 +785,7 @@#if !defined(_WIN32)/* Check if we added a host route as the assigned client IP address was * not in the on link scope defined by --ifconfig */ -in_addr_t ifconfig_local = mi->context.c2.push_ifconfig_local; +in_addr_t ifconfig_local = c->c2.push_ifconfig_local;if (multi_check_push_ifconfig_extra_route (mi,htonl (ifconfig_local))) {
@@ -761,8 +796,22 @@ }#endif } +#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */ +} -if (mi->context.c2.push_ifconfig_ipv6_defined) +void +dco_delete_iroutes_v6 (struct multi_context *m,struct multi_instance *mi) +{ +#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32) +if (!dco_enabled (&m->top.options)) + { +return ; + } +ASSERT (TUNNEL_TYPE (mi->context.c1.tuntap) ==DEV_TYPE_TUN ); + +struct context *c = &mi->context; + +if (c->c2.push_ifconfig_ipv6_defined) {for (const struct iroute_ipv6 *ir6 = c->options.iroutes_ipv6; ir6; ir6 = ir6->next) {
@@ -770,7 +819,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -778,7 +827,7 @@/* Checked if we added a host route as the assigned client IP address was * outside the --ifconfig-ipv6 tun interface config */ #if !defined(_WIN32) -struct in6_addr *dest = &mi->context.c2.push_ifconfig_ipv6_local; +struct in6_addr *dest = &c->c2.push_ifconfig_ipv6_local;if (multi_check_push_ifconfig_ipv6_extra_route (mi, dest)) {/* On windows we do not install these routes, so we also do not need to delete them */
src/openvpn/dco.h +40 -3
65 lines not on this page · raw message
src/openvpn/dco_freebsd.c +6 -0
@@ -559,6 +559,12 @@return ret; } +int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} +static void dco_update_peer_stat (struct multi_context *m,uint32_t peerid,const nvlist_t *nvl) {
src/openvpn/dco_linux.c +44 -0
50 lines not on this page · raw message
src/openvpn/dco_win.c +6 -0
@@ -526,6 +526,12 @@ }int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} + +int dco_new_key (dco_context_t *dco,unsigned int peerid,int keyid,dco_key_slot_t slot,const uint8_t *encrypt_key,const uint8_t *encrypt_iv,const uint8_t *decrypt_key,const uint8_t *decrypt_iv,const char *ciphername,bool epoch)
src/openvpn/multi.c +191 -87
345 lines not on this page · raw message
src/openvpn/multi.h +1 -3
@@ -714,8 +714,6 @@#endif void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6); -void unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi); -void unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi); +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6);#endif /* MULTI_H */
src/openvpn/push_util.c +32 -29
86 lines not on this page · raw message
tests/unit_tests/openvpn/test_push_update_msg.c +1 -13
@@ -31,19 +31,7 @@ }void -unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) {return ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88f37e47026a7d7ea0f7c6bde1d79d32c14e5297
Gerrit-Change-Number: 1450
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
to look at the new patch set (#4).
Change subject: PUSH_UPDATE: add DCO and iroutes support on server
......................................................................
PUSH_UPDATE: add DCO and iroutes support on server
Renamed update_vhash() to update_vaddr().
Moved the -ifconfig logic from send_single_push_update() to update_vaddr(). Changed canary logic to use the current value of ifconfig (if present) as canary. Added logic in the update_vaddr() to not unlearn and re-learn the same address.
Added logic to update the peer's virtual address(es) in the DCO to the current value(s) after sending a PUSH_UPDATE message on Linux.
Added dco_multi_update_peer_addr() and dco_update_peer_addr() to do so.
Added logic to update iroutes after changing the peer's virtual address(es). Divided dco_delete_iroutes() in _v4() and _v6() to better updating iroutes.
---
M src/openvpn/dco.c
M src/openvpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_linux.c
M src/openvpn/dco_win.c
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/push_util.c
M tests/unit_tests/openvpn/test_push_update_msg.c
9 files changed, 379 insertions(+), 142 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/1450/4
src/openvpn/dco.c +56 -7
@@ -658,6 +658,41 @@return 0 ; } +int +dco_multi_update_peer_addr (struct multi_context *m,struct multi_instance *mi,int flags) +{ +if (!flags) + { +return 0 ; + } + +struct context *c = &mi->context; +int peer_id = c->c2.tls_multi->dco_peer_id; + +/* In server mode we need to fetch the remote addresses from the push config */ +struct in_addr vpn_ip4 = {0 }; +struct in_addr *vpn_addr4 =NULL ; +if (c->c2.push_ifconfig_defined) + { + vpn_ip4.s_addr =htonl (c->c2.push_ifconfig_local); + vpn_addr4 = &vpn_ip4; + } + +struct in6_addr *vpn_addr6 =NULL ; +if (c->c2.push_ifconfig_ipv6_defined) + { + vpn_addr6 = &c->c2.push_ifconfig_ipv6_local; + } + +int ret =dco_update_peer_addr (&c->c1.tuntap->dco, peer_id, vpn_addr4, vpn_addr6, flags); +if (ret <0 ) + { +return ret; + } + +return 0 ; +} +void dco_install_iroute (struct multi_context *m,struct multi_instance *mi,struct mroute_addr *addr) {
@@ -723,7 +758,7 @@ }void -dco_delete_iroutes (struct multi_context *m,struct multi_instance *mi) +dco_delete_iroutes_v4 (struct multi_context *m,struct multi_instance *mi) {#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32)if (!dco_enabled (&m->top.options))
@@ -734,7 +769,7 @@struct context *c = &mi->context; -if (mi->context.c2.push_ifconfig_defined) +if (c->c2.push_ifconfig_defined) {for (const struct iroute *ir = c->options.iroutes; ir; ir = ir->next) {
@@ -742,7 +777,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -750,7 +785,7 @@#if !defined(_WIN32)/* Check if we added a host route as the assigned client IP address was * not in the on link scope defined by --ifconfig */ -in_addr_t ifconfig_local = mi->context.c2.push_ifconfig_local; +in_addr_t ifconfig_local = c->c2.push_ifconfig_local;if (multi_check_push_ifconfig_extra_route (mi,htonl (ifconfig_local))) {
@@ -761,8 +796,22 @@ }#endif } +#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */ +} -if (mi->context.c2.push_ifconfig_ipv6_defined) +void +dco_delete_iroutes_v6 (struct multi_context *m,struct multi_instance *mi) +{ +#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32) +if (!dco_enabled (&m->top.options)) + { +return ; + } +ASSERT (TUNNEL_TYPE (mi->context.c1.tuntap) ==DEV_TYPE_TUN ); + +struct context *c = &mi->context; + +if (c->c2.push_ifconfig_ipv6_defined) {for (const struct iroute_ipv6 *ir6 = c->options.iroutes_ipv6; ir6; ir6 = ir6->next) {
@@ -770,7 +819,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -778,7 +827,7 @@/* Checked if we added a host route as the assigned client IP address was * outside the --ifconfig-ipv6 tun interface config */ #if !defined(_WIN32) -struct in6_addr *dest = &mi->context.c2.push_ifconfig_ipv6_local; +struct in6_addr *dest = &c->c2.push_ifconfig_ipv6_local;if (multi_check_push_ifconfig_ipv6_extra_route (mi, dest)) {/* On windows we do not install these routes, so we also do not need to delete them */
src/openvpn/dco.h +40 -3
65 lines not on this page · raw message
src/openvpn/dco_freebsd.c +6 -0
@@ -559,6 +559,12 @@return ret; } +int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} +static void dco_update_peer_stat (struct multi_context *m,uint32_t peerid,const nvlist_t *nvl) {
src/openvpn/dco_linux.c +44 -0
50 lines not on this page · raw message
src/openvpn/dco_win.c +6 -0
@@ -526,6 +526,12 @@ }int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} + +int dco_new_key (dco_context_t *dco,unsigned int peerid,int keyid,dco_key_slot_t slot,const uint8_t *encrypt_key,const uint8_t *encrypt_iv,const uint8_t *decrypt_key,const uint8_t *decrypt_iv,const char *ciphername,bool epoch)
src/openvpn/multi.c +193 -87
347 lines not on this page · raw message
src/openvpn/multi.h +1 -3
@@ -714,8 +714,6 @@#endif void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6); -void unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi); -void unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi); +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6);#endif /* MULTI_H */
src/openvpn/push_util.c +32 -29
86 lines not on this page · raw message
tests/unit_tests/openvpn/test_push_update_msg.c +1 -13
@@ -31,19 +31,7 @@ }void -unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) {return ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88f37e47026a7d7ea0f7c6bde1d79d32c14e5297
Gerrit-Change-Number: 1450
Gerrit-PatchSet: 4
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
to look at the new patch set (#6).
Change subject: PUSH_UPDATE: add DCO and iroutes support on server
......................................................................
PUSH_UPDATE: add DCO and iroutes support on server
Renamed update_vhash() to update_vaddr().
Moved the -ifconfig logic from send_single_push_update() to update_vaddr(). Changed canary logic to use the current value of ifconfig (if present) as canary. Added logic in the update_vaddr() to not unlearn and re-learn the same address.
Added logic to update the peer's virtual address(es) in the DCO to the current value(s) after sending a PUSH_UPDATE message on Linux.
Added dco_multi_update_peer_addr() and dco_update_peer_addr() to do so.
Added logic to update iroutes after changing the peer's virtual address(es). Divided dco_delete_iroutes() in _v4() and _v6() to better updating iroutes.
---
M src/openvpn/dco.c
M src/openvpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_linux.c
M src/openvpn/dco_win.c
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/push_util.c
M tests/unit_tests/openvpn/test_push_update_msg.c
9 files changed, 379 insertions(+), 142 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/1450/6
src/openvpn/dco.c +56 -7
@@ -658,6 +658,41 @@return 0 ; } +int +dco_multi_update_peer_addr (struct multi_context *m,struct multi_instance *mi,int flags) +{ +if (!flags) + { +return 0 ; + } + +struct context *c = &mi->context; +int peer_id = c->c2.tls_multi->dco_peer_id; + +/* In server mode we need to fetch the remote addresses from the push config */ +struct in_addr vpn_ip4 = {0 }; +struct in_addr *vpn_addr4 =NULL ; +if (c->c2.push_ifconfig_defined) + { + vpn_ip4.s_addr =htonl (c->c2.push_ifconfig_local); + vpn_addr4 = &vpn_ip4; + } + +struct in6_addr *vpn_addr6 =NULL ; +if (c->c2.push_ifconfig_ipv6_defined) + { + vpn_addr6 = &c->c2.push_ifconfig_ipv6_local; + } + +int ret =dco_update_peer_addr (&c->c1.tuntap->dco, peer_id, vpn_addr4, vpn_addr6, flags); +if (ret <0 ) + { +return ret; + } + +return 0 ; +} +void dco_install_iroute (struct multi_context *m,struct multi_instance *mi,struct mroute_addr *addr) {
@@ -723,7 +758,7 @@ }void -dco_delete_iroutes (struct multi_context *m,struct multi_instance *mi) +dco_delete_iroutes_v4 (struct multi_context *m,struct multi_instance *mi) {#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32)if (!dco_enabled (&m->top.options))
@@ -734,7 +769,7 @@struct context *c = &mi->context; -if (mi->context.c2.push_ifconfig_defined) +if (c->c2.push_ifconfig_defined) {for (const struct iroute *ir = c->options.iroutes; ir; ir = ir->next) {
@@ -742,7 +777,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -750,7 +785,7 @@#if !defined(_WIN32)/* Check if we added a host route as the assigned client IP address was * not in the on link scope defined by --ifconfig */ -in_addr_t ifconfig_local = mi->context.c2.push_ifconfig_local; +in_addr_t ifconfig_local = c->c2.push_ifconfig_local;if (multi_check_push_ifconfig_extra_route (mi,htonl (ifconfig_local))) {
@@ -761,8 +796,22 @@ }#endif } +#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */ +} -if (mi->context.c2.push_ifconfig_ipv6_defined) +void +dco_delete_iroutes_v6 (struct multi_context *m,struct multi_instance *mi) +{ +#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32) +if (!dco_enabled (&m->top.options)) + { +return ; + } +ASSERT (TUNNEL_TYPE (mi->context.c1.tuntap) ==DEV_TYPE_TUN ); + +struct context *c = &mi->context; + +if (c->c2.push_ifconfig_ipv6_defined) {for (const struct iroute_ipv6 *ir6 = c->options.iroutes_ipv6; ir6; ir6 = ir6->next) {
@@ -770,7 +819,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -778,7 +827,7 @@/* Checked if we added a host route as the assigned client IP address was * outside the --ifconfig-ipv6 tun interface config */ #if !defined(_WIN32) -struct in6_addr *dest = &mi->context.c2.push_ifconfig_ipv6_local; +struct in6_addr *dest = &c->c2.push_ifconfig_ipv6_local;if (multi_check_push_ifconfig_ipv6_extra_route (mi, dest)) {/* On windows we do not install these routes, so we also do not need to delete them */
src/openvpn/dco.h +40 -3
65 lines not on this page · raw message
src/openvpn/dco_freebsd.c +6 -0
@@ -559,6 +559,12 @@return ret; } +int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} +#if defined(__GNUC__) || defined(__clang__)#pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wsign-compare"
src/openvpn/dco_linux.c +44 -0
50 lines not on this page · raw message
src/openvpn/dco_win.c +6 -0
@@ -526,6 +526,12 @@ }int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} + +int dco_new_key (dco_context_t *dco,unsigned int peerid,int keyid,dco_key_slot_t slot,const uint8_t *encrypt_key,const uint8_t *encrypt_iv,const uint8_t *decrypt_key,const uint8_t *decrypt_iv,const char *ciphername,bool epoch)
src/openvpn/multi.c +193 -87
347 lines not on this page · raw message
src/openvpn/multi.h +1 -3
@@ -723,8 +723,6 @@#endif void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6); -void unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi); -void unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi); +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6);#endif /* MULTI_H */
src/openvpn/push_util.c +32 -29
86 lines not on this page · raw message
tests/unit_tests/openvpn/test_push_update_msg.c +1 -13
@@ -31,19 +31,7 @@ }void -unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) {return ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88f37e47026a7d7ea0f7c6bde1d79d32c14e5297
Gerrit-Change-Number: 1450
Gerrit-PatchSet: 6
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
to look at the new patch set (#9).
Change subject: PUSH_UPDATE: add DCO and iroutes support on server
......................................................................
PUSH_UPDATE: add DCO and iroutes support on server
Renamed update_vhash() to update_vaddr().
Moved the -ifconfig logic from send_single_push_update() to update_vaddr(). Changed canary logic to use the current value of ifconfig (if present) as canary. Added logic in the update_vaddr() to not unlearn and re-learn the same address.
Added logic to update the peer's virtual address(es) in the DCO to the current value(s) after sending a PUSH_UPDATE message on Linux.
Added dco_multi_update_peer_addr() and dco_update_peer_addr() to do so.
Added logic to update iroutes after changing the peer's virtual address(es). Divided dco_delete_iroutes() in _v4() and _v6() to better updating iroutes.
---
M src/openvpn/dco.c
M src/openvpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_linux.c
M src/openvpn/dco_win.c
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/push_util.c
M tests/unit_tests/openvpn/test_push_update_msg.c
9 files changed, 379 insertions(+), 142 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/1450/9
src/openvpn/dco.c +56 -7
@@ -659,6 +659,41 @@return 0 ; } +int +dco_multi_update_peer_addr (struct multi_context *m,struct multi_instance *mi,int flags) +{ +if (!flags) + { +return 0 ; + } + +struct context *c = &mi->context; +int peer_id = c->c2.tls_multi->dco_peer_id; + +/* In server mode we need to fetch the remote addresses from the push config */ +struct in_addr vpn_ip4 = {0 }; +struct in_addr *vpn_addr4 =NULL ; +if (c->c2.push_ifconfig_defined) + { + vpn_ip4.s_addr =htonl (c->c2.push_ifconfig_local); + vpn_addr4 = &vpn_ip4; + } + +struct in6_addr *vpn_addr6 =NULL ; +if (c->c2.push_ifconfig_ipv6_defined) + { + vpn_addr6 = &c->c2.push_ifconfig_ipv6_local; + } + +int ret =dco_update_peer_addr (&c->c1.tuntap->dco, peer_id, vpn_addr4, vpn_addr6, flags); +if (ret <0 ) + { +return ret; + } + +return 0 ; +} +void dco_install_iroute (struct multi_context *m,struct multi_instance *mi,struct mroute_addr *addr) {
@@ -724,7 +759,7 @@ }void -dco_delete_iroutes (struct multi_context *m,struct multi_instance *mi) +dco_delete_iroutes_v4 (struct multi_context *m,struct multi_instance *mi) {#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32)if (!dco_enabled (&m->top.options))
@@ -735,7 +770,7 @@struct context *c = &mi->context; -if (mi->context.c2.push_ifconfig_defined) +if (c->c2.push_ifconfig_defined) {for (const struct iroute *ir = c->options.iroutes; ir; ir = ir->next) {
@@ -743,7 +778,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -751,7 +786,7 @@#if !defined(_WIN32)/* Check if we added a host route as the assigned client IP address was * not in the on link scope defined by --ifconfig */ -in_addr_t ifconfig_local = mi->context.c2.push_ifconfig_local; +in_addr_t ifconfig_local = c->c2.push_ifconfig_local;if (multi_check_push_ifconfig_extra_route (mi,htonl (ifconfig_local))) {
@@ -762,8 +797,22 @@ }#endif } +#endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */ +} -if (mi->context.c2.push_ifconfig_ipv6_defined) +void +dco_delete_iroutes_v6 (struct multi_context *m,struct multi_instance *mi) +{ +#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD ) || defined(_WIN32) +if (!dco_enabled (&m->top.options)) + { +return ; + } +ASSERT (TUNNEL_TYPE (mi->context.c1.tuntap) ==DEV_TYPE_TUN ); + +struct context *c = &mi->context; + +if (c->c2.push_ifconfig_ipv6_defined) {for (const struct iroute_ipv6 *ir6 = c->options.iroutes_ipv6; ir6; ir6 = ir6->next) {
@@ -771,7 +820,7 @@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, c->c1.tuntap->actual_name,0 , + &c->c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name,0 ,DCO_IROUTE_METRIC );#endif }
@@ -779,7 +828,7 @@/* Checked if we added a host route as the assigned client IP address was * outside the --ifconfig-ipv6 tun interface config */ #if !defined(_WIN32) -struct in6_addr *dest = &mi->context.c2.push_ifconfig_ipv6_local; +struct in6_addr *dest = &c->c2.push_ifconfig_ipv6_local;if (multi_check_push_ifconfig_ipv6_extra_route (mi, dest)) {/* On windows we do not install these routes, so we also do not need to delete them */
src/openvpn/dco.h +40 -3
65 lines not on this page · raw message
src/openvpn/dco_freebsd.c +6 -0
@@ -559,6 +559,12 @@return ret; } +int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} +static void dco_update_peer_stat (struct multi_context *m,uint32_t peerid,const nvlist_t *nvl) {
src/openvpn/dco_linux.c +44 -0
50 lines not on this page · raw message
src/openvpn/dco_win.c +6 -0
@@ -526,6 +526,12 @@ }int +dco_update_peer_addr (dco_context_t *dco,unsigned int peerid,struct in_addr *vpn_ipv4,struct in6_addr *vpn_ipv6,int flags) +{ +return 0 ; +} + +int dco_new_key (dco_context_t *dco,unsigned int peerid,int keyid,dco_key_slot_t slot,const uint8_t *encrypt_key,const uint8_t *encrypt_iv,const uint8_t *decrypt_key,const uint8_t *decrypt_iv,const char *ciphername,bool epoch)
src/openvpn/multi.c +193 -87
347 lines not on this page · raw message
src/openvpn/multi.h +1 -3
@@ -722,8 +722,6 @@#endif void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6); -void unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi); -void unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi); +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6);#endif /* MULTI_H */
src/openvpn/push_util.c +32 -29
86 lines not on this page · raw message
tests/unit_tests/openvpn/test_push_update_msg.c +1 -13
@@ -31,19 +31,7 @@ }void -unlearn_ifconfig (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -unlearn_ifconfig_ipv6 (struct multi_context *m,struct multi_instance *mi) -{ -return ; -} - -void -update_vhash (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) +update_vaddr (struct multi_context *m,struct multi_instance *mi,const char *new_ip,const char *new_ipv6) {return ; }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1450?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88f37e47026a7d7ea0f7c6bde1d79d32c14e5297
Gerrit-Change-Number: 1450
Gerrit-PatchSet: 9
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>