VirtualBox

Ignore:
Timestamp:
Apr 7, 2010 6:37:43 AM (15 years ago)
Author:
vboxsync
Message:

intnet, VBoxNet*, network device & drivers: GSO preps.

Location:
trunk/src/VBox/NetworkServices/NetLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NetLib/VBoxNetARP.cpp

    r27856 r28025  
    4444{
    4545    /*
    46      * Valid IntNet Ethernet frame?
     46     * Valid IntNet Ethernet frame? Skip GSO, no ARP in there.
    4747     */
    4848    PCINTNETHDR pHdr = INTNETRingGetNextFrameToRead(&pBuf->Recv);
  • trunk/src/VBox/NetworkServices/NetLib/VBoxNetUDP.cpp

    r27856 r28025  
    2929#include <iprt/rand.h>
    3030#include <VBox/log.h>
     31#include <VBox/pdmnetinline.h>
    3132#include <VBox/intnetinline.h>
    3233
     
    6465     */
    6566    PCINTNETHDR pHdr = INTNETRingGetNextFrameToRead(&pBuf->Recv);
    66     if (!pHdr || pHdr->u16Type != INTNETHDR_TYPE_FRAME)
     67    if (    !pHdr
     68        ||  (   pHdr->u16Type != INTNETHDR_TYPE_FRAME
     69             && pHdr->u16Type != INTNETHDR_TYPE_GSO))
    6770        return NULL;
    6871
    6972    size_t          cbFrame = pHdr->cbFrame;
    7073    const void     *pvFrame = INTNETHdrGetFramePtr(pHdr, pBuf);
     74    PCPDMNETWORKGSO pGso    = NULL;
     75    if (pHdr->u16Type == INTNETHDR_TYPE_GSO)
     76    {
     77        pGso = (PCPDMNETWORKGSO)pvFrame;
     78        if (!PDMNetGsoIsValid(pGso, cbFrame, cbFrame - sizeof(*pGso)))
     79            return NULL;
     80        /** @todo IPv6 UDP support, goes for this entire function really.  Not really
     81         *        important yet since this is currently only used by the DHCP server. */
     82        if (pGso->u8Type != PDMNETWORKGSOTYPE_IPV4_UDP)
     83            return NULL;
     84        pvFrame  = pGso + 1;
     85        cbFrame -= sizeof(*pGso);
     86    }
     87
    7188    PCRTNETETHERHDR pEthHdr = (PCRTNETETHERHDR)pvFrame;
    7289    if (pHdrs)
     
    106123
    107124    /*
     125     * If we're working on a GSO frame, we need to make sure the length fields
     126     * are set correctly (they are usually set to 0).
     127     */
     128    if (pGso)
     129        PDMNetGsoPrepForDirectUse(pGso, (void *)pvFrame, cbFrame, false /*fHeaderChecskum*/, false /*fPayloadChecksum*/);
     130
     131    /*
    108132     * IP validation and matching.
    109133     */
     
    118142    /* Valid IPv4 header? */
    119143    size_t const offIpHdr = (uintptr_t)pIpHdr - (uintptr_t)pEthHdr;
    120     if (!RTNetIPv4IsHdrValid(pIpHdr, cbFrame - offIpHdr, cbFrame - offIpHdr))
     144    if (!RTNetIPv4IsHdrValid(pIpHdr, cbFrame - offIpHdr, cbFrame - offIpHdr, !pGso /*fChecksum*/))
    121145        return NULL;
    122146
     
    132156        return NULL;
    133157
    134     /* Validate the UDP header according to flags. */
    135     size_t      offUdpHdr = (uintptr_t)pUdpHdr - (uintptr_t)pEthHdr;
    136     if (fFlags & (VBOXNETUDP_MATCH_CHECKSUM | VBOXNETUDP_MATCH_REQUIRE_CHECKSUM))
     158    if (!pGso)
    137159    {
    138         if (!RTNetIPv4IsUDPValid(pIpHdr, pUdpHdr, pUdpHdr + 1, cbFrame - offUdpHdr))
    139             return NULL;
    140         if (    (fFlags & VBOXNETUDP_MATCH_REQUIRE_CHECKSUM)
    141             &&  !pUdpHdr->uh_sum)
    142             return NULL;
    143     }
    144     else
    145     {
    146         if (!RTNetIPv4IsUDPSizeValid(pIpHdr, pUdpHdr, cbFrame - offUdpHdr))
    147             return NULL;
     160        /* Validate the UDP header according to flags. */
     161        size_t      offUdpHdr = (uintptr_t)pUdpHdr - (uintptr_t)pEthHdr;
     162        if (fFlags & (VBOXNETUDP_MATCH_CHECKSUM | VBOXNETUDP_MATCH_REQUIRE_CHECKSUM))
     163        {
     164            if (!RTNetIPv4IsUDPValid(pIpHdr, pUdpHdr, pUdpHdr + 1, cbFrame - offUdpHdr, true /*fChecksum*/))
     165                return NULL;
     166            if (    (fFlags & VBOXNETUDP_MATCH_REQUIRE_CHECKSUM)
     167                &&  !pUdpHdr->uh_sum)
     168                return NULL;
     169        }
     170        else
     171        {
     172            if (!RTNetIPv4IsUDPSizeValid(pIpHdr, pUdpHdr, cbFrame - offUdpHdr))
     173                return NULL;
     174        }
    148175    }
    149176
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