Skip to content

Commit 777cdf3

Browse files
authored
Fix FNMP multi-NB filtering logic and test case (#17)
* add support for multiple NBs per NBL on TX filtering path * fix whitespace * fix tests on 2019 * fix previous fix * fix filtering and test case
1 parent 6005fa7 commit 777cdf3

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/sys/fnio/filter.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,26 @@ FnIoGetFilteredFrame(
176176
}
177177

178178
NetBuffer = NET_BUFFER_LIST_FIRST_NB(Nbl);
179+
ASSERT(NetBuffer != NULL);
179180

180-
for (UINT32 NbIndex = 0; NbIndex < SubIndex; NbIndex++) {
181-
if (NetBuffer == NULL) {
182-
Status = STATUS_NOT_FOUND;
183-
goto Exit;
184-
}
185-
181+
do {
186182
//
187183
// Only count NBs that match the filter.
188184
//
189-
if (!FnIoFilterNb(Filter, NetBuffer)) {
190-
NbIndex--;
185+
if (FnIoFilterNb(Filter, NetBuffer)) {
186+
if (SubIndex == 0) {
187+
break;
188+
} else {
189+
SubIndex--;
190+
}
191191
}
192192

193193
NetBuffer = NetBuffer->Next;
194-
}
194+
if (NetBuffer == NULL) {
195+
Status = STATUS_NOT_FOUND;
196+
goto Exit;
197+
}
198+
} while (TRUE);
195199

196200
BufferCount = 0;
197201
OutputSize = sizeof(*Frame);

test/functional/tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,13 @@ BasicTx()
639639
BOOLEAN Uso = TRUE;
640640

641641
UCHAR UdpPayload[] = "BasicTx0BasicTx1";
642-
UCHAR Pattern[UDP_HEADER_BACKFILL(AF_INET) + (sizeof(UdpPayload) - 1) / 2];
642+
UCHAR Pattern[UDP_HEADER_BACKFILL(AF_INET) + sizeof(UdpPayload) / 2 - 1];
643643
UCHAR Mask[sizeof(Pattern)];
644644
UINT32 ExpectedUdpPayloadSize = sizeof(UdpPayload) / 2;
645645
UINT32 SendSize = sizeof(UdpPayload);
646646

647647
RtlZeroMemory(Pattern, sizeof(Pattern));
648-
RtlCopyMemory(Pattern + UDP_HEADER_BACKFILL(AF_INET), UdpPayload, (sizeof(UdpPayload) - 1) / 2);
648+
RtlCopyMemory(Pattern + UDP_HEADER_BACKFILL(AF_INET), UdpPayload, sizeof(UdpPayload) / 2 - 1);
649649

650650
RtlZeroMemory(Mask, sizeof(Mask));
651651
for (int i = UDP_HEADER_BACKFILL(AF_INET); i < sizeof(Mask); i++) {

0 commit comments

Comments
 (0)