Skip to content

Commit

Permalink
Set adapter state to "disconnected" on file close even if peer is rem…
Browse files Browse the repository at this point in the history
…oved

After peer is removed we don't immediately set adapter state
to "disconnected" in order to support persist tun. We are supposed to
do it after the last handle to the device is closed. Due to bug in code,
in file close callback we just exit if peer deletion failed
(even though it is normal il peer was explicitly deleted by client)
and skipped changing adapter state.

Instead of exiting, ignore peer removal result (it is logged already)
and proceed to changing adapter state.

Signed-off-by: Lev Stipakov <[email protected]>
  • Loading branch information
lstipakov committed Sep 29, 2022
1 parent 8711042 commit 1679f79
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,11 @@ _Use_decl_annotations_
VOID OvpnEvtFileCleanup(WDFFILEOBJECT fileObject) {
POVPN_DEVICE device = OvpnGetDeviceContext(WdfFileObjectGetDevice(fileObject));

NTSTATUS status = OvpnPeerDel(device);
if (!NT_SUCCESS(status))
return;

LOG_INFO("Uninitializing device");

// peer might already be deleted
(VOID)OvpnPeerDel(device);

InterlockedExchange(&device->UserspacePid, 0);

OvpnAdapterSetLinkState(OvpnGetAdapterContext(device->Adapter), MediaConnectStateDisconnected);
Expand Down

0 comments on commit 1679f79

Please sign in to comment.