Skip to content

Commit

Permalink
Add resource-dropped packets to drop count
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Sep 26, 2023
1 parent dfd3215 commit 47e6b81
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packetWin7/npf/npf/Read.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ NPF_DoTap(
/* If we got this far, there is at least 1 instance at OpenRunning,
* so gather metadata before locking the list. */
ULONG resdropped = NPF_GetMetadata(NetBufferLists, &NBLCopiesHead, pFiltMod, SystemTime, PerfCount);
BOOLEAN firstpass = TRUE;
/* Lock the filter programs */
// Read-only lock since list is not being modified.
NdisAcquireRWLockRead(pFiltMod->BpfProgramsLock, &lockState,
Expand All @@ -730,6 +731,12 @@ NPF_DoTap(
{
continue;
}
if (firstpass)
{
// Account for packets lost due to inadequate resources earlier
NpfInterlockedExchangeAdd(&(LONG)pOpen->ResourceDropped, resdropped);
}

ULONG TotalPacketSize = pSrcNB->pNBCopy->ulPacketSize;
PMDL pSrcCurrMdl = NET_BUFFER_CURRENT_MDL(pSrcNB->pNetBuffer);
ULONG ulCurrMdlOffset = NET_BUFFER_CURRENT_MDL_OFFSET(pSrcNB->pNetBuffer);
Expand Down Expand Up @@ -774,6 +781,7 @@ NPF_DoTap(
}
// Copy maxFres of data from the packet
pSrcNB->ulDesired = maxFres;
firstpass = FALSE;
}
}
/* Release the spin lock no matter what. */
Expand Down

0 comments on commit 47e6b81

Please sign in to comment.