VirtualBox

Changeset 30558 in vbox


Ignore:
Timestamp:
Jul 1, 2010 2:15:22 PM (15 years ago)
Author:
vboxsync
Message:

VBoxNetFlt-linux.c: QDisc related fixes.

File:
1 edited

Legend:

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

    r30262 r30558  
    222222static int vboxNetFltQdiscEnqueue(struct sk_buff *skb, struct Qdisc *sch)
    223223{
    224     int rc;
    225     PVBOXNETQDISCPRIV pPriv = qdisc_priv(sch);
     224    PVBOXNETQDISCPRIV   pPriv = qdisc_priv(sch);
     225    int                 rc;
     226
    226227#ifdef VBOXNETFLT_QDISC_ENQUEUE
    227228    if (VALID_PTR(pPriv->pVBoxNetFlt))
     
    230231        PCRTNETETHERHDR      pEtherHdr;
    231232        PINTNETTRUNKSWPORT   pSwitchPort;
    232 
    233         pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(skb, 0, sizeof(abHdrBuf), &abHdrBuf[0]);
     233        uint32_t             cbHdrs = skb_headlen(skb);
     234
     235        cbHdrs = RT_MIN(cbHdrs, sizeof(abHdrBuf));
     236        pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(skb, 0, cbHdrs, &abHdrBuf[0]);
    234237        if (   pEtherHdr
    235238            && (pSwitchPort = pPriv->pVBoxNetFlt->pSwitchPort) != NULL
    236239            && VALID_PTR(pSwitchPort)
    237             )
    238         {
    239             struct sk_buff      *pBuf;
    240             INTNETSWDECISION    enmDecision;
    241             uint32_t            cbHdrs = skb_headlen(skb);
    242             cbHdrs = RT_MAX(cbHdrs, sizeof(abHdrBuf));
    243 
    244 #if 1
    245             /* Test stub due to missing implementation of pfnPreRecv */
    246             static uint8_t       tmpAddr[] = { 0x08, 0x00, 0x27, 0xBB, 0x1E, 0xA0 };
    247             if (memcmp(pEtherHdr, tmpAddr, 6) != 0)
    248                 enmDecision = INTNETSWDECISION_BROADCAST;
    249             else
    250                 enmDecision = INTNETSWDECISION_INTNET;
    251 #else
    252             enmDecision = pSwitchPort->pfnPreRecv(pSwitchPort, pEtherHdr, cbHdrs, INTNETTRUNKDIR_HOST);
    253 #endif
     240            && cbHdrs >= 6)
     241        {
     242            /** @todo consider reference counting, etc. */
     243            INTNETSWDECISION enmDecision = pSwitchPort->pfnPreRecv(pSwitchPort, pEtherHdr, cbHdrs, INTNETTRUNKDIR_HOST);
    254244            if (enmDecision == INTNETSWDECISION_INTNET)
    255245            {
    256                 pBuf = skb_copy(skb, GFP_ATOMIC);
     246                struct sk_buff *pBuf = skb_copy(skb, GFP_ATOMIC);
    257247                pBuf->pkt_type = PACKET_OUTGOING;
    258248                vboxNetFltLinuxForwardToIntNet(pPriv->pVBoxNetFlt, pBuf);
     
    293283    while ((pSkb = pPriv->pChild->dequeue(pPriv->pChild)) != NULL)
    294284    {
    295         struct sk_buff *pBuf;
     285        struct sk_buff     *pBuf;
    296286        INTNETSWDECISION    enmDecision;
    297         uint32_t            cbHdrs = skb_headlen(pSkb);
     287        uint32_t            cbHdrs;
    298288
    299289        --sch->q.qlen;
     
    302292            break;
    303293
    304         pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(pSkb, 0, sizeof(abHdrBuf), &abHdrBuf[0]);
     294        cbHdrs = skb_headlen(pSkb);
     295        cbHdrs = RT_MIN(cbHdrs, sizeof(abHdrBuf));
     296        pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(pSkb, 0, cbHdrs, &abHdrBuf[0]);
    305297        if (   !pEtherHdr
    306298            || (pSwitchPort = pPriv->pVBoxNetFlt->pSwitchPort) == NULL
    307299            || !VALID_PTR(pSwitchPort)
    308             )
     300            || cbHdrs < 6)
    309301            break;
    310302
    311         cbHdrs = RT_MAX(cbHdrs, sizeof(abHdrBuf));
    312 
    313 #if 1
    314         /* Test stub due to missing implementation of pfnPreRecv */
    315         static uint8_t       tmpAddr[] = { 0x08, 0x00, 0x27, 0xBB, 0x1E, 0xA0 };
    316         if (memcmp(pEtherHdr, tmpAddr, 6) != 0)
    317             enmDecision = INTNETSWDECISION_BROADCAST;
    318         else
    319             enmDecision = INTNETSWDECISION_INTNET;
    320 #else
     303        /** @todo consider reference counting, etc. */
    321304        enmDecision = pSwitchPort->pfnPreRecv(pSwitchPort, pEtherHdr, cbHdrs, INTNETTRUNKDIR_HOST);
    322 #endif
    323305        if (enmDecision != INTNETSWDECISION_INTNET)
    324306            break;
     
    834816    PCRTNETETHERHDR             pEtherHdr;
    835817    PINTNETTRUNKSWPORT          pSwitchPort;
     818    uint32_t                    cbHdrs;
    836819
    837820
     
    860843     *       drop it.
    861844     */
    862     pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(pSkb, 0, sizeof(abHdrBuf), &abHdrBuf[0]);
     845    cbHdrs = skb_headlen(pSkb);
     846    cbHdrs = RT_MIN(cbHdrs, sizeof(abHdrBuf));
     847    pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(pSkb, 0, cbHdrs, &abHdrBuf[0]);
    863848    if (   pEtherHdr
    864849        && VALID_PTR(pOverride->pVBoxNetFlt)
    865850        && (pSwitchPort = pOverride->pVBoxNetFlt->pSwitchPort) != NULL
    866851        && VALID_PTR(pSwitchPort)
    867        )
    868     {
    869         INTNETSWDECISION    enmDecision;
    870         uint32_t            cbHdrs = skb_headlen(pSkb);
    871         cbHdrs = RT_MAX(cbHdrs, sizeof(abHdrBuf));
     852        && cbHdrs >= 6)
     853    {
     854        INTNETSWDECISION enmDecision;
    872855
    873856        /** @todo consider reference counting, etc. */
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