Index: /trunk/include/VBox/intnet.h
===================================================================
--- /trunk/include/VBox/intnet.h	(revision 17183)
+++ /trunk/include/VBox/intnet.h	(revision 17184)
@@ -593,13 +593,13 @@
      * @param   pSwitchPort         Pointer to the port interface on the switch that
      *                              this interface is being connected to.
+     * @param   fFlags              Creation flags, see below.
      * @param   ppIfPort            Where to store the pointer to the interface port
      *                              on success.
-     * @param   fNoPromisc          Do not put the interface into promiscuous mode.
      *
      * @remarks Called while owning the network and the out-bound trunk semaphores.
      */
     DECLR0CALLBACKMEMBER(int, pfnCreateAndConnect,(struct INTNETTRUNKFACTORY *pIfFactory, const char *pszName,
-                                                   PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort,
-                                                   bool fNoPromisc));
+                                                   PINTNETTRUNKSWPORT pSwitchPort, uint32_t fFlags,
+                                                   PINTNETTRUNKIFPORT *ppIfPort));
 } INTNETTRUNKFACTORY;
 /** Pointer to the trunk factory. */
@@ -607,5 +607,14 @@
 
 /** The UUID for the (current) trunk factory. (case sensitive) */
-#define INTNETTRUNKFACTORY_UUID_STR     "a200dee8-ad4a-4e32-b875-425f74103a22"
+#define INTNETTRUNKFACTORY_UUID_STR     "449a2799-7564-464d-b4b2-7a877418fd0c"
+
+/** @name INTNETTRUNKFACTORY::pfnCreateAndConnect flags.
+ * @{ */
+/** Don't put the filtered interface in promiscuous mode.
+ * This is used for wireless interface since these can misbehave if
+ * we try to put them in promiscuous mode. (Wireless interfaces are
+ * normally bridged on level 3 instead of level 2.) */
+#define INTNETTRUNKFACTORY_FLAG_NO_PROMISC      RT_BIT_32(0)
+/** @} */
 
 
Index: /trunk/include/VBox/log.h
===================================================================
--- /trunk/include/VBox/log.h	(revision 17183)
+++ /trunk/include/VBox/log.h	(revision 17184)
@@ -236,8 +236,8 @@
     /** MM Page pool group. */
     LOG_GROUP_MM_POOL,
+    /** The network adaptor driver group. */
+    LOG_GROUP_NET_ADP_DRV,
     /** The network filter driver group. */
     LOG_GROUP_NET_FLT_DRV,
-    /** The network tap driver group. */
-    LOG_GROUP_NET_TAP_DRV,
     /** PATM group. */
     LOG_GROUP_PATM,
@@ -429,6 +429,6 @@
     "MM_PHYS",      \
     "MM_POOL",      \
+    "NET_ADP_DRV",  \
     "NET_FLT_DRV",  \
-    "NET_TAP_DRV",  \
     "PATM",         \
     "PDM",          \
Index: /trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
===================================================================
--- /trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp	(revision 17183)
+++ /trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp	(revision 17184)
@@ -3743,5 +3743,8 @@
         if (RT_SUCCESS(rc))
         {
-            rc = pTrunkFactory->pfnCreateAndConnect(pTrunkFactory, pNetwork->szTrunk, &pTrunkIF->SwitchPort, &pTrunkIF->pIfPort, !!(pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE));
+            rc = pTrunkFactory->pfnCreateAndConnect(pTrunkFactory, pNetwork->szTrunk, &pTrunkIF->SwitchPort, !
+                                                    pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE
+                                                    ? INTNETTRUNKFACTORY_FLAG_NO_PROMISC : 0,
+                                                    &pTrunkIF->pIfPort);
             pTrunkFactory->pfnRelease(pTrunkFactory);
             if (RT_SUCCESS(rc))
@@ -3899,5 +3902,5 @@
      */
     PINTNETNETWORK pCur;
-    uint8_t cchName = strlen(pszNetwork);
+    uint8_t cchName = (uint8_t)strlen(pszNetwork);
     Assert(cchName && cchName < sizeof(pCur->szName)); /* caller ensures this */
 
@@ -4008,5 +4011,5 @@
         pNew->fFlags = fFlags;
         size_t cchName = strlen(pszNetwork);
-        pNew->cchName = cchName;
+        pNew->cchName = (uint8_t)cchName;
         Assert(cchName && cchName < sizeof(pNew->szName));  /* caller's responsibility. */
         memcpy(pNew->szName, pszNetwork, cchName);          /* '\0' by alloc. */
Index: /trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c	(revision 17184)
@@ -20,8 +20,18 @@
  */
 
+/** @page pg_netadp     VBoxNetAdp - Network Adapter
+ *
+ * This is a kernel module that creates a virtual interface that can be attached
+ * to an internal network.
+ *
+ * In the big picture we're one of the three trunk interface on the internal
+ * network, the one named "TAP Interface": @image html Networking_Overview.gif
+ *
+ */
+
 /*******************************************************************************
 *   Header Files                                                               *
 *******************************************************************************/
-#define LOG_GROUP LOG_GROUP_NET_TAP_DRV
+#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
 #include "VBoxNetAdpInternal.h"
 
@@ -35,13 +45,14 @@
 #include <iprt/uuid.h>
 
+/** r=bird: why is this here in the agnositc code? */
 #ifndef RT_OS_SOLARIS
-#include <net/ethernet.h>
-#include <net/if_ether.h>
-#include <net/if_types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <sys/errno.h>
-#include <sys/param.h>
+# include <net/ethernet.h>
+# include <net/if_ether.h>
+# include <net/if_types.h>
+# include <sys/socket.h>
+# include <net/if.h>
+# include <net/if_dl.h>
+# include <sys/errno.h>
+# include <sys/param.h>
 #endif
 
@@ -79,4 +90,5 @@
 
 
+AssertCompileMemberSize(VBOXNETADP, enmState, sizeof(uint32_t));
 
 /**
@@ -107,4 +119,5 @@
     ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmState, enmNewState);
 }
+
 
 /**
@@ -125,5 +138,4 @@
     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
 }
-
 
 
@@ -147,4 +159,5 @@
 }
 
+
 /**
  * Checks and sets the enmState member atomically.
@@ -161,6 +174,7 @@
     bool fRc = true; /* be optimistic */
     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
+
     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
-    enmActualState = vboxNetAdpGetState(pThis);
+    enmActualState = vboxNetAdpGetState(pThis); /** @todo r=bird: ASMAtomicCmpXchgU32()*/
     if (enmActualState == enmOldState)
         vboxNetAdpSetState(pThis, enmNewState);
@@ -168,4 +182,5 @@
         fRc = false;
     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
+
     if (fRc)
         Log(("vboxNetAdpCheckAndSetState: pThis=%p, state changed: %d -> %d.\n", pThis, enmOldState, enmNewState));
@@ -176,5 +191,12 @@
 
 
-
+/**
+ * Finds a instance by its name, the caller does the locking.
+ *
+ *
+ * @returns Pointer to the instance by the given name. NULL if not found.
+ * @param   pGlobals        The globals.
+ * @param   pszName         The name of the instance.
+ */
 static PVBOXNETADP vboxNetAdpFind(PVBOXNETADPGLOBALS pGlobals, const char *pszName)
 {
@@ -186,6 +208,6 @@
         PVBOXNETADP pThis = &pGlobals->aAdapters[i];
         RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
-        if (vboxNetAdpGetState(pThis)
-            && !strcmp(pThis->szName, pszName))
+        if (    vboxNetAdpGetState(pThis)
+            &&  !strcmp(pThis->szName, pszName))
         {
             RTSpinlockRelease(pThis->hSpinlock, &Tmp);
@@ -196,4 +218,5 @@
     return NULL;
 }
+
 
 /**
@@ -226,4 +249,5 @@
 }
 
+
 /**
  * Decrements the busy counter and does idle wakeup.
@@ -254,4 +278,5 @@
         Assert(cBusy < UINT32_MAX / 2);
 }
+
 
 /**
@@ -285,4 +310,5 @@
 }
 
+
 /**
  * Increments busy counter.
@@ -309,4 +335,5 @@
 }
 
+
 /**
  * Checks if receive is possible and increases busy and ref counters if so.
@@ -335,4 +362,5 @@
     return fCanReceive;
 }
+
 
 /**
@@ -356,4 +384,5 @@
     vboxNetAdpRelease(pThis);
 }
+
 
 /**
@@ -424,4 +453,5 @@
     vboxNetAdpBusy(pThis);
     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
+
     rc = vboxNetAdpPortOsXmit(pThis, pSG, fDst);
     vboxNetAdpIdle(pThis);
@@ -543,4 +573,5 @@
     Log(("vboxNetAdpPortSetActive: pThis=%p, fActive=%d, state before: %d.\n", pThis, fActive, vboxNetAdpGetState(pThis)));
     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
+
     fPreviouslyActive = vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Active;
     if (fPreviouslyActive != fActive)
@@ -558,6 +589,7 @@
         }
     }
+
     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
-    Log(("vboxNetAdpPortSetActive: state after: %d.\n", vboxNetAdpGetState(pThis)));
+    Log(("vboxNetAdpPortSetActive: state after: %RTbool.\n", vboxNetAdpGetState(pThis)));
     return fPreviouslyActive;
 }
@@ -633,5 +665,5 @@
         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
         PVBOXNETADP pThis = &pGlobals->aAdapters[i];
-    
+
         if (vboxNetAdpCheckAndSetState(pThis, kVBoxNetAdpState_Invalid, kVBoxNetAdpState_Transitional))
         {
@@ -657,5 +689,5 @@
     int rc = VINF_SUCCESS;
     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
-    
+
     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Available || pThis->cBusy)
@@ -716,16 +748,20 @@
 }
 
+
 /**
  * @copydoc INTNETTRUNKFACTORY::pfnCreateAndConnect
  */
 static DECLCALLBACK(int) vboxNetAdpFactoryCreateAndConnect(PINTNETTRUNKFACTORY pIfFactory, const char *pszName,
-                                                           PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort, bool fNoPromisc)
-{
+                                                           PINTNETTRUNKSWPORT pSwitchPort, uint32_t fFlags,
+                                                           PINTNETTRUNKIFPORT *ppIfPort)
+{
+    PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));
     PVBOXNETADP pThis;
     int rc;
-    PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));
-
-    LogFlow(("vboxNetAdpFactoryCreateAndConnect: pszName=%p:{%s}\n", pszName, pszName));
+
+    LogFlow(("vboxNetAdpFactoryCreateAndConnect: pszName=%p:{%s} fFlags=%#x\n", pszName, pszName, fFlags));
     Assert(pGlobals->cFactoryRefs > 0);
+    AssertMsgReturn(fFlags,
+                    ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
 
     /*
@@ -749,4 +785,5 @@
     return rc;
 }
+
 
 /**
@@ -956,4 +993,5 @@
 }
 
+
 /**
  * Called by the native part when the OS wants the driver to unload.
@@ -966,5 +1004,5 @@
 {
     int rc = vboxNetAdpTryDeleteIdc(pGlobals);
-    if(RT_SUCCESS(rc))
+    if (RT_SUCCESS(rc))
     {
         vboxNetAdpDeleteGlobalsBase(pGlobals);
@@ -1037,9 +1075,10 @@
         if (RT_SUCCESS(rc))
         {
-            /* @todo REMOVE ME! */
+#if 1 /** @todo REMOVE ME! */
             PVBOXNETADP pTmp;
             rc = vboxNetAdpCreate(&pGlobals->TrunkFactory, &pTmp);
             if (RT_FAILURE(rc))
                 Log(("Failed to create vboxnet0, rc=%Rrc.\n", rc));
+#endif
             Log(("VBoxNetAdp: pSession=%p\n", SUPR0IdcGetSession(&pGlobals->SupDrvIDC)));
             return rc;
@@ -1083,2 +1122,3 @@
     return rc;
 }
+
Index: /trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp	(revision 17184)
@@ -32,5 +32,5 @@
 #undef PVM
 
-#define LOG_GROUP LOG_GROUP_NET_TAP_DRV
+#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
 #include <VBox/log.h>
 #include <VBox/err.h>
Index: /trunk/src/VBox/HostDrivers/VBoxNetAdp/solaris/VBoxNetAdp-solaris.c
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetAdp/solaris/VBoxNetAdp-solaris.c	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetAdp/solaris/VBoxNetAdp-solaris.c	(revision 17184)
@@ -27,5 +27,5 @@
 #endif
 
-#define LOG_GROUP LOG_GROUP_NET_TAP_DRV
+#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
 #include <VBox/log.h>
 #include <VBox/err.h>
Index: /trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c	(revision 17184)
@@ -236,7 +236,36 @@
 
 
+AssertCompileMemberSize(VBOXNETFLTINS, enmState, sizeof(uint32_t));
+
+/**
+ * Sets the enmState member atomically.
+ *
+ * Used for all updates.
+ *
+ * @param   pThis           The instance.
+ * @param   enmNewState     The new value.
+ */
+DECLINLINE(void) vboxNetFltSetState(PVBOXNETFLTINS pThis, VBOXNETFTLINSSTATE enmNewState)
+{
+    ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmState, enmNewState);
+}
+
+
+/**
+ * Gets the enmState member atomically.
+ *
+ * Used for all reads.
+ *
+ * @returns The enmState value.
+ * @param   pThis           The instance.
+ */
+DECLINLINE(VBOXNETFTLINSSTATE) vboxNetFltGetState(PVBOXNETFLTINS pThis)
+{
+    return (VBOXNETFTLINSSTATE)ASMAtomicUoReadU32((uint32_t volatile *)&pThis->enmState);
+}
+
+
 /**
  * Finds a instance by its name, the caller does the locking.
- *
  *
  * @returns Pointer to the instance by the given name. NULL if not found.
@@ -256,4 +285,7 @@
 /**
  * Finds a instance by its name, will request the mutex.
+ *
+ * No reference to the instance is retained, we're assuming the caller to
+ * already have one but just for some reason doesn't have the pointer to it.
  *
  * @returns Pointer to the instance by the given name. NULL if not found.
@@ -300,34 +332,4 @@
 
 
-AssertCompileMemberSize(VBOXNETFLTINS, enmState, sizeof(uint32_t));
-
-/**
- * Sets the enmState member atomically.
- *
- * Used for all updates.
- *
- * @param   pThis           The instance.
- * @param   enmNewState     The new value.
- */
-DECLINLINE(void) vboxNetFltSetState(PVBOXNETFLTINS pThis, VBOXNETFTLINSSTATE enmNewState)
-{
-    ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmState, enmNewState);
-}
-
-
-/**
- * Gets the enmState member atomically.
- *
- * Used for all reads.
- *
- * @returns The enmState value.
- * @param   pThis           The instance.
- */
-DECLINLINE(VBOXNETFTLINSSTATE) vboxNetFltGetState(PVBOXNETFLTINS pThis)
-{
-    return (VBOXNETFTLINSSTATE)ASMAtomicUoReadU32((uint32_t volatile *)&pThis->enmState);
-}
-
-
 /**
  * Performs interface rediscovery if it was disconnected from the host.
@@ -611,14 +613,14 @@
  * Destroy a device that has been disconnected from the switch.
  *
- * @return true iff the instance is destroyed, false otherwise
+ * @returns true if the instance is destroyed, false otherwise.
  * @param   pThis               The instance to be destroyed. This is
  *                              no longer valid when this function returns.
  */
-static bool vboxNetFltCheckDestroyInstance(PVBOXNETFLTINS pThis)
+static bool vboxNetFltDestroyInstance(PVBOXNETFLTINS pThis)
 {
     PVBOXNETFLTGLOBALS pGlobals = pThis->pGlobals;
+    uint32_t cRefs = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->cRefs);
     int rc;
-    uint32_t cRefs = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->cRefs);
-    LogFlow(("vboxNetFltCheckDestroyInstance: pThis=%p (%s)\n", pThis, pThis->szName));
+    LogFlow(("vboxNetFltDestroyInstance: pThis=%p (%s)\n", pThis, pThis->szName));
 
     /*
@@ -638,9 +640,18 @@
 
     /*
-     * Make sure the state is 'disconnecting' and let the OS specific code
-     * do its part of the cleanup outside the mutex.
+     * Make sure the state is 'disconnecting' / 'destroying' and let the OS
+     * specific code do its part of the cleanup outside the mutex.
      */
     rc = RTSemFastMutexRequest(pGlobals->hFastMtx); AssertRC(rc);
-    if(cRefs != 0)
+#ifdef VBOXNETFLT_STATIC_CONFIG
+/** @todo r=bird: This looks kind of insane! I ASSUME this is specific to the
+ * static config and to devices in the Unconnected state only. This *looks* like
+ * a very unhealthy race between driver unloading and vboxNetFltFactoryCreateAndConnect.
+ * If I'm right, then vboxNetFltFactoryCreateAndConnect should be made to back down one
+ * way or the other, it should not the other way around. (see suggestion further down)
+ *
+ * If I'm wrong, then please explain in full.
+ */
+    if (cRefs != 0)
     {
         Assert(cRefs < UINT32_MAX / 2);
@@ -649,4 +660,7 @@
     }
     vboxNetFltSetState(pThis, kVBoxNetFltInsState_Destroying);
+#else
+    vboxNetFltSetState(pThis, kVBoxNetFltInsState_Disconnecting);
+#endif
     RTSemFastMutexRelease(pGlobals->hFastMtx);
 
@@ -716,5 +730,5 @@
     cRefs = ASMAtomicDecU32(&pThis->cRefs);
     if (!cRefs)
-        vboxNetFltCheckDestroyInstance(pThis);
+        vboxNetFltDestroyInstance(pThis);
     else
         Assert(cRefs < UINT32_MAX / 2);
