mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 12:12:15 +02:00
Added TunIO callback tun_error_handler() to inform parent
of errors. Use this callback to detect STATUS_CANCELLED returns from Windows TAP driver which translates to ERROR_OPERATION_ABORTED 995 (0x3E3) from userspace. This will trigger a fatal error in the client Error::TUN_IFACE_DISABLED ("TAP adapter is disabled").
This commit is contained in:
parent
aa92a7a522
commit
282556997c
@ -334,6 +334,14 @@ namespace openvpn {
|
||||
stop();
|
||||
}
|
||||
break;
|
||||
case Error::TUN_IFACE_DISABLED:
|
||||
{
|
||||
ClientEvent::Base::Ptr ev = new ClientEvent::TunIfaceDisabled(client->fatal_reason());
|
||||
client_options->events().add_event(ev);
|
||||
client_options->stats().error(Error::TUN_IFACE_DISABLED);
|
||||
stop();
|
||||
}
|
||||
break;
|
||||
case Error::PROXY_ERROR:
|
||||
{
|
||||
ClientEvent::Base::Ptr ev = new ClientEvent::ProxyError(client->fatal_reason());
|
||||
|
@ -49,6 +49,7 @@ namespace openvpn {
|
||||
PROXY_ERROR,
|
||||
TUN_SETUP_FAILED,
|
||||
TUN_IFACE_CREATE,
|
||||
TUN_IFACE_DISABLED,
|
||||
EPKI_ERROR, // EPKI refers to External PKI errors, i.e. errors in accessing external
|
||||
EPKI_INVALID_ALIAS, // certificates or keys.
|
||||
|
||||
@ -86,6 +87,7 @@ namespace openvpn {
|
||||
"PROXY_ERROR",
|
||||
"TUN_SETUP_FAILED",
|
||||
"TUN_IFACE_CREATE",
|
||||
"TUN_IFACE_DISABLED",
|
||||
"EPKI_ERROR",
|
||||
"EPKI_INVALID_ALIAS",
|
||||
};
|
||||
@ -294,6 +296,11 @@ namespace openvpn {
|
||||
TunIfaceCreate(const std::string& reason) : ReasonBase(TUN_IFACE_CREATE, reason) {}
|
||||
};
|
||||
|
||||
struct TunIfaceDisabled : public ReasonBase
|
||||
{
|
||||
TunIfaceDisabled(const std::string& reason) : ReasonBase(TUN_IFACE_DISABLED, reason) {}
|
||||
};
|
||||
|
||||
struct EpkiError : public ReasonBase
|
||||
{
|
||||
EpkiError(const std::string& reason) : ReasonBase(EPKI_ERROR, reason) {}
|
||||
|
@ -32,6 +32,7 @@ namespace openvpn {
|
||||
TUN_FRAMING_ERROR, // error with tun PF_INET/PF_INET6 prefix
|
||||
TUN_SETUP_FAILED, // error setting up tun/tap interface
|
||||
TUN_IFACE_CREATE, // error creating tun/tap interface
|
||||
TUN_IFACE_DISABLED, // tun/tap interface is disabled
|
||||
TAP_NOT_SUPPORTED, // dev tap is present in profile but not supported
|
||||
REROUTE_GW_NO_DNS, // redirect-gateway specified without alt DNS servers
|
||||
TCP_OVERFLOW, // TCP output queue overflow
|
||||
@ -99,6 +100,7 @@ namespace openvpn {
|
||||
"TUN_FRAMING_ERROR",
|
||||
"TUN_SETUP_FAILED",
|
||||
"TUN_IFACE_CREATE",
|
||||
"TUN_IFACE_DISABLED",
|
||||
"TAP_NOT_SUPPORTED",
|
||||
"REROUTE_GW_NO_DNS",
|
||||
"TCP_OVERFLOW",
|
||||
|
@ -235,6 +235,11 @@ namespace openvpn {
|
||||
parent.tun_recv(pfp->buf);
|
||||
}
|
||||
|
||||
void tun_error_handler(const Error::Type errtype, // called by TunImpl
|
||||
const boost::system::error_code* error)
|
||||
{
|
||||
}
|
||||
|
||||
void stop_()
|
||||
{
|
||||
if (!halt)
|
||||
|
@ -139,6 +139,11 @@ namespace openvpn {
|
||||
parent.tun_recv(pfp->buf);
|
||||
}
|
||||
|
||||
void tun_error_handler(const Error::Type errtype, // called by TunImpl
|
||||
const boost::system::error_code* error)
|
||||
{
|
||||
}
|
||||
|
||||
void stop_()
|
||||
{
|
||||
if (!halt)
|
||||
|
@ -133,6 +133,11 @@ namespace openvpn {
|
||||
parent.tun_recv(pfp->buf);
|
||||
}
|
||||
|
||||
void tun_error_handler(const Error::Type errtype, // called by TunImpl
|
||||
const boost::system::error_code* error)
|
||||
{
|
||||
}
|
||||
|
||||
void stop_()
|
||||
{
|
||||
if (!halt)
|
||||
|
@ -68,14 +68,14 @@ namespace openvpn {
|
||||
break;
|
||||
default:
|
||||
OPENVPN_LOG_TUN_ERROR("TUN write error: cannot identify IP version for prefix");
|
||||
stats->error(Error::TUN_FRAMING_ERROR);
|
||||
tun_error(Error::TUN_FRAMING_ERROR, NULL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OPENVPN_LOG_TUN_ERROR("TUN write error: cannot write prefix");
|
||||
stats->error(Error::TUN_FRAMING_ERROR);
|
||||
tun_error(Error::TUN_FRAMING_ERROR, NULL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -89,14 +89,14 @@ namespace openvpn {
|
||||
else
|
||||
{
|
||||
OPENVPN_LOG_TUN_ERROR("TUN partial write error");
|
||||
stats->error(Error::TUN_WRITE_ERROR);
|
||||
tun_error(Error::TUN_WRITE_ERROR, NULL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (boost::system::system_error& e)
|
||||
{
|
||||
OPENVPN_LOG_TUN_ERROR("TUN write error: " << e.what());
|
||||
stats->error(Error::TUN_WRITE_ERROR);
|
||||
tun_error(Error::TUN_WRITE_ERROR, &e.code());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -182,18 +182,25 @@ namespace openvpn {
|
||||
else
|
||||
{
|
||||
OPENVPN_LOG_TUN_ERROR("TUN Read Error: cannot read prefix");
|
||||
stats->error(Error::TUN_READ_ERROR);
|
||||
tun_error(Error::TUN_READ_ERROR, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OPENVPN_LOG_TUN_ERROR("TUN Read Error: " << error.message());
|
||||
stats->error(Error::TUN_READ_ERROR);
|
||||
tun_error(Error::TUN_READ_ERROR, &error);
|
||||
}
|
||||
queue_read(pfp.release()); // reuse buffer if still available
|
||||
if (!halt)
|
||||
queue_read(pfp.release()); // reuse buffer if still available
|
||||
}
|
||||
}
|
||||
|
||||
void tun_error(const Error::Type errtype, const boost::system::error_code* error)
|
||||
{
|
||||
stats->error(errtype);
|
||||
read_handler->tun_error_handler(errtype, error);
|
||||
}
|
||||
|
||||
// should be set by derived class constructor
|
||||
std::string name_;
|
||||
STREAM *stream;
|
||||
|
@ -495,6 +495,13 @@ namespace openvpn {
|
||||
#endif
|
||||
}
|
||||
|
||||
void tun_error_handler(const Error::Type errtype, // called by TunImpl
|
||||
const boost::system::error_code* error)
|
||||
{
|
||||
if (errtype == Error::TUN_READ_ERROR && error && error->value() == 995)
|
||||
parent.tun_error(Error::TUN_IFACE_DISABLED, "TAP adapter is disabled");
|
||||
}
|
||||
|
||||
void stop_()
|
||||
{
|
||||
if (!halt)
|
||||
|
Loading…
Reference in New Issue
Block a user