VirtualBox

Changeset 23927 in vbox


Ignore:
Timestamp:
Oct 21, 2009 9:18:34 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53734
Message:

netflt/win: alternative loopback handling mechanism (disabled for now)

Location:
trunk/src/VBox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk

    r23526 r23927  
    5151 VBoxNetFlt_SOURCES.win += win/VBoxNetFltMp-win.c
    5252endif
     53#ifdef VBOX_LOOPBACK_USEFLAGS
     54 VBoxNetFlt_DEFS.win += VBOX_LOOPBACK_USEFLAGS
     55#endif
    5356VBoxNetFlt_SOURCES = VBoxNetFlt.c
    5457VBoxNetFlt_LDFLAGS.darwin = -v -Wl,-whyload -Wl,-v -Wl,-whatsloaded
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.c

    r22441 r23927  
    118118INIT_IDC_INFO g_InitIdcInfo;
    119119
     120#ifdef VBOX_LOOPBACK_USEFLAGS
    120121UINT g_fPacketDontLoopBack;
    121122UINT g_fPacketIsLoopedBack;
     123#endif
    122124
    123125#define LIST_ENTRY_2_JOB(pListEntry) \
     
    522524        if(bSrcHost)
    523525        {
    524 #ifdef DEBUG_NETFLT_LOOPBACK
    525 # error "implement (see comments in the sources below this #error:)"
    526         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    527         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    528         similar to that used in TrasferData handling should be used;
    529         */
    530 
    531 //            SET_PACKET_TO_INFO(pInfo, pMyPacket);
    532 //            /* we are not using flags here, so they are not valid here */
    533 //            /* SET_FLAGS_TO_INFO(pInfo, 0); */
    534 //            LogFlow(("sending packet (%p)\n", pMyPacket));
    535 //            vboxNetFltWinDoSendViaInfo(&fStatus, pAdapt, pInfo);
    536 //            LogFlow(("done sending packet (%p), status (%d)\n", pMyPacket, fStatus));
    537 #else
     526#if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
     527            vboxNetFltWinLbPutSendPacket(pAdapt, pMyPacket, false /* bFromIntNet */);
     528#endif
    538529            NdisSend(&fStatus, pAdapt->hBindingHandle, pMyPacket);
    539 #endif
    540530
    541531            if (fStatus != NDIS_STATUS_PENDING)
    542532            {
     533#if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
    543534                /* the status is NOT pending, complete the packet */
    544 #ifdef DEBUG_NETFLT_LOOPBACK
    545 # error "implement (see comments in the sources below this #error:)"
    546         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    547         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    548         similar to that used in TrasferData handling should be used;
    549         */
    550 
    551 //                vboxNetFltWinDoCompleteSendViaInfo(pAdapt, pInfo);
     535                bool bTmp = vboxNetFltWinLbRemoveSendPacket(pAdapt, pMyPacket);
     536                Assert(bTmp);
    552537#endif
    553538                if(pPacket)
     
    572557        else
    573558        {
    574 #ifdef DEBUG_NETFLT_LOOPBACK
    575 # error "implement (see comments in the sources below this #error:)"
    576         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    577         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    578         similar to that used in TrasferData handling should be used;
    579         */
    580 
    581 //            SET_PACKET_TO_INFO(pInfo, pMyPacket);
    582 //            /* we are not using flags here, so they are not valid here */
    583 //            /* SET_FLAGS_TO_INFO(pInfo, 0); */
    584 //
    585 //            LogFlow(("indicating receive packet (%p)\n", pMyPacket));
    586 //            vboxNetFltWinDoIndicateReceiveViaInfo(pAdapt, pInfo);
    587 //            /* the packet return will be processed in the vboxNetFltWinMpReturnPacket call-back unless
    588 //             * we specify NDIS_STATUS_RESOURCES as the packet status, which we are NOT doing currently */
    589 //            LogFlow(("done indicating receive packet (%p)\n", pMyPacket));
    590 #else
    591559            NdisMIndicateReceivePacket(pAdapt->hMiniportHandle, &pMyPacket, 1);
    592 #endif
    593560
    594561            fStatus = NDIS_STATUS_PENDING;
     
    17981765                    pSendRsvd->pOriginalPkt = NULL;
    17991766                    pSendRsvd->pBufToFree = pBufToFree;
    1800 
     1767#ifdef VBOX_LOOPBACK_USEFLAGS
    18011768                    /* set "don't loopback" flags */
    18021769                    NdisSetPacketFlags(pPacket, g_fPacketDontLoopBack);
     1770#else
     1771                    NdisSetPacketFlags(pPacket, 0);
     1772#endif
    18031773                }
    18041774#ifndef VBOX_NETFLT_ONDEMAND_BIND
     
    19911961    do
    19921962    {
     1963#ifdef VBOX_LOOPBACK_USEFLAGS
    19931964        ULONG MjVersion;
    19941965        ULONG MnVersion;
     1966#endif
    19951967
    19961968#ifdef VBOX_NETFLT_ONDEMAND_BIND
     
    20081980            break;
    20091981        }
    2010 
     1982#ifdef VBOX_LOOPBACK_USEFLAGS
    20111983        PsGetVersion(&MjVersion, &MnVersion,
    20121984          NULL, /* PULONG  BuildNumber  OPTIONAL */
     
    20231995
    20241996        g_fPacketIsLoopedBack = NDIS_FLAGS_IS_LOOPBACK_PACKET;
     1997#endif
    20251998
    20261999#ifndef VBOX_NETFLT_ONDEMAND_BIND
     
    21002073        vboxNetFltWinCopyPacketInfoOnSend(*ppMyPacket, pPacket);
    21012074
    2102 //        if(bNetFltActive)
    2103 //        {
    2104             NdisGetPacketFlags(*ppMyPacket) |= g_fPacketDontLoopBack;
    2105 //        }
     2075#ifdef VBOX_LOOPBACK_USEFLAGS
     2076        NdisGetPacketFlags(*ppMyPacket) |= g_fPacketDontLoopBack;
     2077#endif
    21062078    }
    21072079    else
     
    23302302
    23312303    FINI_INTERLOCKED_SINGLE_LIST(&pAdapt->TransferDataList);
    2332 #endif
    2333 #ifdef DEBUG_NETFLT_LOOPBACK
    2334 # error "add list cleaning code here"
    2335 #endif
    2336 
     2304# if defined(DEBUG_NETFLT_LOOPBACK) || !defined(VBOX_LOOPBACK_USEFLAGS)
     2305    FINI_INTERLOCKED_SINGLE_LIST(&pAdapt->SendPacketQueue);
     2306# endif
     2307#endif
    23372308
    23382309#ifndef VBOX_NETFLT_ONDEMAND_BIND
     
    24582429
    24592430        INIT_INTERLOCKED_SINGLE_LIST(&pAdapt->TransferDataList);
     2431
     2432# if defined(DEBUG_NETFLT_LOOPBACK) || !defined(VBOX_LOOPBACK_USEFLAGS)
     2433        INIT_INTERLOCKED_SINGLE_LIST(&pAdapt->SendPacketQueue);
     2434# endif
    24602435#endif
    24612436        /* TODO: do we need it here ?? */
    24622437        pAdapt->MPState.PowerState = NdisDeviceStateD3;
    24632438        vboxNetFltWinSetOpState(&pAdapt->MPState, kVBoxNetDevOpState_Deinitialized);
    2464 
    2465 #ifdef DEBUG_NETFLT_LOOPBACK
    2466 # error "add list initialization code here"
    2467 #endif
    24682439
    24692440#ifdef VBOX_NETFLT_ONDEMAND_BIND
     
    25062477#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
    25072478
    2508 #ifdef DEBUG_NETFLT_PACKETS
    2509 
     2479#ifndef VBOXNETADP
     2480
     2481#ifdef DEBUG_misha
     2482
     2483RTMAC g_vboxNetFltWinVerifyMACBroadcast = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
     2484RTMAC g_vboxNetFltWinVerifyMACGuest = {0x08, 0x00, 0x27, 0x01, 0x02, 0x03};
     2485
     2486DECLHIDDEN(PRTNETETHERHDR) vboxNetFltWinGetEthHdr(PNDIS_PACKET pPacket)
     2487{
     2488    UINT cBufCount1;
     2489    PNDIS_BUFFER pBuffer1;
     2490    UINT uTotalPacketLength1;
     2491    RTNETETHERHDR* pEth;
     2492    UINT cbLength1 = 0;
     2493    UINT i = 0;
     2494
     2495    NdisQueryPacket(pPacket, NULL, &cBufCount1, &pBuffer1, &uTotalPacketLength1);
     2496
     2497    Assert(pBuffer1);
     2498    Assert(uTotalPacketLength1 >= ETH_HEADER_SIZE);
     2499    if(uTotalPacketLength1 < ETH_HEADER_SIZE)
     2500        return NULL;
     2501
     2502    NdisQueryBufferSafe(pBuffer1, &pEth, &cbLength1, NormalPagePriority);
     2503    Assert(cbLength1 >= ETH_HEADER_SIZE);
     2504    if(cbLength1 < ETH_HEADER_SIZE)
     2505        return NULL;
     2506
     2507    return pEth;
     2508}
     2509
     2510DECLHIDDEN(PRTNETETHERHDR) vboxNetFltWinGetEthHdrSG(PINTNETSG pSG)
     2511{
     2512    Assert(pSG->cSegsUsed);
     2513    Assert(pSG->cSegsAlloc >= pSG->cSegsUsed);
     2514    Assert(pSG->aSegs[0].cb >= ETH_HEADER_SIZE);
     2515
     2516    if(!pSG->cSegsUsed)
     2517        return NULL;
     2518
     2519    if(pSG->aSegs[0].cb < ETH_HEADER_SIZE)
     2520        return NULL;
     2521
     2522    return (PRTNETETHERHDR)pSG->aSegs[0].pv;
     2523}
     2524
     2525DECLHIDDEN(bool) vboxNetFltWinCheckMACs(PNDIS_PACKET pPacket, PRTMAC pDst, PRTMAC pSrc)
     2526{
     2527    PRTNETETHERHDR pHdr = vboxNetFltWinGetEthHdr(pPacket);
     2528    Assert(pHdr);
     2529
     2530    if(!pHdr)
     2531        return false;
     2532
     2533    if(pDst && memcmp(pDst, &pHdr->DstMac, sizeof(RTMAC)))
     2534        return false;
     2535
     2536    if(pSrc && memcmp(pSrc, &pHdr->SrcMac, sizeof(RTMAC)))
     2537        return false;
     2538
     2539    return true;
     2540}
     2541
     2542DECLHIDDEN(bool) vboxNetFltWinCheckMACsSG(PINTNETSG pSG, PRTMAC pDst, PRTMAC pSrc)
     2543{
     2544    PRTNETETHERHDR pHdr = vboxNetFltWinGetEthHdrSG(pSG);
     2545    Assert(pHdr);
     2546
     2547    if(!pHdr)
     2548        return false;
     2549
     2550    if(pDst && memcmp(pDst, &pHdr->DstMac, sizeof(RTMAC)))
     2551        return false;
     2552
     2553    if(pSrc && memcmp(pSrc, &pHdr->SrcMac, sizeof(RTMAC)))
     2554        return false;
     2555
     2556    return true;
     2557}
     2558#endif
     2559
     2560# if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS)
    25102561/*
    25112562 * answers whether the two given packets match based on the packet length and the first cbMatch bytes of the packets
     
    25172568    PNDIS_BUFFER pBuffer1;
    25182569    UINT uTotalPacketLength1;
    2519     PVOID pMemBuf1;
     2570    uint8_t* pMemBuf1;
    25202571    UINT cbLength1 = 0;
    25212572
     
    25232574    PNDIS_BUFFER pBuffer2;
    25242575    UINT uTotalPacketLength2;
    2525     PVOID pMemBuf2;
     2576    uint8_t* pMemBuf2;
    25262577    UINT cbLength2 = 0;
    25272578    bool bMatch = true;
     
    25432594    else
    25442595    {
     2596        UINT ucbLength2Match = 0;
    25452597        UINT ucbMatch;
    25462598        if(cbMatch < 0 || (UINT)cbMatch > uTotalPacketLength1)
     
    25572609        }
    25582610
    2559         do
    2560         {
    2561             UINT ucbLength2Match;
     2611        for(;;)
     2612        {
    25622613            if(!cbLength1)
    25632614            {
     
    25652616                NdisGetNextBuffer(pBuffer1, &pBuffer1);
    25662617            }
     2618            else
     2619            {
     2620                Assert(pMemBuf1);
     2621                Assert(ucbLength2Match);
     2622                pMemBuf1 += ucbLength2Match;
     2623            }
    25672624
    25682625            if(!cbLength2)
     
    25712628                NdisGetNextBuffer(pBuffer2, &pBuffer2);
    25722629            }
     2630            else
     2631            {
     2632                Assert(pMemBuf2);
     2633                Assert(ucbLength2Match);
     2634                pMemBuf2 += ucbLength2Match;
     2635            }
    25732636
    25742637            ucbLength2Match = MIN(ucbMatch, cbLength1);
    25752638            ucbLength2Match = MIN(ucbMatch, cbLength2);
    25762639
    2577             if(memcmp(pMemBuf1, pMemBuf2, ucbLength2Match))
     2640            if(memcmp((PVOID*)pMemBuf1, (PVOID*)pMemBuf2, ucbLength2Match))
    25782641            {
    25792642                bMatch = false;
    25802643                break;
    25812644            }
     2645
    25822646            ucbMatch -= ucbLength2Match;
     2647            if(!ucbMatch)
     2648                break;
     2649
    25832650            cbLength1 -= ucbLength2Match;
    25842651            cbLength2 -= ucbLength2Match;
    2585         } while (ucbMatch);
     2652        }
    25862653    }
    25872654
     
    26062673    PNDIS_BUFFER pBuffer1;
    26072674    UINT uTotalPacketLength1;
    2608     PVOID pMemBuf1;
     2675    uint8_t* pMemBuf1;
    26092676    UINT cbLength1 = 0;
    26102677    UINT uTotalPacketLength2 = pSG->cbTotal;
    2611     PVOID pMemBuf2;
     2678    uint8_t* pMemBuf2;
    26122679    UINT cbLength2 = 0;
    26132680    bool bMatch = true;
     
    26282695    else
    26292696    {
     2697        UINT ucbLength2Match = 0;
    26302698        UINT ucbMatch;
     2699
    26312700        if(cbMatch < 0 || (UINT)cbMatch > uTotalPacketLength1)
    26322701        {
     
    26402709        }
    26412710
    2642         do
    2643         {
    2644             UINT ucbLength2Match;
     2711        for(;;)
     2712        {
    26452713            if(!cbLength1)
    26462714            {
     
    26482716                NdisGetNextBuffer(pBuffer1, &pBuffer1);
    26492717            }
     2718            else
     2719            {
     2720                Assert(pMemBuf1);
     2721                Assert(ucbLength2Match);
     2722                pMemBuf1 += ucbLength2Match;
     2723            }
    26502724
    26512725            if(!cbLength2)
    26522726            {
    26532727                Assert(i < pSG->cSegsUsed);
    2654                 pMemBuf2 = pSG->aSegs[i].pv;
     2728                pMemBuf2 = (uint8_t*)pSG->aSegs[i].pv;
    26552729                cbLength2 = pSG->aSegs[i].cb;
    26562730                i++;
    26572731            }
     2732            else
     2733            {
     2734                Assert(pMemBuf2);
     2735                Assert(ucbLength2Match);
     2736                pMemBuf2 += ucbLength2Match;
     2737            }
    26582738
    26592739            ucbLength2Match = MIN(ucbMatch, cbLength1);
    26602740            ucbLength2Match = MIN(ucbMatch, cbLength2);
    26612741
    2662             if(memcmp(pMemBuf1, pMemBuf2, ucbLength2Match))
     2742            if(memcmp((PVOID*)pMemBuf1, (PVOID*)pMemBuf2, ucbLength2Match))
    26632743            {
    26642744                bMatch = false;
     
    26662746                break;
    26672747            }
     2748
    26682749            ucbMatch -= ucbLength2Match;
     2750            if(!ucbMatch)
     2751                break;
     2752
    26692753            cbLength1 -= ucbLength2Match;
    26702754            cbLength2 -= ucbLength2Match;
    2671         } while (ucbMatch);
     2755        }
    26722756    }
    26732757
     
    26802764}
    26812765
     2766#  if 0
    26822767/*
    26832768 * answers whether the two PINTNETSGs match based on the packet length and the first cbMatch bytes of the PINTNETSG
     
    27632848    return bMatch;
    27642849}
     2850#  endif
     2851# endif
    27652852#endif
    27662853
     
    33393426        {
    33403427            NDIS_STATUS fStatus;
    3341 # ifdef DEBUG_NETFLT_LOOPBACK
    3342 # error "implement (see comments in the sources below this #error:)"
    3343         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    3344         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    3345         similar to that used in TrasferData handling should be used;
    3346         */
    3347 
    3348 //            PPACKET_INFO pInfo = vboxNetFltWinDoSend(&fStatus, pAdapt, pPacket);
    3349 # else
     3428
     3429#if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
     3430            vboxNetFltWinLbPutSendPacket(pAdapt, pPacket, true /* bFromIntNet */);
     3431#endif
    33503432            NdisSend(&fStatus, pAdapt->hBindingHandle, pPacket);
    3351 # endif
    33523433            if (fStatus != NDIS_STATUS_PENDING)
    33533434            {
     3435#if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
     3436                /* the status is NOT pending, complete the packet */
     3437                bool bTmp = vboxNetFltWinLbRemoveSendPacket(pAdapt, pPacket);
     3438                Assert(bTmp);
     3439#endif
    33543440                if(!NT_SUCCESS(fStatus))
    33553441                {
     
    33573443                    rc = VERR_GENERAL_FAILURE;
    33583444                }
    3359 # ifdef DEBUG_NETFLT_LOOPBACK
    3360 #  error "implement (see comments in the sources below this #error:)"
    3361         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    3362         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    3363         similar to that used in TrasferData handling should be used;
    3364         */
    3365 
    3366 //                if(pInfo)
    3367 //                {
    3368 //                    /* TODO: FIXME: remove this assert */
    3369 //                    Assert(fStatus == NDIS_STATUS_SUCCESS);
    3370 //
    3371 //                    vboxNetFltWinDoCompleteSendViaInfo(pAdapt, pInfo);
    3372 //                    vboxNetFltWinPpFreePacketInfo(pInfo);
    3373 //                }
    3374 //                else
    3375 //                {
    3376 //                    Assert(0);
    3377 //                }
    3378 # endif
     3445
    33793446                vboxNetFltWinFreeSGNdisPacket(pPacket, true);
    33803447            }
     
    34033470        if (pPacket)
    34043471        {
    3405 # ifndef DEBUG_NETFLT_LOOPBACK
    34063472            NdisMIndicateReceivePacket(pAdapt->hMiniportHandle, &pPacket, 1);
    3407 # else
    3408 #  error "implement (see comments in the sources below this #error:)"
    3409         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    3410         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    3411         similar to that used in TrasferData handling should be used;
    3412         */
    3413 
    3414 //            PPACKET_INFO pInfo = vboxNetFltWinDoIndicateReceive(pAdapt, pPacket);
    3415 //            if(!pInfo)
    3416 //            {
    3417 //                Assert(0);
    3418 //                vboxNetFltWinFreeSGNdisPacket(pPacket, true);
    3419 //                rc = VERR_NO_MEMORY;
    3420 //            }
    3421 //            else
    3422 # endif
    3423             {
    3424                 cRefs--;
    3425             }
     3473            cRefs--;
    34263474#ifdef VBOXNETADP
    34273475            STATISTIC_INCREASE(pAdapt->cRxSuccess);
     
    34593507            return false;
    34603508
    3461         bPromiscuous = (pAdapt->fOurSetFilter & NDIS_PACKET_TYPE_PROMISCUOUS) == NDIS_PACKET_TYPE_PROMISCUOUS;
     3509        bPromiscuous = (pAdapt->fUpperProtocolSetFilter & NDIS_PACKET_TYPE_PROMISCUOUS) == NDIS_PACKET_TYPE_PROMISCUOUS;
    34623510            /*vboxNetFltWinIsPromiscuous(pAdapt);*/
    34633511
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.h

    r22599 r23927  
    3434extern NDIS_SPIN_LOCK     g_GlobalLock;
    3535
     36#ifdef VBOX_LOOPBACK_USEFLAGS
    3637extern UINT g_fPacketDontLoopBack;
    3738extern UINT g_fPacketIsLoopedBack;
     39#endif
    3840
    3941/*
     
    5355DECLHIDDEN(NTSTATUS) vboxNetFltWinPtDispatch(IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp);
    5456DECLHIDDEN(VOID) vboxNetFltWinUnload(IN PDRIVER_OBJECT DriverObject);
     57
     58#ifndef VBOXNETADP
     59# if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS)
     60DECLHIDDEN(bool) vboxNetFltWinMatchPackets(PNDIS_PACKET pPacket1, PNDIS_PACKET pPacket2, const INT cbMatch);
     61DECLHIDDEN(bool) vboxNetFltWinMatchPacketAndSG(PNDIS_PACKET pPacket, PINTNETSG pSG, const INT cbMatch);
     62# endif
     63#endif
    5564
    5665/*************************
     
    6271    ( (PPACKET_INFO)((uint8_t *)(pListEntry) - RT_OFFSETOF(PACKET_INFO, ListEntry)) )
    6372
     73#if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS)
     74
     75#define VBOX_SLE_2_SEND_RSVD(_pEntry) \
     76    ( (PSEND_RSVD)((uint8_t *)(_pEntry) - RT_OFFSETOF(SEND_RSVD, ListEntry)) )
     77
     78#define VBOX_SLE_2_SENDPACKET(_pEntry) \
     79    ( (PNDIS_PACKET)((uint8_t *)(VBOX_SLE_2_SEND_RSVD(_pEntry)) - RT_OFFSETOF(NDIS_PACKET, ProtocolReserved)) )
     80
     81#endif
    6482/**
    6583 * enqueus the packet info to the tail of the queue
     
    201219#endif
    202220
    203 
     221#ifndef VBOXNETADP
    204222/**
    205223 * searches the list entry in a single-linked list
     
    228246}
    229247
     248#if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS)
     249
     250DECLINLINE(PNDIS_PACKET) vboxNetFltWinSearchPacket(PSINGLE_LIST pList, PNDIS_PACKET pPacket2Search, int cbMatch, bool bRemove)
     251{
     252    PSINGLE_LIST_ENTRY pHead = &pList->Head;
     253    PSINGLE_LIST_ENTRY pCur;
     254    PSINGLE_LIST_ENTRY pPrev;
     255    PNDIS_PACKET pCurPacket;
     256    for(pCur = pHead->Next, pPrev = pHead; pCur; pPrev = pCur, pCur = pCur->Next)
     257    {
     258        pCurPacket = VBOX_SLE_2_SENDPACKET(pCur);
     259        if(pCurPacket == pPacket2Search || vboxNetFltWinMatchPackets(pPacket2Search, pCurPacket, cbMatch))
     260        {
     261            if(bRemove)
     262            {
     263                pPrev->Next = pCur->Next;
     264                if(pCur == pList->pTail)
     265                {
     266                    pList->pTail = pPrev;
     267                }
     268            }
     269            return pCurPacket;
     270        }
     271    }
     272    return NULL;
     273}
     274
     275DECLINLINE(PNDIS_PACKET) vboxNetFltWinSearchPacketBySG(PSINGLE_LIST pList, PINTNETSG pSG, int cbMatch, bool bRemove)
     276{
     277    PSINGLE_LIST_ENTRY pHead = &pList->Head;
     278    PSINGLE_LIST_ENTRY pCur;
     279    PSINGLE_LIST_ENTRY pPrev;
     280    PNDIS_PACKET pCurPacket;
     281    for(pCur = pHead->Next, pPrev = pHead; pCur; pPrev = pCur, pCur = pCur->Next)
     282    {
     283        pCurPacket = VBOX_SLE_2_SENDPACKET(pCur);
     284        if(vboxNetFltWinMatchPacketAndSG(pCurPacket, pSG, cbMatch))
     285        {
     286            if(bRemove)
     287            {
     288                pPrev->Next = pCur->Next;
     289                if(pCur == pList->pTail)
     290                {
     291                    pList->pTail = pPrev;
     292                }
     293            }
     294            return pCurPacket;
     295        }
     296    }
     297    return NULL;
     298}
     299
     300#endif /* #if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS) */
     301
     302DECLINLINE(bool) vboxNetFltWinSListIsEmpty(PSINGLE_LIST pList)
     303{
     304    return !pList->Head.Next;
     305}
     306
    230307DECLINLINE(void) vboxNetFltWinPutTail(PSINGLE_LIST pList, PSINGLE_LIST_ENTRY pEntry)
    231308{
     
    235312}
    236313
     314DECLINLINE(void) vboxNetFltWinPutHead(PSINGLE_LIST pList, PSINGLE_LIST_ENTRY pEntry)
     315{
     316    pEntry->Next = pList->Head.Next;
     317    pList->Head.Next = pEntry;
     318    if(!pEntry->Next)
     319        pList->pTail = pEntry;
     320}
     321
    237322DECLINLINE(PSINGLE_LIST_ENTRY) vboxNetFltWinGetHead(PSINGLE_LIST pList)
    238323{
     
    240325    if(pEntry && pEntry == pList->pTail)
    241326    {
     327        pList->Head.Next = NULL;
    242328        pList->pTail = &pList->Head;
    243329    }
     
    254340}
    255341
     342#if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS)
     343
     344DECLINLINE(PNDIS_PACKET) vboxNetFltWinInterlockedSearchPacket(PINTERLOCKED_SINGLE_LIST pList, PNDIS_PACKET pPacket2Search, int cbMatch, bool bRemove)
     345{
     346    PNDIS_PACKET pFound;
     347    NdisAcquireSpinLock(&pList->Lock);
     348    pFound = vboxNetFltWinSearchPacket(&pList->List, pPacket2Search, cbMatch, bRemove);
     349    NdisReleaseSpinLock(&pList->Lock);
     350    return pFound;
     351}
     352
     353DECLINLINE(PNDIS_PACKET) vboxNetFltWinInterlockedSearchPacketBySG(PINTERLOCKED_SINGLE_LIST pList, PINTNETSG pSG, int cbMatch, bool bRemove)
     354{
     355    PNDIS_PACKET pFound;
     356    NdisAcquireSpinLock(&pList->Lock);
     357    pFound = vboxNetFltWinSearchPacketBySG(&pList->List, pSG, cbMatch, bRemove);
     358    NdisReleaseSpinLock(&pList->Lock);
     359    return pFound;
     360}
     361#endif /* #if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS) */
     362
    256363DECLINLINE(void) vboxNetFltWinInterlockedPutTail(PINTERLOCKED_SINGLE_LIST pList, PSINGLE_LIST_ENTRY pEntry)
    257364{
    258365    NdisAcquireSpinLock(&pList->Lock);
    259366    vboxNetFltWinPutTail(&pList->List, pEntry);
     367    NdisReleaseSpinLock(&pList->Lock);
     368}
     369
     370DECLINLINE(void) vboxNetFltWinInterlockedPutHead(PINTERLOCKED_SINGLE_LIST pList, PSINGLE_LIST_ENTRY pEntry)
     371{
     372    NdisAcquireSpinLock(&pList->Lock);
     373    vboxNetFltWinPutHead(&pList->List, pEntry);
    260374    NdisReleaseSpinLock(&pList->Lock);
    261375}
     
    270384}
    271385
     386# if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
     387DECLINLINE(void) vboxNetFltWinLbPutSendPacket(PADAPT pAdapt, PNDIS_PACKET pPacket, bool bFromIntNet)
     388{
     389    PSEND_RSVD pSrv = (PSEND_RSVD)pPacket->ProtocolReserved;
     390    pSrv->bFromIntNet = bFromIntNet;
     391    vboxNetFltWinInterlockedPutHead(&pAdapt->SendPacketQueue, &pSrv->ListEntry);
     392}
     393
     394DECLINLINE(bool) vboxNetFltWinLbIsFromIntNet(PNDIS_PACKET pPacket)
     395{
     396    PSEND_RSVD pSrv = (PSEND_RSVD)pPacket->ProtocolReserved;
     397    return pSrv->bFromIntNet;
     398}
     399
     400DECLINLINE(PNDIS_PACKET) vboxNetFltWinLbSearchLoopBack(PADAPT pAdapt, PNDIS_PACKET pPacket, bool bRemove)
     401{
     402    return vboxNetFltWinInterlockedSearchPacket(&pAdapt->SendPacketQueue, pPacket, VBOXNETFLT_PACKETMATCH_LENGTH, bRemove);
     403}
     404
     405DECLINLINE(PNDIS_PACKET) vboxNetFltWinLbSearchLoopBackBySG(PADAPT pAdapt, PINTNETSG pSG, bool bRemove)
     406{
     407    return vboxNetFltWinInterlockedSearchPacketBySG(&pAdapt->SendPacketQueue, pSG, VBOXNETFLT_PACKETMATCH_LENGTH, bRemove);
     408}
     409
     410DECLINLINE(bool) vboxNetFltWinLbRemoveSendPacket(PADAPT pAdapt, PNDIS_PACKET pPacket)
     411{
     412    PSEND_RSVD pSrv = (PSEND_RSVD)pPacket->ProtocolReserved;
     413    return vboxNetFltWinInterlockedSearchListEntry(&pAdapt->SendPacketQueue, &pSrv->ListEntry, true);
     414}
     415
     416# endif
     417
     418#endif
     419
     420#ifdef DEBUG_misha
     421DECLHIDDEN(bool) vboxNetFltWinCheckMACs(PNDIS_PACKET pPacket, PRTMAC pDst, PRTMAC pSrc);
     422DECLHIDDEN(bool) vboxNetFltWinCheckMACsSG(PINTNETSG pSG, PRTMAC pDst, PRTMAC pSrc);
     423extern RTMAC g_vboxNetFltWinVerifyMACBroadcast;
     424extern RTMAC g_vboxNetFltWinVerifyMACGuest;
     425
     426# define VBOXNETFLT_LBVERIFY(_pnf, _p) \
     427    do { \
     428        Assert(!vboxNetFltWinCheckMACs(_p, NULL, &g_vboxNetFltWinVerifyMACGuest)); \
     429        Assert(!vboxNetFltWinCheckMACs(_p, NULL, &(_pnf)->u.s.Mac)); \
     430    } while(0)
     431
     432# define VBOXNETFLT_LBVERIFYSG(_pnf, _p) \
     433    do { \
     434        Assert(!vboxNetFltWinCheckMACsSG(_p, NULL, &g_vboxNetFltWinVerifyMACGuest)); \
     435        Assert(!vboxNetFltWinCheckMACsSG(_p, NULL, &(_pnf)->u.s.Mac)); \
     436    } while(0)
     437
     438#else
     439# define VBOXNETFLT_LBVERIFY(_pnf, _p) do{}while(0)
     440# define VBOXNETFLT_LBVERIFYSG(_pnf, _p) do{}while(0)
     441#endif
     442
    272443/** initializes the list */
    273444#define INIT_SINGLE_LIST(_pList) \
     
    279450/** initializes the list */
    280451#define INIT_INTERLOCKED_SINGLE_LIST(_pList) \
    281     { \
     452    do { \
    282453        INIT_SINGLE_LIST(&(_pList)->List); \
    283454        NdisAllocateSpinLock(&(_pList)->Lock); \
    284     }
     455    } while(0)
    285456
    286457/** delete the packet queue */
    287 #define FINI_INTERLOCKED_SINGLE_LIST(_pList) NdisFreeSpinLock(&(_pList)->Lock)
     458#define FINI_INTERLOCKED_SINGLE_LIST(_pList) \
     459    do { \
     460        Assert(vboxNetFltWinSListIsEmpty(&(_pList)->List)); \
     461        NdisFreeSpinLock(&(_pList)->Lock) \
     462    } while(0)
     463
    288464
    289465/** obtains the PTRANSFERDATA_RSVD given a single list entry it contains */
     
    778954
    779955DECLHIDDEN(void) vboxNetFltWinFreeSGNdisPacket(PNDIS_PACKET pPacket, bool bFreeMem);
    780 
    781 #ifdef DEBUG_NETFLT_PACKETS
    782 DECLHIDDEN(bool) vboxNetFltWinMatchPacketAndSG(PNDIS_PACKET pPacket, PINTNETSG pSG, const INT cbMatch);
    783 
    784 DECLHIDDEN(bool) vboxNetFltWinMatchPackets(PNDIS_PACKET pPacket1, PNDIS_PACKET pPacket2, const INT cbMatch);
    785 
    786 #endif
    787956
    788957#ifdef DEBUG_NETFLT_PACKETS
     
    822991 * @return true if the packet is a looped back one, false otherwise
    823992 */
    824 #ifdef DEBUG_NETFLT_LOOPBACK
    825 # error "implement (see comments in the sources below this #error:)"
    826         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    827         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    828         similar to that used in TrasferData handling should be used;
    829         */
    830 
    831 //#ifdef VBOX_NETFLT_ONDEMAND_BIND
    832 //DECLHIDDEN(bool) vboxNetFltWinIsLoopedBackPacket(PADAPT pAdapt, PNDIS_PACKET pPacket);
    833 //#else
    834 //DECLHIDDEN(bool) vboxNetFltWinIsLoopedBackPacket(PADAPT pAdapt, PNDIS_PACKET pPacket, bool bOnRecv);
    835 //#endif
    836 //
    837 //#ifdef VBOX_NETFLT_ONDEMAND_BIND
    838 //DECLHIDDEN(bool) vboxNetFltWinIsLoopedBackPacketSG(PADAPT pAdapt, PINTNETSG pSG);
    839 //#else
    840 //DECLHIDDEN(bool) vboxNetFltWinIsLoopedBackPacketSG(PADAPT pAdapt, PINTNETSG pSG, bool bOnRecv);
    841 //#endif
    842 #else
     993#ifdef VBOX_LOOPBACK_USEFLAGS
    843994DECLINLINE(bool) vboxNetFltWinIsLoopedBackPacket(PNDIS_PACKET pPacket)
    844995{
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltCommon-win.h

    r22599 r23927  
    153153#define VBOX_NETFLT_PACKET_HEADER_MATCH_SIZE 24
    154154
     155#if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
     156# define VBOXNETFLT_PACKETMATCH_LENGTH (ETH_HEADER_SIZE + 2)
     157#endif
     158
    155159#ifdef VBOXNETADP
    156160#define     VBOXNETADP_HEADER_SIZE             14
     
    316320    /** miniport device state */
    317321    ADAPT_DEVICE             MPState;
    318 #ifdef DEBUG_NETFLT_LOOPBACK
    319 # error "implement (see comments in the sources below this #error:)"
    320         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    321         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    322         similar to that used in TrasferData handling should be used;
    323         */
    324     /** Pending receive packet queue (i.e. packets that were indicated to the upperlying protocols, but not completed yet)*/
    325 //    INTERLOCKED_PACKET_QUEUE                   RecvPacketQueue;
    326 #endif
    327322    /** ndis packet pool used for receives */
    328323    NDIS_HANDLE                    hRecvPacketPoolHandle;
     
    389384
    390385#ifndef VBOXNETADP
     386#if defined(DEBUG_NETFLT_LOOPBACK) || !defined(VBOX_LOOPBACK_USEFLAGS)
     387    /** used for maintaining the pending send packets for handling packet loopback */
     388    INTERLOCKED_SINGLE_LIST SendPacketQueue;
     389#endif
    391390    /** used for serializing calls to the NdisRequest in the vboxNetFltWinSynchNdisRequest */
    392391    RTSEMFASTMUTEX                 hSynchRequestMutex;
    393 
    394392    /** event used to synchronize with the Ndis Request completion in the vboxNetFltWinSynchNdisRequest */
    395393    KEVENT                         hSynchCompletionEvent;
     
    398396    /** pointer to the Ndis Request being executed by the vboxNetFltWinSynchNdisRequest */
    399397    PNDIS_REQUEST volatile         pSynchRequest;
    400 #endif
    401 #ifdef DEBUG_NETFLT_LOOPBACK
    402 # error "implement (see comments in the sources below this #error:)"
    403         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    404         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    405         similar to that used in TrasferData handling should be used;
    406         */
    407     /** Pending send packet queue (i.e. packets that were sent to the underlying miniport, but not completed yet)*/
    408 
    409     INTERLOCKED_PACKET_QUEUE                   SendPacketQueue;
    410     /** Packet info pool, i.e. the pool for the packet queue elements */
    411 #endif
    412 #ifndef VBOXNETADP
    413398    /** ndis packet pool used for sends */
    414399    NDIS_HANDLE                    hSendPacketPoolHandle;
     
    454439     * can be null if the packet was originated by intnet */
    455440    PNDIS_PACKET    pOriginalPkt;
    456 
    457441    /** pointer to the buffer to be freed on send completion
    458442     * can be null if no buffer is to be freed */
    459443    PVOID           pBufToFree;
     444#if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS)
     445    SINGLE_LIST_ENTRY ListEntry;
     446    /* true if the packet is from IntNet */
     447    bool bFromIntNet;
     448#endif
    460449} SEND_RSVD, *PSEND_RSVD;
    461450
     
    500489C_ASSERT(sizeof(UINT) == sizeof(uint32_t));
    501490
     491#ifdef VBOX_LOOPBACK_USEFLAGS
    502492#define NDIS_FLAGS_SKIP_LOOPBACK_W2K    0x400
     493#endif
    503494
    504495#include "../VBoxNetFltInternal.h"
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltMp-win.c

    r22441 r23927  
    456456    if (fStatus == NDIS_STATUS_SUCCESS)
    457457    {
    458 #ifdef DEBUG_NETFLT_LOOPBACK
    459 # error "implement (see comments in the sources below this #error:)"
    460         /* @todo FIXME no need the PPACKET_INFO mechanism here;
    461         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    462         similar to that used in TrasferData handling should be used;
    463         */
    464 //        /* need to enqueue to enable callback discarding
    465 //         * since we now always discard all callbacks */
    466 //        PPACKET_INFO pInfo = vboxNetFltWinDoSend(&fStatus, pAdapt, pMyPacket);
    467 //
    468 //        Assert(pInfo);
    469 #else
     458#if !defined(VBOX_LOOPBACK_USEFLAGS) /* || defined(DEBUG_NETFLT_PACKETS) */
     459        /* no need for the loop enqueue & check in a passthru mode , ndis will do everything for us */
     460#endif
    470461        NdisSend(&fStatus,
    471462                 pAdapt->hBindingHandle,
    472463                 pMyPacket);
    473 #endif
    474464        if (fStatus != NDIS_STATUS_PENDING)
    475465        {
    476 #ifdef DEBUG_NETFLT_LOOPBACK
    477 # error "implement (see comments in the sources below this #error:)"
    478         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    479         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    480         similar to that used in TrasferData handling should be used;
    481         */
    482 
    483 //            vboxNetFltWinDoCompleteSendViaInfo(pAdapt, pInfo);
    484 //            vboxNetFltWinPpFreePacketInfo(pInfo);
    485 #endif
    486 
    487466#ifndef WIN9X
    488467            NdisIMCopySendCompletePerPacketInfo (pPacket, pMyPacket);
     
    842821            pPacket = pPacketArray[i];
    843822
    844 #ifdef DEBUG_NETFLT_LOOPBACK
    845 # error "implement (see comments in the sources below this #error:)"
    846         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    847         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    848         similar to that used in TrasferData handling should be used;
    849         */
    850 
    851 //            if(vboxNetFltWinIsLoopedBackPacket(pAdapt, pPacket, false))
     823            if(!cNetFltRefs
     824                    || (fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_SRC_HOST)) != NDIS_STATUS_SUCCESS)
     825            {
     826#ifndef VBOXNETADP
     827                fStatus = vboxNetFltWinSendPassThru(pAdapt, pPacket);
    852828#else
    853             if(vboxNetFltWinIsLoopedBackPacket(pPacket))
     829                if(!cNetFltRefs)
     830                {
     831# ifdef VBOXNETADP_REPORT_DISCONNECTED
     832                    fStatus = NDIS_STATUS_MEDIA_DISCONNECT;
     833                    STATISTIC_INCREASE(pAdapt->cTxError);
     834# else
     835                    fStatus = NDIS_STATUS_SUCCESS;
     836# endif
     837                }
    854838#endif
    855839
    856             {
    857                 /* we should not have loopbacks on send */
    858                 Assert(0);
    859 
    860                 NdisMSendComplete(pAdapt->hMiniportHandle,
    861                                   pPacket,
    862                                   NDIS_STATUS_SUCCESS);
    863             }
    864             else
    865             {
    866                 if(!cNetFltRefs
    867                     || (fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_SRC_HOST)) != NDIS_STATUS_SUCCESS)
     840                if (fStatus != NDIS_STATUS_PENDING)
    868841                {
    869 #ifndef VBOXNETADP
    870                     fStatus = vboxNetFltWinSendPassThru(pAdapt, pPacket);
    871 #else
    872                     if(!cNetFltRefs)
    873                     {
    874 # ifdef VBOXNETADP_REPORT_DISCONNECTED
    875                         fStatus = NDIS_STATUS_MEDIA_DISCONNECT;
    876                         STATISTIC_INCREASE(pAdapt->cTxError);
    877 # else
    878                         fStatus = NDIS_STATUS_SUCCESS;
    879 # endif
    880                     }
    881 #endif
    882 
    883                     if (fStatus != NDIS_STATUS_PENDING)
    884                     {
    885                         NdisMSendComplete(pAdapt->hMiniportHandle,
     842                    NdisMSendComplete(pAdapt->hMiniportHandle,
    886843                                      pPacket,
    887844                                      fStatus);
    888                     }
    889                     else
    890                     {
    891                         cAdaptRefs--;
    892                     }
    893845                }
    894846                else
    895847                {
    896848                    cAdaptRefs--;
    897                     cNetFltRefs--;
    898849                }
     850            }
     851            else
     852            {
     853                cAdaptRefs--;
     854                cNetFltRefs--;
    899855            }
    900856        }
     
    24602416        PNDIS_PACKET    MyPacket;
    24612417        PRECV_RSVD      RecvRsvd;
    2462 #ifdef DEBUG_NETFLT_LOOPBACK
    2463 # error "implement (see comments in the sources below this #error:)"
    2464         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    2465         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    2466         similar to that used in TrasferData handling should be used;
    2467         */
    2468 
    2469 //        PPACKET_INFO pInfo = vboxNetFltWinDoCompleteIndicateReceive(pAdapt, Packet);
    2470 //
    2471 //        if(pInfo)
    2472 //        {
    2473 //            vboxNetFltWinPpFreePacketInfo(pInfo);
    2474 //        }
    2475 #endif
     2418
    24762419        RecvRsvd = (PRECV_RSVD)(Packet->MiniportReserved);
    24772420        MyPacket = RecvRsvd->pOriginalPkt;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltPt-win.c

    r22599 r23927  
    552552            /* save mac options for adaptor below us to use it with the NdisCopyLookaheadData when our ProtocolReceive is called */
    553553            pAdapt->fMacOptions = *(PULONG)NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer;
    554 
     554#ifndef VBOX_LOOPBACK_USEFLAGS
     555            /*
     556             * Remove the no-loopback bit from mac-options. In essence we are
     557             * telling NDIS that we can handle loopback. We don't, but the
     558             * interface below us does. If we do not do this, then loopback
     559             * processing happens both below us and above us. This is wasteful
     560             * at best and if Netmon is running, it will see multiple copies
     561             * of loopback packets when sniffing above us.
     562             *
     563             * Only the lowest miniport is a stack of layered miniports should
     564             * ever report this bit set to NDIS.
     565             */
     566            *(PULONG)NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer &= ~NDIS_MAC_OPTION_NO_LOOPBACK;
     567#else
    555568            /* we have to catch loopbacks from the underlying driver, so no duplications will occur,
    556569             * just indicate NDIS to handle loopbacks for the packets coming from the protocol */
    557570            *(PULONG)NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer |= NDIS_MAC_OPTION_NO_LOOPBACK;
     571#endif
    558572        }
    559573        if(Oid == OID_GEN_CURRENT_PACKET_FILTER && VBOXNETFLT_PROMISCUOUS_SUPPORTED(pAdapt))
     
    737751    {
    738752        PSEND_RSVD        SendRsvd;
    739 #ifdef DEBUG_NETFLT_LOOPBACK
    740 # error "implement (see comments in the sources below this #error:)"
    741         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    742         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    743         similar to that used in TrasferData handling should be used;
    744         */
    745 
    746 //        PPACKET_INFO pInfo = vboxNetFltWinDoCompleteSend(pAdapt, Packet);
    747 //
    748 //        if(pInfo)
    749 //        {
    750 //            vboxNetFltWinPpFreePacketInfo(pInfo);
    751 //        }
     753
     754#if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
     755        /* @todo: for optimization we could check only for netflt-mode packets
     756         * do it for all for now */
     757        vboxNetFltWinLbRemoveSendPacket(pAdapt, Packet);
    752758#endif
    753759//        Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
     
    813819    vboxNetFltWinInterlockedPutTail(pList, &pTDR->ListEntry);
    814820}
    815 
    816 #endif
    817 
    818 static bool vboxNetFltWinPtTransferDataCompleteActive(IN PADAPT pAdapt,
    819         IN PNDIS_PACKET pPacket,
    820         IN NDIS_STATUS Status)
    821 {
    822     PVBOXNETFLTINS pNetFltIf = PADAPT_2_PVBOXNETFLTINS(pAdapt);
    823     PNDIS_BUFFER pBuffer;
    824     PTRANSFERDATA_RSVD pTDR;
    825 
    826     if(!vboxNetFltWinRemovePacketFromList(&pAdapt->TransferDataList, pPacket))
    827         return false;
    828 
    829     pTDR = &((PPT_RSVD)pPacket->ProtocolReserved)->u.TransferDataRsvd;
    830     Assert(pTDR);
    831     Assert(pTDR->pOriginalBuffer);
    832 
    833     do
    834     {
    835         NdisUnchainBufferAtFront(pPacket, &pBuffer);
    836 
    837         Assert(pBuffer);
    838 
    839         NdisFreeBuffer(pBuffer);
    840 
    841         pBuffer = pTDR->pOriginalBuffer;
    842 
    843         NdisChainBufferAtBack(pPacket, pBuffer);
    844 
    845         /* data transfer was initiated when the netFlt was active
    846          * the netFlt is still retained by us
    847          * 1. check if loopback
    848          * 2. enqueue packet
    849          * 3. release netFlt */
    850 
    851         if(Status == NDIS_STATUS_SUCCESS)
    852         {
    853 
    854 #ifdef DEBUG_NETFLT_LOOPBACK
    855 # error "implement (see comments in the sources below this #error:)"
    856     /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    857     instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    858     similar to that used in TrasferData handling should be used;
    859     */
    860 
    861 //                /* 1. if loopback then quit with  NDIS_STATUS_NOT_ACCEPTED */
    862 //#ifdef VBOX_NETFLT_ONDEMAND_BIND
    863 //                if(vboxNetFltWinIsLoopedBackPacket(pAdapt, pPacket))
    864 //#else
    865 //                if(vboxNetFltWinIsLoopedBackPacket(pAdapt, pPacket, true))
    866 //#endif
    867 #else
    868             if(vboxNetFltWinIsLoopedBackPacket(pPacket))
    869 #endif
    870             {
    871                 Assert(0);
    872             }
    873             else
    874             {
    875                 PRECV_RSVD            pRecvRsvd;
    876                 /* 2. enqueue */
    877                 /* use the same packet info to put the packet in the processing packet queue */
    878 #ifdef VBOX_NETFLT_ONDEMAND_BIND
    879                 PNDIS_BUFFER pBuffer;
    880                 PVOID pVA;
    881                 UINT cbLength;
    882                 uint32_t fFlags;
    883 
    884                 NdisQueryPacket(pPacket, NULL, NULL, &pBuffer, NULL);
    885                 NdisQueryBufferSafe(pBuffer, &pVA, &cbLength, NormalPagePriority);
    886 
    887                 fFlags = MACS_EQUAL(((PRTNETETHERHDR)pVA)->SrcMac, pNetFltIf->u.s.Mac) ?
    888                                                 PACKET_MINE | PACKET_SRC_HOST : PACKET_MINE;
    889                 SET_FLAGS_TO_INFO(pInfo, fFlags);
    890 
    891                 pRecvRsvd = (PRECV_RSVD)(pPacket->MiniportReserved);
    892                 pRecvRsvd->pOriginalPkt = NULL;
    893                 pRecvRsvd->pBufToFree = NULL;
    894 
    895                 NdisSetPacketFlags(pPacket, 0);
    896 
    897                 Status = vboxNetFltWinQuEnqueuePacket(pNetFltIf, pPacket, fFlags);
    898 #else
    899                 pRecvRsvd = (PRECV_RSVD)(pPacket->MiniportReserved);
    900                 pRecvRsvd->pOriginalPkt = NULL;
    901                 pRecvRsvd->pBufToFree = NULL;
    902 
    903                 NdisSetPacketFlags(pPacket, 0);
    904 
    905                 Status = vboxNetFltWinQuEnqueuePacket(pNetFltIf, pPacket, PACKET_MINE);
    906 #endif
    907                 if(Status == NDIS_STATUS_SUCCESS)
    908                 {
    909                     break;
    910                 }
    911                 Assert(0);
    912             }
    913         }
    914         else
    915         {
    916             Assert(0);
    917         }
    918         /* we are here because of error either in data transfer or in enqueueing the packet */
    919         vboxNetFltWinFreeSGNdisPacket(pPacket, true);
    920         vboxNetFltWinDereferenceNetFlt(pNetFltIf);
    921         vboxNetFltWinDereferenceAdapt(pAdapt);
    922     } while(0);
    923 
    924     return true;
    925 }
    926 
    927 /**
    928  * Entry point called by NDIS to indicate completion of a call by us
    929  * to NdisTransferData.
    930  *
    931  * See notes under SendComplete.
    932  */
    933 static VOID
    934 vboxNetFltWinPtTransferDataComplete(
    935     IN  NDIS_HANDLE         ProtocolBindingContext,
    936     IN  PNDIS_PACKET        pPacket,
    937     IN  NDIS_STATUS         Status,
    938     IN  UINT                BytesTransferred
    939     )
    940 {
    941     PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;
    942     if(!vboxNetFltWinPtTransferDataCompleteActive(pAdapt, pPacket, Status))
    943     {
    944 #ifndef VBOX_NETFLT_ONDEMAND_BIND
    945         if(pAdapt->hMiniportHandle)
    946         {
    947             NdisMTransferDataComplete(pAdapt->hMiniportHandle,
    948                                       pPacket,
    949                                       Status,
    950                                       BytesTransferred);
    951         }
    952 
    953         vboxNetFltWinDereferenceAdapt(pAdapt);
    954 #else
    955         /* we are here because we've failed to allocate packet info */
    956         Assert(0);
    957 #endif
    958     }
    959 }
    960 #ifndef VBOX_NETFLT_ONDEMAND_BIND
    961821
    962822/**
     
    1051911}
    1052912
     913#endif
     914
     915static bool vboxNetFltWinPtTransferDataCompleteActive(IN PADAPT pAdapt,
     916        IN PNDIS_PACKET pPacket,
     917        IN NDIS_STATUS Status)
     918{
     919    PVBOXNETFLTINS pNetFltIf = PADAPT_2_PVBOXNETFLTINS(pAdapt);
     920    PNDIS_BUFFER pBuffer;
     921    PTRANSFERDATA_RSVD pTDR;
     922
     923    if(!vboxNetFltWinRemovePacketFromList(&pAdapt->TransferDataList, pPacket))
     924        return false;
     925
     926    pTDR = &((PPT_RSVD)pPacket->ProtocolReserved)->u.TransferDataRsvd;
     927    Assert(pTDR);
     928    Assert(pTDR->pOriginalBuffer);
     929
     930    do
     931    {
     932        NdisUnchainBufferAtFront(pPacket, &pBuffer);
     933
     934        Assert(pBuffer);
     935
     936        NdisFreeBuffer(pBuffer);
     937
     938        pBuffer = pTDR->pOriginalBuffer;
     939
     940        NdisChainBufferAtBack(pPacket, pBuffer);
     941
     942        /* data transfer was initiated when the netFlt was active
     943         * the netFlt is still retained by us
     944         * 1. check if loopback
     945         * 2. enqueue packet
     946         * 3. release netFlt */
     947
     948        if(Status == NDIS_STATUS_SUCCESS)
     949        {
     950
     951#ifdef VBOX_LOOPBACK_USEFLAGS
     952            if(vboxNetFltWinIsLoopedBackPacket(pPacket))
     953            {
     954                /* should not be here */
     955                Assert(0);
     956            }
     957#else
     958            PNDIS_PACKET pLb = vboxNetFltWinLbSearchLoopBack(pAdapt, pPacket, false);
     959            if(pLb)
     960            {
     961                /* should not be here */
     962                Assert(0);
     963                if(!vboxNetFltWinLbIsFromIntNet(pLb))
     964                {
     965                    /* the packet is not from int net, need to pass it up to the host */
     966                    vboxNetFltWinPtQueueReceivedPacket(pAdapt, pPacket, true);
     967                    /* dereference NetFlt, pAdapt will be dereferenced on Packet return */
     968                    vboxNetFltWinDereferenceNetFlt(pNetFltIf);
     969                    break;
     970                }
     971            }
     972#endif
     973            else
     974            {
     975                PRECV_RSVD            pRecvRsvd;
     976                /* 2. enqueue */
     977                /* use the same packet info to put the packet in the processing packet queue */
     978#ifdef VBOX_NETFLT_ONDEMAND_BIND
     979                PNDIS_BUFFER pBuffer;
     980                PVOID pVA;
     981                UINT cbLength;
     982                uint32_t fFlags;
     983
     984                NdisQueryPacket(pPacket, NULL, NULL, &pBuffer, NULL);
     985                NdisQueryBufferSafe(pBuffer, &pVA, &cbLength, NormalPagePriority);
     986
     987                fFlags = MACS_EQUAL(((PRTNETETHERHDR)pVA)->SrcMac, pNetFltIf->u.s.Mac) ?
     988                                                PACKET_MINE | PACKET_SRC_HOST : PACKET_MINE;
     989                SET_FLAGS_TO_INFO(pInfo, fFlags);
     990
     991                pRecvRsvd = (PRECV_RSVD)(pPacket->MiniportReserved);
     992                pRecvRsvd->pOriginalPkt = NULL;
     993                pRecvRsvd->pBufToFree = NULL;
     994
     995                NdisSetPacketFlags(pPacket, 0);
     996
     997                Status = vboxNetFltWinQuEnqueuePacket(pNetFltIf, pPacket, fFlags);
     998#else
     999                VBOXNETFLT_LBVERIFY(pNetFltIf, pPacket);
     1000
     1001                pRecvRsvd = (PRECV_RSVD)(pPacket->MiniportReserved);
     1002                pRecvRsvd->pOriginalPkt = NULL;
     1003                pRecvRsvd->pBufToFree = NULL;
     1004
     1005                NdisSetPacketFlags(pPacket, 0);
     1006
     1007                Status = vboxNetFltWinQuEnqueuePacket(pNetFltIf, pPacket, PACKET_MINE);
     1008#endif
     1009                if(Status == NDIS_STATUS_SUCCESS)
     1010                {
     1011                    break;
     1012                }
     1013                Assert(0);
     1014            }
     1015        }
     1016        else
     1017        {
     1018            Assert(0);
     1019        }
     1020        /* we are here because of error either in data transfer or in enqueueing the packet */
     1021        vboxNetFltWinFreeSGNdisPacket(pPacket, true);
     1022        vboxNetFltWinDereferenceNetFlt(pNetFltIf);
     1023        vboxNetFltWinDereferenceAdapt(pAdapt);
     1024    } while(0);
     1025
     1026    return true;
     1027}
     1028
     1029/**
     1030 * Entry point called by NDIS to indicate completion of a call by us
     1031 * to NdisTransferData.
     1032 *
     1033 * See notes under SendComplete.
     1034 */
     1035static VOID
     1036vboxNetFltWinPtTransferDataComplete(
     1037    IN  NDIS_HANDLE         ProtocolBindingContext,
     1038    IN  PNDIS_PACKET        pPacket,
     1039    IN  NDIS_STATUS         Status,
     1040    IN  UINT                BytesTransferred
     1041    )
     1042{
     1043    PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;
     1044    if(!vboxNetFltWinPtTransferDataCompleteActive(pAdapt, pPacket, Status))
     1045    {
     1046#ifndef VBOX_NETFLT_ONDEMAND_BIND
     1047        if(pAdapt->hMiniportHandle)
     1048        {
     1049            NdisMTransferDataComplete(pAdapt->hMiniportHandle,
     1050                                      pPacket,
     1051                                      Status,
     1052                                      BytesTransferred);
     1053        }
     1054
     1055        vboxNetFltWinDereferenceAdapt(pAdapt);
     1056#else
     1057        /* we are here because we've failed to allocate packet info */
     1058        Assert(0);
     1059#endif
     1060    }
     1061}
     1062#ifndef VBOX_NETFLT_ONDEMAND_BIND
    10531063/**
    10541064 * This routine process the queued the packet, if anything is fine, indicate the packet
     
    12931303
    12941304#ifndef DEBUG_NETFLT_RECV_TRANSFERDATA
    1295         /* can check for loopback? check it*/
    12961305        if (cbPacket == cbLookaheadBuffer)
    12971306        {
     
    12991308            PINTNETSG pSG;
    13001309            PUCHAR pRcvData;
    1301 
    1302 #ifdef DEBUG_NETFLT_LOOPBACK
    1303                 /* TODO: can we check for loopback here ?
    1304                  * for now just get the complete SG and then decide if it is a loopback one */
    1305                 /* if loopback then quit */
    1306 #endif
    1307                 /* allocate SG buffer */
    1308                 Status = vboxNetFltWinAllocSG(cbPacket + cbHeaderBuffer, &pSG);
    1309                 if(Status != NDIS_STATUS_SUCCESS)
    1310                 {
    1311                     Assert(0);
    1312                     break;
    1313                 }
    1314 
    1315                 pRcvData = (PUCHAR)pSG->aSegs[0].pv;
    1316 
    1317                 NdisMoveMappedMemory(pRcvData, pHeaderBuffer, cbHeaderBuffer);
    1318 
    1319                 NdisCopyLookaheadData(pRcvData+cbHeaderBuffer,
     1310#ifndef VBOX_LOOPBACK_USEFLAGS
     1311            PNDIS_PACKET pLb;
     1312#endif
     1313
     1314            /* allocate SG buffer */
     1315            Status = vboxNetFltWinAllocSG(cbPacket + cbHeaderBuffer, &pSG);
     1316            if(Status != NDIS_STATUS_SUCCESS)
     1317            {
     1318                Assert(0);
     1319                break;
     1320            }
     1321
     1322            pRcvData = (PUCHAR)pSG->aSegs[0].pv;
     1323
     1324            NdisMoveMappedMemory(pRcvData, pHeaderBuffer, cbHeaderBuffer);
     1325
     1326            NdisCopyLookaheadData(pRcvData+cbHeaderBuffer,
    13201327                                                  pLookaheadBuffer,
    13211328                                                  cbLookaheadBuffer,
    13221329                                                  pAdapt->fMacOptions);
    1323 #ifdef DEBUG_NETFLT_LOOPBACK
    1324 # error "implement (see comments in the sources below this #error:)"
    1325         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    1326         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    1327         similar to that used in TrasferData handling should be used;
    1328         */
    1329 
    1330 //                /* check if it is a loopback */
    1331 //# ifdef VBOX_NETFLT_ONDEMAND_BIND
    1332 //                if(vboxNetFltWinIsLoopedBackPacketSG(pAdapt, pSG))
    1333 //# else
    1334 //                if(vboxNetFltWinIsLoopedBackPacketSG(pAdapt, pSG, true))
    1335 //# endif
    1336 //                {
    1337 //                    Assert(0);
    1338 //                    vboxNetFltWinMemFree(pSG);
    1339 //                    Status = NDIS_STATUS_NOT_ACCEPTED;
    1340 //                    break;
    1341 //                }
    1342 #endif
     1330#ifndef VBOX_LOOPBACK_USEFLAGS
     1331            pLb = vboxNetFltWinLbSearchLoopBackBySG(pAdapt, pSG, false);
     1332            if(pLb)
     1333            {
     1334                /* should not be here */
     1335                Assert(0);
     1336
     1337                if(!vboxNetFltWinLbIsFromIntNet(pLb))
     1338                {
     1339                    PNDIS_PACKET pMyPacket;
     1340                    pMyPacket = vboxNetFltWinNdisPacketFromSG(pAdapt, /* PADAPT */
     1341                        pSG, /* PINTNETSG */
     1342                        pSG, /* PVOID pBufToFree */
     1343                        false, /* bool bToWire */
     1344                        false); /* bool bCopyMemory */
     1345                    if(pMyPacket)
     1346                    {
     1347                        vboxNetFltWinPtQueueReceivedPacket(pAdapt, pMyPacket, true);
     1348                        /* dereference the NetFlt here & indicate SUCCESS, which would mean the caller would not do a dereference
     1349                         * the pAdapt dereference will be done on packet return */
     1350                        vboxNetFltWinDereferenceNetFlt(pNetFlt);
     1351                        Status = NDIS_STATUS_SUCCESS;
     1352                    }
     1353                    else
     1354                    {
     1355                        vboxNetFltWinMemFree(pSG);
     1356                        Status = NDIS_STATUS_FAILURE;
     1357                    }
     1358                }
     1359                else
     1360                {
     1361                    vboxNetFltWinMemFree(pSG);
     1362                    Status = NDIS_STATUS_NOT_ACCEPTED;
     1363                }
     1364                break;
     1365            }
     1366#endif
     1367            VBOXNETFLT_LBVERIFYSG(pNetFlt, pSG);
     1368
    13431369                /* enqueue SG */
    13441370#ifdef VBOX_NETFLT_ONDEMAND_BIND
     
    13491375                }
    13501376#else
    1351                 Status = vboxNetFltWinQuEnqueuePacket(pNetFlt, pSG, PACKET_SG | PACKET_MINE);
    1352 #endif
    1353                 if(Status != NDIS_STATUS_SUCCESS)
    1354                 {
    1355                     Assert(0);
    1356                     vboxNetFltWinMemFree(pSG);
    1357                     break;
    1358                 }
     1377            Status = vboxNetFltWinQuEnqueuePacket(pNetFlt, pSG, PACKET_SG | PACKET_MINE);
     1378#endif
     1379            if(Status != NDIS_STATUS_SUCCESS)
     1380            {
     1381                Assert(0);
     1382                vboxNetFltWinMemFree(pSG);
     1383                break;
     1384            }
    13591385        }
    13601386        else
     
    13661392            PUCHAR pMemBuf;
    13671393            UINT cbBuf = cbPacket + cbHeaderBuffer;
    1368 //            PPACKET_INFO pInfo;
    13691394            UINT                    BytesTransferred;
    1370                 /* TODO: can check for loopback here ? */
    1371                 /* for now just get the complete complete packet and then decide if it is a looped back one */
    1372                 /* if loopback then quit with  NDIS_STATUS_NOT_ACCEPTED
    1373                  * {
    1374                  *     Status = NDIS_STATUS_NOT_ACCEPTED;
    1375                  *     break;
    1376                  * }
    1377                  * */
    1378 
    1379                 /* allocate NDIS Packet buffer */
     1395
     1396            /* allocate NDIS Packet buffer */
    13801397#ifdef VBOX_NETFLT_ONDEMAND_BIND
    13811398            /* use the Send packet pool for packet allocation */
     
    13901407            }
    13911408
     1409#ifdef VBOX_LOOPBACK_USEFLAGS
    13921410            /* set "don't loopback" flags */
    13931411            NdisSetPacketFlags(pPacket, g_fPacketDontLoopBack);
     1412#endif
    13941413
    13951414            Status = vboxNetFltWinMemAlloc(&pMemBuf, cbBuf);
     
    16031622                do
    16041623                {
    1605 #ifdef DEBUG_NETFLT_LOOPBACK
    1606 # error "implement (see comments in the sources below this #error:)"
    1607         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    1608         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    1609         similar to that used in TrasferData handling should be used;
    1610         */
    1611 
    1612 //                    if(vboxNetFltWinIsLoopedBackPacket(pAdapt, pPacket, true))
    1613 #else
     1624#ifdef VBOX_LOOPBACK_USEFLAGS
    16141625                    if(vboxNetFltWinIsLoopedBackPacket(pPacket))
    1615 #endif
    1616 
    16171626                    {
    16181627                        Assert(0);
     
    16231632                    }
    16241633
     1634                    VBOXNETFLT_LBVERIFY(pNetFlt, pPacket);
     1635#else
     1636                    PNDIS_PACKET pLb = NULL;
     1637#endif
    16251638                    if(bNetFltActive)
    16261639                    {
    1627                         Status = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_COPY);
    1628                         if(Status == NDIS_STATUS_SUCCESS)
     1640#ifndef VBOX_LOOPBACK_USEFLAGS
     1641                        pLb = vboxNetFltWinLbSearchLoopBack(pAdapt, pPacket, true /* ??? no need to keep it, so remove */);
     1642                        if(!pLb)
     1643#endif
    16291644                        {
     1645                            VBOXNETFLT_LBVERIFY(pNetFlt, pPacket);
     1646
     1647                            Status = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_COPY);
     1648                            Assert(Status == NDIS_STATUS_SUCCESS);
     1649                            if(Status == NDIS_STATUS_SUCCESS)
     1650                            {
     1651                                //NdisReturnPackets(&pPacket, 1);
     1652                                fAdaptActive = false;
     1653                                bNetFltActive = false;
     1654                                break;
     1655                            }
     1656                        }
     1657#ifndef VBOX_LOOPBACK_USEFLAGS
     1658                        else if(vboxNetFltWinLbIsFromIntNet(pLb))
     1659                        {
     1660                            /* nothing else to do here, just return the packet */
    16301661                            //NdisReturnPackets(&pPacket, 1);
    1631                             fAdaptActive = false;
    1632                             bNetFltActive = false;
     1662                            Status = NDIS_STATUS_NOT_ACCEPTED;
    16331663                            break;
    16341664                        }
     1665                        /* we are here because this is a looped back packet set not from intnet
     1666                         * we will post it to the upper protocol */
     1667#endif
    16351668                    }
    16361669
     1670#ifndef VBOX_LOOPBACK_USEFLAGS
     1671                    Assert(pLb && !vboxNetFltWinLbIsFromIntNet(pLb));
     1672#endif
    16371673                    Status = vboxNetFltWinRecvPassThru(pAdapt, pPacket);
    16381674                    /* we are done with packet processing, and we will
     
    16421678                } while(FALSE);
    16431679
    1644                 if(Status == NDIS_STATUS_SUCCESS || Status == NDIS_STATUS_NOT_ACCEPTED)
     1680                if(Status == NDIS_STATUS_SUCCESS || Status == NDIS_STATUS_NOT_ACCEPTED
     1681#ifndef VBOX_LOOPBACK_USEFLAGS
     1682                        || pLb
     1683#endif
     1684                        )
    16451685                {
    16461686                    break;
    16471687                }
    16481688            }
    1649 #endif /* todo: remove */
     1689#endif
    16501690            if(bNetFltActive)
    16511691            {
     
    16611701                    else
    16621702                    {
     1703#ifndef VBOX_LOOPBACK_USEFLAGS
    16631704                        /* this is a loopback packet, nothing to do here */
     1705#else
     1706                        Assert(0);
     1707                        /* should not be here */
     1708#endif
    16641709                    }
    16651710                    break;
     
    18951940        do
    18961941        {
    1897 #ifdef DEBUG_NETFLT_LOOPBACK
    1898 # error "implement (see comments in the sources below this #error:)"
    1899         /* @todo FIXME no need for the PPACKET_INFO mechanism here;
    1900         instead the the NDIS_PACKET.ProtocolReserved + INTERLOCKED_SINGLE_LIST mechanism \
    1901         similar to that used in TrasferData handling should be used;
    1902         */
    1903 
    1904 //            if(vboxNetFltWinIsLoopedBackPacket(pAdapt, pPacket, true))
    1905 #else
     1942#ifdef VBOX_LOOPBACK_USEFLAGS
    19061943            if(vboxNetFltWinIsLoopedBackPacket(pPacket))
    1907 #endif
    1908 
    19091944            {
    19101945                Assert(0);
     
    19171952            }
    19181953
     1954            VBOXNETFLT_LBVERIFY(pNetFlt, pPacket);
     1955#endif
     1956
    19191957            if(bNetFltActive)
    19201958            {
    1921                 bool bResources = NDIS_GET_PACKET_STATUS(pPacket) == NDIS_STATUS_RESOURCES;
    1922                 NDIS_STATUS fStatus;
    1923 
    1924                 /*TODO: remove this assert.
    1925                  * this is a temporary assert for debugging purposes:
    1926                  * we're probably doing something wrong with the packets if the miniport reports NDIS_STATUS_RESOURCES */
    1927                 Assert(!bResources);
    1928 
    1929                 fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, bResources ? PACKET_COPY : 0);
    1930                 if(fStatus == NDIS_STATUS_SUCCESS)
     1959#ifndef VBOX_LOOPBACK_USEFLAGS
     1960                PNDIS_PACKET pLb = vboxNetFltWinLbSearchLoopBack(pAdapt, pPacket, true /* ??? no need to keep it, so remove */);
     1961                if(!pLb)
     1962#endif
    19311963                {
    1932                     bNetFltActive = false;
    1933                     fAdaptActive = false;
    1934                     if(bResources)
     1964                    NDIS_STATUS fStatus;
     1965                    bool bResources = NDIS_GET_PACKET_STATUS(pPacket) == NDIS_STATUS_RESOURCES;
     1966
     1967                    VBOXNETFLT_LBVERIFY(pNetFlt, pPacket);
     1968
     1969                    /*TODO: remove this assert.
     1970                     * this is a temporary assert for debugging purposes:
     1971                     * we're probably doing something wrong with the packets if the miniport reports NDIS_STATUS_RESOURCES */
     1972                    Assert(!bResources);
     1973
     1974                    fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, bResources ? PACKET_COPY : 0);
     1975                    if(fStatus == NDIS_STATUS_SUCCESS)
    19351976                    {
    1936                         cRefCount = 0;
    1937                         //NdisReturnPackets(&pPacket, 1);
     1977                        bNetFltActive = false;
     1978                        fAdaptActive = false;
     1979                        if(bResources)
     1980                        {
     1981                            cRefCount = 0;
     1982                            //NdisReturnPackets(&pPacket, 1);
     1983                        }
     1984                        else
     1985                        {
     1986                            cRefCount = 1;
     1987                        }
     1988                        break;
    19381989                    }
    19391990                    else
    19401991                    {
    1941                         cRefCount = 1;
     1992                        Assert(0);
    19421993                    }
     1994                }
     1995#ifndef VBOX_LOOPBACK_USEFLAGS
     1996                else if(vboxNetFltWinLbIsFromIntNet(pLb))
     1997                {
     1998                    /* the packet is from intnet, it has already been set to the host,
     1999                     * no need for loopng it back to the host again */
     2000                    /* nothing else to do here, just return the packet */
     2001                    cRefCount = 0;
     2002                    //NdisReturnPackets(&pPacket, 1);
    19432003                    break;
    19442004                }
    1945                 else
    1946                 {
    1947                     Assert(0);
    1948                 }
     2005#endif
    19492006            }
    19502007
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r23641 r23927  
    111111    AssertReturn(pvPageCpu, VERR_INVALID_PARAMETER);
    112112
    113 #if defined(LOG_ENABLED) && !defined(DEBUG_bird)
     113#if defined(LOG_ENABLED) && !defined(DEBUG_bird) && !defined(DEBUG_misha)
    114114    SUPR0Printf("VMXR0EnableCpu cpu %d page (%x) %x\n", pCpu->idCpu, pvPageCpu, (uint32_t)pPageCpuPhys);
    115115#endif
     
    158158    ASMSetCR4(ASMGetCR4() & ~X86_CR4_VMXE);
    159159
    160 #if defined(LOG_ENABLED) && !defined(DEBUG_bird)
     160#if defined(LOG_ENABLED) && !defined(DEBUG_bird) && !defined(DEBUG_misha)
    161161    SUPR0Printf("VMXR0DisableCpu cpu %d\n", pCpu->idCpu);
    162162#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette