VirtualBox

Changeset 75122 in vbox for trunk


Ignore:
Timestamp:
Oct 27, 2018 5:53:48 PM (6 years ago)
Author:
vboxsync
Message:

VBoxNetAdp: Same fixes for bugref:9233 ticketref:18046 as was applied to VBoxNetLwf.

Location:
trunk/src/VBox/HostDrivers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/win/VBoxNetAdp-win.cpp

    r73097 r75122  
    476476}
    477477
     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 */
    478483DECLINLINE(ULONG) vboxNetAdpWinCalcSegments(PNET_BUFFER pNetBuf)
    479484{
    480485    ULONG cSegs = 0;
    481486    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    }
    483492    return cSegs;
    484493}
    485494
     495/**
     496 * @note vboxNetLwfWinNBtoSG() is a copy of this code.
     497 */
    486498DECLHIDDEN(PINTNETSG) vboxNetAdpWinNBtoSG(PVBOXNETADP_ADAPTER pThis, PNET_BUFFER pNetBuf)
    487499{
    488500    ULONG cbPacket = NET_BUFFER_DATA_LENGTH(pNetBuf);
    489     UINT cSegs = vboxNetAdpWinCalcSegments(pNetBuf);
     501    ULONG cSegs = vboxNetAdpWinCalcSegments(pNetBuf);
    490502    /* Allocate and initialize SG */
    491503    PINTNETSG pSG = (PINTNETSG)NdisAllocateMemoryWithTagPriority(pThis->hAdapter,
     
    497509    IntNetSgInitTempSegs(pSG, cbPacket /*cbTotal*/, cSegs, cSegs /*cSegsUsed*/);
    498510
    499     int rc = NDIS_STATUS_SUCCESS;
    500511    ULONG uOffset = NET_BUFFER_CURRENT_MDL_OFFSET(pNetBuf);
    501512    cSegs = 0;
     
    504515         pMdl = NDIS_MDL_LINKAGE(pMdl))
    505516    {
     517        ULONG cbSrc = MmGetMdlByteCount(pMdl);
     518        if (cbSrc == 0)
     519            continue; /* Skip empty MDLs (see @bugref{9233}) */
     520
    506521        PUCHAR pSrc = (PUCHAR)MmGetSystemAddressForMdlSafe(pMdl, LowPagePriority);
    507522        if (!pSrc)
    508523        {
    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;
    519526        }
    520527
     
    522529            cbSrc = cbPacket;
    523530
     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);
    524547        pSG->aSegs[cSegs].pv = pSrc;
    525548        pSG->aSegs[cSegs].cb = cbSrc;
     
    529552    }
    530553
    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
    543560    return pSG;
    544561}
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp

    r75121 r75122  
    13911391/**
    13921392 * 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.
    13941395 */
    13951396DECLINLINE(ULONG) vboxNetLwfWinCalcSegments(PNET_BUFFER pNetBuf)
     
    15991600}
    16001601
     1602/**
     1603 * @note vboxNetAdpWinNBtoSG() is a copy of this code.
     1604 */
    16011605static PINTNETSG vboxNetLwfWinNBtoSG(PVBOXNETLWF_MODULE pModule, PNET_BUFFER pNetBuf)
    16021606{
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette