VirtualBox

Changeset 52394 in vbox


Ignore:
Timestamp:
Aug 15, 2014 10:25:31 PM (10 years ago)
Author:
vboxsync
Message:

intnetR0TrunkIfPortDisconnect: Must always release the busy reference to the interface side (netflt) and must not trust pThis->pIfPort to be working as it's cleared before doing the busy waiting in intnetR0TrunkIfDestroy. So, pfnDisconnect has been extended with a pIfPort pointer as well as a function pointer to a busy-release function for pIfPort.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/intnet.h

    r52393 r52394  
    387387
    388388
     389/** Pointer to the interface side of a trunk port. */
     390typedef struct INTNETTRUNKIFPORT *PINTNETTRUNKIFPORT;
     391
     392
     393/**
     394 * Special variation of INTNETTRUNKIFPORT::pfnRelease for use with
     395 * INTNETTRUNKSWPORT::pfnDisconnect.
     396 *
     397 * @param   pIfPort     Pointer to the INTNETTRUNKIFPORT instance.
     398 */
     399typedef DECLCALLBACK(void) FNINTNETTRUNKIFPORTRELEASEBUSY(PINTNETTRUNKIFPORT pIfPort);
     400/** Pointer to a FNINTNETTRUNKIFPORTRELEASEBUSY function. */
     401typedef FNINTNETTRUNKIFPORTRELEASEBUSY *PFNINTNETTRUNKIFPORTRELEASEBUSY;
     402
     403
    389404/** Pointer to the switch side of a trunk port. */
    390405typedef struct INTNETTRUNKSWPORT *PINTNETTRUNKSWPORT;
     
    566581     *
    567582     * The caller shall must be busy when calling this method to prevent racing the
    568      * network destruction code. This method will consume this busy reference
    569      * (released via INTNETTRUNKIFPORT::pfnRelease).
     583     * network destruction code. This method will always consume this busy reference
     584     * (released via @a pfnReleaseBusy using @a pIfPort).
    570585     *
    571586     * The caller shall guarantee that there are absolutely no chance of concurrent
     
    573588     *
    574589     * @param   pSwitchPort         Pointer to this structure.
    575      */
    576     DECLR0CALLBACKMEMBER(void, pfnDisconnect,(PINTNETTRUNKSWPORT pSwitchPort));
     590     * @param   pIfPort             The interface port structure corresponding to @a
     591     *                              pSwitchPort and which should be used when
     592     *                              calling @a pfnReleaseBusy.  This is required as
     593     *                              the method may no longer have access to a valid
     594     *                              @a pIfPort pointer.
     595     * @param   pfnReleaseBusy      Callback for releasing the callers busy
     596     *                              reference to it's side of things.
     597     */
     598    DECLR0CALLBACKMEMBER(void, pfnDisconnect,(PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT pIfPort,
     599                                              PFNINTNETTRUNKIFPORTRELEASEBUSY pfnReleaseBusy));
    577600#endif /* VBOX_WITH_INTNET_DISCONNECT */
    578601
     
    583606/** Version number for the INTNETTRUNKIFPORT::u32Version and INTNETTRUNKIFPORT::u32VersionEnd fields. */
    584607#ifdef VBOX_WITH_INTNET_DISCONNECT
    585 #define INTNETTRUNKSWPORT_VERSION   UINT32_C(0xA2CDf002)
    586 #else /* !VBOX_WITH_INTNET_DISCONNECT */
    587 #define INTNETTRUNKSWPORT_VERSION   UINT32_C(0xA2CDf001)
    588 #endif /* !VBOX_WITH_INTNET_DISCONNECT */
     608# define INTNETTRUNKSWPORT_VERSION   UINT32_C(0xA2CDf003)
     609#else
     610# define INTNETTRUNKSWPORT_VERSION   UINT32_C(0xA2CDf001)
     611#endif
    589612
    590613
     
    610633} INTNETTRUNKIFSTATE;
    611634
    612 /** Pointer to the interface side of a trunk port. */
    613 typedef struct INTNETTRUNKIFPORT *PINTNETTRUNKIFPORT;
     635
    614636/**
    615637 * This is the port on the trunk interface, i.e. the driver side which the
     
    639661     * This must be called for every pfnRetain call.
    640662     *
    641      *
    642663     * @param   pIfPort     Pointer to this structure.
    643664     *
    644665     * @remarks May own the big mutex, no spinlocks.
    645666     */
    646 #ifdef VBOX_WITH_INTNET_DISCONNECT
    647     DECLR0CALLBACKMEMBER(void, pfnRelease,(PINTNETTRUNKIFPORT pIfPort, bool fBusy));
    648 #else /* !VBOX_WITH_INTNET_DISCONNECT */
    649667    DECLR0CALLBACKMEMBER(void, pfnRelease,(PINTNETTRUNKIFPORT pIfPort));
    650 #endif /* !VBOX_WITH_INTNET_DISCONNECT */
    651668
    652669    /**
     
    770787
    771788/** Version number for the INTNETTRUNKIFPORT::u32Version and INTNETTRUNKIFPORT::u32VersionEnd fields. */
    772 #ifdef VBOX_WITH_INTNET_DISCONNECT
    773 #define INTNETTRUNKIFPORT_VERSION   UINT32_C(0xA2CDe002)
    774 #else /* !VBOX_WITH_INTNET_DISCONNECT */
    775789#define INTNETTRUNKIFPORT_VERSION   UINT32_C(0xA2CDe001)
    776 #endif /* !VBOX_WITH_INTNET_DISCONNECT */
    777790
    778791
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r52393 r52394  
    450450
    451451
    452 #ifdef VBOX_WITH_INTNET_DISCONNECT
    453452/*******************************************************************************
    454453*   Forward Declarations                                                       *
     
    472471    return false;
    473472}
    474 #endif /* VBOX_WITH_INTNET_DISCONNECT */
    475473
    476474
     
    50125010#ifdef VBOX_WITH_INTNET_DISCONNECT
    50135011/** @copydoc INTNETTRUNKSWPORT::pfnDisconnect */
    5014 static DECLCALLBACK(void) intnetR0TrunkIfPortDisconnect(PINTNETTRUNKSWPORT pSwitchPort)
     5012static DECLCALLBACK(void) intnetR0TrunkIfPortDisconnect(PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT pIfPort,
     5013                                                        PFNINTNETTRUNKIFPORTRELEASEBUSY pfnReleaseBusy)
    50155014{
    50165015    PINTNETTRUNKIF pThis = INTNET_SWITCHPORT_2_TRUNKIF(pSwitchPort);
     
    50375036         * pointer after taking ownership of the big mutex.
    50385037         */
    5039         pThis->pIfPort->pfnRelease(pThis->pIfPort, true /*fBusy*/);
     5038        pfnReleaseBusy(pIfPort);
    50405039
    50415040        RTSemMutexRequest(pIntNet->hMtxCreateOpenDestroy, RT_INDEFINITE_WAIT);
     
    50445043        {
    50455044            Assert(pNetwork->MacTab.pTrunk == pThis); /* Must be valid as long as tehre are no concurrent calls to this method. */
     5045            Assert(pThis->pIfPort == pIfPort);        /* Ditto */
    50465046
    50475047            /*
     
    50495049             * intnetR0NetworkDestruct.
    50505050             */
    5051             pThis->pIfPort->pfnSetState(pThis->pIfPort, INTNETTRUNKIFSTATE_DISCONNECTING);
     5051            pIfPort->pfnSetState(pIfPort, INTNETTRUNKIFSTATE_DISCONNECTING);
    50525052
    50535053            RTSpinlockAcquire(pNetwork->hAddrSpinlock);
     
    50605060        RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy);
    50615061    }
     5062    /*
     5063     * We must always release the busy reference.
     5064     */
     5065    else
     5066        pfnReleaseBusy(pIfPort);
    50625067}
    50635068#endif /* VBOX_WITH_INTNET_DISCONNECT */
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c

    r52134 r52394  
    749749
    750750/**
    751  * @copydoc INTNETTRUNKIFPORT::pfnRetain
    752  */
    753 #ifdef VBOX_WITH_INTNET_DISCONNECT
    754 static DECLCALLBACK(void) vboxNetFltPortRelease(PINTNETTRUNKIFPORT pIfPort, bool fBusy)
    755 {
    756     PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);
    757     vboxNetFltRelease(pThis, fBusy);
    758 }
    759 #else /* !VBOX_WITH_INTNET_DISCONNECT */
     751 * @copydoc INTNETTRUNKIFPORT::pfnRelease
     752 */
    760753static DECLCALLBACK(void) vboxNetFltPortRelease(PINTNETTRUNKIFPORT pIfPort)
    761754{
     
    763756    vboxNetFltRelease(pThis, false /* fBusy */);
    764757}
    765 #endif /* !VBOX_WITH_INTNET_DISCONNECT */
     758
     759
     760/**
     761 * @callback_method_impl{FNINTNETTRUNKIFPORTRELEASEBUSY}
     762 */
     763DECLHIDDEN(DECLCALLBACK(void)) vboxNetFltPortReleaseBusy(PINTNETTRUNKIFPORT pIfPort)
     764{
     765    PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);
     766    vboxNetFltRelease(pThis, true /*fBusy*/);
     767}
    766768
    767769
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h

    r46904 r52394  
    330330DECLHIDDEN(PVBOXNETFLTINS) vboxNetFltFindInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName);
    331331
     332DECLHIDDEN(DECLCALLBACK(void)) vboxNetFltPortReleaseBusy(PINTNETTRUNKIFPORT pIfPort);
    332333DECLHIDDEN(void) vboxNetFltRetain(PVBOXNETFLTINS pThis, bool fBusy);
    333334DECLHIDDEN(bool) vboxNetFltTryRetainBusyActive(PVBOXNETFLTINS pThis);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette