Changeset 56205 in vbox
- Timestamp:
- Jun 2, 2015 2:34:47 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 100744
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/ndis6/VBoxNetLwf-win.cpp
r56201 r56205 18 18 //#define VBOXNETLWF_SYNC_SEND 19 19 #define VBOXNETLWF_NO_BYPASS 20 #define VBOXNETLWF_SUPRESS_REDUNDANT_NOTIFICATIONS21 20 22 21 #include <VBox/version.h> … … 81 80 /** filter module context handle */ 82 81 NDIS_HANDLE hModuleCtx; 82 /** IP address change notifier handle */ 83 HANDLE hNotifier; /* Must be here as hModuleCtx may already be NULL when vboxNetFltOsDeleteInstance is called */ 83 84 } VBOXNETFLTWIN, *PVBOXNETFLTWIN; 84 85 #define VBOXNETFLT_NO_PACKET_QUEUE … … 191 192 /** MAC address of underlying adapter */ 192 193 RTMAC MacAddr; 193 /** Index of underlying adapter */194 NET_IFINDEX uIfIndex;195 /** IP address change notifier handle */196 HANDLE hNotifier;197 194 /** Saved offload configuration */ 198 195 NDIS_OFFLOAD SavedOffloadConfig; … … 803 800 pModuleCtx->pGlobals = pGlobals; 804 801 pModuleCtx->hFilter = hFilter; 805 pModuleCtx->uIfIndex = pParameters->BaseMiniportIfIndex;806 pModuleCtx->hNotifier = NULL;807 802 vboxNetLwfWinChangeState(pModuleCtx, LwfState_Attaching); 808 803 /* Insert into module chain */ … … 2194 2189 PVBOXNETLWF_MODULE pModule = (PVBOXNETLWF_MODULE)pThis->u.s.WinIf.hModuleCtx; 2195 2190 2196 #ifdef VBOXNETLWF_SUPRESS_REDUNDANT_NOTIFICATIONS2197 /* Ignore notifications on the interfaces we are not attached to. */2198 if (pRow && pModule->uIfIndex != pRow->InterfaceIndex)2199 {2200 Log((__FUNCTION__ ": ignoring notification for luid %d-%d, index %d\n",2201 pRow->InterfaceLuid.Info.IfType, pRow->InterfaceLuid.Info.NetLuidIndex,2202 pRow->InterfaceIndex));2203 return;2204 }2205 #endif /* VBOXNETLWF_SUPRESS_REDUNDANT_NOTIFICATIONS */2206 2207 2191 /* We are only interested in add or remove notifications. */ 2208 2192 bool fAdded; … … 2219 2203 { 2220 2204 case AF_INET: 2221 Log(( "vboxNetLwfWinIpAddrChangeCallback: %s IPv4 addr=%RTnaipv4 on luid=(%u,%u)\n",2205 Log((__FUNCTION__": %s IPv4 addr=%RTnaipv4 on luid=(%u,%u)\n", 2222 2206 fAdded ? "add" : "remove", pRow->Address.Ipv4.sin_addr, 2223 2207 pRow->InterfaceLuid.Info.IfType, pRow->InterfaceLuid.Info.NetLuidIndex)); … … 2226 2210 break; 2227 2211 case AF_INET6: 2228 Log(( "vboxNetLwfWinIpAddrChangeCallback: %s IPv6 addr=%RTnaipv6 luid=(%u,%u)\n",2212 Log((__FUNCTION__": %s IPv6 addr=%RTnaipv6 luid=(%u,%u)\n", 2229 2213 fAdded ? "add" : "remove", &pRow->Address.Ipv6.sin6_addr, 2230 2214 pRow->InterfaceLuid.Info.IfType, pRow->InterfaceLuid.Info.NetLuidIndex)); … … 2235 2219 } 2236 2220 else 2237 Log(( "vboxNetLwfWinIpAddrChangeCallback: pRow=%p pfnNotifyHostAddress=%p\n",2221 Log((__FUNCTION__": pRow=%p pfnNotifyHostAddress=%p\n", 2238 2222 pRow, pThis->pSwitchPort->pfnNotifyHostAddress)); 2239 2223 } 2240 2224 2241 void vboxNetLwfWinRegisterIpAddrNotifier(PVBOXNETFLTINS pThis , PVBOXNETLWF_MODULE pModuleCtx)2225 void vboxNetLwfWinRegisterIpAddrNotifier(PVBOXNETFLTINS pThis) 2242 2226 { 2243 2227 if (pThis->pSwitchPort && pThis->pSwitchPort->pfnNotifyHostAddress) 2244 2228 { 2245 2229 NETIO_STATUS Status; 2230 /* First we need to go over all host IP addresses and add them via pfnNotifyHostAddress. */ 2231 PMIB_UNICASTIPADDRESS_TABLE HostIpAddresses = NULL; 2232 Status = GetUnicastIpAddressTable(AF_UNSPEC, &HostIpAddresses); 2233 if (NETIO_SUCCESS(Status)) 2234 { 2235 for (int i = 0; i < HostIpAddresses->NumEntries; i++) 2236 vboxNetLwfWinIpAddrChangeCallback(pThis, &HostIpAddresses->Table[i], MibAddInstance); 2237 } 2238 else 2239 Log((__FUNCTION__": GetUnicastIpAddressTable failed with %x\n", Status)); 2240 /* Now we can register a callback function to keep track of address changes. */ 2246 2241 Status = NotifyUnicastIpAddressChange(AF_UNSPEC, vboxNetLwfWinIpAddrChangeCallback, 2247 pThis, false, &p ModuleCtx->hNotifier);2248 if ( !NETIO_SUCCESS(Status))2249 Log(( "vboxNetLwfWinRegisterIpAddrNotifier: NotifyUnicastIpAddressChange failed with %x\n", Status));2242 pThis, false, &pThis->u.s.WinIf.hNotifier); 2243 if (NETIO_SUCCESS(Status)) 2244 Log((__FUNCTION__": notifier=%p\n", pThis->u.s.WinIf.hNotifier)); 2250 2245 else 2251 Log(( "vboxNetLwfWinRegisterIpAddrNotifier: notifier=%p\n", pModuleCtx->hNotifier));2246 Log((__FUNCTION__": NotifyUnicastIpAddressChange failed with %x\n", Status)); 2252 2247 } 2253 2248 else 2254 p ModuleCtx->hNotifier = NULL;2255 } 2256 2257 void vboxNetLwfWinUnregisterIpAddrNotifier(PVBOXNET LWF_MODULE pModuleCtx)2258 { 2259 Log(( "vboxNetLwfWinUnregisterIpAddrNotifier: notifier=%p\n", pModuleCtx->hNotifier));2260 if (p ModuleCtx->hNotifier)2261 CancelMibChangeNotify2(p ModuleCtx->hNotifier);2249 pThis->u.s.WinIf.hNotifier = NULL; 2250 } 2251 2252 void vboxNetLwfWinUnregisterIpAddrNotifier(PVBOXNETFLTINS pThis) 2253 { 2254 Log((__FUNCTION__": notifier=%p\n", pThis->u.s.WinIf.hNotifier)); 2255 if (pThis->u.s.WinIf.hNotifier) 2256 CancelMibChangeNotify2(pThis->u.s.WinIf.hNotifier); 2262 2257 } 2263 2258 … … 2267 2262 LogFlow(("==>"__FUNCTION__": instance=%p module=%p\n", pThis, pModuleCtx)); 2268 2263 /* Cancel IP address change notifications */ 2269 vboxNetLwfWinUnregisterIpAddrNotifier(p ModuleCtx);2264 vboxNetLwfWinUnregisterIpAddrNotifier(pThis); 2270 2265 /* Technically it is possible that the module has already been gone by now. */ 2271 2266 if (pModuleCtx) … … 2310 2305 pModuleCtx->pNetFlt = pThis; 2311 2306 vboxNetLwfWinReportCapabilities(pThis, pModuleCtx); 2312 vboxNetLwfWinRegisterIpAddrNotifier(pThis , pModuleCtx);2307 vboxNetLwfWinRegisterIpAddrNotifier(pThis); 2313 2308 LogFlow(("<=="__FUNCTION__": return 0\n")); 2314 2309 return VINF_SUCCESS; … … 2323 2318 LogFlow(("==>"__FUNCTION__": instance=%p\n", pThis)); 2324 2319 pThis->u.s.WinIf.hModuleCtx = 0; 2320 pThis->u.s.WinIf.hNotifier = NULL; 2325 2321 LogFlow(("<=="__FUNCTION__": return 0\n")); 2326 2322 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.