VirtualBox

Ignore:
Timestamp:
Nov 16, 2010 11:02:14 AM (14 years ago)
Author:
vboxsync
Message:

NetFlt/win: rx path fixs

Location:
trunk/src/VBox/HostDrivers/VBoxNetFlt/win
Files:
4 edited

Legend:

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

    r33540 r34102  
    23012301    }
    23022302
    2303 
    23042303    FINI_INTERLOCKED_SINGLE_LIST(&pAdapt->TransferDataList);
    23052304# if defined(DEBUG_NETFLT_LOOPBACK) || !defined(VBOX_LOOPBACK_USEFLAGS)
     
    24532452        }
    24542453#endif
    2455 
    24562454        /* moved to vboxNetFltOsInitInstance */
    24572455    } while(0);
     
    35423540        if (pPacket)
    35433541        {
     3542#ifdef VBOXNETADP
    35443543            NdisMIndicateReceivePacket(pAdapt->hMiniportHandle, &pPacket, 1);
     3544#else
     3545            /* flush any packets currently queued */
     3546            vboxNetFltWinPtQueueReceivedPacket(pAdapt, pPacket, TRUE /* BOOLEAN DoIndicate */);
     3547#endif
    35453548            cRefs--;
    35463549#ifdef VBOXNETADP
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltCommon-win.h

    r33540 r34102  
    334334#ifndef VBOXNETADP
    335335    /** true if we should indicate the receive complete used by the ProtocolReceeive mechanism */
    336     bool                        bIndicateRcvComplete;
     336    bool                        abIndicateRcvComplete[64];
    337337
    338338    /** TRUE iff a request is pending at the miniport below */
     
    366366    /** number of packets in the aReceivedPackets array*/
    367367    ULONG                          cReceivedPacketCount;
    368     /** flag indicating whether rx packet queueing is allowed */
    369     BOOLEAN                        bIsReceivePacketQueueingDisabled;
    370368    /** packet filter flags set by the upper protocols */
    371369    ULONG                          fUpperProtocolSetFilter;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltPt-win.c

    r33540 r34102  
    328328
    329329        pAdapt->cReceivedPacketCount = 0;
    330         /* reset the value in case */
    331         pAdapt->bIsReceivePacketQueueingDisabled = FALSE;
    332330        ReturnPackets = TRUE;
    333331    }
     
    836834 * @return NONE
    837835 */
    838 static VOID
    839 vboxNetFltWinPtQueueReceivedPacket(
     836DECLHIDDEN(VOID) vboxNetFltWinPtQueueReceivedPacket(
    840837    IN PADAPT       pAdapt,
    841838    IN PNDIS_PACKET Packet,
     
    849846    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    850847
    851     Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
    852848    do{
    853849        RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     
    878874         */
    879875
    880         if ((pAdapt->cReceivedPacketCount == MAX_RECEIVE_PACKET_ARRAY_SIZE) || DoIndicate || bReturn
    881                 || pAdapt->bIsReceivePacketQueueingDisabled)
     876        if ((pAdapt->cReceivedPacketCount == MAX_RECEIVE_PACKET_ARRAY_SIZE) || DoIndicate || bReturn)
    882877        {
    883878            NdisMoveMemory(PacketArray,
     
    894889            {
    895890                DoIndicate = TRUE;
    896                 pAdapt->bIsReceivePacketQueueingDisabled = TRUE;
    897891            }
    898892        }
     
    904898        if(DoIndicate)
    905899        {
    906             /* the tcp stack can send ACK packets right in the context of its PtReceive for this packet,
    907              * and those (tcp-sent) packets can be looped back again.
    908              * If this happens there is a possibility that new RX packets are received by us
    909              * after we do this NdisMIndicateReceivePacket and before we do a new NdisMIndicateReceivePacket
    910              * for the looped back tcp-sent packet.
    911              * If we queue those newly received packets and indicate them together with the looped back packet
    912              * with the latter NdisMIndicateReceivePacket, we may end up tcp stack sending ACKs in the context of its PtReceive again.
    913              * Thus this may lead to stack overflows on a heavy network loads.
    914              * To prevent this we disable the RX packet queuing when we do NdisMIndicateReceivePacket here,
    915              * thus if new packets arrive to us in another thread, we simply indicate them up instead of queuing them.
    916              * */
    917             Assert(pAdapt->bIsReceivePacketQueueingDisabled);
    918900            NdisMIndicateReceivePacket(pAdapt->hMiniportHandle, PacketArray, NumberOfPackets);
    919             RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
    920             pAdapt->bIsReceivePacketQueueingDisabled = FALSE;
    921             RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
    922901        }
    923902    }
     
    18201799            Assert(fAdaptActive);
    18211800
    1822             pAdapt->bIndicateRcvComplete = TRUE;
    1823             switch (pAdapt->Medium)
    1824             {
    1825                 case NdisMedium802_3:
    1826                 case NdisMediumWan:
    1827                     NdisMEthIndicateReceive(pAdapt->hMiniportHandle,
    1828                                                  MacReceiveContext,
    1829                                                  (PCHAR)pHeaderBuffer,
    1830                                                  cbHeaderBuffer,
    1831                                                  pLookAheadBuffer,
    1832                                                  cbLookAheadBuffer,
    1833                                                  cbPacket);
    1834                     break;
    1835                 default:
    1836                     Assert(FALSE);
    1837                     break;
     1801            {
     1802                ULONG Proc = KeGetCurrentProcessorNumber();
     1803                pAdapt->abIndicateRcvComplete[Proc] = TRUE;
     1804                switch (pAdapt->Medium)
     1805                {
     1806                    case NdisMedium802_3:
     1807                    case NdisMediumWan:
     1808                        NdisMEthIndicateReceive(pAdapt->hMiniportHandle,
     1809                                                     MacReceiveContext,
     1810                                                     (PCHAR)pHeaderBuffer,
     1811                                                     cbHeaderBuffer,
     1812                                                     pLookAheadBuffer,
     1813                                                     cbLookAheadBuffer,
     1814                                                     cbPacket);
     1815                        break;
     1816                    default:
     1817                        Assert(FALSE);
     1818                        break;
     1819                }
    18381820            }
    18391821        } while(0);
     
    18821864    bool bNetFltActive;
    18831865    bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt(pNetFlt, pAdapt, &bNetFltActive);
     1866    ULONG Proc = KeGetCurrentProcessorNumber();
    18841867
    18851868    vboxNetFltWinPtFlushReceiveQueue(pAdapt, false);
     
    18871870    if ((pAdapt->hMiniportHandle != NULL)
    18881871               /* && (pAdapt->MPDeviceState == NdisDeviceStateD0) */
    1889                 && (pAdapt->bIndicateRcvComplete == TRUE))
     1872                && (pAdapt->abIndicateRcvComplete[Proc] == TRUE))
    18901873    {
    18911874        switch (pAdapt->Medium)
     
    19011884    }
    19021885
    1903     pAdapt->bIndicateRcvComplete = FALSE;
     1886    pAdapt->abIndicateRcvComplete[Proc] = FALSE;
    19041887
    19051888    if(fAdaptActive)
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltPt-win.h

    r28800 r34102  
    3030DECLHIDDEN(NDIS_STATUS) vboxNetFltWinPtDoUnbinding(PADAPT pAdapt, bool bOnUnbind);
    3131DECLHIDDEN(VOID) vboxNetFltWinPtFlushReceiveQueue(IN PADAPT pAdapt, IN bool bReturn);
     32DECLHIDDEN(VOID) vboxNetFltWinPtQueueReceivedPacket(IN PADAPT pAdapt, IN PNDIS_PACKET Packet, IN BOOLEAN DoIndicate);
    3233DECLHIDDEN(VOID) vboxNetFltWinPtRequestComplete(IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_REQUEST NdisRequest, IN NDIS_STATUS Status);
    3334DECLHIDDEN(bool) vboxNetFltWinPtCloseAdapter(PADAPT pAdapt, PNDIS_STATUS pStatus);
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