@@ -822,7 +836,5 @@
     {
         vboxNetFltSetState(pThis, kVBoxNetFltInsState_Connected);
-#ifdef VBOXNETFLT_STATIC_CONFIG
         *ppIfPort = &pThis->MyPort;
-#endif
     }
     else
@@ -846,12 +858,10 @@
  * @param   pszName             The instance name.
  * @param   pSwitchPort         The port on the switch that we're connected with (dynamic only).
+ * @param   fNoPromisc          Do not attempt going into promiscuous mode.
+ * @param   pvContext           Context argument for vboxNetFltOsInitInstance.
  * @param   ppIfPort            Where to store the pointer to our port interface (dynamic only).
- * @param   fNoPromisc          Do not attempt going into promiscuous mode.
- */
-static int vboxNetFltNewInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort, bool fNoPromisc
-#ifdef VBOXNETFLT_STATIC_CONFIG
-        , void * pContext
-#endif
-        )
+ */
+static int vboxNetFltNewInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PINTNETTRUNKSWPORT pSwitchPort,
+                                 bool fNoPromisc, void *pvContext, PINTNETTRUNKIFPORT *ppIfPort)
 {
     /*
@@ -914,20 +924,19 @@
                          * Call the OS specific initialization code.
                          */
-                        rc = vboxNetFltOsInitInstance(pNew
-#ifdef VBOXNETFLT_STATIC_CONFIG
-                                , pContext
-#endif
-                                );
+                        rc = vboxNetFltOsInitInstance(pNew, pvContext);
                         RTSemFastMutexRequest(pGlobals->hFastMtx);
                         if (RT_SUCCESS(rc))
                         {
 #ifdef VBOXNETFLT_STATIC_CONFIG
+                            /*
+                             * Static instances are unconnected at birth.
+                             */
+                            Assert(!pSwitchPort);
                             pNew->enmState = kVBoxNetFltInsState_Unconnected;
-                            Assert(!pSwitchPort);
+                            RTSemFastMutexRelease(pGlobals->hFastMtx);
                             *ppIfPort = &pNew->MyPort;
-                            RTSemFastMutexRelease(pGlobals->hFastMtx);
                             return rc;
 
-#else
+#else  /* !VBOXNETFLT_STATIC_CONFIG */
                             /*
                              * Connect it as well, the OS specific bits has to be done outside
@@ -938,5 +947,5 @@
                             {
                                 RTSemFastMutexRelease(pGlobals->hFastMtx);
-                                *ppIfPort = &pNew->MyPort;
+                                Assert(*ppIfPort == &pNew->MyPort);
                                 return rc;
                             }
@@ -944,5 +953,5 @@
                             /* Bail out (failed). */
                             vboxNetFltOsDeleteInstance(pNew);
-#endif
+#endif /* !VBOXNETFLT_STATIC_CONFIG */
                         }
                         vboxNetFltUnlinkLocked(pGlobals, pNew);
@@ -962,13 +971,19 @@
 }
 
+
 #ifdef VBOXNETFLT_STATIC_CONFIG
-
-/**
- * searches for the NetFlt instance by its name and creates the new one if not found
- *
- * @return VINF_SUCCESS if new instance was created, VINF_ALREADY_INITIALIZED if an instanmce already exists,
- * VERR_xxx in case of a failure
- */
-DECLHIDDEN(int) vboxNetFltSearchCreateInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PVBOXNETFLTINS *ppInstance, void * pContext)
+/**
+ * Searches for the NetFlt instance by its name and creates the new one if not found.
+ *
+ * @returns VBox status code.
+ * @retval  VINF_SUCCESS and *ppInstance if a new instance was created.
+ * @retval  VINF_ALREADY_INITIALIZED and *ppInstance if an instance already exists.
+ *
+ * @param   pGlobal     Pointer to the globals.
+ * @param   pszName     The instance name.
+ * @param   ppInstance  Where to return the instance pointer on success.
+ * @param   pvContext   Context which needs to be passed along to vboxNetFltOsInitInstance.
+ */
+DECLHIDDEN(int) vboxNetFltSearchCreateInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PVBOXNETFLTINS *ppInstance, void *pvContext)
 {
     PINTNETTRUNKIFPORT pIfPort;
@@ -978,35 +993,43 @@
     AssertRCReturn(rc, rc);
 
+    /*
+     * Look for an existing instance in the list.
+     *
+     * If found that it's being destroyed, wait for it to go away.
+     * Return instances in other states ASSUMING that it has lost the
+     * connection.
+     */
     *ppInstance = vboxNetFltFindInstanceLocked(pGlobals, pszName);
-    if(*ppInstance)
+    while (*ppInstance)
     {
         VBOXNETFTLINSSTATE enmState = vboxNetFltGetState(*ppInstance);
-        if(enmState != kVBoxNetFltInsState_Destroying && enmState != kVBoxNetFltInsState_Destroyed)
+        if (    enmState != kVBoxNetFltInsState_Destroying
+            &&  enmState != kVBoxNetFltInsState_Destroyed)
         {
-            vboxNetFltRetain(*ppInstance, false);
+            /** @todo r=bird: who is making sure this is a genuine reconnection case? */
+            vboxNetFltRetain(*ppInstance, false /* fBusy */);
             RTSemFastMutexRelease(pGlobals->hFastMtx);
             return VINF_ALREADY_INITIALIZED;
         }
 
-        /*wait for the instance to be removed from the list */
-
-        *ppInstance = NULL;
-
-        do
-        {
-            RTSemFastMutexRelease(pGlobals->hFastMtx);
-
-            RTSemEventWait(pGlobals->hTimerEvent, 2);
-
-            rc = RTSemFastMutexRequest(pGlobals->hFastMtx);
-            AssertRCReturn(rc, rc);
-        } while(vboxNetFltFindInstanceLocked(pGlobals, pszName));
+        /* 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... */
+        RTSemFastMutexRelease(pGlobals->hFastMtx);
+        RTSemEventWait(pGlobals->hBlockEvent, 2);
+        rc = RTSemFastMutexRequest(pGlobals->hFastMtx);
+        AssertRCReturn(rc, rc);
+
+        /* try again */
+        *ppInstance = vboxNetFltFindInstanceLocked(pGlobals, pszName);
     }
 
     RTSemFastMutexRelease(pGlobals->hFastMtx);
 
-    rc = vboxNetFltNewInstance(pGlobals, pszName, NULL, &pIfPort, false, pContext);
-    if(RT_SUCCESS(rc))
-        *ppInstance =  IFPORT_2_VBOXNETFLTINS(pIfPort);
+    /*
+     * Try create a new instance.
+     * (fNoPromisc is overridden in the vboxNetFltFactoryCreateAndConnect path, so pass true here.)
+     */
+    rc = vboxNetFltNewInstance(pGlobals, pszName, NULL, true /* fNoPromisc */, pvContext, &pIfPort);
+    if (RT_SUCCESS(rc))
+        *ppInstance = IFPORT_2_VBOXNETFLTINS(pIfPort);
     else
         *ppInstance = NULL;
@@ -1014,6 +1037,6 @@
     return rc;
 }
-
-#endif
+#endif /* VBOXNETFLT_STATIC_CONFIG */
+
 
 /**
@@ -1021,5 +1044,6 @@
  */
 static DECLCALLBACK(int) vboxNetFltFactoryCreateAndConnect(PINTNETTRUNKFACTORY pIfFactory, const char *pszName,
-                                                           PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort, bool fNoPromisc)
+                                                           PINTNETTRUNKSWPORT pSwitchPort, uint32_t fFlags,
+                                                           PINTNETTRUNKIFPORT *ppIfPort)
 {
     PVBOXNETFLTGLOBALS pGlobals = (PVBOXNETFLTGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETFLTGLOBALS, TrunkFactory));
@@ -1027,6 +1051,8 @@
     int rc;
 
-    LogFlow(("vboxNetFltFactoryCreateAndConnect: pszName=%p:{%s}\n", pszName, pszName));
+    LogFlow(("vboxNetFltFactoryCreateAndConnect: pszName=%p:{%s} fFlags=%#x\n", pszName, pszName, fFlags));
     Assert(pGlobals->cFactoryRefs > 0);
+    AssertMsgReturn(fFlags & ~(INTNETTRUNKFACTORY_FLAG_NO_PROMISC),
+                    ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
 
     /*
@@ -1039,5 +1065,5 @@
 #if defined(VBOX_TAPMINIPORT) && defined(RT_OS_WINDOWS)
     /* temporary hack to pick up the first adapter */
-    pCur = pGlobals->pInstanceHead;
+    pCur = pGlobals->pInstanceHead; /** @todo Don't for get to remove this temporary hack... :-) */
 #else
     pCur = vboxNetFltFindInstanceLocked(pGlobals, pszName);
@@ -1046,32 +1072,50 @@
     {
 #ifdef VBOXNETFLT_STATIC_CONFIG
-        switch (vboxNetFltGetState(pCur))
+# if 0 /** @todo r=bird: We need to fix the race here. The race is against release+destructor, the
+        * tell tale is a cRefs of and since cRefs is manipulated in an atomic fashion we can simply attempt
+        * to grab a reference atomically, the worst thing that can happen is that we have to decrement it again..
+        * Here is my suggestion: */
+        /* Try grab a reference. If the count had already reached zero we're racing the
+           destructor code and must back down. */
+        uint32_t cRefs = ASMAtomicIncU32(&pCur->cRefs);
+        if (cRefs > 1)
         {
-            case kVBoxNetFltInsState_Unconnected:
-                /* instance can be destroyed when it is neither used by the IntNet nor by the ndis filter driver mechanism
-                 * (i.e. the driver is not bound to the specified adapter)*/
-                /* Prevent setting promiscuous mode for WiFi adapters. */
-                pCur->fDisablePromiscuous = fNoPromisc;
-                LogAleksey(("fNoPromisc=%d\n", pCur->fDisablePromiscuous));
-                vboxNetFltRetain(pCur, false /* fBusy */); /** @todo who releases this on failure? */
+            if (vboxNetFltGetState(pCur) == kVBoxNetFltInsState_Unconnected)
+            {
+                pCur->fDisablePromiscuous = !!(fFlags & INTNETTRUNKFACTORY_FLAG_NO_PROMISC);
                 rc = vboxNetFltConnectIt(pCur, pSwitchPort, ppIfPort);
-                break;
-            case kVBoxNetFltInsState_Connected:
-                AssertFailed();
+                if (RT_SUCCESS(rc))
+                    pCur = NULL; /* Don't release it, reference given to the caller. */
+            }
+            else
                 rc = VERR_INTNET_FLT_IF_BUSY;
-                break;
-            case kVBoxNetFltInsState_Disconnecting:
-                AssertFailed();
-                rc = VERR_INTNET_FLT_IF_BUSY;
-                break;
-            default:
-                /** @todo what? */
-                rc = VERR_INTNET_FLT_IF_BUSY;
-                break;
         }
+        else
+        {
+            Assert(cRefs == 1);
+            ASMAtomicDecU32(&pCur->cRefs);
+            pCur = NULL; /* nothing to release */
+            rc = VERR_INTNET_FLT_IF_NOT_FOUND;
+        }
+
+        RTSemFastMutexRelease(pGlobals->hFastMtx);
+        if (pCur)
+            vboxNetFltRelease(pCur, false /* fBusy */);
+
+# else
+        if (vboxNetFltGetState(pCur) == kVBoxNetFltInsState_Unconnected)
+        {
+            vboxNetFltRetain(pCur, false /* fBusy */); /** @todo r=bird: Who releases this on failure?  */
+            pCur->fDisablePromiscuous = !!(fFlags & INTNETTRUNKFACTORY_FLAG_NO_PROMISC);
+            rc = vboxNetFltConnectIt(pCur, pSwitchPort, ppIfPort);
+        }
+        else
+            rc = VERR_INTNET_FLT_IF_BUSY;
+        RTSemFastMutexRelease(pGlobals->hFastMtx);
+# endif
 #else
         rc = VERR_INTNET_FLT_IF_BUSY;
+        RTSemFastMutexRelease(pGlobals->hFastMtx);
 #endif
-        RTSemFastMutexRelease(pGlobals->hFastMtx);
         LogFlow(("vboxNetFltFactoryCreateAndConnect: returns %Rrc\n", rc));
         return rc;
@@ -1086,5 +1130,7 @@
      * Dynamically create a new instance.
      */
-    rc = vboxNetFltNewInstance(pGlobals, pszName, pSwitchPort, ppIfPort, fNoPromisc);
+    rc = vboxNetFltNewInstance(pGlobals, pszName, pSwitchPort,
+                               !!(fFlags & INTNETTRUNKFACTORY_FLAG_NO_PROMISC),
+                               ppIfPort);
 #endif
     LogFlow(("vboxNetFltFactoryCreateAndConnect: returns %Rrc\n", rc));
@@ -1165,13 +1211,15 @@
 }
 
-/**
- * tries to deinitialize Idc
- * we separate the globals settings "base" which is actually
- * "general" globals settings except for Idc, and idc.
- * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
- * thus it's not possible to make idc initialization from the driver startup routine for it,
- * though the "base is still needed for the driver to functions".
- * @param pGlobals
- * @return VINF_SUCCESS on succes, VERR_WRONG_ORDER if we're busy.
+
+/**
+ * Try to close the IDC connection to SUPDRV if established.
+ *
+ * @returns VBox status code.
+ * @retval  VINF_SUCCESS on success.
+ * @retval  VERR_WRONG_ORDER if we're busy.
+ *
+ * @param   pGlobals        Pointer to the globals.
+ *
+ * @sa      vboxNetFltTryDeleteIdcAndGlobals()
  */
 DECLHIDDEN(int) vboxNetFltTryDeleteIdc(PVBOXNETFLTGLOBALS pGlobals)
@@ -1187,34 +1235,77 @@
         return VERR_WRONG_ORDER;
 
-    /*
-     * Disconnect from SUPDRV and check that nobody raced us,
-     * reconnect if that should happen.
-     */
-    rc = SUPR0IdcComponentDeregisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
-    AssertRC(rc);
-    if (!vboxNetFltCanUnload(pGlobals))
+    if (!pGlobals->fIDCOpen)
+        rc = VINF_SUCCESS;
+    else
+    {
+        /*
+         * Disconnect from SUPDRV and check that nobody raced us,
+         * reconnect if that should happen.
+         */
+        rc = SUPR0IdcComponentDeregisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
+        AssertRC(rc);
+        if (!vboxNetFltCanUnload(pGlobals))
+        {
+            rc = SUPR0IdcComponentRegisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
+            AssertRC(rc);
+            return VERR_WRONG_ORDER;
+        }
+
+        SUPR0IdcClose(&pGlobals->SupDrvIDC);
+        pGlobals->fIDCOpen = false;
+    }
+
+    return rc;
+}
+
+
+/**
+ * Establishes the IDC connection to SUPDRV and registers our component factory.
+ *
+ * @returns VBox status code.
+ * @param   pGlobals    Pointer to the globals.
+ * @sa      vboxNetFltInitGlobalsAndIdc().
+ */
+DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals)
+{
+    int rc;
+    Assert(!pGlobals->fIDCOpen);
+
+    /*
+     * Establish a connection to SUPDRV and register our component factory.
+     */
+    rc = SUPR0IdcOpen(&pGlobals->SupDrvIDC, 0 /* iReqVersion = default */, 0 /* iMinVersion = default */, NULL, NULL, NULL);
+    if (RT_SUCCESS(rc))
     {
         rc = SUPR0IdcComponentRegisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
-        AssertRC(rc);
-        return VERR_WRONG_ORDER;
+        if (RT_SUCCESS(rc))
+        {
+            pGlobals->fIDCOpen = true;
+            Log(("VBoxNetFlt: pSession=%p\n", SUPR0IdcGetSession(&pGlobals->SupDrvIDC)));
+            return rc;
+        }
+
+        /* bail out. */
+        LogRel(("VBoxNetFlt: Failed to register component factory, rc=%Rrc\n", rc));
+        SUPR0IdcClose(&pGlobals->SupDrvIDC);
     }
 
-    SUPR0IdcClose(&pGlobals->SupDrvIDC);
-
     return rc;
 }
 
