- Timestamp:
- Oct 27, 2018 5:53:48 PM (6 years ago)
- Location:
- trunk/src/VBox/HostDrivers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetAdp/win/VBoxNetAdp-win.cpp
r73097 r75122 476 476 } 477 477 478 /** 479 * Worker for vboxNetAdpWinNBtoSG() that gets the max segment count needed. 480 * @note vboxNetAdpWinNBtoSG may use fewer depending on cbPacket and offset! 481 * @note vboxNetLwfWinCalcSegments() is a copy of this code. 482 */ 478 483 DECLINLINE(ULONG) vboxNetAdpWinCalcSegments(PNET_BUFFER pNetBuf) 479 484 { 480 485 ULONG cSegs = 0; 481 486 for (PMDL pMdl = NET_BUFFER_CURRENT_MDL(pNetBuf); pMdl; pMdl = NDIS_MDL_LINKAGE(pMdl)) 482 cSegs++; 487 { 488 /* Skip empty MDLs (see @bugref{9233}) */ 489 if (MmGetMdlByteCount(pMdl)) 490 cSegs++; 491 } 483 492 return cSegs; 484 493 } 485 494 495 /** 496 * @note vboxNetLwfWinNBtoSG() is a copy of this code. 497 */ 486 498 DECLHIDDEN(PINTNETSG) vboxNetAdpWinNBtoSG(PVBOXNETADP_ADAPTER pThis, PNET_BUFFER pNetBuf) 487 499 { 488 500 ULONG cbPacket = NET_BUFFER_DATA_LENGTH(pNetBuf); 489 U INTcSegs = vboxNetAdpWinCalcSegments(pNetBuf);501 ULONG cSegs = vboxNetAdpWinCalcSegments(pNetBuf); 490 502 /* Allocate and initialize SG */ 491 503 PINTNETSG pSG = (PINTNETSG)NdisAllocateMemoryWithTagPriority(pThis->hAdapter, … … 497 509 IntNetSgInitTempSegs(pSG, cbPacket /*cbTotal*/, cSegs, cSegs /*cSegsUsed*/); 498 510 499 int rc = NDIS_STATUS_SUCCESS;500 511 ULONG uOffset = NET_BUFFER_CURRENT_MDL_OFFSET(pNetBuf); 501 512 cSegs = 0; … … 504 515 pMdl = NDIS_MDL_LINKAGE(pMdl)) 505 516 { 517 ULONG cbSrc = MmGetMdlByteCount(pMdl); 518 if (cbSrc == 0) 519 continue; /* Skip empty MDLs (see @bugref{9233}) */ 520 506 521 PUCHAR pSrc = (PUCHAR)MmGetSystemAddressForMdlSafe(pMdl, LowPagePriority); 507 522 if (!pSrc) 508 523 { 509 rc = NDIS_STATUS_RESOURCES; 510 break; 511 } 512 ULONG cbSrc = MmGetMdlByteCount(pMdl); 513 if (uOffset) 514 { 515 Assert(uOffset < cbSrc); 516 pSrc += uOffset; 517 cbSrc -= uOffset; 518 uOffset = 0; 524 vboxNetAdpWinDestroySG(pSG); 525 return NULL; 519 526 } 520 527 … … 522 529 cbSrc = cbPacket; 523 530 531 if (uOffset) 532 { 533 if (uOffset < cbSrc) 534 { 535 pSrc += uOffset; 536 cbSrc -= uOffset; 537 uOffset = 0; 538 } 539 else 540 { 541 uOffset -= cbSrc; 542 continue; 543 } 544 } 545 546 Assert(cSegs < pSG->cSegsAlloc); 524 547 pSG->aSegs[cSegs].pv = pSrc; 525 548 pSG->aSegs[cSegs].cb = cbSrc; … … 529 552 } 530 553 531 Assert(cSegs <= pSG->cSegsAlloc); 532 533 if (RT_FAILURE(rc)) 534 { 535 vboxNetAdpWinDestroySG(pSG); 536 pSG = NULL; 537 } 538 else 539 { 540 Assert(cbPacket == 0); 541 Assert(pSG->cSegsUsed == cSegs); 542 } 554 Assert(cbPacket == 0); 555 Assert(cSegs <= pSG->cSegsUsed); 556 557 /* Update actual segment count in case we used fewer than anticipated. */ 558 pSG->cSegsUsed = (uint16_t)cSegs; 559 543 560 return pSG; 544 561 } -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp
r75121 r75122 1391 1391 /** 1392 1392 * Worker for vboxNetLwfWinNBtoSG() that gets the max segment count needed. 1393 * @note vboxNetLwfWinNBtoSG may use fewer depending on cbPacket and offset! 1393 * @note vboxNetLwfWinNBtoSG may use fewer depending on cbPacket and offset! 1394 * @note vboxNetAdpWinCalcSegments() is a copy of this code. 1394 1395 */ 1395 1396 DECLINLINE(ULONG) vboxNetLwfWinCalcSegments(PNET_BUFFER pNetBuf) … … 1599 1600 } 1600 1601 1602 /** 1603 * @note vboxNetAdpWinNBtoSG() is a copy of this code. 1604 */ 1601 1605 static PINTNETSG vboxNetLwfWinNBtoSG(PVBOXNETLWF_MODULE pModule, PNET_BUFFER pNetBuf) 1602 1606 {
Note:
See TracChangeset
for help on using the changeset viewer.