VirtualBox

Changeset 17184 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 27, 2009 12:37:35 AM (16 years ago)
Author:
vboxsync
Message:

VBoxNetFlt: review of core changes, several review comments needing follow up. untested

Location:
trunk/src/VBox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r16856 r17184  
    37433743        if (RT_SUCCESS(rc))
    37443744        {
    3745             rc = pTrunkFactory->pfnCreateAndConnect(pTrunkFactory, pNetwork->szTrunk, &pTrunkIF->SwitchPort, &pTrunkIF->pIfPort, !!(pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE));
     3745            rc = pTrunkFactory->pfnCreateAndConnect(pTrunkFactory, pNetwork->szTrunk, &pTrunkIF->SwitchPort, !
     3746                                                    pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE
     3747                                                    ? INTNETTRUNKFACTORY_FLAG_NO_PROMISC : 0,
     3748                                                    &pTrunkIF->pIfPort);
    37463749            pTrunkFactory->pfnRelease(pTrunkFactory);
    37473750            if (RT_SUCCESS(rc))
     
    38993902     */
    39003903    PINTNETNETWORK pCur;
    3901     uint8_t cchName = strlen(pszNetwork);
     3904    uint8_t cchName = (uint8_t)strlen(pszNetwork);
    39023905    Assert(cchName && cchName < sizeof(pCur->szName)); /* caller ensures this */
    39033906
     
    40084011        pNew->fFlags = fFlags;
    40094012        size_t cchName = strlen(pszNetwork);
    4010         pNew->cchName = cchName;
     4013        pNew->cchName = (uint8_t)cchName;
    40114014        Assert(cchName && cchName < sizeof(pNew->szName));  /* caller's responsibility. */
    40124015        memcpy(pNew->szName, pszNetwork, cchName);          /* '\0' by alloc. */
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c

    r17118 r17184  
    2020 */
    2121
     22/** @page pg_netadp     VBoxNetAdp - Network Adapter
     23 *
     24 * This is a kernel module that creates a virtual interface that can be attached
     25 * to an internal network.
     26 *
     27 * In the big picture we're one of the three trunk interface on the internal
     28 * network, the one named "TAP Interface": @image html Networking_Overview.gif
     29 *
     30 */
     31
    2232/*******************************************************************************
    2333*   Header Files                                                               *
    2434*******************************************************************************/
    25 #define LOG_GROUP LOG_GROUP_NET_TAP_DRV
     35#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
    2636#include "VBoxNetAdpInternal.h"
    2737
     
    3545#include <iprt/uuid.h>
    3646
     47/** r=bird: why is this here in the agnositc code? */
    3748#ifndef RT_OS_SOLARIS
    38 #include <net/ethernet.h>
    39 #include <net/if_ether.h>
    40 #include <net/if_types.h>
    41 #include <sys/socket.h>
    42 #include <net/if.h>
    43 #include <net/if_dl.h>
    44 #include <sys/errno.h>
    45 #include <sys/param.h>
     49# include <net/ethernet.h>
     50# include <net/if_ether.h>
     51# include <net/if_types.h>
     52# include <sys/socket.h>
     53# include <net/if.h>
     54# include <net/if_dl.h>
     55# include <sys/errno.h>
     56# include <sys/param.h>
    4657#endif
    4758
     
    7990
    8091
     92AssertCompileMemberSize(VBOXNETADP, enmState, sizeof(uint32_t));
    8193
    8294/**
     
    107119    ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmState, enmNewState);
    108120}
     121
    109122
    110123/**
     
    125138    RTSpinlockRelease(pThis->hSpinlock, &Tmp);
    126139}
    127 
    128140
    129141
     
    147159}
    148160
     161
    149162/**
    150163 * Checks and sets the enmState member atomically.
     
    161174    bool fRc = true; /* be optimistic */
    162175    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
     176
    163177    RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    164     enmActualState = vboxNetAdpGetState(pThis);
     178    enmActualState = vboxNetAdpGetState(pThis); /** @todo r=bird: ASMAtomicCmpXchgU32()*/
    165179    if (enmActualState == enmOldState)
    166180        vboxNetAdpSetState(pThis, enmNewState);
     
    168182        fRc = false;
    169183    RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     184
    170185    if (fRc)
    171186        Log(("vboxNetAdpCheckAndSetState: pThis=%p, state changed: %d -> %d.\n", pThis, enmOldState, enmNewState));
     
    176191
    177192
    178 
     193/**
     194 * Finds a instance by its name, the caller does the locking.
     195 *
     196 *
     197 * @returns Pointer to the instance by the given name. NULL if not found.
     198 * @param   pGlobals        The globals.
     199 * @param   pszName         The name of the instance.
     200 */
    179201static PVBOXNETADP vboxNetAdpFind(PVBOXNETADPGLOBALS pGlobals, const char *pszName)
    180202{
     
    186208        PVBOXNETADP pThis = &pGlobals->aAdapters[i];
    187209        RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    188         if (vboxNetAdpGetState(pThis)
    189             && !strcmp(pThis->szName, pszName))
     210        if (    vboxNetAdpGetState(pThis)
     211            &&  !strcmp(pThis->szName, pszName))
    190212        {
    191213            RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     
    196218    return NULL;
    197219}
     220
    198221
    199222/**
     
    226249}
    227250
     251
    228252/**
    229253 * Decrements the busy counter and does idle wakeup.
     
    254278        Assert(cBusy < UINT32_MAX / 2);
    255279}
     280
    256281
    257282/**
     
    285310}
    286311
     312
    287313/**
    288314 * Increments busy counter.
     
    309335}
    310336
     337
    311338/**
    312339 * Checks if receive is possible and increases busy and ref counters if so.
     
    335362    return fCanReceive;
    336363}
     364
    337365
    338366/**
     
    356384    vboxNetAdpRelease(pThis);
    357385}
     386
    358387
    359388/**
     
    424453    vboxNetAdpBusy(pThis);
    425454    RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     455
    426456    rc = vboxNetAdpPortOsXmit(pThis, pSG, fDst);
    427457    vboxNetAdpIdle(pThis);
     
    543573    Log(("vboxNetAdpPortSetActive: pThis=%p, fActive=%d, state before: %d.\n", pThis, fActive, vboxNetAdpGetState(pThis)));
    544574    RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     575
    545576    fPreviouslyActive = vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Active;
    546577    if (fPreviouslyActive != fActive)
     
    558589        }
    559590    }
     591
    560592    RTSpinlockRelease(pThis->hSpinlock, &Tmp);
    561     Log(("vboxNetAdpPortSetActive: state after: %d.\n", vboxNetAdpGetState(pThis)));
     593    Log(("vboxNetAdpPortSetActive: state after: %RTbool.\n", vboxNetAdpGetState(pThis)));
    562594    return fPreviouslyActive;
    563595}
     
    633665        RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    634666        PVBOXNETADP pThis = &pGlobals->aAdapters[i];
    635    
     667
    636668        if (vboxNetAdpCheckAndSetState(pThis, kVBoxNetAdpState_Invalid, kVBoxNetAdpState_Transitional))
    637669        {
     
    657689    int rc = VINF_SUCCESS;
    658690    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    659    
     691
    660692    RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    661693    if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Available || pThis->cBusy)
     
    716748}
    717749
     750
    718751/**
    719752 * @copydoc INTNETTRUNKFACTORY::pfnCreateAndConnect
    720753 */
    721754static DECLCALLBACK(int) vboxNetAdpFactoryCreateAndConnect(PINTNETTRUNKFACTORY pIfFactory, const char *pszName,
    722                                                            PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort, bool fNoPromisc)
    723 {
     755                                                           PINTNETTRUNKSWPORT pSwitchPort, uint32_t fFlags,
     756                                                           PINTNETTRUNKIFPORT *ppIfPort)
     757{
     758    PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));
    724759    PVBOXNETADP pThis;
    725760    int rc;
    726     PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));
    727 
    728     LogFlow(("vboxNetAdpFactoryCreateAndConnect: pszName=%p:{%s}\n", pszName, pszName));
     761
     762    LogFlow(("vboxNetAdpFactoryCreateAndConnect: pszName=%p:{%s} fFlags=%#x\n", pszName, pszName, fFlags));
    729763    Assert(pGlobals->cFactoryRefs > 0);
     764    AssertMsgReturn(fFlags,
     765                    ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
    730766
    731767    /*
     
    749785    return rc;
    750786}
     787
    751788
    752789/**
     
    956993}
    957994
     995
    958996/**
    959997 * Called by the native part when the OS wants the driver to unload.
     
    9661004{
    9671005    int rc = vboxNetAdpTryDeleteIdc(pGlobals);
    968     if(RT_SUCCESS(rc))
     1006    if (RT_SUCCESS(rc))
    9691007    {
    9701008        vboxNetAdpDeleteGlobalsBase(pGlobals);
     
    10371075        if (RT_SUCCESS(rc))
    10381076        {
    1039             /* @todo REMOVE ME! */
     1077#if 1 /** @todo REMOVE ME! */
    10401078            PVBOXNETADP pTmp;
    10411079            rc = vboxNetAdpCreate(&pGlobals->TrunkFactory, &pTmp);
    10421080            if (RT_FAILURE(rc))
    10431081                Log(("Failed to create vboxnet0, rc=%Rrc.\n", rc));
     1082#endif
    10441083            Log(("VBoxNetAdp: pSession=%p\n", SUPR0IdcGetSession(&pGlobals->SupDrvIDC)));
    10451084            return rc;
     
    10831122    return rc;
    10841123}
     1124
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp

    r17118 r17184  
    3232#undef PVM
    3333
    34 #define LOG_GROUP LOG_GROUP_NET_TAP_DRV
     34#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
    3535#include <VBox/log.h>
    3636#include <VBox/err.h>
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/solaris/VBoxNetAdp-solaris.c

    r17025 r17184  
    2727#endif
    2828
    29 #define LOG_GROUP LOG_GROUP_NET_TAP_DRV
     29#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
    3030#include <VBox/log.h>
    3131#include <VBox/err.h>
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c

    r16927 r17184  
    236236
    237237
     238AssertCompileMemberSize(VBOXNETFLTINS, enmState, sizeof(uint32_t));
     239
     240/**
     241 * Sets the enmState member atomically.
     242 *
     243 * Used for all updates.
     244 *
     245 * @param   pThis           The instance.
     246 * @param   enmNewState     The new value.
     247 */
     248DECLINLINE(void) vboxNetFltSetState(PVBOXNETFLTINS pThis, VBOXNETFTLINSSTATE enmNewState)
     249{
     250    ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmState, enmNewState);
     251}
     252
     253
     254/**
     255 * Gets the enmState member atomically.
     256 *
     257 * Used for all reads.
     258 *
     259 * @returns The enmState value.
     260 * @param   pThis           The instance.
     261 */
     262DECLINLINE(VBOXNETFTLINSSTATE) vboxNetFltGetState(PVBOXNETFLTINS pThis)
     263{
     264    return (VBOXNETFTLINSSTATE)ASMAtomicUoReadU32((uint32_t volatile *)&pThis->enmState);
     265}
     266
     267
    238268/**
    239269 * Finds a instance by its name, the caller does the locking.
    240  *
    241270 *
    242271 * @returns Pointer to the instance by the given name. NULL if not found.
     
    256285/**
    257286 * Finds a instance by its name, will request the mutex.
     287 *
     288 * No reference to the instance is retained, we're assuming the caller to
     289 * already have one but just for some reason doesn't have the pointer to it.
    258290 *
    259291 * @returns Pointer to the instance by the given name. NULL if not found.
     
    300332
    301333
    302 AssertCompileMemberSize(VBOXNETFLTINS, enmState, sizeof(uint32_t));
    303 
    304 /**
    305  * Sets the enmState member atomically.
    306  *
    307  * Used for all updates.
    308  *
    309  * @param   pThis           The instance.
    310  * @param   enmNewState     The new value.
    311  */
    312 DECLINLINE(void) vboxNetFltSetState(PVBOXNETFLTINS pThis, VBOXNETFTLINSSTATE enmNewState)
    313 {
    314     ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmState, enmNewState);
    315 }
    316 
    317 
    318 /**
    319  * Gets the enmState member atomically.
    320  *
    321  * Used for all reads.
    322  *
    323  * @returns The enmState value.
    324  * @param   pThis           The instance.
    325  */
    326 DECLINLINE(VBOXNETFTLINSSTATE) vboxNetFltGetState(PVBOXNETFLTINS pThis)
    327 {
    328     return (VBOXNETFTLINSSTATE)ASMAtomicUoReadU32((uint32_t volatile *)&pThis->enmState);
    329 }
    330 
    331 
    332334/**
    333335 * Performs interface rediscovery if it was disconnected from the host.
     
    611613 * Destroy a device that has been disconnected from the switch.
    612614 *
    613  * @return true iff the instance is destroyed, false otherwise
     615 * @returns true if the instance is destroyed, false otherwise.
    614616 * @param   pThis               The instance to be destroyed. This is
    615617 *                              no longer valid when this function returns.
    616618 */
    617 static bool vboxNetFltCheckDestroyInstance(PVBOXNETFLTINS pThis)
     619static bool vboxNetFltDestroyInstance(PVBOXNETFLTINS pThis)
    618620{
    619621    PVBOXNETFLTGLOBALS pGlobals = pThis->pGlobals;
     622    uint32_t cRefs = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->cRefs);
    620623    int rc;
    621     uint32_t cRefs = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->cRefs);
    622     LogFlow(("vboxNetFltCheckDestroyInstance: pThis=%p (%s)\n", pThis, pThis->szName));
     624    LogFlow(("vboxNetFltDestroyInstance: pThis=%p (%s)\n", pThis, pThis->szName));
    623625
    624626    /*
     
    638640
    639641    /*
    640      * Make sure the state is 'disconnecting' and let the OS specific code
    641      * do its part of the cleanup outside the mutex.
     642     * Make sure the state is 'disconnecting' / 'destroying' and let the OS
     643     * specific code do its part of the cleanup outside the mutex.
    642644     */
    643645    rc = RTSemFastMutexRequest(pGlobals->hFastMtx); AssertRC(rc);
    644     if(cRefs != 0)
     646#ifdef VBOXNETFLT_STATIC_CONFIG
     647/** @todo r=bird: This looks kind of insane! I ASSUME this is specific to the
     648 * static config and to devices in the Unconnected state only. This *looks* like
     649 * a very unhealthy race between driver unloading and vboxNetFltFactoryCreateAndConnect.
     650 * If I'm right, then vboxNetFltFactoryCreateAndConnect should be made to back down one
     651 * way or the other, it should not the other way around. (see suggestion further down)
     652 *
     653 * If I'm wrong, then please explain in full.
     654 */
     655    if (cRefs != 0)
    645656    {
    646657        Assert(cRefs < UINT32_MAX / 2);
     
    649660    }
    650661    vboxNetFltSetState(pThis, kVBoxNetFltInsState_Destroying);
     662#else
     663    vboxNetFltSetState(pThis, kVBoxNetFltInsState_Disconnecting);
     664#endif
    651665    RTSemFastMutexRelease(pGlobals->hFastMtx);
    652666
     
    716730    cRefs = ASMAtomicDecU32(&pThis->cRefs);
    717731    if (!cRefs)
    718         vboxNetFltCheckDestroyInstance(pThis);
     732        vboxNetFltDestroyInstance(pThis);
    719733    else
    720734        Assert(cRefs < UINT32_MAX / 2);
     
    822836    {
    823837        vboxNetFltSetState(pThis, kVBoxNetFltInsState_Connected);
    824 #ifdef VBOXNETFLT_STATIC_CONFIG
    825838        *ppIfPort = &pThis->MyPort;
    826 #endif
    827839    }
    828840    else
     
    846858 * @param   pszName             The instance name.
    847859 * @param   pSwitchPort         The port on the switch that we're connected with (dynamic only).
     860 * @param   fNoPromisc          Do not attempt going into promiscuous mode.
     861 * @param   pvContext           Context argument for vboxNetFltOsInitInstance.
    848862 * @param   ppIfPort            Where to store the pointer to our port interface (dynamic only).
    849  * @param   fNoPromisc          Do not attempt going into promiscuous mode.
    850  */
    851 static int vboxNetFltNewInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort, bool fNoPromisc
    852 #ifdef VBOXNETFLT_STATIC_CONFIG
    853         , void * pContext
    854 #endif
    855         )
     863 */
     864static int vboxNetFltNewInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PINTNETTRUNKSWPORT pSwitchPort,
     865                                 bool fNoPromisc, void *pvContext, PINTNETTRUNKIFPORT *ppIfPort)
    856866{
    857867    /*
     
    914924                         * Call the OS specific initialization code.
    915925                         */
    916                         rc = vboxNetFltOsInitInstance(pNew
    917 #ifdef VBOXNETFLT_STATIC_CONFIG
    918                                 , pContext
    919 #endif
    920                                 );
     926                        rc = vboxNetFltOsInitInstance(pNew, pvContext);
    921927                        RTSemFastMutexRequest(pGlobals->hFastMtx);
    922928                        if (RT_SUCCESS(rc))
    923929                        {
    924930#ifdef VBOXNETFLT_STATIC_CONFIG
     931                            /*
     932                             * Static instances are unconnected at birth.
     933                             */
     934                            Assert(!pSwitchPort);
    925935                            pNew->enmState = kVBoxNetFltInsState_Unconnected;
    926                             Assert(!pSwitchPort);
     936                            RTSemFastMutexRelease(pGlobals->hFastMtx);
    927937                            *ppIfPort = &pNew->MyPort;
    928                             RTSemFastMutexRelease(pGlobals->hFastMtx);
    929938                            return rc;
    930939
    931 #else
     940#else  /* !VBOXNETFLT_STATIC_CONFIG */
    932941                            /*
    933942                             * Connect it as well, the OS specific bits has to be done outside
     
    938947                            {
    939948                                RTSemFastMutexRelease(pGlobals->hFastMtx);
    940                                 *ppIfPort = &pNew->MyPort;
     949                                Assert(*ppIfPort == &pNew->MyPort);
    941950                                return rc;
    942951                            }
     
    944953                            /* Bail out (failed). */
    945954                            vboxNetFltOsDeleteInstance(pNew);
    946 #endif
     955#endif /* !VBOXNETFLT_STATIC_CONFIG */
    947956                        }
    948957                        vboxNetFltUnlinkLocked(pGlobals, pNew);
     
    962971}
    963972
     973
    964974#ifdef VBOXNETFLT_STATIC_CONFIG
    965 
    966 /**
    967  * searches for the NetFlt instance by its name and creates the new one if not found
    968  *
    969  * @return VINF_SUCCESS if new instance was created, VINF_ALREADY_INITIALIZED if an instanmce already exists,
    970  * VERR_xxx in case of a failure
    971  */
    972 DECLHIDDEN(int) vboxNetFltSearchCreateInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PVBOXNETFLTINS *ppInstance, void * pContext)
     975/**
     976 * Searches for the NetFlt instance by its name and creates the new one if not found.
     977 *
     978 * @returns VBox status code.
     979 * @retval  VINF_SUCCESS and *ppInstance if a new instance was created.
     980 * @retval  VINF_ALREADY_INITIALIZED and *ppInstance if an instance already exists.
     981 *
     982 * @param   pGlobal     Pointer to the globals.
     983 * @param   pszName     The instance name.
     984 * @param   ppInstance  Where to return the instance pointer on success.
     985 * @param   pvContext   Context which needs to be passed along to vboxNetFltOsInitInstance.
     986 */
     987DECLHIDDEN(int) vboxNetFltSearchCreateInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PVBOXNETFLTINS *ppInstance, void *pvContext)
    973988{
    974989    PINTNETTRUNKIFPORT pIfPort;
     
    978993    AssertRCReturn(rc, rc);
    979994
     995    /*
     996     * Look for an existing instance in the list.
     997     *
     998     * If found that it's being destroyed, wait for it to go away.
     999     * Return instances in other states ASSUMING that it has lost the
     1000     * connection.
     1001     */
    9801002    *ppInstance = vboxNetFltFindInstanceLocked(pGlobals, pszName);
    981     if(*ppInstance)
     1003    while (*ppInstance)
    9821004    {
    9831005        VBOXNETFTLINSSTATE enmState = vboxNetFltGetState(*ppInstance);
    984         if(enmState != kVBoxNetFltInsState_Destroying && enmState != kVBoxNetFltInsState_Destroyed)
     1006        if (    enmState != kVBoxNetFltInsState_Destroying
     1007            &&  enmState != kVBoxNetFltInsState_Destroyed)
    9851008        {
    986             vboxNetFltRetain(*ppInstance, false);
     1009            /** @todo r=bird: who is making sure this is a genuine reconnection case? */
     1010            vboxNetFltRetain(*ppInstance, false /* fBusy */);
    9871011            RTSemFastMutexRelease(pGlobals->hFastMtx);
    9881012            return VINF_ALREADY_INITIALIZED;
    9891013        }
    9901014
    991         /*wait for the instance to be removed from the list */
    992 
    993         *ppInstance = NULL;
    994 
    995         do
    996         {
    997             RTSemFastMutexRelease(pGlobals->hFastMtx);
    998 
    999             RTSemEventWait(pGlobals->hTimerEvent, 2);
    1000 
    1001             rc = RTSemFastMutexRequest(pGlobals->hFastMtx);
    1002             AssertRCReturn(rc, rc);
    1003         } while(vboxNetFltFindInstanceLocked(pGlobals, pszName));
     1015        /* wait 2 ms */ /** @todo r=bird: Doesn't RTThreadSleep() work here? If it's bust, I'd like to know it so we can fix it... */
     1016        RTSemFastMutexRelease(pGlobals->hFastMtx);
     1017        RTSemEventWait(pGlobals->hBlockEvent, 2);
     1018        rc = RTSemFastMutexRequest(pGlobals->hFastMtx);
     1019        AssertRCReturn(rc, rc);
     1020
     1021        /* try again */
     1022        *ppInstance = vboxNetFltFindInstanceLocked(pGlobals, pszName);
    10041023    }
    10051024
    10061025    RTSemFastMutexRelease(pGlobals->hFastMtx);
    10071026
    1008     rc = vboxNetFltNewInstance(pGlobals, pszName, NULL, &pIfPort, false, pContext);
    1009     if(RT_SUCCESS(rc))
    1010         *ppInstance =  IFPORT_2_VBOXNETFLTINS(pIfPort);
     1027    /*
     1028     * Try create a new instance.
     1029     * (fNoPromisc is overridden in the vboxNetFltFactoryCreateAndConnect path, so pass true here.)
     1030     */
     1031    rc = vboxNetFltNewInstance(pGlobals, pszName, NULL, true /* fNoPromisc */, pvContext, &pIfPort);
     1032    if (RT_SUCCESS(rc))
     1033        *ppInstance = IFPORT_2_VBOXNETFLTINS(pIfPort);
    10111034    else
    10121035        *ppInstance = NULL;
     
    10141037    return rc;
    10151038}
    1016 
    1017 #endif
     1039#endif /* VBOXNETFLT_STATIC_CONFIG */
     1040
    10181041
    10191042/**
     
    10211044 */
    10221045static DECLCALLBACK(int) vboxNetFltFactoryCreateAndConnect(PINTNETTRUNKFACTORY pIfFactory, const char *pszName,
    1023                                                            PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort, bool fNoPromisc)
     1046                                                           PINTNETTRUNKSWPORT pSwitchPort, uint32_t fFlags,
     1047                                                           PINTNETTRUNKIFPORT *ppIfPort)
    10241048{
    10251049    PVBOXNETFLTGLOBALS pGlobals = (PVBOXNETFLTGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETFLTGLOBALS, TrunkFactory));
     
    10271051    int rc;
    10281052
    1029     LogFlow(("vboxNetFltFactoryCreateAndConnect: pszName=%p:{%s}\n", pszName, pszName));
     1053    LogFlow(("vboxNetFltFactoryCreateAndConnect: pszName=%p:{%s} fFlags=%#x\n", pszName, pszName, fFlags));
    10301054    Assert(pGlobals->cFactoryRefs > 0);
     1055    AssertMsgReturn(fFlags & ~(INTNETTRUNKFACTORY_FLAG_NO_PROMISC),
     1056                    ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
    10311057
    10321058    /*
     
    10391065#if defined(VBOX_TAPMINIPORT) && defined(RT_OS_WINDOWS)
    10401066    /* temporary hack to pick up the first adapter */
    1041     pCur = pGlobals->pInstanceHead;
     1067    pCur = pGlobals->pInstanceHead; /** @todo Don't for get to remove this temporary hack... :-) */
    10421068#else
    10431069    pCur = vboxNetFltFindInstanceLocked(pGlobals, pszName);
     
    10461072    {
    10471073#ifdef VBOXNETFLT_STATIC_CONFIG
    1048         switch (vboxNetFltGetState(pCur))
     1074# if 0 /** @todo r=bird: We need to fix the race here. The race is against release+destructor, the
     1075        * tell tale is a cRefs of and since cRefs is manipulated in an atomic fashion we can simply attempt
     1076        * to grab a reference atomically, the worst thing that can happen is that we have to decrement it again..
     1077        * Here is my suggestion: */
     1078        /* Try grab a reference. If the count had already reached zero we're racing the
     1079           destructor code and must back down. */
     1080        uint32_t cRefs = ASMAtomicIncU32(&pCur->cRefs);
     1081        if (cRefs > 1)
    10491082        {
    1050             case kVBoxNetFltInsState_Unconnected:
    1051                 /* instance can be destroyed when it is neither used by the IntNet nor by the ndis filter driver mechanism
    1052                  * (i.e. the driver is not bound to the specified adapter)*/
    1053                 /* Prevent setting promiscuous mode for WiFi adapters. */
    1054                 pCur->fDisablePromiscuous = fNoPromisc;
    1055                 LogAleksey(("fNoPromisc=%d\n", pCur->fDisablePromiscuous));
    1056                 vboxNetFltRetain(pCur, false /* fBusy */); /** @todo who releases this on failure? */
     1083            if (vboxNetFltGetState(pCur) == kVBoxNetFltInsState_Unconnected)
     1084            {
     1085                pCur->fDisablePromiscuous = !!(fFlags & INTNETTRUNKFACTORY_FLAG_NO_PROMISC);
    10571086                rc = vboxNetFltConnectIt(pCur, pSwitchPort, ppIfPort);
    1058                 break;
    1059             case kVBoxNetFltInsState_Connected:
    1060                 AssertFailed();
     1087                if (RT_SUCCESS(rc))
     1088                    pCur = NULL; /* Don't release it, reference given to the caller. */
     1089            }
     1090            else
    10611091                rc = VERR_INTNET_FLT_IF_BUSY;
    1062                 break;
    1063             case kVBoxNetFltInsState_Disconnecting:
    1064                 AssertFailed();
    1065                 rc = VERR_INTNET_FLT_IF_BUSY;
    1066                 break;
    1067             default:
    1068                 /** @todo what? */
    1069                 rc = VERR_INTNET_FLT_IF_BUSY;
    1070                 break;
    10711092        }
     1093        else
     1094        {
     1095            Assert(cRefs == 1);
     1096            ASMAtomicDecU32(&pCur->cRefs);
     1097            pCur = NULL; /* nothing to release */
     1098            rc = VERR_INTNET_FLT_IF_NOT_FOUND;
     1099        }
     1100
     1101        RTSemFastMutexRelease(pGlobals->hFastMtx);
     1102        if (pCur)
     1103            vboxNetFltRelease(pCur, false /* fBusy */);
     1104
     1105# else
     1106        if (vboxNetFltGetState(pCur) == kVBoxNetFltInsState_Unconnected)
     1107        {
     1108            vboxNetFltRetain(pCur, false /* fBusy */); /** @todo r=bird: Who releases this on failure?  */
     1109            pCur->fDisablePromiscuous = !!(fFlags & INTNETTRUNKFACTORY_FLAG_NO_PROMISC);
     1110            rc = vboxNetFltConnectIt(pCur, pSwitchPort, ppIfPort);
     1111        }
     1112        else
     1113            rc = VERR_INTNET_FLT_IF_BUSY;
     1114        RTSemFastMutexRelease(pGlobals->hFastMtx);
     1115# endif
    10721116#else
    10731117        rc = VERR_INTNET_FLT_IF_BUSY;
     1118        RTSemFastMutexRelease(pGlobals->hFastMtx);
    10741119#endif
    1075         RTSemFastMutexRelease(pGlobals->hFastMtx);
    10761120        LogFlow(("vboxNetFltFactoryCreateAndConnect: returns %Rrc\n", rc));
    10771121        return rc;
     
    10861130     * Dynamically create a new instance.
    10871131     */
    1088     rc = vboxNetFltNewInstance(pGlobals, pszName, pSwitchPort, ppIfPort, fNoPromisc);
     1132    rc = vboxNetFltNewInstance(pGlobals, pszName, pSwitchPort,
     1133                               !!(fFlags & INTNETTRUNKFACTORY_FLAG_NO_PROMISC),
     1134                               ppIfPort);
    10891135#endif
    10901136    LogFlow(("vboxNetFltFactoryCreateAndConnect: returns %Rrc\n", rc));
     
    11651211}
    11661212
    1167 /**
    1168  * tries to deinitialize Idc
    1169  * we separate the globals settings "base" which is actually
    1170  * "general" globals settings except for Idc, and idc.
    1171  * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
    1172  * thus it's not possible to make idc initialization from the driver startup routine for it,
    1173  * though the "base is still needed for the driver to functions".
    1174  * @param pGlobals
    1175  * @return VINF_SUCCESS on succes, VERR_WRONG_ORDER if we're busy.
     1213
     1214/**
     1215 * Try to close the IDC connection to SUPDRV if established.
     1216 *
     1217 * @returns VBox status code.
     1218 * @retval  VINF_SUCCESS on success.
     1219 * @retval  VERR_WRONG_ORDER if we're busy.
     1220 *
     1221 * @param   pGlobals        Pointer to the globals.
     1222 *
     1223 * @sa      vboxNetFltTryDeleteIdcAndGlobals()
    11761224 */
    11771225DECLHIDDEN(int) vboxNetFltTryDeleteIdc(PVBOXNETFLTGLOBALS pGlobals)
     
    11871235        return VERR_WRONG_ORDER;
    11881236
    1189     /*
    1190      * Disconnect from SUPDRV and check that nobody raced us,
    1191      * reconnect if that should happen.
    1192      */
    1193     rc = SUPR0IdcComponentDeregisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
    1194     AssertRC(rc);
    1195     if (!vboxNetFltCanUnload(pGlobals))
     1237    if (!pGlobals->fIDCOpen)
     1238        rc = VINF_SUCCESS;
     1239    else
     1240    {
     1241        /*
     1242         * Disconnect from SUPDRV and check that nobody raced us,
     1243         * reconnect if that should happen.
     1244         */
     1245        rc = SUPR0IdcComponentDeregisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
     1246        AssertRC(rc);
     1247        if (!vboxNetFltCanUnload(pGlobals))
     1248        {
     1249            rc = SUPR0IdcComponentRegisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
     1250            AssertRC(rc);
     1251            return VERR_WRONG_ORDER;
     1252        }
     1253
     1254        SUPR0IdcClose(&pGlobals->SupDrvIDC);
     1255        pGlobals->fIDCOpen = false;
     1256    }
     1257
     1258    return rc;
     1259}
     1260
     1261
     1262/**
     1263 * Establishes the IDC connection to SUPDRV and registers our component factory.
     1264 *
     1265 * @returns VBox status code.
     1266 * @param   pGlobals    Pointer to the globals.
     1267 * @sa      vboxNetFltInitGlobalsAndIdc().
     1268 */
     1269DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals)
     1270{
     1271    int rc;
     1272    Assert(!pGlobals->fIDCOpen);
     1273
     1274    /*
     1275     * Establish a connection to SUPDRV and register our component factory.
     1276     */
     1277    rc = SUPR0IdcOpen(&pGlobals->SupDrvIDC, 0 /* iReqVersion = default */, 0 /* iMinVersion = default */, NULL, NULL, NULL);
     1278    if (RT_SUCCESS(rc))
    11961279    {
    11971280        rc = SUPR0IdcComponentRegisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
    1198         AssertRC(rc);
    1199         return VERR_WRONG_ORDER;
     1281        if (RT_SUCCESS(rc))
     1282        {
     1283            pGlobals->fIDCOpen = true;
     1284            Log(("VBoxNetFlt: pSession=%p\n", SUPR0IdcGetSession(&pGlobals->SupDrvIDC)));
     1285            return rc;
     1286        }
     1287
     1288        /* bail out. */
     1289        LogRel(("VBoxNetFlt: Failed to register component factory, rc=%Rrc\n", rc));
     1290        SUPR0IdcClose(&pGlobals->SupDrvIDC);
    12001291    }
    12011292
    1202     SUPR0IdcClose(&pGlobals->SupDrvIDC);
    1203 
    12041293    return rc;
    12051294}
    12061295
    1207 /**
    1208  * performs "base" globals deinitialization
    1209  * we separate the globals settings "base" which is actually
    1210  * "general" globals settings except for Idc, and idc.
    1211  * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
    1212  * thus it's not possible to make idc initialization from the driver startup routine for it,
    1213  * though the "base is still needed for the driver to functions".
    1214  * @param pGlobals
    1215  * @return none
    1216  */
    1217 DECLHIDDEN(void) vboxNetFltDeleteGlobalsBase(PVBOXNETFLTGLOBALS pGlobals)
    1218 {
     1296
     1297/**
     1298 * Deletes the globals.
     1299 *
     1300 * This must be called after the IDC connection has been closed,
     1301 * see vboxNetFltTryDeleteIdc().
     1302 *
     1303 * @param   pGlobals        Pointer to the globals.
     1304 * @sa      vboxNetFltTryDeleteIdcAndGlobals()
     1305 */
     1306DECLHIDDEN(void) vboxNetFltDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals)
     1307{
     1308    Assert(!pGlobals->fIDCOpen);
     1309
    12191310    /*
    12201311     * Release resources.
     
    12241315
    12251316#ifdef VBOXNETFLT_STATIC_CONFIG
    1226     RTSemEventDestroy(pGlobals->hTimerEvent);
    1227     pGlobals->hTimerEvent = NIL_RTSEMEVENT;
     1317    RTSemEventDestroy(pGlobals->hBlockEvent);
     1318    pGlobals->hBlockEvent = NIL_RTSEMEVENT;
    12281319#endif
    12291320
    12301321}
    12311322
    1232 /**
    1233  * Called by the native part when the OS wants the driver to unload.
    1234  *
    1235  * @returns VINF_SUCCESS on succes, VERR_WRONG_ORDER if we're busy.
    1236  *
     1323
     1324/**
     1325 * Initializes the globals.
     1326 *
     1327 * @returns VBox status code.
    12371328 * @param   pGlobals        Pointer to the globals.
    1238  */
    1239 DECLHIDDEN(int) vboxNetFltTryDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals)
    1240 {
    1241     int rc = vboxNetFltTryDeleteIdc(pGlobals);
    1242     if(RT_SUCCESS(rc))
    1243     {
    1244         vboxNetFltDeleteGlobalsBase(pGlobals);
    1245     }
    1246     return rc;
    1247 }
    1248 
    1249 /**
    1250  * performs the "base" globals initialization
    1251  * we separate the globals initialization to globals "base" initialization which is actually
    1252  * "general" globals initialization except for Idc not being initialized, and idc initialization.
    1253  * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
    1254  * thus it's not possible to make idc initialization from the driver startup routine for it.
    1255  *
    1256  * @returns VBox status code.
    1257  * @param   pGlobals    Pointer to the globals. */
    1258 DECLHIDDEN(int) vboxNetFltInitGlobalsBase(PVBOXNETFLTGLOBALS pGlobals)
     1329 * @sa      vboxNetFltInitGlobalsAndIdc().
     1330 */
     1331DECLHIDDEN(int) vboxNetFltInitGlobals(PVBOXNETFLTGLOBALS pGlobals)
    12591332{
    12601333    /*
     
    12651338    {
    12661339#ifdef VBOXNETFLT_STATIC_CONFIG
    1267         rc = RTSemEventCreate(&pGlobals->hTimerEvent);
     1340        rc = RTSemEventCreate(&pGlobals->hBlockEvent);
    12681341        if (RT_SUCCESS(rc))
    12691342        {
     
    12791352#endif
    12801353            pGlobals->SupDrvFactory.pfnQueryFactoryInterface = vboxNetFltQueryFactoryInterface;
     1354            pGlobals->fIDCOpen = false;
    12811355
    12821356            return rc;
     
    12901364}
    12911365
    1292 /**
    1293  * performs the Idc initialization
    1294  * we separate the globals initialization to globals "base" initialization which is actually
    1295  * "general" globals initialization except for Idc not being initialized, and idc initialization.
    1296  * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
    1297  * thus it's not possible to make idc initialization from the driver startup routine for it.
    1298  *
    1299  * @returns VBox status code.
    1300  * @param   pGlobals    Pointer to the globals. */
    1301 DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals)
    1302 {
    1303     int rc;
    1304     /*
    1305      * Establish a connection to SUPDRV and register our component factory.
    1306      */
    1307     rc = SUPR0IdcOpen(&pGlobals->SupDrvIDC, 0 /* iReqVersion = default */, 0 /* iMinVersion = default */, NULL, NULL, NULL);
     1366
     1367/**
     1368 * Called by the native part when the OS wants the driver to unload.
     1369 *
     1370 * @returns VINF_SUCCESS on success, VERR_WRONG_ORDER if we're busy.
     1371 *
     1372 * @param   pGlobals        Pointer to the globals.
     1373 */
     1374DECLHIDDEN(int) vboxNetFltTryDeleteIdcAndGlobals(PVBOXNETFLTGLOBALS pGlobals)
     1375{
     1376    int rc = vboxNetFltTryDeleteIdc(pGlobals);
    13081377    if (RT_SUCCESS(rc))
    1309     {
    1310         rc = SUPR0IdcComponentRegisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
    1311         if (RT_SUCCESS(rc))
    1312         {
    1313             Log(("VBoxNetFlt: pSession=%p\n", SUPR0IdcGetSession(&pGlobals->SupDrvIDC)));
    1314             return rc;
    1315         }
    1316 
    1317         /* bail out. */
    1318         LogRel(("VBoxNetFlt: Failed to register component factory, rc=%Rrc\n", rc));
    1319         SUPR0IdcClose(&pGlobals->SupDrvIDC);
    1320     }
    1321 
     1378        vboxNetFltDeleteGlobals(pGlobals);
    13221379    return rc;
    13231380}
    13241381
     1382
    13251383/**
    13261384 * Called by the native driver/kext module initialization routine.
    13271385 *
    13281386 * It will initialize the common parts of the globals, assuming the caller
    1329  * has already taken care of the OS specific bits.
     1387 * has already taken care of the OS specific bits, and establish the IDC
     1388 * connection to SUPDRV.
    13301389 *
    13311390 * @returns VBox status code.
    13321391 * @param   pGlobals    Pointer to the globals.
    13331392 */
    1334 DECLHIDDEN(int) vboxNetFltInitGlobals(PVBOXNETFLTGLOBALS pGlobals)
     1393DECLHIDDEN(int) vboxNetFltInitGlobalsAndIdc(PVBOXNETFLTGLOBALS pGlobals)
    13351394{
    13361395    /*
    13371396     * Initialize the common portions of the structure.
    13381397     */
    1339     int rc = vboxNetFltInitGlobalsBase(pGlobals);
     1398    int rc = vboxNetFltInitGlobals(pGlobals);
    13401399    if (RT_SUCCESS(rc))
    13411400    {
    13421401        rc = vboxNetFltInitIdc(pGlobals);
    13431402        if (RT_SUCCESS(rc))
    1344         {
    13451403            return rc;
    1346         }
    13471404
    13481405        /* bail out. */
    1349         vboxNetFltDeleteGlobalsBase(pGlobals);
     1406        vboxNetFltDeleteGlobals(pGlobals);
    13501407    }
    13511408
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h

    r16183 r17184  
    6868     * Partly for reasons of deadlock avoidance again. */
    6969    kVBoxNetFltInsState_Disconnecting,
     70#ifdef VBOXNETFLT_STATIC_CONFIG
    7071    /** Destroying the instance
    7172     * Partly for reasons of deadlock avoidance again. */
    7273    kVBoxNetFltInsState_Destroying,
     74#endif
    7375    /** The instance has been disconnected from both the host and the internal network. */
    7476    kVBoxNetFltInsState_Destroyed,
     
    255257    /** The number of current factory references. */
    256258    int32_t volatile cFactoryRefs;
    257 #ifdef VBOXNETFLT_STATIC_CONFIG
    258     /* wait timer event */
    259     RTSEMEVENT hTimerEvent;
    260 #endif
     259    /** Whether the IDC connection is open or not.
     260     * This is only for cleaning up correctly after the separate IDC init on Windows. */
     261    bool fIDCOpen;
    261262    /** The SUPDRV IDC handle (opaque struct). */
    262263    SUPDRVIDCHANDLE SupDrvIDC;
     264
     265#ifdef VBOXNETFLT_STATIC_CONFIG
     266    /** Something we can block on while waiting for an instance to be unlinked. */
     267    RTSEMEVENT hBlockEvent;
     268#endif
    263269} VBOXNETFLTGLOBALS;
    264270
    265271
     272DECLHIDDEN(int) vboxNetFltInitGlobalsAndIdc(PVBOXNETFLTGLOBALS pGlobals);
    266273DECLHIDDEN(int) vboxNetFltInitGlobals(PVBOXNETFLTGLOBALS pGlobals);
    267 DECLHIDDEN(int) vboxNetFltTryDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals);
     274DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals);
     275DECLHIDDEN(int) vboxNetFltTryDeleteIdcAndGlobals(PVBOXNETFLTGLOBALS pGlobals);
     276DECLHIDDEN(void) vboxNetFltDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals);
     277DECLHIDDEN(int) vboxNetFltTryDeleteIdc(PVBOXNETFLTGLOBALS pGlobals);
     278
    268279DECLHIDDEN(bool) vboxNetFltCanUnload(PVBOXNETFLTGLOBALS pGlobals);
    269280DECLHIDDEN(PVBOXNETFLTINS) vboxNetFltFindInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName);
     
    274285#ifdef VBOXNETFLT_STATIC_CONFIG
    275286DECLHIDDEN(int) vboxNetFltSearchCreateInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PVBOXNETFLTINS *ppInstance, void * pContext);
    276 DECLHIDDEN(int) vboxNetFltInitGlobalsBase(PVBOXNETFLTGLOBALS pGlobals);
    277 DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals);
    278 DECLHIDDEN(void) vboxNetFltDeleteGlobalsBase(PVBOXNETFLTGLOBALS pGlobals);
    279 DECLHIDDEN(int) vboxNetFltTryDeleteIdc(PVBOXNETFLTGLOBALS pGlobals);
    280 #endif
     287#endif
     288
    281289
    282290
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r16195 r17184  
    171171             */
    172172            memset(&g_VBoxNetFltGlobals, 0, sizeof(g_VBoxNetFltGlobals));
    173             rc = vboxNetFltInitGlobals(&g_VBoxNetFltGlobals);
     173            rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltGlobals);
    174174            if (RT_SUCCESS(rc))
    175175            {
     
    204204     * tracking for us!
    205205     */
    206     int rc = vboxNetFltTryDeleteGlobals(&g_VBoxNetFltGlobals);
     206    int rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltGlobals);
    207207    if (RT_FAILURE(rc))
    208208    {
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r17062 r17184  
    9999        flags = (dev->flags & ~(IFF_PROMISC |
    100100                                IFF_ALLMULTI |
    101                                 IFF_RUNNING)) | 
     101                                IFF_RUNNING)) |
    102102                (dev->gflags & (IFF_PROMISC |
    103103                                IFF_ALLMULTI));
     
    209209{
    210210    Log(("vboxTapValidateAddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
    211          dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], 
     211         dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
    212212         dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]));
    213213    return -EADDRNOTAVAIL;
     
    221221    /// @todo Use Sun vendor id
    222222    memcpy(pNetDev->dev_addr, "\0vbnet", ETH_ALEN);
    223     Log(("vboxTapNetDevInit: pNetDev->dev_addr = %.6Rhxd\n", pNetDev->dev_addr)); 
     223    Log(("vboxTapNetDevInit: pNetDev->dev_addr = %.6Rhxd\n", pNetDev->dev_addr));
    224224    pNetDev->open = vboxTapOpen;
    225225    pNetDev->stop = vboxTapStop;
     
    297297         */
    298298        memset(&g_VBoxNetFltGlobals, 0, sizeof(g_VBoxNetFltGlobals));
    299         rc = vboxNetFltInitGlobals(&g_VBoxNetFltGlobals);
     299        rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltGlobals);
    300300        if (RT_SUCCESS(rc))
    301301        {
     
    337337    rc = vboxTapUnregisterNetDev();
    338338    AssertRC(rc);
    339     rc = vboxNetFltTryDeleteGlobals(&g_VBoxNetFltGlobals);
     339    rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltGlobals);
    340340    AssertRC(rc); NOREF(rc);
    341341
     
    598598    if (!pBuf)
    599599        return 0;
    600    
     600
    601601    pThis = VBOX_FLT_PT_TO_INST(pPacketType);
    602602    pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);
     
    669669    }
    670670#endif
    671            
     671
    672672    dev_kfree_skb(pBuf);
    673673}
     
    10881088        {
    10891089            if (pThis->u.s.fPromiscuousSet)
    1090             {   
     1090            {
    10911091                rtnl_lock();
    10921092                dev_set_promiscuity(pDev, -1);
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c

    r16928 r17184  
    430430             */
    431431            memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals));
    432             rc = vboxNetFltInitGlobals(&g_VBoxNetFltSolarisGlobals);
     432            rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltSolarisGlobals);
    433433            if (RT_SUCCESS(rc))
    434434            {
     
    438438
    439439                LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc));
    440                 vboxNetFltTryDeleteGlobals(&g_VBoxNetFltSolarisGlobals);
     440                vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals);
    441441            }
    442442            else
     
    465465     * Undo the work done during start (in reverse order).
    466466     */
    467     rc = vboxNetFltTryDeleteGlobals(&g_VBoxNetFltSolarisGlobals);
     467    rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals);
    468468    if (RT_FAILURE(rc))
    469469    {
     
    29762976            int Pcp:3;
    29772977            int Cfi:1;
    2978             int Vid:12; 
     2978            int Vid:12;
    29792979        } VLANHEADER;
    29802980
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