-/**
- * performs "base" globals deinitialization
- * we separate the globals settings "base" which is actually
- * "general" globals settings except for Idc, and idc.
- * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
- * thus it's not possible to make idc initialization from the driver startup routine for it,
- * though the "base is still needed for the driver to functions".
- * @param pGlobals
- * @return none
- */
-DECLHIDDEN(void) vboxNetFltDeleteGlobalsBase(PVBOXNETFLTGLOBALS pGlobals)
-{
+
+/**
+ * Deletes the globals.
+ *
+ * This must be called after the IDC connection has been closed,
+ * see vboxNetFltTryDeleteIdc().
+ *
+ * @param   pGlobals        Pointer to the globals.
+ * @sa      vboxNetFltTryDeleteIdcAndGlobals()
+ */
+DECLHIDDEN(void) vboxNetFltDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals)
+{
+    Assert(!pGlobals->fIDCOpen);
+
     /*
      * Release resources.
@@ -1224,37 +1315,19 @@
 
 #ifdef VBOXNETFLT_STATIC_CONFIG
-    RTSemEventDestroy(pGlobals->hTimerEvent);
-    pGlobals->hTimerEvent = NIL_RTSEMEVENT;
+    RTSemEventDestroy(pGlobals->hBlockEvent);
+    pGlobals->hBlockEvent = NIL_RTSEMEVENT;
 #endif
 
 }
 
-/**
- * Called by the native part when the OS wants the driver to unload.
- *
- * @returns VINF_SUCCESS on succes, VERR_WRONG_ORDER if we're busy.
- *
+
+/**
+ * Initializes the globals.
+ *
+ * @returns VBox status code.
  * @param   pGlobals        Pointer to the globals.
- */
-DECLHIDDEN(int) vboxNetFltTryDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals)
-{
-    int rc = vboxNetFltTryDeleteIdc(pGlobals);
-    if(RT_SUCCESS(rc))
-    {
-        vboxNetFltDeleteGlobalsBase(pGlobals);
-    }
-    return rc;
-}
-
-/**
- * performs the "base" globals initialization
- * we separate the globals initialization to globals "base" initialization which is actually
- * "general" globals initialization except for Idc not being initialized, and idc initialization.
- * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
- * thus it's not possible to make idc initialization from the driver startup routine for it.
- *
- * @returns VBox status code.
- * @param   pGlobals    Pointer to the globals. */
-DECLHIDDEN(int) vboxNetFltInitGlobalsBase(PVBOXNETFLTGLOBALS pGlobals)
+ * @sa      vboxNetFltInitGlobalsAndIdc().
+ */
+DECLHIDDEN(int) vboxNetFltInitGlobals(PVBOXNETFLTGLOBALS pGlobals)
 {
     /*
@@ -1265,5 +1338,5 @@
     {
 #ifdef VBOXNETFLT_STATIC_CONFIG
-        rc = RTSemEventCreate(&pGlobals->hTimerEvent);
+        rc = RTSemEventCreate(&pGlobals->hBlockEvent);
         if (RT_SUCCESS(rc))
         {
@@ -1279,4 +1352,5 @@
 #endif
             pGlobals->SupDrvFactory.pfnQueryFactoryInterface = vboxNetFltQueryFactoryInterface;
+            pGlobals->fIDCOpen = false;
 
             return rc;
@@ -1290,62 +1364,45 @@
 }
 
-/**
- * performs the Idc initialization
- * we separate the globals initialization to globals "base" initialization which is actually
- * "general" globals initialization except for Idc not being initialized, and idc initialization.
- * This is needed for windows filter driver, which gets loaded prior to VBoxDrv,
- * thus it's not possible to make idc initialization from the driver startup routine for it.
- *
- * @returns VBox status code.
- * @param   pGlobals    Pointer to the globals. */
-DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals)
-{
-    int rc;
-    /*
-     * Establish a connection to SUPDRV and register our component factory.
-     */
-    rc = SUPR0IdcOpen(&pGlobals->SupDrvIDC, 0 /* iReqVersion = default */, 0 /* iMinVersion = default */, NULL, NULL, NULL);
+
+/**
+ * Called by the native part when the OS wants the driver to unload.
+ *
+ * @returns VINF_SUCCESS on success, VERR_WRONG_ORDER if we're busy.
+ *
+ * @param   pGlobals        Pointer to the globals.
+ */
+DECLHIDDEN(int) vboxNetFltTryDeleteIdcAndGlobals(PVBOXNETFLTGLOBALS pGlobals)
+{
+    int rc = vboxNetFltTryDeleteIdc(pGlobals);
     if (RT_SUCCESS(rc))
-    {
-        rc = SUPR0IdcComponentRegisterFactory(&pGlobals->SupDrvIDC, &pGlobals->SupDrvFactory);
-        if (RT_SUCCESS(rc))
-        {
-            Log(("VBoxNetFlt: pSession=%p\n", SUPR0IdcGetSession(&pGlobals->SupDrvIDC)));
-            return rc;
-        }
-
-        /* bail out. */
-        LogRel(("VBoxNetFlt: Failed to register component factory, rc=%Rrc\n", rc));
-        SUPR0IdcClose(&pGlobals->SupDrvIDC);
-    }
-
+        vboxNetFltDeleteGlobals(pGlobals);
     return rc;
 }
 
+
 /**
  * Called by the native driver/kext module initialization routine.
  *
  * It will initialize the common parts of the globals, assuming the caller
- * has already taken care of the OS specific bits.
+ * has already taken care of the OS specific bits, and establish the IDC
+ * connection to SUPDRV.
  *
  * @returns VBox status code.
  * @param   pGlobals    Pointer to the globals.
  */
-DECLHIDDEN(int) vboxNetFltInitGlobals(PVBOXNETFLTGLOBALS pGlobals)
+DECLHIDDEN(int) vboxNetFltInitGlobalsAndIdc(PVBOXNETFLTGLOBALS pGlobals)
 {
     /*
      * Initialize the common portions of the structure.
      */
-    int rc = vboxNetFltInitGlobalsBase(pGlobals);
+    int rc = vboxNetFltInitGlobals(pGlobals);
     if (RT_SUCCESS(rc))
     {
         rc = vboxNetFltInitIdc(pGlobals);
         if (RT_SUCCESS(rc))
-        {
             return rc;
-        }
 
         /* bail out. */
-        vboxNetFltDeleteGlobalsBase(pGlobals);
+        vboxNetFltDeleteGlobals(pGlobals);
     }
 
Index: /trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h	(revision 17184)
@@ -68,7 +68,9 @@
      * Partly for reasons of deadlock avoidance again. */
     kVBoxNetFltInsState_Disconnecting,
+#ifdef VBOXNETFLT_STATIC_CONFIG
     /** Destroying the instance
      * Partly for reasons of deadlock avoidance again. */
     kVBoxNetFltInsState_Destroying,
+#endif
     /** The instance has been disconnected from both the host and the internal network. */
     kVBoxNetFltInsState_Destroyed,
@@ -255,15 +257,24 @@
     /** The number of current factory references. */
     int32_t volatile cFactoryRefs;
-#ifdef VBOXNETFLT_STATIC_CONFIG
-    /* wait timer event */
-    RTSEMEVENT hTimerEvent;
-#endif
+    /** Whether the IDC connection is open or not.
+     * This is only for cleaning up correctly after the separate IDC init on Windows. */
+    bool fIDCOpen;
     /** The SUPDRV IDC handle (opaque struct). */
     SUPDRVIDCHANDLE SupDrvIDC;
+
+#ifdef VBOXNETFLT_STATIC_CONFIG
+    /** Something we can block on while waiting for an instance to be unlinked. */
+    RTSEMEVENT hBlockEvent;
+#endif
 } VBOXNETFLTGLOBALS;
 
 
+DECLHIDDEN(int) vboxNetFltInitGlobalsAndIdc(PVBOXNETFLTGLOBALS pGlobals);
 DECLHIDDEN(int) vboxNetFltInitGlobals(PVBOXNETFLTGLOBALS pGlobals);
-DECLHIDDEN(int) vboxNetFltTryDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals);
+DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals);
+DECLHIDDEN(int) vboxNetFltTryDeleteIdcAndGlobals(PVBOXNETFLTGLOBALS pGlobals);
+DECLHIDDEN(void) vboxNetFltDeleteGlobals(PVBOXNETFLTGLOBALS pGlobals);
+DECLHIDDEN(int) vboxNetFltTryDeleteIdc(PVBOXNETFLTGLOBALS pGlobals);
+
 DECLHIDDEN(bool) vboxNetFltCanUnload(PVBOXNETFLTGLOBALS pGlobals);
 DECLHIDDEN(PVBOXNETFLTINS) vboxNetFltFindInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName);
