VirtualBox

Changeset 12209

Show
Ignore:
Timestamp:
09/08/08 11:40:34 (2 months ago)
Author:
vboxsync
Message:

Solaris/vboxnetflt: No rediscovery.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c

    r12123 r12209  
    6767/** The module name. */ 
    6868#define DEVICE_NAME              "vboxflt" 
     69/** The module descriptions as seen in 'modinfo'. */ 
    6970#define DEVICE_DESC_DRV          "VirtualBox NetFilter Driver" 
    7071#define DEVICE_DESC_MOD          "VirtualBox NetFilter Module" 
    71  
    7272 
    7373/** @todo Remove the below hackery once done! */ 
     
    370370    { 
    371371        /* 
    372          * Initialize the globals and connect to the support driver. 
    373          * 
    374          * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv) 
    375          * for establishing the connect to the support driver. 
     372         * Initialize Solaris specific globals here. 
    376373         */ 
    377         memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals)); 
    378         rc = vboxNetFltInitGlobals(&g_VBoxNetFltSolarisGlobals); 
     374        g_VBoxNetFltSolarisState.pOpenedStreams = NULL; 
     375        g_VBoxNetFltSolarisState.pCurInstance = NULL; 
     376        rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx); 
    379377        if (RT_SUCCESS(rc)) 
    380             return mod_install(&g_VBoxNetFltSolarisModLinkage); 
     378        { 
     379            /* 
     380             * Initialize the globals and connect to the support driver. 
     381             * 
     382             * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv) 
     383             * for establishing the connect to the support driver. 
     384             */ 
     385            memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals)); 
     386            rc = vboxNetFltInitGlobals(&g_VBoxNetFltSolarisGlobals); 
     387            if (RT_SUCCESS(rc)) 
     388            { 
     389                rc = mod_install(&g_VBoxNetFltSolarisModLinkage); 
     390                if (!rc) 
     391                    return rc; 
     392 
     393                LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc)); 
     394                vboxNetFltTryDeleteGlobals(&g_VBoxNetFltSolarisGlobals);                 
     395            } 
     396            else 
     397                LogRel((DEVICE_NAME ":failed to initialize globals.\n")); 
     398 
     399            RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx); 
     400            g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX; 
     401        } 
    381402        else 
    382             LogRel((DEVICE_NAME ":failed to initialize globals.\n")); 
     403            LogRel((DEVICE_NAME ":failed to create mutex.\n")); 
    383404 
    384405        RTR0Term(); 
     
    407428    } 
    408429 
     430    if (g_VBoxNetFltSolarisMtx != NIL_RTSEMFASTMUTEX) 
     431    { 
     432        RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx); 
     433        g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX; 
     434    } 
     435 
    409436    RTR0Term(); 
    410437 
     
    440467        case DDI_ATTACH: 
    441468        { 
    442             int rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx); 
    443             if (RT_SUCCESS(rc)) 
     469            int instance = ddi_get_instance(pDip); 
     470            int rc = ddi_create_minor_node(pDip, DEVICE_NAME, S_IFCHR, instance, DDI_PSEUDO, CLONE_DEV); 
     471            if (rc == DDI_SUCCESS) 
    444472            { 
    445                 int instance = ddi_get_instance(pDip); 
    446                 int rc = ddi_create_minor_node(pDip, DEVICE_NAME, S_IFCHR, instance, DDI_PSEUDO, CLONE_DEV); 
    447                 if (rc == DDI_SUCCESS) 
    448                 { 
    449                     g_VBoxNetFltSolarisState.pDip = pDip; 
    450                     g_VBoxNetFltSolarisState.pOpenedStreams = NULL; 
    451                     g_VBoxNetFltSolarisState.pCurInstance = NULL; 
    452                     ddi_report_dev(pDip); 
    453                     return DDI_SUCCESS; 
    454                 } 
    455                 else 
    456                     LogRel((DEVICE_NAME ":VBoxNetFltSolarisAttach failed to create minor node. rc%d\n", rc)); 
    457  
    458                 RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx); 
    459                 g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX; 
     473                g_VBoxNetFltSolarisState.pDip = pDip; 
     474                ddi_report_dev(pDip); 
     475                return DDI_SUCCESS; 
    460476            } 
    461477            else 
    462                 LogRel((DEVICE_NAME ":VBoxNetFltSolarisAttach failed to create mutex.rc=%d\n", rc)); 
     478                LogRel((DEVICE_NAME ":VBoxNetFltSolarisAttach failed to create minor node. rc%d\n", rc)); 
    463479            return DDI_FAILURE; 
    464480        } 
     
    492508            int instance = ddi_get_instance(pDip); 
    493509            ddi_remove_minor_node(pDip, NULL); 
    494  
    495             RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx); 
    496             g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX; 
    497510            return DDI_SUCCESS; 
    498511        } 
     
    652665     */ 
    653666    if (pStream->Type == kIpStream) 
    654         vboxNetFltSolarisPhysAddrReq(pQueue); 
     667        vboxNetFltSolarisPhysAddrReq(pStream->pReadQueue); 
    655668 
    656669    /* 
     
    14871500/** 
    14881501 * Dynamically attaches this streams module on to the host stack. 
    1489  * As a side-effect, this streams also gets opened during the actual 
    1490  * insertion phase. 
     1502 * As a side-effect, this streams also gets opened/closed during 
     1503 * the actual injection/ejection phase. 
    14911504 * 
    14921505 * @returns VBox status code. 
    1493  * @param   pThis           The instance. 
    1494  * @param   fRediscovery    Rediscovery attempt, currently unused on solaris
     1506 * @param   pThis       The instance. 
     1507 * @param   fAttach     Is this an attach or detach
    14951508 */ 
    14961509static int vboxNetFltSolarisModSetup(PVBOXNETFLTINS pThis, bool fAttach) 
    14971510{ 
    14981511    LogFlow(("vboxNetFltSolarisModSetup: pThis=%p (%s) fAttach=%s\n", pThis, pThis->szName, fAttach ? "true" : "false")); 
    1499  
    1500     Assert(!g_VBoxNetFltSolarisState.pCurInstance); 
    1501     Assert(g_VBoxNetFltSolarisState.CurType == kUndefined); 
    15021512 
    15031513    /* 
     
    16191629                                /* 
    16201630                                 * Set global data which will be grabbed by ModOpen. 
     1631                                 * There is a known (though very unlikely) race here because 
     1632                                 * of the inability to pass user data while inserting. 
    16211633                                 */ 
    16221634                                g_VBoxNetFltSolarisState.pCurInstance = pThis; 
     
    23312343 
    23322344 
     2345/** 
     2346 * Simple packet dump, used for internal debugging. 
     2347 * 
     2348 * @param   pMsg    Pointer to the message to analyze and dump. 
     2349 */ 
    23332350static void vboxNetFltSolarisAnalyzeMBlk(mblk_t *pMsg) 
    23342351{ 
     
    23392356    { 
    23402357        PRTNETIPV4 pIpHdr = (PRTNETIPV4)(pEthHdr + 1); 
    2341         size_t cbLen = MBLKSIZE(pMsg) - sizeof(*pEthHdr); 
     2358        size_t cbLen = MBLKL(pMsg) - sizeof(*pEthHdr); 
    23422359        if (RTNetIPv4IsHdrValid(pIpHdr, cbLen, cbLen)) 
    23432360        { 
     
    23972414bool vboxNetFltPortOsIsHostMac(PVBOXNETFLTINS pThis, PCRTMAC pMac) 
    23982415{ 
    2399     /* ASSUMES that the MAC address never changes. */ 
     2416    /* 
     2417     * MAC address change acknowledgements are intercepted on the read side 
     2418     * hence theoritically we are always update to date with any changes. 
     2419     */ 
    24002420    return pThis->u.s.Mac.au16[0] == pMac->au16[0] 
    24012421        && pThis->u.s.Mac.au16[1] == pMac->au16[1] 
     
    24092429 
    24102430    /* 
    2411      * Enable promiscuous mode. 
     2431     * Enable/disable promiscuous mode. 
    24122432     */ 
    24132433    vboxnetflt_stream_t *pStream = pThis->u.s.pvStream; 
     
    24612481bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThis) 
    24622482{ 
    2463     return true; 
     2483    /* 
     2484     * We don't support interface rediscovery on Solaris hosts because the 
     2485     * filter is very tightly bound to the stream. 
     2486     */ 
     2487    return false; 
    24642488} 
    24652489 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy