VirtualBox

Ignore:
Timestamp:
Aug 22, 2017 10:16:26 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117655
Message:

NetLwf/Win: (bugref:8976) Align outgoing packets at word boundary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp

    r68112 r68500  
    13961396        return NULL;
    13971397    }
     1398    const ULONG cbAlignmentMask = sizeof(USHORT) - 1; /* Microsoft LB/FO provider expects packets to be aligned at word boundary. */
     1399    ULONG cbAlignedFrame = (pSG->cbTotal + cbAlignmentMask) & ~cbAlignmentMask;
     1400    Assert(cbAlignedFrame >= pSG->cbTotal);
     1401    Assert(cbFrame >= cbAlignedFrame);
    13981402    NET_BUFFER *pBuffer = NET_BUFFER_LIST_FIRST_NB(pBufList);
    1399     NDIS_STATUS Status = NdisRetreatNetBufferDataStart(pBuffer, pSG->cbTotal, 0 /** @todo DataBackfill */, NULL);
     1403    NDIS_STATUS Status = NdisRetreatNetBufferDataStart(pBuffer, cbAlignedFrame, 0 /** @todo DataBackfill */, NULL);
    14001404    if (Status == NDIS_STATUS_SUCCESS)
    14011405    {
     
    14081412                pDst += pSG->aSegs[i].cb;
    14091413            }
     1414            if (cbAlignedFrame > pSG->cbTotal)
     1415            {
     1416                Log4(("vboxNetLwfWinSGtoNB: padding %d-byte packet with %d zero bytes", pSG->cbTotal, cbAlignedFrame - pSG->cbTotal));
     1417                NdisZeroMemory(pDst, cbAlignedFrame - pSG->cbTotal);
     1418            }
    14101419            Log4(("vboxNetLwfWinSGtoNB: allocated NBL+NB 0x%p\n", pBufList));
    14111420            pBufList->SourceHandle = pModule->hFilter;
     
    14141423        {
    14151424            LogError(("vboxNetLwfWinSGtoNB: failed to obtain the buffer pointer (size=%u)\n", pSG->cbTotal));
    1416             NdisAdvanceNetBufferDataStart(pBuffer, pSG->cbTotal, false, NULL); /** @todo why bother? */
     1425            NdisAdvanceNetBufferDataStart(pBuffer, cbAlignedFrame, false, NULL); /** @todo why bother? */
    14171426            NdisFreeNetBufferList(pBufList);
    14181427            pBufList = NULL;
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