Changeset 29635 in vbox for trunk/src/VBox
- Timestamp:
- May 18, 2010 1:42:54 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r29491 r29635 3189 3189 * Learn the MAC address of the sender. No re-learning as the interface 3190 3190 * user will normally tell us the right MAC address. 3191 * 3192 * Note! We don't notify the trunk about these mainly because of the 3193 * problematic contexts we might be called in. 3191 3194 */ 3192 3195 if (RT_UNLIKELY( pIfSender … … 3607 3610 if (pNetwork) 3608 3611 { 3609 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 3612 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 3613 PINTNETTRUNKIF pTrunk = NULL; 3614 3610 3615 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 3611 3616 … … 3615 3620 hIf, &pIf->MacAddr, pMac)); 3616 3621 3622 /* Update the two copies. */ 3617 3623 PINTNETMACTABENTRY pEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIf); Assert(pEntry); 3618 3624 if (RT_LIKELY(pEntry)) … … 3620 3626 pIf->MacAddr = *pMac; 3621 3627 pIf->fMacSet = true; 3628 3629 /* Grab a busy reference to the trunk so we release the lock before notifying it. */ 3630 pTrunk = pNetwork->MacTab.pTrunk; 3631 if (pTrunk) 3632 intnetR0BusyIncTrunk(pTrunk); 3622 3633 } 3623 3634 3624 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;3625 3635 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp); 3626 if (pTrunk && pTrunk->pIfPort) 3636 3637 if (pTrunk) 3627 3638 { 3628 3639 Log(("IntNetR0IfSetMacAddress: pfnNotifyMacAddress hIf=%RX32\n", hIf)); 3629 pTrunk->pIfPort->pfnNotifyMacAddress(pTrunk->pIfPort, hIf, pMac); 3640 PINTNETTRUNKIFPORT pIfPort = pTrunk->pIfPort; 3641 if (pIfPort) 3642 pIfPort->pfnNotifyMacAddress(pIfPort, hIf, pMac); 3643 intnetR0BusyDecTrunk(pTrunk); 3630 3644 } 3631 3645 } … … 3898 3912 /* 3899 3913 * Validate and free the handle. 3914 * 3915 * We grab the big mutex before we free the handle to avoid any handle 3916 * confusion on the trunk. 3900 3917 */ 3901 3918 PINTNET pIntNet = g_pIntNet; … … 3903 3920 AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC); 3904 3921 3922 RTSemMutexRequest(pIntNet->hMtxCreateOpenDestroy, RT_INDEFINITE_WAIT); 3923 3905 3924 PINTNETIF pIf = (PINTNETIF)RTHandleTableFreeWithCtx(pIntNet->hHtIfs, hIf, pSession); 3906 3925 if (!pIf) 3926 { 3927 RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy); 3907 3928 return VERR_INVALID_HANDLE; 3908 3909 /* mark the handle as freed so intnetR0IfDestruct won't free it again. */ 3929 } 3930 3931 /* Mark the handle as freed so intnetR0IfDestruct won't free it again. */ 3910 3932 ASMAtomicWriteU32(&pIf->hIf, INTNET_HANDLE_INVALID); 3911 3933 3912 /* 3913 * Release the references to the interface object (handle + free lookup). 3914 * But signal the event semaphore first so any waiter holding a reference 3915 * will wake up too (he'll see hIf == invalid and return correctly). 3934 /* Notify the trunk that the interface has been disconnected. */ 3935 PINTNETNETWORK pNetwork = pIf->pNetwork; 3936 PINTNETTRUNKIF pTrunk = pNetwork ? pNetwork->MacTab.pTrunk : NULL; 3937 if (pTrunk && pTrunk->pIfPort) 3938 pTrunk->pIfPort->pfnDisconnectInterface(pTrunk->pIfPort, hIf); 3939 3940 RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy); 3941 3942 /* 3943 * Signal the event semaphore to wake up any threads in IntNetR0IfWait 3944 * and give them a moment to get out and release the interface. 3916 3945 */ 3917 3946 uint32_t i = pIf->cSleepers; … … 3923 3952 RTSemEventSignal(pIf->hRecvEvent); 3924 3953 3954 /* 3955 * Release the references to the interface object (handle + free lookup). 3956 */ 3925 3957 void *pvObj = pIf->pvObj; 3926 3958 intnetR0IfRelease(pIf, pSession); /* (RTHandleTableFreeWithCtx) */ … … 3970 4002 ASMAtomicWriteBool(&pIf->fDestroying, true); 3971 4003 3972 PINTNETNETWORK pNetwork = pIf->pNetwork;3973 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;3974 if (pTrunk && pTrunk->pIfPort)3975 {3976 Log(("intnetR0IfDestruct: pfnDisconnectInterface hIf=%RX32\n", pIf->hIf));3977 pTrunk->pIfPort->pfnDisconnectInterface(pTrunk->pIfPort, pIf->hIf);3978 }3979 3980 4004 /* 3981 4005 * Delete the interface handle so the object no longer can be used. … … 3993 4017 * of cleanup order we might have been orphaned by the network destructor. 3994 4018 */ 4019 PINTNETNETWORK pNetwork = pIf->pNetwork; 3995 4020 if (pNetwork) 3996 4021 { … … 4014 4039 } 4015 4040 4041 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk; 4042 4016 4043 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp); 4044 4045 /* If we freed the handle just now, notify the trunk about the 4046 interface being destroyed. */ 4047 if (hIf != INTNET_HANDLE_INVALID && pTrunk && pTrunk->pIfPort) 4048 pTrunk->pIfPort->pfnDisconnectInterface(pTrunk->pIfPort, hIf); 4017 4049 4018 4050 /* Wait for the interface to quiesce while we still can. */ … … 4214 4246 pIf->pNetwork = pNetwork; 4215 4247 4216 /** @todo handle failure of pfnConnectInterface */ 4248 /* 4249 * Grab a busy reference (paranoia) to the trunk before releaseing 4250 * the spinlock and then notify it about the new interface. 4251 */ 4217 4252 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk; 4218 if (pTrunk && pTrunk->pIfPort) 4253 if (pTrunk) 4254 intnetR0BusyIncTrunk(pTrunk); 4255 4256 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp); 4257 4258 if (pTrunk) 4219 4259 { 4220 4260 Log(("intnetR0NetworkCreateIf: pfnConnectInterface hIf=%RX32\n", pIf->hIf)); 4221 pTrunk->pIfPort->pfnConnectInterface(pTrunk->pIfPort, pIf->hIf); 4261 if (pTrunk->pIfPort) 4262 rc = pTrunk->pIfPort->pfnConnectInterface(pTrunk->pIfPort, pIf->hIf); 4263 intnetR0BusyDecTrunk(pTrunk); 4222 4264 } 4223 4224 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp); 4225 4226 *phIf = pIf->hIf; 4227 Log(("intnetR0NetworkCreateIf: returns VINF_SUCCESS *phIf=%RX32 cbSend=%u cbRecv=%u cbBuf=%u\n", 4228 *phIf, pIf->pIntBufDefault->cbSend, pIf->pIntBufDefault->cbRecv, pIf->pIntBufDefault->cbBuf)); 4229 return VINF_SUCCESS; 4265 if (RT_SUCCESS(rc)) 4266 { 4267 /* 4268 * We're good! 4269 */ 4270 *phIf = pIf->hIf; 4271 Log(("intnetR0NetworkCreateIf: returns VINF_SUCCESS *phIf=%RX32 cbSend=%u cbRecv=%u cbBuf=%u\n", 4272 *phIf, pIf->pIntBufDefault->cbSend, pIf->pIntBufDefault->cbRecv, pIf->pIntBufDefault->cbBuf)); 4273 return VINF_SUCCESS; 4274 } 4230 4275 } 4231 4276 … … 4852 4897 intnetR0BusyWait(pNetwork, &pNetwork->MacTab.paEntries[iIf].pIf->cBusy); 4853 4898 4854 /* Orphan the interfaces (not trunk). */ 4899 /* Orphan the interfaces (not trunk). Don't bother with calling 4900 pfnDisconnectInterface here since the networking is going away. */ 4855 4901 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 4856 4902 while ((iIf = pNetwork->MacTab.cEntries) > 0) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c
r29492 r29635 558 558 static DECLCALLBACK(int) vboxNetFltPortConnectInterface(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf) 559 559 { 560 PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);561 int rc = VINF_SUCCESS;560 PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort); 561 int rc; 562 562 563 563 /* … … 578 578 * @copydoc INTNETTRUNKIFPORT::pfnDisconnectInterface 579 579 */ 580 static DECLCALLBACK( int) vboxNetFltPortDisconnectInterface(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf)581 { 582 PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);583 int rc = VINF_SUCCESS;580 static DECLCALLBACK(void) vboxNetFltPortDisconnectInterface(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf) 581 { 582 PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort); 583 int rc; 584 584 585 585 /* … … 592 592 rc = vboxNetFltPortOsDisconnectInterface(pThis, hIf); 593 593 vboxNetFltRelease(pThis, false /* fBusy */); 594 595 return rc; 594 AssertRC(rc); /** @todo fix vboxNetFltPortOsDisconnectInterface. */ 596 595 } 597 596 … … 998 997 pNew->MyPort.pfnNotifyMacAddress = vboxNetFltPortNotifyMacAddress; 999 998 pNew->MyPort.pfnConnectInterface = vboxNetFltPortConnectInterface; 1000 pNew->MyPort.pfnDisconnectInterface = vboxNetFltPortDisconnectInterface; 999 pNew->MyPort.pfnDisconnectInterface = vboxNetFltPortDisconnectInterface; 1001 1000 pNew->MyPort.u32VersionEnd = INTNETTRUNKIFPORT_VERSION; 1002 1001 pNew->pSwitchPort = pSwitchPort;
Note:
See TracChangeset
for help on using the changeset viewer.