Changeset 29108 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/win
- Timestamp:
- May 5, 2010 8:17:42 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 61168
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt/win
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.c
r28830 r29108 424 424 * packet queue functions 425 425 ************************************************************************************/ 426 426 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 427 427 #if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP) 428 428 static NDIS_STATUS vboxNetFltWinQuPostPacket(PADAPT pAdapt, PNDIS_PACKET pPacket, PINTNETSG pSG, uint32_t fFlags … … 549 549 #endif 550 550 551 static bool vboxNetFltWinQuProcessInfo(PVBOXNETFLTINS pNetFltIf, PPACKET_QUEUE_WORKER pWorker, PPACKET_INFO pInfo) 551 static bool vboxNetFltWinQuProcessInfo(PVBOXNETFLTINS pNetFltIf, PPACKET_QUEUE_WORKER pWorker, PVOID pvPacket, const UINT fFlags) 552 #else 553 DECLHIDDEN(bool) vboxNetFltWinPostIntnet(PVBOXNETFLTINS pNetFltIf, PVOID pvPacket, const UINT fFlags) 554 #endif 552 555 { 553 556 PNDIS_PACKET pPacket = NULL; 554 557 PINTNETSG pSG = NULL; 555 558 PADAPT pAdapt = PVBOXNETFLTINS_2_PADAPT(pNetFltIf); 556 UINT fFlags;557 559 NDIS_STATUS Status; 558 560 #ifndef VBOXNETADP 559 561 bool bSrcHost; 562 bool bDropIt; 563 # ifndef VBOXNETFLT_NO_PACKET_QUEUE 560 564 bool bPending; 561 bool bDropIt; 565 # endif 566 #endif 567 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 568 bool bDeleteSG = false; 562 569 #endif 563 570 #ifdef DEBUG_NETFLT_PACKETS … … 566 573 #endif 567 574 568 fFlags = GET_FLAGS_FROM_INFO(pInfo);569 575 #ifndef VBOXNETADP 570 576 bSrcHost = (fFlags & PACKET_SRC_HOST) != 0; … … 594 600 UINT cbPacketLength; 595 601 596 pPacket = (PNDIS_PACKET)GET_PACKET_FROM_INFO(pInfo); 602 pPacket = (PNDIS_PACKET)pvPacket; 603 597 604 LogFlow(("ndis packet info, packet (%p)\n", pPacket)); 598 605 … … 607 614 Assert(cBufferCount); 608 615 616 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 617 pSG = vboxNetFltWinCreateSG(cBufferCount); 618 #else 609 619 /* we can not allocate the INTNETSG on stack since in this case we may get stack overflow 610 620 * somewhere outside of our driver (3 pages of system thread stack does not seem to be enough) … … 627 637 } 628 638 } 639 #endif 629 640 630 641 if(pSG) 631 642 { 643 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 644 bDeleteSG = true; 645 #endif 632 646 /* reinitialize */ 633 647 IntNetSgInitTempSegs(pSG, 0 /*cbTotal*/, pSG->cSegsAlloc, 0 /*cSegsUsed*/); … … 659 673 /* we have both host and wire in ProtocolReceive */ 660 674 #endif 661 pSG = (PINTNETSG) GET_PACKET_FROM_INFO(pInfo);675 pSG = (PINTNETSG)pvPacket; 662 676 663 677 LogFlow(("not ndis packet info, pSG (%p)\n", pSG)); … … 704 718 #endif 705 719 706 #if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP) 720 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 721 722 # if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP) 707 723 if(!bDropIt) 708 724 { 709 725 Status = vboxNetFltWinQuPostPacket(pAdapt, pPacket, pSG, fFlags 710 # ifdef DEBUG_NETFLT_PACKETS726 # ifdef DEBUG_NETFLT_PACKETS 711 727 , pTmpPacket 712 # endif728 # endif 713 729 ); 714 730 … … 721 737 } 722 738 else 723 # endif739 # endif 724 740 { 725 741 Status = NDIS_STATUS_SUCCESS; … … 731 747 if(!(fFlags & PACKET_MINE)) 732 748 { 733 # if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP)749 # if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP) 734 750 /* complete the packets */ 735 751 if(fFlags & PACKET_SRC_HOST) 736 752 { 737 # endif738 # ifndef VBOX_NETFLT_ONDEMAND_BIND753 # endif 754 # ifndef VBOX_NETFLT_ONDEMAND_BIND 739 755 /* NDIS_SET_PACKET_STATUS(pPacket, Status); */ 740 756 NdisMSendComplete(pAdapt->hMiniportHandle, pPacket, Status); 741 # endif742 # if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP)757 # endif 758 # if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP) 743 759 } 744 760 else 745 761 { 746 # endif747 # ifndef VBOXNETADP762 # endif 763 # ifndef VBOXNETADP 748 764 NdisReturnPackets(&pPacket, 1); 749 # endif750 # if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP)765 # endif 766 # if !defined(VBOX_NETFLT_ONDEMAND_BIND) && !defined(VBOXNETADP) 751 767 } 752 # endif768 # endif 753 769 } 754 770 else 755 771 { 756 # ifndef VBOX_NETFLT_ONDEMAND_BIND772 # ifndef VBOX_NETFLT_ONDEMAND_BIND 757 773 Assert(!(fFlags & PACKET_SRC_HOST)); 758 # endif774 # endif 759 775 vboxNetFltWinFreeSGNdisPacket(pPacket, true); 760 776 } … … 765 781 vboxNetFltWinMemFree(pSG); 766 782 } 767 # ifndef VBOXNETADP783 # ifndef VBOXNETADP 768 784 bPending = false; 769 # endif785 # endif 770 786 } while(0); 771 787 … … 782 798 return false; 783 799 #endif 784 } 800 #else /* #ifdef VBOXNETFLT_NO_PACKET_QUEUE */ 801 } while(0); 802 # ifndef VBOXNETADP 803 return bDropIt; 804 # else 805 return true; 806 # endif 807 #endif 808 } 809 810 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 785 811 /* 786 812 * thread start function for the thread which processes the packets enqueued in our send and receive callbacks called by ndis … … 846 872 LogFlow(("==> found info (%p)\n", pInfo)); 847 873 848 if(vboxNetFltWinQuProcessInfo(pNetFltIf, pWorker, pInfo ))874 if(vboxNetFltWinQuProcessInfo(pNetFltIf, pWorker, pInfo->pPacket, pInfo->fFlags)) 849 875 { 850 876 cNumPostedToHostWire++; … … 871 897 PsTerminateSystemThread(STATUS_SUCCESS); 872 898 } 873 899 #endif 874 900 /** 875 901 * thread start function for the job processing thread … … 1053 1079 } 1054 1080 1081 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 1082 1055 1083 /** 1056 1084 * initializes the packet queue … … 1134 1162 } 1135 1163 } 1164 1165 #endif 1136 1166 1137 1167 /* … … 1158 1188 } 1159 1189 1190 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 1160 1191 /** 1161 1192 * put the packet info to the queue … … 1167 1198 KeSetEvent(&pWorker->NotifyEvent, IO_NETWORK_INCREMENT, FALSE); 1168 1199 } 1169 1170 1200 1171 1201 /** … … 1266 1296 return fStatus; 1267 1297 } 1298 #endif 1268 1299 1269 1300 #ifndef VBOX_NETFLT_ONDEMAND_BIND … … 2275 2306 /* moved to vboxNetFltWinDetachFromInterfaceWorker */ 2276 2307 #else 2308 # ifndef VBOXNETFLT_NO_PACKET_QUEUE 2277 2309 vboxNetFltWinQuFiniPacketQueue(pAdapt); 2310 # endif 2278 2311 #endif 2279 2312 … … 3029 3062 #endif 3030 3063 Assert(pAdapt->MPState.OpState == kVBoxNetDevOpState_Deinitialized); 3064 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 3031 3065 Assert(!pThis->u.s.PacketQueueWorker.pSG); 3066 #endif 3032 3067 // Assert(!pAdapt->hMiniportHandle); 3033 3068 … … 3051 3086 static NDIS_STATUS vboxNetFltWinDisconnectIt(PVBOXNETFLTINS pInstance) 3052 3087 { 3088 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 3053 3089 vboxNetFltWinQuFiniPacketQueue(pInstance); 3090 #endif 3054 3091 return NDIS_STATUS_SUCCESS; 3055 3092 } … … 3629 3666 static void vboxNetFltWinConnectItWorker(PWORKER_INFO pInfo) 3630 3667 { 3668 #if !defined(VBOXNETADP) || !defined(VBOXNETFLT_NO_PACKET_QUEUE) 3631 3669 NDIS_STATUS Status; 3670 #endif 3632 3671 PVBOXNETFLTINS pInstance = pInfo->pNetFltIf; 3633 3672 PADAPT pAdapt = PVBOXNETFLTINS_2_PADAPT(pInstance); … … 3643 3682 #endif 3644 3683 { 3684 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 3685 pInfo->Status = VINF_SUCCESS; 3686 #else 3645 3687 Status = vboxNetFltWinQuInitPacketQueue(pInstance); 3646 3688 if(Status == NDIS_STATUS_SUCCESS) … … 3652 3694 pInfo->Status = VERR_GENERAL_FAILURE; 3653 3695 } 3696 #endif 3654 3697 } 3655 3698 #ifndef VBOXNETADP -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.h
r28830 r29108 207 207 #define SET_FLAGS_TO_INFO(_pPacketInfo, _fFlags) (ASMAtomicUoWriteU32((volatile uint32_t *)&(_pPacketInfo)->fFlags, (_fFlags))) 208 208 209 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 210 DECLHIDDEN(bool) vboxNetFltWinPostIntnet(PVBOXNETFLTINS pInstance, PVOID pvPacket, const UINT fFlags); 211 #else 209 212 DECLHIDDEN(NDIS_STATUS) vboxNetFltWinQuEnqueuePacket(PVBOXNETFLTINS pInstance, PVOID pPacket, const UINT fPacketFlags); 210 213 … … 214 217 DECLHIDDEN(NTSTATUS) vboxNetFltWinQuInitPacketQueue(PVBOXNETFLTINS pInstance); 215 218 #endif 219 220 #endif /* #ifndef VBOXNETFLT_NO_PACKET_QUEUE */ 221 216 222 217 223 #ifndef VBOXNETADP -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltCommon-win.h
r28800 r29108 176 176 #define PACKET_SRC_HOST 0x00000002 177 177 178 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 178 179 /** flag specifying the packet was originated by our driver 179 180 * i.e. we could use it on our needs and should not return it … … 186 187 * this is supported for Ndis Packet only */ 187 188 #define PACKET_COPY 0x00000008 189 #endif 188 190 189 191 /** packet queue element containing the packet info */ -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltMp-win.c
r28830 r29108 800 800 { 801 801 PADAPT pAdapt = (PADAPT)fMiniportAdapterContext; 802 NDIS_STATUS fStatus ;802 NDIS_STATUS fStatus = NDIS_STATUS_SUCCESS; 803 803 UINT i; 804 804 PVBOXNETFLTINS pNetFlt = PADAPT_2_PVBOXNETFLTINS(pAdapt); … … 830 830 831 831 if(!cNetFltRefs 832 || (fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_SRC_HOST)) != NDIS_STATUS_SUCCESS) 832 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 833 || !vboxNetFltWinPostIntnet(pNetFlt, pPacket, PACKET_SRC_HOST) 834 #else 835 || (fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_SRC_HOST)) != NDIS_STATUS_SUCCESS 836 #endif 837 ) 833 838 { 834 839 #ifndef VBOXNETADP … … 859 864 else 860 865 { 866 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 867 NdisMSendComplete(pAdapt->hMiniportHandle, 868 pPacket, 869 NDIS_STATUS_SUCCESS); 870 #else 861 871 cAdaptRefs--; 862 872 cNetFltRefs--; 873 #endif 863 874 } 864 875 } -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltPt-win.c
r28830 r29108 984 984 /* use the same packet info to put the packet in the processing packet queue */ 985 985 #ifdef VBOX_NETFLT_ONDEMAND_BIND 986 # error "port me or remove VBOX_NETFLT_ONDEMAND_BIND" 986 987 PNDIS_BUFFER pBuffer; 987 988 PVOID pVA; … … 1011 1012 1012 1013 NdisSetPacketFlags(pPacket, 0); 1013 1014 # ifdef VBOXNETFLT_NO_PACKET_QUEUE 1015 if (vboxNetFltWinPostIntnet(pNetFltIf, pPacket, 0)) 1016 { 1017 /* drop it */ 1018 vboxNetFltWinFreeSGNdisPacket(pPacket, true); 1019 vboxNetFltWinDereferenceAdapt(pAdapt); 1020 } 1021 else 1022 { 1023 NdisMIndicateReceivePacket(pAdapt->hMiniportHandle, &pPacket, 1); 1024 } 1025 vboxNetFltWinDereferenceNetFlt(pNetFltIf); 1026 break; 1027 # else 1014 1028 Status = vboxNetFltWinQuEnqueuePacket(pNetFltIf, pPacket, PACKET_MINE); 1015 #endif 1016 if(Status == NDIS_STATUS_SUCCESS) 1029 if (Status == NDIS_STATUS_SUCCESS) 1017 1030 { 1018 1031 break; 1019 1032 } 1020 1033 Assert(0); 1034 # endif 1035 #endif 1021 1036 } 1022 1037 } … … 1376 1391 /* enqueue SG */ 1377 1392 #ifdef VBOX_NETFLT_ONDEMAND_BIND 1393 # ifdef VBOXNETFLT_NO_PACKET_QUEUE 1394 # error "port me or remove VBOX_NETFLT_ONDEMAND_BIND" 1395 # endif 1378 1396 { 1379 1397 uint32_t fFlags = MACS_EQUAL(((PRTNETETHERHDR)pRcvData)->SrcMac, pNetFlt->u.s.MacAddr) ? … … 1382 1400 } 1383 1401 #else 1402 # ifdef VBOXNETFLT_NO_PACKET_QUEUE 1403 if (vboxNetFltWinPostIntnet(pNetFlt, pSG, PACKET_SG)) 1404 { 1405 /* drop it */ 1406 vboxNetFltWinMemFree(pSG); 1407 vboxNetFltWinDereferenceAdapt(pAdapt); 1408 } 1409 else 1410 { 1411 PNDIS_PACKET pMyPacket = vboxNetFltWinNdisPacketFromSG(pAdapt, /* PADAPT */ 1412 pSG, /* PINTNETSG */ 1413 pSG, /* PVOID pBufToFree */ 1414 false, /* bool bToWire */ 1415 false); /* bool bCopyMemory */ 1416 Assert(pMyPacket); 1417 if (pMyPacket) 1418 { 1419 NDIS_SET_PACKET_STATUS(pMyPacket, NDIS_STATUS_SUCCESS); 1420 1421 DBG_CHECK_PACKET_AND_SG(pMyPacket, pSG); 1422 1423 LogFlow(("non-ndis packet info, packet created (%p)\n", pMyPacket)); 1424 NdisMIndicateReceivePacket(pAdapt->hMiniportHandle, &pMyPacket, 1); 1425 } 1426 else 1427 { 1428 vboxNetFltWinDereferenceAdapt(pAdapt); 1429 Status = NDIS_STATUS_RESOURCES; 1430 } 1431 } 1432 vboxNetFltWinDereferenceNetFlt(pNetFlt); 1433 # else 1384 1434 Status = vboxNetFltWinQuEnqueuePacket(pNetFlt, pSG, PACKET_SG | PACKET_MINE); 1385 #endif1386 1435 if(Status != NDIS_STATUS_SUCCESS) 1387 1436 { … … 1390 1439 break; 1391 1440 } 1441 # endif 1442 #endif 1392 1443 } 1393 1444 else … … 1657 1708 VBOXNETFLT_LBVERIFY(pNetFlt, pPacket); 1658 1709 1710 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 1711 if (vboxNetFltWinPostIntnet(pNetFlt, pPacket, 0)) 1712 { 1713 /* drop it */ 1714 break; 1715 } 1716 #else 1659 1717 Status = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, PACKET_COPY); 1660 1718 Assert(Status == NDIS_STATUS_SUCCESS); … … 1666 1724 break; 1667 1725 } 1726 #endif 1668 1727 } 1669 1728 #ifndef VBOX_LOOPBACK_USEFLAGS … … 1690 1749 } while(FALSE); 1691 1750 1751 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 1692 1752 if(Status == NDIS_STATUS_SUCCESS || Status == NDIS_STATUS_NOT_ACCEPTED 1693 # ifndef VBOX_LOOPBACK_USEFLAGS1753 # ifndef VBOX_LOOPBACK_USEFLAGS 1694 1754 || pLb 1695 # endif1755 # endif 1696 1756 ) 1757 #endif 1697 1758 { 1698 1759 break; … … 1974 2035 #endif 1975 2036 { 2037 #ifndef VBOXNETFLT_NO_PACKET_QUEUE 1976 2038 NDIS_STATUS fStatus; 2039 #endif 1977 2040 bool bResources = NDIS_GET_PACKET_STATUS(pPacket) == NDIS_STATUS_RESOURCES; 1978 2041 … … 1984 2047 Assert(!bResources); 1985 2048 2049 #ifdef VBOXNETFLT_NO_PACKET_QUEUE 2050 if (vboxNetFltWinPostIntnet(pNetFlt, pPacket, 0)) 2051 { 2052 /* drop it */ 2053 cRefCount = 0; 2054 break; 2055 } 2056 2057 #else 1986 2058 fStatus = vboxNetFltWinQuEnqueuePacket(pNetFlt, pPacket, bResources ? PACKET_COPY : 0); 1987 2059 if(fStatus == NDIS_STATUS_SUCCESS) … … 2004 2076 Assert(0); 2005 2077 } 2078 #endif 2006 2079 } 2007 2080 #ifndef VBOX_LOOPBACK_USEFLAGS
Note:
See TracChangeset
for help on using the changeset viewer.