0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00

dco-win: reorder ioctl calls

Set keepalive parameters and start vpn on "tun start" event,
which seems like a more logical place comparison to "primary key ready" event.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
This commit is contained in:
Lev Stipakov 2022-04-29 14:44:28 +03:00
parent ac15879588
commit 2b7f97c78b

View File

@ -77,6 +77,9 @@ public:
dc_settings.set_factory(CryptoDCFactory::Ptr(new KoRekey::Factory(
dc_settings.factory(), this, config->transport.frame)));
set_keepalive_();
start_vpn_();
tun_parent->tun_connected();
}
@ -97,9 +100,7 @@ public:
switch (rktype) {
case CryptoDCInstance::ACTIVATE_PRIMARY:
add_keepalive_();
add_crypto_(rktype, key());
start_vpn_();
break;
case CryptoDCInstance::NEW_SECONDARY:
@ -276,7 +277,7 @@ protected:
}
}
void add_keepalive_() {
void set_keepalive_() {
if (!transport_parent->is_keepalive_enabled())
return;
@ -285,17 +286,13 @@ protected:
// since userspace doesn't know anything about presense or
// absense of data channel traffic, ping should be handled in kernel
transport_parent->disable_keepalive(keepalive_interval,
keepalive_timeout);
transport_parent->disable_keepalive(keepalive_interval, keepalive_timeout);
if (config->ping_restart_override)
keepalive_timeout = config->ping_restart_override;
// enable keepalive in kernel
OVPN_SET_PEER peer = {};
peer.KeepaliveInterval = static_cast<LONG>(keepalive_interval);
peer.KeepaliveTimeout = static_cast<LONG>(keepalive_timeout);
OVPN_SET_PEER peer{static_cast<LONG>(keepalive_interval), static_cast<LONG>(keepalive_timeout), -1};
dco_ioctl_(OVPN_IOCTL_SET_PEER, &peer, sizeof(peer));
}