Changeset 75121 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Oct 27, 2018 2:27:30 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126196
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp
r74484 r75121 1389 1389 } 1390 1390 1391 /** 1392 * Worker for vboxNetLwfWinNBtoSG() that gets the max segment count needed. 1393 * @note vboxNetLwfWinNBtoSG may use fewer depending on cbPacket and offset! 1394 */ 1391 1395 DECLINLINE(ULONG) vboxNetLwfWinCalcSegments(PNET_BUFFER pNetBuf) 1392 1396 { … … 1598 1602 { 1599 1603 ULONG cbPacket = NET_BUFFER_DATA_LENGTH(pNetBuf); 1600 U INTcSegs = vboxNetLwfWinCalcSegments(pNetBuf);1604 ULONG cSegs = vboxNetLwfWinCalcSegments(pNetBuf); 1601 1605 /* Allocate and initialize SG */ 1602 1606 PINTNETSG pSG = (PINTNETSG)NdisAllocateMemoryWithTagPriority(pModule->hFilter, … … 1608 1612 IntNetSgInitTempSegs(pSG, cbPacket /*cbTotal*/, cSegs, cSegs /*cSegsUsed*/); 1609 1613 1610 int rc = NDIS_STATUS_SUCCESS;1611 1614 ULONG uOffset = NET_BUFFER_CURRENT_MDL_OFFSET(pNetBuf); 1612 1615 cSegs = 0; … … 1615 1618 pMdl = NDIS_MDL_LINKAGE(pMdl)) 1616 1619 { 1617 PUCHAR pSrc = (PUCHAR)MmGetSystemAddressForMdlSafe(pMdl, LowPagePriority);1618 if (!pSrc)1619 {1620 rc = NDIS_STATUS_RESOURCES;1621 break;1622 }1623 1620 ULONG cbSrc = MmGetMdlByteCount(pMdl); 1624 1621 if (cbSrc == 0) 1625 1622 continue; /* Skip empty MDLs (see @bugref{9233}) */ 1626 1623 1627 if (uOffset) 1628 { 1629 Assert(uOffset < cbSrc); 1630 pSrc += uOffset; 1631 cbSrc -= uOffset; 1632 uOffset = 0; 1624 PUCHAR pSrc = (PUCHAR)MmGetSystemAddressForMdlSafe(pMdl, LowPagePriority); 1625 if (!pSrc) 1626 { 1627 vboxNetLwfWinDestroySG(pSG); 1628 return NULL; 1633 1629 } 1634 1630 … … 1636 1632 cbSrc = cbPacket; 1637 1633 1634 if (uOffset) 1635 { 1636 if (uOffset < cbSrc) 1637 { 1638 pSrc += uOffset; 1639 cbSrc -= uOffset; 1640 uOffset = 0; 1641 } 1642 else 1643 { 1644 uOffset -= cbSrc; 1645 continue; 1646 } 1647 } 1648 1649 Assert(cSegs < pSG->cSegsAlloc); 1638 1650 pSG->aSegs[cSegs].pv = pSrc; 1639 1651 pSG->aSegs[cSegs].cb = cbSrc; … … 1643 1655 } 1644 1656 1645 Assert(cSegs <= pSG->cSegsAlloc); 1646 1647 if (RT_FAILURE(rc)) 1648 { 1649 vboxNetLwfWinDestroySG(pSG); 1650 pSG = NULL; 1651 } 1652 else 1653 { 1654 Assert(cbPacket == 0); 1655 Assert(pSG->cSegsUsed == cSegs); 1656 } 1657 Assert(cbPacket == 0); 1658 Assert(cSegs <= pSG->cSegsUsed); 1659 1660 /* Update actual segment count in case we used fewer than anticipated. */ 1661 pSG->cSegsUsed = (uint16_t)cSegs; 1662 1657 1663 return pSG; 1658 1664 }
Note:
See TracChangeset
for help on using the changeset viewer.