Changeset 59653 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Feb 12, 2016 12:29:58 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp
r59065 r59653 17 17 18 18 //#define VBOXNETLWF_SYNC_SEND 19 /* Payload + Ethernet header + VLAN tag = Max Ethernet frame size */ 20 #define VBOXNETLWF_MAX_FRAME_SIZE(mtu) (mtu + sizeof(RTNETETHERHDR) + 4) 19 21 20 22 #include <VBox/version.h> … … 193 195 /** MAC address of underlying adapter */ 194 196 RTMAC MacAddr; 197 /** Saved MTU size */ 198 ULONG uMtuSize; 195 199 /** Saved offload configuration */ 196 200 NDIS_OFFLOAD SavedOffloadConfig; … … 834 838 pModuleCtx->cPendingBuffers = 0; 835 839 #endif /* !VBOXNETLWF_SYNC_SEND */ 836 /* Allocate buffer pools */837 NET_BUFFER_LIST_POOL_PARAMETERS PoolParams;838 NdisZeroMemory(&PoolParams, sizeof(PoolParams));839 PoolParams.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;840 PoolParams.Header.Revision = NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;841 PoolParams.Header.Size = sizeof(PoolParams);842 PoolParams.ProtocolId = NDIS_PROTOCOL_ID_DEFAULT;843 PoolParams.fAllocateNetBuffer = TRUE;844 PoolParams.ContextSize = 0; /** @todo Do we need to consider underlying drivers? I think not. */845 PoolParams.PoolTag = VBOXNETLWF_MEM_TAG;846 #ifndef VBOXNETLWF_SYNC_SEND847 PoolParams.DataSize = 2048; /** @todo figure out the optimal size, use several pools if necessary, make configurable, etc */848 #endif /* !VBOXNETLWF_SYNC_SEND */849 850 pModuleCtx->hPool = NdisAllocateNetBufferListPool(hFilter, &PoolParams);851 if (!pModuleCtx->hPool)852 {853 LogError(("vboxNetLwfWinAttach: NdisAllocateNetBufferListPool failed\n"));854 NdisFreeIoWorkItem(pModuleCtx->hWorkItem);855 NdisFreeMemory(pModuleCtx, 0, 0);856 return NDIS_STATUS_RESOURCES;857 }858 Log4(("vboxNetLwfWinAttach: allocated NBL+NB pool 0x%p\n", pModuleCtx->hPool));859 840 860 841 NDIS_FILTER_ATTRIBUTES Attributes; … … 970 951 vboxNetLwfWinChangeState(pModuleCtx, LwfState_Restarting, LwfState_Paused); 971 952 972 vboxNetLwfWinChangeState(pModuleCtx, LwfState_Running, LwfState_Restarting);973 953 NDIS_STATUS Status = NDIS_STATUS_SUCCESS; 954 ULONG uNewMtuSize = 1500; /* If we fail to find out MTU, we can always assume 1500. */ 955 PNDIS_RESTART_ATTRIBUTES pAttributes = pParameters->RestartAttributes; 956 while (pAttributes && pAttributes->Oid != OID_GEN_MINIPORT_RESTART_ATTRIBUTES) 957 pAttributes = pAttributes->Next; 958 if (pAttributes) 959 { 960 PNDIS_RESTART_GENERAL_ATTRIBUTES pGenAttrs = (PNDIS_RESTART_GENERAL_ATTRIBUTES)pAttributes->Data; 961 uNewMtuSize = pGenAttrs->MtuSize; 962 } 963 964 /* Let's see if MTU has changed. Re-allocate the pool if it has. */ 965 if (pModuleCtx->uMtuSize != uNewMtuSize) 966 { 967 pModuleCtx->uMtuSize = uNewMtuSize; 968 if (pModuleCtx->hPool) 969 { 970 /* 971 * Don't need to wait for pending sends to complete since we are already 972 * in paused state. Just free the old pool. 973 */ 974 NdisFreeNetBufferListPool(pModuleCtx->hPool); 975 pModuleCtx->hPool = NULL; 976 } 977 } 978 if (!pModuleCtx->hPool) 979 { 980 /* Allocate a new pool. */ 981 NET_BUFFER_LIST_POOL_PARAMETERS PoolParams; 982 NdisZeroMemory(&PoolParams, sizeof(PoolParams)); 983 PoolParams.Header.Type = NDIS_OBJECT_TYPE_DEFAULT; 984 PoolParams.Header.Revision = NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1; 985 PoolParams.Header.Size = sizeof(PoolParams); 986 PoolParams.ProtocolId = NDIS_PROTOCOL_ID_DEFAULT; 987 PoolParams.fAllocateNetBuffer = TRUE; 988 PoolParams.ContextSize = 0; /** @todo Do we need to consider underlying drivers? I think not. */ 989 PoolParams.PoolTag = VBOXNETLWF_MEM_TAG; 990 #ifndef VBOXNETLWF_SYNC_SEND 991 PoolParams.DataSize = VBOXNETLWF_MAX_FRAME_SIZE(pModuleCtx->uMtuSize); 992 #endif /* !VBOXNETLWF_SYNC_SEND */ 993 994 pModuleCtx->hPool = NdisAllocateNetBufferListPool(pModuleCtx->hFilter, &PoolParams); 995 if (!pModuleCtx->hPool) 996 { 997 LogError(("vboxNetLwfWinRestart: NdisAllocateNetBufferListPool failed\n")); 998 Status = NDIS_STATUS_RESOURCES; 999 } 1000 else 1001 { 1002 Log4(("vboxNetLwfWinRestart: allocated NBL+NB pool 0x%p with MTU=%u\n", 1003 pModuleCtx->hPool, pModuleCtx->uMtuSize)); 1004 } 1005 } 1006 1007 vboxNetLwfWinChangeState(pModuleCtx, Status == NDIS_STATUS_SUCCESS ? LwfState_Running : LwfState_Paused, LwfState_Restarting); 974 1008 LogFlow(("<==vboxNetLwfWinRestart: Status = 0x%x\n", Status)); 975 1009 return Status; … … 1022 1056 uint16_t uEthType = RT_N2H_U16(*(uint16_t*)(pHdr+12)); 1023 1057 Log2(("NetLWF: %s (%d bytes), %RTmac => %RTmac, EthType=%s(0x%x)\n", 1024 cszText, cb, pHdr+6, pHdr, vboxNetLwfWinEthTypeStr(uEthType), uEthType));1058 cszText, pSG->cbTotal, pHdr+6, pHdr, vboxNetLwfWinEthTypeStr(uEthType), uEthType)); 1025 1059 pHdr += sizeof(RTNETETHERHDR); 1026 1060 if (uEthType == RTNET_ETHERTYPE_VLAN) … … 1169 1203 { 1170 1204 AssertReturn(pSG->cSegsUsed >= 1, NULL); 1171 LogFlow(("==>vboxNetLwfWinSGtoNB: segments=%d\n", pSG->cSegsUsed)); 1205 LogFlow(("==>vboxNetLwfWinSGtoNB: segments=%d hPool=%p cb=%u max=%u\n", pSG->cSegsUsed, 1206 pModule->hPool, pSG->cbTotal, VBOXNETLWF_MAX_FRAME_SIZE(pModule->uMtuSize))); 1207 AssertReturn(pModule->hPool, NULL); 1172 1208 1173 1209 #ifdef VBOXNETLWF_SYNC_SEND … … 1214 1250 } 1215 1251 #else /* !VBOXNETLWF_SYNC_SEND */ 1216 AssertReturn(pSG->cbTotal < 2048, NULL);1252 AssertReturn(pSG->cbTotal <= VBOXNETLWF_MAX_FRAME_SIZE(pModule->uMtuSize), NULL); 1217 1253 PNET_BUFFER_LIST pBufList = NdisAllocateNetBufferList(pModule->hPool, 1218 1254 0 /** @todo ContextSize */,
Note:
See TracChangeset
for help on using the changeset viewer.