Skip to content

Commit

Permalink
Better error handling in TCP connect
Browse files Browse the repository at this point in the history
In some cases TCP connect may fail withing OvpnSocketTcpConnect(),
before we queued IO request. This means that we don't have a way to
notify userspace about failure and client should rely on client-side TCP connection
timeout, which could be quite long.

Fix by enqueueing IO request before initiating TCP connect and
if connect fails, userspace got notified immediately.

Signed-off-by: Lev Stipakov <[email protected]>
  • Loading branch information
lstipakov committed Jun 16, 2022
1 parent 63e7d51 commit 677d217
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 0 additions & 3 deletions Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ OvpnEvtIoDeviceControl(WDFQUEUE queue, WDFREQUEST request, size_t outputBufferLe

case OVPN_IOCTL_NEW_PEER:
status = OvpnPeerNew(device, request);
if (status == STATUS_PENDING) {
LOG_IF_NOT_NT_SUCCESS(WdfRequestForwardToIoQueue(request, device->PendingNewPeerQueue));
}
break;

case OVPN_IOCTL_START_VPN:
Expand Down
1 change: 1 addition & 0 deletions peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ OvpnPeerNew(POVPN_DEVICE device, WDFREQUEST request)
OvpnPeerZeroStats(&device->Stats);

if (proto_tcp) {
LOG_IF_NOT_NT_SUCCESS(status = WdfRequestForwardToIoQueue(request, device->PendingNewPeerQueue));
// start async connect
status = OvpnSocketTcpConnect(socket, device, (PSOCKADDR)&peer->Remote);
}
Expand Down

0 comments on commit 677d217

Please sign in to comment.