@@ -274,9 +285,6 @@
 #ifdef VBOXNETFLT_STATIC_CONFIG
 DECLHIDDEN(int) vboxNetFltSearchCreateInstance(PVBOXNETFLTGLOBALS pGlobals, const char *pszName, PVBOXNETFLTINS *ppInstance, void * pContext);
-DECLHIDDEN(int) vboxNetFltInitGlobalsBase(PVBOXNETFLTGLOBALS pGlobals);
-DECLHIDDEN(int) vboxNetFltInitIdc(PVBOXNETFLTGLOBALS pGlobals);
-DECLHIDDEN(void) vboxNetFltDeleteGlobalsBase(PVBOXNETFLTGLOBALS pGlobals);
-DECLHIDDEN(int) vboxNetFltTryDeleteIdc(PVBOXNETFLTGLOBALS pGlobals);
-#endif
+#endif
+
 
 
Index: /trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp	(revision 17184)
@@ -171,5 +171,5 @@
              */
             memset(&g_VBoxNetFltGlobals, 0, sizeof(g_VBoxNetFltGlobals));
-            rc = vboxNetFltInitGlobals(&g_VBoxNetFltGlobals);
+            rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltGlobals);
             if (RT_SUCCESS(rc))
             {
@@ -204,5 +204,5 @@
      * tracking for us!
      */
-    int rc = vboxNetFltTryDeleteGlobals(&g_VBoxNetFltGlobals);
+    int rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltGlobals);
     if (RT_FAILURE(rc))
     {
Index: /trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c	(revision 17184)
@@ -99,5 +99,5 @@
         flags = (dev->flags & ~(IFF_PROMISC |
                                 IFF_ALLMULTI |
-                                IFF_RUNNING)) | 
+                                IFF_RUNNING)) |
                 (dev->gflags & (IFF_PROMISC |
                                 IFF_ALLMULTI));
