VirtualBox

Changeset 28069 in vbox for trunk


Ignore:
Timestamp:
Apr 7, 2010 10:37:39 PM (15 years ago)
Author:
vboxsync
Message:

vboxNetFltLinuxSkBufFromSG: The internal network can now send us SGs with more than one segment (GSO).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r28025 r28069  
    291291    struct sk_buff *pPkt;
    292292    struct net_device *pDev;
    293     /*
    294      * Because we're lazy, we will ASSUME that all SGs coming from INTNET
    295      * will only contain one single segment.
    296      */
    297     if (pSG->cSegsUsed != 1 || pSG->cbTotal != pSG->aSegs[0].cb)
    298     {
    299         LogRel(("VBoxNetFlt: Dropped multi-segment(%d) packet coming from internal network.\n", pSG->cSegsUsed));
    300         return NULL;
    301     }
     293
    302294    if (pSG->cbTotal == 0)
    303295    {
     
    308300    /*
    309301     * Allocate a packet and copy over the data.
    310      *
    311302     */
    312303    pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);
    313304    pPkt = dev_alloc_skb(pSG->cbTotal + NET_IP_ALIGN);
    314     if (pPkt)
    315     {
    316         pPkt->dev = pDev;
    317         /* Align IP header on 16-byte boundary: 2 + 14 (ethernet hdr size). */
    318         skb_reserve(pPkt, NET_IP_ALIGN);
    319         skb_put(pPkt, pSG->cbTotal);
    320         memcpy(pPkt->data, pSG->aSegs[0].pv, pSG->cbTotal);
    321         /* Set protocol and packet_type fields. */
    322         pPkt->protocol = eth_type_trans(pPkt, pDev);
    323         pPkt->ip_summed = CHECKSUM_NONE;
    324         if (fDstWire)
    325         {
    326             VBOX_SKB_RESET_NETWORK_HDR(pPkt);
    327             /* Restore ethernet header back. */
    328             skb_push(pPkt, ETH_HLEN);
    329             VBOX_SKB_RESET_MAC_HDR(pPkt);
    330         }
    331         VBOXNETFLT_SKB_TAG(pPkt) = VBOXNETFLT_CB_TAG(pPkt);
    332 
    333         return pPkt;
    334     }
    335     else
     305    if (RT_UNLIKELY(!pPkt))
     306    {
    336307        Log(("vboxNetFltLinuxSkBufFromSG: Failed to allocate sk_buff(%u).\n", pSG->cbTotal));
    337     pSG->pvUserData = NULL;
    338 
    339     return NULL;
     308        pSG->pvUserData = NULL;
     309        return NULL;
     310    }
     311
     312    pPkt->dev = pDev;
     313
     314    /* Align IP header on 16-byte boundary: 2 + 14 (ethernet hdr size). */
     315    skb_reserve(pPkt, NET_IP_ALIGN);
     316
     317    /* Copy the segments. */
     318    skb_put(pPkt, pSG->cbTotal);
     319    memcpy(pPkt->data, pSG->aSegs[0].pv, pSG->aSegs[0].cb);
     320    if (pSG->cSegsUsed > 1)
     321    {
     322        uint8_t *pbDst = (uint8_t *)pPkt->data + pSG->aSegs[0].cb;
     323        size_t   iSeg  = 0;
     324        while (++iSeg < pSG->cSegsUsed)
     325        {
     326            memcpy(pbDst, pSG->aSegs[iSeg].pv, pSG->aSegs[iSeg].cb);
     327            pbDst += pSG->aSegs[iSeg].cb;
     328            Assert((uintptr_t)pbDst - (uintptr_t)pPkt->data <= pSG->cbTotal);
     329        }
     330    }
     331
     332    /* Set protocol and packet_type fields. */
     333    pPkt->protocol = eth_type_trans(pPkt, pDev);
     334    pPkt->ip_summed = CHECKSUM_NONE;
     335    if (fDstWire)
     336    {
     337        VBOX_SKB_RESET_NETWORK_HDR(pPkt);
     338        /* Restore ethernet header back. */
     339        skb_push(pPkt, ETH_HLEN);
     340        VBOX_SKB_RESET_MAC_HDR(pPkt);
     341    }
     342    VBOXNETFLT_SKB_TAG(pPkt) = VBOXNETFLT_CB_TAG(pPkt);
     343
     344    return pPkt;
    340345}
    341346
     
    545550
    546551#ifndef LOG_ENABLED
    547 #define vboxNetFltDumpPacket(a, b, c, d)
     552# define vboxNetFltDumpPacket(a, b, c, d) do {} while (0)
    548553#else
    549554static void vboxNetFltDumpPacket(PINTNETSG pSG, bool fEgress, const char *pszWhere, int iIncrement)
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