Changeset 22441 in vbox
- Timestamp:
- Aug 25, 2009 3:38:53 PM (15 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h
r20374 r22441 195 195 /** Filter driver device context. */ 196 196 ADAPT IfAdaptor; 197 /** since the driver is able to work in different modes (NetFlt or PassThru) 198 * we need to wait for the old-mode operations to complete before switching to the new mode 199 * The most trickiest here is NetFlt->PassThru switch as we can not block in PtSent/Receive 200 * because they typically run at DPC level 201 * we also not allowed to re-order packets, so on NetFlt-PassThru switch (kVBoxNetDevMode_NetFltDeinitializing mode) 202 * we put them to the pending queue to process them in order on final mode activation stage */ 203 volatile VBOXNETDEVMODE_TYPE enmModeMP; 204 volatile VBOXNETDEVMODE_TYPE enmModePT; 205 volatile uint32_t cModeNetFltRefs; 206 volatile uint32_t cModePassThruRefs; 207 197 208 /** Packet worker thread info */ 198 209 PACKET_QUEUE_WORKER PacketQueueWorker; -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.c
r21904 r22441 157 157 DBGPRINT(("device not idle")); 158 158 Assert(0); 159 break;159 // break; 160 160 } 161 161 #endif … … 3490 3490 #endif 3491 3491 PADAPT pAdapt = PVBOXNETFLTINS_2_PADAPT(pThis); 3492 3493 /* we first wait for all pending ops to complete 3494 * this might include all packets queued for processing */ 3495 for(;;) 3496 { 3497 if(fActive) 3498 { 3499 if(!pThis->u.s.cModePassThruRefs) 3500 { 3501 break; 3502 } 3503 } 3504 else 3505 { 3506 if(!pThis->u.s.cModeNetFltRefs) 3507 { 3508 break; 3509 } 3510 } 3511 vboxNetFltWinSleep(2); 3512 } 3513 3492 3514 if(!vboxNetFltWinReferenceAdapt(pAdapt)) 3493 return; 3494 3495 #ifndef VBOXNETADP 3496 # ifndef VBOX_NETFLT_ONDEMAND_BIND 3497 if(fActive) 3498 { 3499 /* 3500 * flush any pass-thru receive-queued packets 3501 */ 3502 vboxNetFltWinPtFlushReceiveQueue(pAdapt, false /*fReturn*/); 3503 } 3504 # endif 3505 3515 return; 3516 #ifndef VBOXNETADP 3517 3518 /* the packets put to ReceiveQueue Array are currently not holding the references, 3519 * simply need to flush them */ 3520 vboxNetFltWinPtFlushReceiveQueue(pAdapt, false /*fReturn*/); 3506 3521 3507 3522 if(fActive) … … 3671 3686 { 3672 3687 PADAPT pAdapt = PVBOXNETFLTINS_2_PADAPT(pThis); 3688 pThis->u.s.cModeNetFltRefs = 0; 3689 pThis->u.s.cModePassThruRefs = 0; 3673 3690 vboxNetFltWinSetAdaptState(pAdapt, kVBoxAdaptState_Disconnected); 3674 3691 vboxNetFltWinSetOpState(&pAdapt->MPState, kVBoxNetDevOpState_Deinitialized); -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.h
r21343 r22441 305 305 DECLHIDDEN(void) vboxNetFltWinWaitDereference(PADAPT_DEVICE pState); 306 306 307 DECLINLINE(void) vboxNetFltWinReferenceModeNetFlt(PVBOXNETFLTINS pIns) 308 { 309 ASMAtomicIncU32((volatile uint32_t *)&pIns->u.s.cModeNetFltRefs); 310 } 311 312 DECLINLINE(void) vboxNetFltWinReferenceModePassThru(PVBOXNETFLTINS pIns) 313 { 314 ASMAtomicIncU32((volatile uint32_t *)&pIns->u.s.cModePassThruRefs); 315 } 316 317 DECLINLINE(void) vboxNetFltWinIncReferenceModeNetFlt(PVBOXNETFLTINS pIns, uint32_t v) 318 { 319 ASMAtomicAddU32((volatile uint32_t *)&pIns->u.s.cModeNetFltRefs, v); 320 } 321 322 DECLINLINE(void) vboxNetFltWinIncReferenceModePassThru(PVBOXNETFLTINS pIns, uint32_t v) 323 { 324 ASMAtomicAddU32((volatile uint32_t *)&pIns->u.s.cModePassThruRefs, v); 325 } 326 327 DECLINLINE(void) vboxNetFltWinDereferenceModeNetFlt(PVBOXNETFLTINS pIns) 328 { 329 ASMAtomicDecU32((volatile uint32_t *)&pIns->u.s.cModeNetFltRefs); 330 } 331 332 DECLINLINE(void) vboxNetFltWinDereferenceModePassThru(PVBOXNETFLTINS pIns) 333 { 334 ASMAtomicDecU32((volatile uint32_t *)&pIns->u.s.cModePassThruRefs); 335 } 336 337 DECLINLINE(void) vboxNetFltWinDecReferenceModeNetFlt(PVBOXNETFLTINS pIns, uint32_t v) 338 { 339 Assert(v); 340 ASMAtomicAddU32((volatile uint32_t *)&pIns->u.s.cModeNetFltRefs, (uint32_t)(-((int32_t)v))); 341 } 342 343 DECLINLINE(void) vboxNetFltWinDecReferenceModePassThru(PVBOXNETFLTINS pIns, uint32_t v) 344 { 345 Assert(v); 346 ASMAtomicAddU32((volatile uint32_t *)&pIns->u.s.cModePassThruRefs, (uint32_t)(-((int32_t)v))); 347 } 348 307 349 DECLINLINE(void) vboxNetFltWinSetPowerState(PADAPT_DEVICE pState, NDIS_DEVICE_POWER_STATE State) 308 350 { … … 374 416 DECLINLINE(void) vboxNetFltWinDecReferenceDevice(PADAPT pAdapt, PADAPT_DEVICE pState, uint32_t v) 375 417 { 418 Assert(v); 376 419 ASMAtomicAddU32((uint32_t volatile *)&pState->cReferences, (uint32_t)(-((int32_t)v))); 377 420 } … … 387 430 DECLINLINE(bool) vboxNetFltWinDoIncReferenceDevice(PADAPT pAdapt, PADAPT_DEVICE pState, uint32_t v) 388 431 { 432 Assert(v); 389 433 if (vboxNetFltWinGetPowerState(pState) == NdisDeviceStateD0 && vboxNetFltWinGetOpState(pState) == kVBoxNetDevOpState_Initialized) 390 434 { … … 439 483 } 440 484 #else 441 DECLINLINE(bool) vboxNetFltWinReferenceAdaptNetFlt FromAdapt(PADAPT pAdapt, PVBOXNETFLTINS *ppNetFlt)485 DECLINLINE(bool) vboxNetFltWinReferenceAdaptNetFlt(PVBOXNETFLTINS pNetFlt, PADAPT pAdapt, bool * pbNetFltActive) 442 486 { 443 487 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 444 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt);445 488 446 489 RTSpinlockAcquire((pNetFlt)->hSpinlock, &Tmp); … … 452 495 { 453 496 RTSpinlockRelease((pNetFlt)->hSpinlock, &Tmp); 454 *p pNetFlt = NULL;497 *pbNetFltActive = false; 455 498 return false; 456 499 } … … 458 501 if(!ASMAtomicUoReadBool(&(pNetFlt)->fActive)) 459 502 { 503 vboxNetFltWinReferenceModePassThru(pNetFlt); 460 504 RTSpinlockRelease((pNetFlt)->hSpinlock, &Tmp); 461 *p pNetFlt = NULL;505 *pbNetFltActive = false; 462 506 return true; 463 507 } 464 508 465 509 vboxNetFltRetain((pNetFlt), true /* fBusy */); 466 510 vboxNetFltWinReferenceModeNetFlt(pNetFlt); 467 511 RTSpinlockRelease((pNetFlt)->hSpinlock, &Tmp); 468 512 469 *p pNetFlt = pNetFlt;513 *pbNetFltActive = true; 470 514 return true; 471 515 } … … 513 557 } 514 558 #else 515 DECLINLINE(bool) vboxNetFltWinIncReferenceAdaptNetFlt FromAdapt(PADAPT pAdapt, PVBOXNETFLTINS *ppNetFlt, uint32_t v)559 DECLINLINE(bool) vboxNetFltWinIncReferenceAdaptNetFlt(PVBOXNETFLTINS pNetFlt, PADAPT pAdapt, uint32_t v, bool *pbNetFltActive) 516 560 { 517 561 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 518 562 uint32_t i; 519 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt);520 563 521 564 Assert(v); 522 565 if(!v) 523 566 { 524 *p pNetFlt = NULL;567 *pbNetFltActive = false; 525 568 return false; 526 569 } … … 534 577 { 535 578 RTSpinlockRelease(pNetFlt->hSpinlock, &Tmp); 536 *p pNetFlt = NULL;579 *pbNetFltActive = false; 537 580 return false; 538 581 } … … 540 583 if(!ASMAtomicUoReadBool(&(pNetFlt)->fActive)) 541 584 { 585 vboxNetFltWinIncReferenceModePassThru(pNetFlt, v); 586 542 587 RTSpinlockRelease((pNetFlt)->hSpinlock, &Tmp); 543 *p pNetFlt = NULL;588 *pbNetFltActive = false; 544 589 return true; 545 590 } 546 591 547 592 vboxNetFltRetain(pNetFlt, true /* fBusy */); 593 594 vboxNetFltWinIncReferenceModeNetFlt(pNetFlt, v); 595 548 596 RTSpinlockRelease(pNetFlt->hSpinlock, &Tmp); 549 597 … … 554 602 } 555 603 556 *p pNetFlt = pNetFlt;604 *pbNetFltActive = true; 557 605 558 606 return true; … … 568 616 vboxNetFltRelease(pNetFlt, true); 569 617 } 618 619 vboxNetFltWinDecReferenceModeNetFlt(pNetFlt, n); 570 620 } 571 621 … … 573 623 { 574 624 vboxNetFltRelease(pNetFlt, true); 625 626 vboxNetFltWinDereferenceModeNetFlt(pNetFlt); 575 627 } 576 628 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltCommon-win.h
r21343 r22441 298 298 } ADAPT_DEVICE, *PADAPT_DEVICE; 299 299 300 301 typedef enum VBOXNETDEVMODE_TYPE 302 { 303 kVBoxNetDevMode_InvalidValue = 0, 304 kVBoxNetDevMode_NetFltInitializing, 305 kVBoxNetDevMode_NetFltInitialized, 306 kVBoxNetDevMode_NetFltDeinitializing, 307 kVBoxNetDevMode_NetFltWaitDeinitialized, 308 kVBoxNetDevMode_NetFltDeinitialized, 309 310 } VBOXNETDEVMODE_TYPE; 311 312 /* packet filter processing mode constants */ 313 #define VBOXNETFLT_PFP_NETFLT 1 314 #define VBOXNETFLT_PFP_PASSTHRU 2 315 300 316 /** represents filter driver device context*/ 301 317 typedef struct _ADAPT … … 351 367 /** @todo join all boolean states to one field treated as flags bitmap */ 352 368 /** true iff we are processing Set packet filter OID */ 353 bool bProcessingPacketFilter;369 uint8_t fProcessingPacketFilter; 354 370 /** true iff the upper protocol filter cache was initialized */ 355 371 bool bUpperProtSetFilterInitialized; -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltMp-win.c
r21343 r22441 815 815 NDIS_STATUS fStatus; 816 816 UINT i; 817 PVBOXNETFLTINS pNetFltIf; 817 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt); 818 bool bNetFltActive; 818 819 819 820 Assert(cNumberOfPackets); 820 821 821 if(vboxNetFltWinIncReferenceAdaptNetFlt FromAdapt(pAdapt, &pNetFltIf, cNumberOfPackets))822 if(vboxNetFltWinIncReferenceAdaptNetFlt(pNetFlt, pAdapt, cNumberOfPackets, &bNetFltActive)) 822 823 { 823 824 uint32_t cAdaptRefs = cNumberOfPackets; 824 uint32_t cNetFltRefs = pNetFltIf ? cNumberOfPackets : 0; 825 uint32_t cNetFltRefs; 826 uint32_t cPassThruRefs; 827 if(bNetFltActive) 828 { 829 cNetFltRefs = cNumberOfPackets; 830 cPassThruRefs = 0; 831 } 832 else 833 { 834 cPassThruRefs = cNumberOfPackets; 835 cNetFltRefs = 0; 836 } 825 837 826 838 for (i = 0; i < cNumberOfPackets; i++) … … 853 865 { 854 866 if(!cNetFltRefs 855 || (fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt If, pPacket, PACKET_SRC_HOST)) != NDIS_STATUS_SUCCESS)867 || (fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_SRC_HOST)) != NDIS_STATUS_SUCCESS) 856 868 { 857 869 #ifndef VBOXNETADP … … 889 901 890 902 if(cNetFltRefs) 891 vboxNetFltWinDecReferenceNetFlt(pNetFltIf, cNetFltRefs); 903 { 904 vboxNetFltWinDecReferenceNetFlt(pNetFlt, cNetFltRefs); 905 } 906 else if(cPassThruRefs) 907 { 908 vboxNetFltWinDecReferenceModePassThru(pNetFlt, cPassThruRefs); 909 } 892 910 if(cAdaptRefs) 911 { 893 912 vboxNetFltWinDecReferenceAdapt(pAdapt, cAdaptRefs); 913 } 894 914 } 895 915 else … … 1051 1071 if(Oid == OID_GEN_CURRENT_PACKET_FILTER && VBOXNETFLT_PROMISCUOUS_SUPPORTED(pAdapt)) 1052 1072 { 1053 PVBOXNETFLTINS pNetFltIf;1054 const bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt FromAdapt(pAdapt, &pNetFltIf);1073 bool fNetFltActive; 1074 const bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt(pNetFlt, pAdapt, &fNetFltActive); 1055 1075 1056 1076 Assert(InformationBuffer); 1057 Assert(!pAdapt-> bProcessingPacketFilter);1058 1059 if( pNetFltIf)1077 Assert(!pAdapt->fProcessingPacketFilter); 1078 1079 if(fNetFltActive) 1060 1080 { 1061 1081 /* netflt is active, simply return the cached value */ … … 1063 1083 1064 1084 Status = NDIS_STATUS_SUCCESS; 1065 vboxNetFltWinDereferenceNetFlt(pNetFlt If);1085 vboxNetFltWinDereferenceNetFlt(pNetFlt); 1066 1086 vboxNetFltWinDereferenceAdapt(pAdapt); 1067 1087 … … 1073 1093 else if(fAdaptActive) 1074 1094 { 1075 vboxNetFltWinDereferenceAdapt(pAdapt); 1095 pAdapt->fProcessingPacketFilter = VBOXNETFLT_PFP_PASSTHRU; 1096 /* we're cleaning it in RequestComplete */ 1076 1097 } 1077 1098 } … … 1397 1418 { 1398 1419 /* need to disable cleaning promiscuous here ?? */ 1399 PVBOXNETFLTINS pNetFltIf;1400 const bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt FromAdapt(pAdapt, &pNetFltIf);1420 bool fNetFltActive; 1421 const bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt(pNetFlt, pAdapt, &fNetFltActive); 1401 1422 1402 1423 Assert(InformationBuffer); 1403 Assert(!pAdapt-> bProcessingPacketFilter);1404 1405 if( pNetFltIf)1424 Assert(!pAdapt->fProcessingPacketFilter); 1425 1426 if(fNetFltActive) 1406 1427 { 1407 1428 Assert(fAdaptActive); … … 1419 1440 pAdapt->Request.DATA.SET_INFORMATION.InformationBuffer = &pAdapt->fSetFilterBuffer; 1420 1441 pAdapt->Request.DATA.SET_INFORMATION.InformationBufferLength = sizeof(pAdapt->fSetFilterBuffer); 1421 pAdapt-> bProcessingPacketFilter = true;1442 pAdapt->fProcessingPacketFilter = VBOXNETFLT_PFP_NETFLT; 1422 1443 /* we'll do dereferencing in request complete */ 1423 1444 } … … 1425 1446 { 1426 1447 Status = NDIS_STATUS_SUCCESS; 1427 vboxNetFltWinDereferenceNetFlt(pNetFlt If);1448 vboxNetFltWinDereferenceNetFlt(pNetFlt); 1428 1449 vboxNetFltWinDereferenceAdapt(pAdapt); 1429 1450 … … 1436 1457 else if(fAdaptActive) 1437 1458 { 1438 vboxNetFltWinDereferenceAdapt(pAdapt); 1459 pAdapt->fProcessingPacketFilter = VBOXNETFLT_PFP_PASSTHRU; 1460 /* dereference on completion */ 1439 1461 } 1440 1462 } … … 1792 1814 #ifdef VBOXNETADP_REPORT_DISCONNECTED 1793 1815 { 1794 PVBOXNETFLTINS pNetFltIf = NULL; 1795 bool bActive = vboxNetFltWinReferenceAdaptNetFltFromAdapt(pAdapt, &pNetFltIf); 1796 if(bActive && pNetFltIf) 1816 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt); 1817 bool bNetFltActive; 1818 bool bActive = vboxNetFltWinReferenceAdaptNetFltFromAdapt(pNetFlt, pAdapt, bNetFltActive); 1819 if(bActive && bNetFltActive) 1797 1820 { 1798 1821 ulInfo = NdisMediaStateConnected; … … 1807 1830 vboxNetFltWinDereferenceAdapt(pAdapt); 1808 1831 } 1809 if( pNetFltIf)1832 if(bNetFltActive) 1810 1833 { 1811 vboxNetFltWinDereferenceNetFlt(pNetFltIf); 1834 vboxNetFltWinDereferenceNetFlt(pNetFlt); 1835 } 1836 else 1837 { 1838 vboxNetFltWinDereferenceModePassThru(pNetFlt); 1812 1839 } 1813 1840 } -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltPt-win.c
r22389 r22441 559 559 if(Oid == OID_GEN_CURRENT_PACKET_FILTER && VBOXNETFLT_PROMISCUOUS_SUPPORTED(pAdapt)) 560 560 { 561 /* we're here _ONLY_ in the passthru mode */ 562 Assert(pAdapt->fProcessingPacketFilter == VBOXNETFLT_PFP_PASSTHRU); 563 if(pAdapt->fProcessingPacketFilter == VBOXNETFLT_PFP_PASSTHRU) 564 { 565 PVBOXNETFLTINS pNetFltIf = PADAPT_2_PVBOXNETFLTINS(pAdapt); 566 Assert(!pNetFltIf->fActive); 567 vboxNetFltWinDereferenceModePassThru(pNetFltIf); 568 vboxNetFltWinDereferenceAdapt(pAdapt); 569 } 570 561 571 if(Status == NDIS_STATUS_SUCCESS) 562 572 { … … 582 592 PVBOXNETFLTINS pNetFltIf = PADAPT_2_PVBOXNETFLTINS(pAdapt); 583 593 Assert(Status == NDIS_STATUS_SUCCESS); 584 if(pAdapt-> bProcessingPacketFilter)594 if(pAdapt->fProcessingPacketFilter == VBOXNETFLT_PFP_NETFLT) 585 595 { 596 Assert(pNetFltIf->fActive); 586 597 if(Status == NDIS_STATUS_SUCCESS) 587 598 { … … 591 602 vboxNetFltWinDereferenceNetFlt(pNetFltIf); 592 603 vboxNetFltWinDereferenceAdapt(pAdapt); 593 pAdapt-> bProcessingPacketFilter = false;604 pAdapt->fProcessingPacketFilter = 0; 594 605 } 595 else 606 else if(pAdapt->fProcessingPacketFilter == VBOXNETFLT_PFP_PASSTHRU) 596 607 { 608 Assert(!pNetFltIf->fActive); 609 597 610 if(Status == NDIS_STATUS_SUCCESS) 598 611 { … … 601 614 pAdapt->bUpperProtSetFilterInitialized = true; 602 615 } 616 vboxNetFltWinDereferenceModePassThru(pNetFltIf); 617 vboxNetFltWinDereferenceAdapt(pAdapt); 618 pAdapt->fProcessingPacketFilter = 0; 603 619 } 604 620 } … … 1488 1504 PADAPT pAdapt = (PADAPT)ProtocolBindingContext; 1489 1505 NDIS_STATUS Status = NDIS_STATUS_SUCCESS; 1490 PVBOXNETFLTINS pNetFlt If;1506 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt); 1491 1507 #ifdef VBOX_NETFLT_ONDEMAND_BIND 1492 1508 #if 0 … … 1571 1587 #else /* if NOT defined VBOX_NETFLT_ONDEMAND_BIND */ 1572 1588 PNDIS_PACKET pPacket = NULL; 1573 bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFltFromAdapt(pAdapt, &pNetFltIf); 1589 bool bNetFltActive; 1590 bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt(pNetFlt, pAdapt, &bNetFltActive); 1591 const bool bPassThruActive = !bNetFltActive; 1574 1592 if(fAdaptActive) 1575 1593 { … … 1605 1623 } 1606 1624 1607 if( pNetFltIf)1625 if(bNetFltActive) 1608 1626 { 1609 Status = vboxNetFltWinQuEnqueuePacket(pNetFlt If, pPacket, PACKET_COPY);1627 Status = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_COPY); 1610 1628 if(Status == NDIS_STATUS_SUCCESS) 1611 1629 { 1612 1630 //NdisReturnPackets(&pPacket, 1); 1613 1631 fAdaptActive = false; 1614 pNetFltIf = NULL;1632 bNetFltActive = false; 1615 1633 break; 1616 1634 } … … 1630 1648 } 1631 1649 #endif /* todo: remove */ 1632 if( pNetFltIf)1650 if(bNetFltActive) 1633 1651 { 1634 1652 Status = vboxNetFltWinPtReceiveActive(pAdapt, MacReceiveContext, pHeaderBuffer, cbHeaderBuffer, … … 1639 1657 { 1640 1658 fAdaptActive = false; 1641 pNetFltIf = NULL;1659 bNetFltActive = false; 1642 1660 } 1643 1661 else … … 1683 1701 } while(0); 1684 1702 1685 if(pNetFltIf) 1686 vboxNetFltWinDereferenceNetFlt(pNetFltIf); 1703 if(bNetFltActive) 1704 { 1705 vboxNetFltWinDereferenceNetFlt(pNetFlt); 1706 } 1707 else if(bPassThruActive) 1708 { 1709 vboxNetFltWinDereferenceModePassThru(pNetFlt); 1710 } 1687 1711 if(fAdaptActive) 1712 { 1688 1713 vboxNetFltWinDereferenceAdapt(pAdapt); 1714 } 1689 1715 } 1690 1716 else … … 1710 1736 #ifndef VBOX_NETFLT_ONDEMAND_BIND 1711 1737 PADAPT pAdapt =(PADAPT)ProtocolBindingContext; 1738 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt); 1712 1739 ULONG NumberOfPackets = 0; 1740 /* since the receive array queued packets do not hold the reference we need to 1741 * reference the PassThru/NetFlt mode here to avoid packet reordering caused by 1742 * concurrently running vboxNetFltWinPtReceiveComplete and vboxNetFltPortOsSetActive 1743 * on netflt activation/deactivation */ 1744 bool bNetFltActive; 1745 bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt(pNetFlt, pAdapt, &bNetFltActive); 1713 1746 1714 1747 vboxNetFltWinPtFlushReceiveQueue(pAdapt, false); … … 1731 1764 1732 1765 pAdapt->bIndicateRcvComplete = FALSE; 1766 1767 if(fAdaptActive) 1768 { 1769 if(bNetFltActive) 1770 { 1771 vboxNetFltWinDereferenceNetFlt(pNetFlt); 1772 } 1773 else 1774 { 1775 vboxNetFltWinDereferenceModePassThru(pNetFlt); 1776 } 1777 vboxNetFltWinDereferenceAdapt(pAdapt); 1778 } 1733 1779 #endif 1734 1780 } … … 1753 1799 PADAPT pAdapt =(PADAPT)ProtocolBindingContext; 1754 1800 INT cRefCount = 0; 1755 PVBOXNETFLTINS pNetFlt If;1801 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt); 1756 1802 #ifdef VBOX_NETFLT_ONDEMAND_BIND 1757 1803 PNDIS_BUFFER pBuffer; … … 1842 1888 return 0; 1843 1889 #else 1844 bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFltFromAdapt(pAdapt, &pNetFltIf); 1890 bool bNetFltActive; 1891 bool fAdaptActive = vboxNetFltWinReferenceAdaptNetFlt(pNetFlt, pAdapt, &bNetFltActive); 1892 const bool bPassThruActive = !bNetFltActive; 1845 1893 if(fAdaptActive) 1846 1894 { … … 1869 1917 } 1870 1918 1871 if( pNetFltIf)1919 if(bNetFltActive) 1872 1920 { 1873 1921 bool bResources = NDIS_GET_PACKET_STATUS(pPacket) == NDIS_STATUS_RESOURCES; … … 1879 1927 Assert(!bResources); 1880 1928 1881 fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt If, pPacket, bResources ? PACKET_COPY : 0);1929 fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, bResources ? PACKET_COPY : 0); 1882 1930 if(fStatus == NDIS_STATUS_SUCCESS) 1883 1931 { 1884 pNetFltIf = NULL;1932 bNetFltActive = false; 1885 1933 fAdaptActive = false; 1886 1934 if(bResources) … … 1910 1958 } while(FALSE); 1911 1959 1912 if(pNetFltIf) 1913 vboxNetFltWinDereferenceNetFlt(pNetFltIf); 1960 if(bNetFltActive) 1961 { 1962 vboxNetFltWinDereferenceNetFlt(pNetFlt); 1963 } 1964 else if(bPassThruActive) 1965 { 1966 vboxNetFltWinDereferenceModePassThru(pNetFlt); 1967 } 1914 1968 if(fAdaptActive) 1969 { 1915 1970 vboxNetFltWinDereferenceAdapt(pAdapt); 1971 } 1916 1972 } 1917 1973 else
Note:
See TracChangeset
for help on using the changeset viewer.