@@ -209,5 +209,5 @@
 {
     Log(("vboxTapValidateAddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
-         dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], 
+         dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
          dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]));
     return -EADDRNOTAVAIL;
@@ -221,5 +221,5 @@
     /// @todo Use Sun vendor id
     memcpy(pNetDev->dev_addr, "\0vbnet", ETH_ALEN);
-    Log(("vboxTapNetDevInit: pNetDev->dev_addr = %.6Rhxd\n", pNetDev->dev_addr)); 
+    Log(("vboxTapNetDevInit: pNetDev->dev_addr = %.6Rhxd\n", pNetDev->dev_addr));
     pNetDev->open = vboxTapOpen;
     pNetDev->stop = vboxTapStop;
@@ -297,5 +297,5 @@
          */
         memset(&g_VBoxNetFltGlobals, 0, sizeof(g_VBoxNetFltGlobals));
-        rc = vboxNetFltInitGlobals(&g_VBoxNetFltGlobals);
+        rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltGlobals);
         if (RT_SUCCESS(rc))
         {
@@ -337,5 +337,5 @@
     rc = vboxTapUnregisterNetDev();
     AssertRC(rc);
-    rc = vboxNetFltTryDeleteGlobals(&g_VBoxNetFltGlobals);
+    rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltGlobals);
     AssertRC(rc); NOREF(rc);
 
@@ -598,5 +598,5 @@
     if (!pBuf)
         return 0;
-    
+
     pThis = VBOX_FLT_PT_TO_INST(pPacketType);
     pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);
@@ -669,5 +669,5 @@
     }
 #endif
-            
+
     dev_kfree_skb(pBuf);
 }
@@ -1088,5 +1088,5 @@
         {
             if (pThis->u.s.fPromiscuousSet)
-            {    
+            {
                 rtnl_lock();
                 dev_set_promiscuity(pDev, -1);
Index: /trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c	(revision 17183)
+++ /trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c	(revision 17184)
@@ -430,5 +430,5 @@
              */
             memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals));
-            rc = vboxNetFltInitGlobals(&g_VBoxNetFltSolarisGlobals);
+            rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltSolarisGlobals);
             if (RT_SUCCESS(rc))
             {
@@ -438,5 +438,5 @@
 
                 LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc));
-                vboxNetFltTryDeleteGlobals(&g_VBoxNetFltSolarisGlobals);
+                vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals);
             }
             else
@@ -465,5 +465,5 @@
      * Undo the work done during start (in reverse order).
      */
-    rc = vboxNetFltTryDeleteGlobals(&g_VBoxNetFltSolarisGlobals);
+    rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals);
     if (RT_FAILURE(rc))
     {
@@ -2976,5 +2976,5 @@
             int Pcp:3;
             int Cfi:1;
-            int Vid:12; 
+            int Vid:12;
         } VLANHEADER;
 
