VirtualBox

Changeset 12620 in vbox for trunk/src


Ignore:
Timestamp:
Sep 21, 2008 3:20:32 PM (16 years ago)
Author:
vboxsync
Message:

Solaris/vboxnetflt: Loopback enabled.

File:
1 edited

Legend:

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

    r12619 r12620  
    316316    bool fRawMode;                        /* whether raw mode request was successful */
    317317    uint32_t ModeReqId;                   /* track MIOCTLs for swallowing our fake request acknowledgements */
    318     PVBOXNETFLTPACKETID pLoopbackHead;    /* loopback packet identifier head */
    319     PVBOXNETFLTPACKETID pLoopbackTail;    /* loopback packet identifier tail */
     318    PVBOXNETFLTPACKETID pHead;            /* loopback packet identifier head */
     319    PVBOXNETFLTPACKETID pTail;            /* loopback packet identifier tail */
    320320    size_t cLoopback;                     /* loopback queue size list */
    321321} vboxnetflt_promisc_stream_t;
     
    17741774    RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    17751775
    1776     vboxnetflt_promisc_stream_t *pPromiscStream = (vboxnetflt_promisc_stream_t *)pThis->u.s.pvPromiscStream;
     1776    vboxnetflt_promisc_stream_t *pPromiscStream = pThis->u.s.pvPromiscStream;
    17771777    if (pPromiscStream)
    17781778    {
     
    17801780         * Free-up loopback buffers.
    17811781         */
    1782         PVBOXNETFLTPACKETID pCur = pPromiscStream->pLoopbackHead;
     1782        PVBOXNETFLTPACKETID pCur = pPromiscStream->pHead;
    17831783        while (pCur)
    17841784        {
     
    24022402
    24032403    PCRTNETETHERHDR pEthHdr = (PCRTNETETHERHDR)pMsg->b_rptr;
    2404     PVBOXNETFLTPACKETID pHead = pPromiscStream->pLoopbackHead;
    2405     PVBOXNETFLTPACKETID pTail = pPromiscStream->pLoopbackTail;
    24062404    PVBOXNETFLTPACKETID pCur = NULL;
    24072405    int rc = VINF_SUCCESS;
     
    24102408        do
    24112409        {
    2412             if (!pHead)
     2410            if (!pPromiscStream->pHead)
    24132411            {
    24142412                pCur = RTMemAllocZ(sizeof(VBOXNETFLTPACKETID));
     
    24212419                vboxNetFltSolarisInitPacketId(pCur, pMsg);
    24222420
    2423                 pHead = pCur;
    2424                 pTail = pHead;
     2421                pPromiscStream->pHead = pCur;
     2422                pPromiscStream->pTail = pPromiscStream->pHead;
    24252423                pPromiscStream->cLoopback++;
     2424
     2425                LogFlow((DEVICE_NAME ":vboxNetFltSolarisQueueLoopback initialized head. checksum=%u.\n",
     2426                        pPromiscStream->pHead->Checksum));
    24262427                break;
    24272428            }
    24282429
    2429             if (   pTail
    2430                 && pTail->cbPacket == 0)
     2430            if (   pPromiscStream->pTail
     2431                && pPromiscStream->pTail->cbPacket == 0)
    24312432            {
    2432                 pCur = pTail;
     2433                pCur = pPromiscStream->pTail;
    24332434                vboxNetFltSolarisInitPacketId(pCur, pMsg);
     2435
     2436                LogFlow((DEVICE_NAME ":vboxNetFltSolarisQueueLoopback re-used tail checksum=%u cLoopback=%d.\n",
     2437                        pCur->Checksum, pPromiscStream->cLoopback));
    24342438                break;
    24352439            }
     
    24422446            }
    24432447
    2444             pTail->pNext = pCur;
     2448            pPromiscStream->pTail->pNext = pCur;
    24452449            vboxNetFltSolarisInitPacketId(pCur, pMsg);
    24462450            pPromiscStream->cLoopback++;
     2451
     2452            LogFlow((DEVICE_NAME ":vboxNetFltSolarisQueueLoopback added tail checksum=%u cLoopback=%d.\n", pCur->Checksum,
     2453                    pPromiscStream->cLoopback));
    24472454            break;
    24482455        } while (0);
     
    24532460         * Maximum loopback queue size reached. Re-use head as tail.
    24542461         */
    2455         PVBOXNETFLTPACKETID pCur = pHead;
    2456         pHead = pHead->pNext;
    2457         pTail->pNext = pCur;
    2458         pTail = pCur;
     2462        PVBOXNETFLTPACKETID pCur = pPromiscStream->pHead;
     2463        pPromiscStream->pHead = pPromiscStream->pHead->pNext;
     2464        pPromiscStream->pTail->pNext = pCur;
     2465        pPromiscStream->pTail = pCur;
    24592466
    24602467        pCur->pNext = NULL;
    24612468        vboxNetFltSolarisInitPacketId(pCur, pMsg);
     2469        LogFlow((DEVICE_NAME ":vboxNetFltSolarisQueueLoopback recycled head!! checksum=%u cLoopback=%d\n", pCur->Checksum,
     2470                pPromiscStream->cLoopback));
    24622471    }
    24632472
     
    24942503        return false;
    24952504
    2496     PVBOXNETFLTPACKETID pCur = pPromiscStream->pLoopbackHead;
     2505    PVBOXNETFLTPACKETID pCur = pPromiscStream->pHead;
     2506    bool fIsOur = false;
    24972507    while (pCur)
    24982508    {
    24992509        if (pCur->cbPacket != cbMsg)
    2500             return false;
     2510        {
     2511            pCur = pCur->pNext;
     2512            continue;
     2513        }
    25012514
    25022515        PCRTNETETHERHDR pEthHdr = (PCRTNETETHERHDR)pMsg->b_rptr;
     
    25142527            || pCur->DstMac.au8[5] != pEthHdr->DstMac.au8[5])
    25152528        {
    2516             return false;
     2529            pCur = pCur->pNext;
     2530            continue;
    25172531        }
    25182532
    25192533        uint16_t Checksum = RTCrc32(pMsg->b_rptr, cbMsg);
    25202534        if (pCur->Checksum != Checksum)
    2521             return false;
     2535        {
     2536            pCur = pCur->pNext;
     2537            continue;
     2538        }
    25222539
    25232540        /*
    2524          * Yes, it really is our own packet.
     2541         * Yes, it really is our own packet, mark it as handled
     2542         * and return it's found.
    25252543         */
     2544        pCur->cbPacket = 0;
     2545        pPromiscStream->cLoopback--;
     2546        LogFlow((DEVICE_NAME ":vboxNetFltSolarisIsOurMBlk found packet %p cLoopback=%d\n", pMsg, pPromiscStream->cLoopback));
    25262547        return true;
    25272548    }
    25282549
     2550    NOREF(pThis);
    25292551    return false;
    25302552}
     
    25502572     * Don't loopback packets we transmit to the wire.
    25512573     */
    2552     /** @todo -XXX- fix this with proper loopback handling. We must not be using unspecified flags. */
    2553     if (pMsg->b_flag & MSGNOLOOP)
     2574    vboxnetflt_promisc_stream_t *pPromiscStream = pThis->u.s.pvPromiscStream;
     2575    if (vboxNetFltSolarisIsOurMBlk(pThis, pPromiscStream, pMsg))
    25542576    {
    25552577        LogFlow((DEVICE_NAME ":Avoiding packet loopback.\n"));
     
    29332955    if (fDst & INTNETTRUNKDIR_WIRE)
    29342956    {
    2935         vboxnetflt_stream_t *pPromiscStream = pThis->u.s.pvPromiscStream;
    2936         queue_t *pPromiscWriteQueue = WR(pPromiscStream->pReadQueue);
     2957        vboxnetflt_promisc_stream_t *pPromiscStream = pThis->u.s.pvPromiscStream;
     2958        queue_t *pPromiscWriteQueue = WR(pPromiscStream->Stream.pReadQueue);
    29372959
    29382960        mblk_t *pMsg = vboxNetFltSolarisMBlkFromSG(pThis, pSG, fDst);
     
    29432965        }
    29442966
    2945         LogFlow((DEVICE_NAME ":vboxNetFltPortOsXmit INTNETTRUNKDIR_WIRE %u\n", DB_CKSUM16(pMsg)));
    2946 
    2947         /*
    2948          * Flag for avoiding loopback. (Should be fixed later)
    2949          */
    2950         pMsg->b_flag |= MSGNOLOOP;
     2967        LogFlow((DEVICE_NAME ":vboxNetFltPortOsXmit INTNETTRUNKDIR_WIRE\n"));
     2968
     2969        vboxNetFltSolarisQueueLoopback(pThis, pPromiscStream, pMsg);
    29512970        putnext(pPromiscWriteQueue, pMsg);
    29522971    }
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