VirtualBox

Ignore:
Timestamp:
Sep 29, 2008 9:31:21 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
37128
Message:

Solaris/vboxnetflt: Unplumbed interfaces. Disabled Main enumeration as it requires NSL link fix.

File:
1 edited

Legend:

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

    r12770 r12783  
    320320} vboxnetflt_promisc_stream_t;
    321321
    322 /**
    323  * vboxnetflt_state_t: per-driver data
    324  */
    325 typedef struct vboxnetflt_state_t
    326 {
    327     /** The list of all opened streams. */
    328     vboxnetflt_stream_t *pOpenedStreams;
    329     /**
    330      * pCurInstance is the currently VBox instance to be associated with the stream being created
    331      * in ModOpen. This is just shared global data between the dynamic attach and the ModOpen procedure.
    332      */
    333     PVBOXNETFLTINS pCurInstance;
    334     /** Goes along with pCurInstance to determine type of stream being opened/created. */
    335     VBOXNETFLTSTREAMTYPE CurType;
    336 } vboxnetflt_state_t;
    337 
    338322
    339323/*******************************************************************************
     
    366350*   Global Variables                                                           *
    367351*******************************************************************************/
     352/** Global device info handle. */
     353static dev_info_t *g_pVBoxNetFltSolarisDip = NULL;
     354
    368355/** The (common) global data. */
    369356static VBOXNETFLTGLOBALS g_VBoxNetFltSolarisGlobals;
    370 /** Global state. */
    371 static vboxnetflt_state_t g_VBoxNetFltSolarisState;
     357
    372358/** Mutex protecting dynamic binding of the filter. */
    373359RTSEMFASTMUTEX g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX;
    374 /** Global device info handle. */
    375 static dev_info_t *g_pVBoxNetFltSolarisDip = NULL;
    376 
     360
     361/** The list of all opened streams. */
     362vboxnetflt_stream_t *g_VBoxNetFltSolarisStreams;
     363
     364/**
     365 * g_VBoxNetFltInstance is the current PVBOXNETFLTINS to be associated with the stream being created
     366 * in ModOpen. This is just shared global data between the dynamic attach and the ModOpen procedure.
     367 */
     368PVBOXNETFLTINS volatile g_VBoxNetFltSolarisInstance;
     369
     370/** Goes along with the instance to determine type of stream being opened/created. */
     371VBOXNETFLTSTREAMTYPE volatile g_VBoxNetFltSolarisStreamType;
    377372
    378373/** GCC C++ hack. */
     
    405400         * Initialize Solaris specific globals here.
    406401         */
    407         g_VBoxNetFltSolarisState.pOpenedStreams = NULL;
    408         g_VBoxNetFltSolarisState.pCurInstance = NULL;
     402        g_VBoxNetFltSolarisStreams = NULL;
     403        g_VBoxNetFltSolarisInstance = NULL;
    409404        rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx);
    410405        if (RT_SUCCESS(rc))
     
    619614     * Check for the VirtualBox instance.
    620615     */
    621     vboxnetflt_state_t *pState = &g_VBoxNetFltSolarisState;
    622     if (RT_UNLIKELY(!pState->pCurInstance))
     616    if (RT_UNLIKELY(!g_VBoxNetFltSolarisInstance))
    623617    {
    624618        LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed to get VirtualBox instance.\n"));
     
    627621
    628622    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    629     PVBOXNETFLTINS pThis = pState->pCurInstance;
     623    PVBOXNETFLTINS pThis = g_VBoxNetFltSolarisInstance;
    630624    RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    631625
     
    633627     * Check VirtualBox stream type.
    634628     */
    635     if (pState->CurType == kUndefined)
     629    if (g_VBoxNetFltSolarisStreamType == kUndefined)
    636630    {
    637631        LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed due to undefined VirtualBox open mode.\n"));
     
    646640    minor_t DevMinor = 0;
    647641    vboxnetflt_stream_t *pStream = NULL;
    648     vboxnetflt_stream_t **ppPrevStream = &pState->pOpenedStreams;
     642    vboxnetflt_stream_t **ppPrevStream = &g_VBoxNetFltSolarisStreams;
    649643    if (fStreamMode == CLONEOPEN)
    650644    {
     
    660654        DevMinor = getminor(*pDev);
    661655
    662     if (pState->CurType == kPromiscStream)
     656    if (g_VBoxNetFltSolarisStreamType == kPromiscStream)
    663657    {
    664658        vboxnetflt_promisc_stream_t *pPromiscStream = RTMemAlloc(sizeof(vboxnetflt_promisc_stream_t));
     
    701695     */
    702696    ASMAtomicUoWritePtr((void * volatile *)&pStream->pThis, pThis);
    703     pStream->Type = pState->CurType;
     697    pStream->Type = g_VBoxNetFltSolarisStreamType;
    704698    switch (pStream->Type)
    705699    {
     
    811805     * Unlink it from the list of streams.
    812806     */
    813     for (ppPrevStream = &g_VBoxNetFltSolarisState.pOpenedStreams; (pStream = *ppPrevStream) != NULL; ppPrevStream = &pStream->pNext)
     807    for (ppPrevStream = &g_VBoxNetFltSolarisStreams; (pStream = *ppPrevStream) != NULL; ppPrevStream = &pStream->pNext)
    814808        if (pStream == (vboxnetflt_stream_t *)pQueue->q_ptr)
    815809            break;
     
    16871681 * the I_PUSH phase.
    16881682 *
     1683 * @param   pThis       The instance.
    16891684 */
    16901685static int vboxNetFltSolarisOpenStream(PVBOXNETFLTINS pThis)
     
    17101705        if (!ret)
    17111706        {
    1712             g_VBoxNetFltSolarisState.pCurInstance = pThis;
    1713             g_VBoxNetFltSolarisState.CurType = kPromiscStream;
     1707            g_VBoxNetFltSolarisInstance = pThis;
     1708            g_VBoxNetFltSolarisStreamType = kPromiscStream;
    17141709
    17151710            rc = ldi_ioctl(pThis->u.s.hIface, I_PUSH, (intptr_t)DEVICE_NAME, FKIOCTL, kcred, &ret);
    17161711
    1717             g_VBoxNetFltSolarisState.pCurInstance = NULL;
    1718             g_VBoxNetFltSolarisState.CurType = kUndefined;
     1712            g_VBoxNetFltSolarisInstance = NULL;
     1713            g_VBoxNetFltSolarisStreamType = kUndefined;
    17191714
    17201715            if (!rc)
     
    17821777     * Statuatory Warning: Hackish code ahead.
    17831778     */
    1784     if (strlen(pThis->szName) > VBOXNETFLT_IFNAME_LEN - 1)
    1785     {
    1786         LogRel((DEVICE_NAME ":vboxNetFltSolarisModSetup: interface name too long %s\n", pThis->szName));
    1787         return VERR_INTNET_FLT_IF_NOT_FOUND;
    1788     }
    1789 
    17901779    char *pszModName = DEVICE_NAME;
    17911780
     
    19001889                                 * of the inability to pass user data while inserting.
    19011890                                 */
    1902                                 g_VBoxNetFltSolarisState.pCurInstance = pThis;
    1903                                 g_VBoxNetFltSolarisState.CurType = kIpStream;
     1891                                g_VBoxNetFltSolarisInstance = pThis;
     1892                                g_VBoxNetFltSolarisStreamType = kIpStream;
    19041893
    19051894                                /*
     
    19131902                                     * Inject/Eject from the host ARP stack.
    19141903                                     */
    1915                                     g_VBoxNetFltSolarisState.CurType = kArpStream;
     1904                                    g_VBoxNetFltSolarisStreamType = kArpStream;
    19161905                                    rc = strioctl(pVNodeArp, fAttach ? _I_INSERT : _I_REMOVE, (intptr_t)&ArpStrMod, 0, K_TO_K,
    19171906                                                kcred, &ret);
    19181907                                    if (!rc)
    19191908                                    {
    1920                                         g_VBoxNetFltSolarisState.pCurInstance = NULL;
    1921                                         g_VBoxNetFltSolarisState.CurType = kUndefined;
     1909                                        g_VBoxNetFltSolarisInstance = NULL;
     1910                                        g_VBoxNetFltSolarisStreamType = kUndefined;
    19221911
    19231912                                        /*
     
    19901979    }
    19911980    else
    1992         LogRel((DEVICE_NAME ":vboxNetFltSolarisModSetup: invalid interface '%s'.\n", pThis->szName));
     1981    {
     1982        /*
     1983         * This would happen for interfaces that are not plumbed.
     1984         */
     1985        LogRel((DEVICE_NAME ":vboxNetFltSolarisModSetup: Warning: seems '%s' is unplumbed.\n", pThis->szName));
     1986        rc = VINF_SUCCESS;
     1987    }
    19931988
    19941989    ldi_close(ARPDevHandle, FREAD | FWRITE, kcred);
    19951990    ldi_close(IPDevHandle, FREAD | FWRITE, kcred);
     1991
     1992    if (RT_SUCCESS(rc))
     1993        return rc;
    19961994
    19971995    return VERR_INTNET_FLT_IF_FAILED;
     
    20182016        if (RT_SUCCESS(rc))
    20192017            ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, false);
     2018        else
     2019            vboxNetFltSolarisCloseStream(pThis);
    20202020    }
    20212021    else
     
    25732573     * Don't loopback packets we transmit to the wire.
    25742574     */
     2575    /** @todo maybe we need not check for loopback for INTNETTRUNKDIR_HOST case? */
    25752576    if (vboxNetFltSolarisIsOurMBlk(pThis, pPromiscStream, pMsg))
    25762577    {
     
    25802581    }
    25812582
    2582 #if 0
    2583     /*
    2584      * Yeah, I wish.
    2585      */
    2586     if (pMsg->b_flag & MSGNOLOOP)
    2587     {
    2588         freemsg(pMsg);
    2589         return VINF_SUCCESS;
    2590     }
    2591 #endif
    2592 
    25932583    /*
    25942584     * Figure out the source of the packet based on the source Mac address.
    25952585     */
    2596     /** @todo Is there a more fool-proof way to determine if the packet was indeed sent from the host?? */
    25972586    uint32_t fSrc = INTNETTRUNKDIR_WIRE;
    25982587    PRTNETETHERHDR pEthHdr = (PRTNETETHERHDR)pMsg->b_rptr;
     
    26422631        return NULL;
    26432632
    2644     vboxnetflt_stream_t *pCur = g_VBoxNetFltSolarisState.pOpenedStreams;
     2633    vboxnetflt_stream_t *pCur = g_VBoxNetFltSolarisStreams;
    26452634    for (; pCur; pCur = pCur->pNext)
    26462635        if (pCur == pStream)
     
    28602849{
    28612850    LogFlow((DEVICE_NAME ":vboxNetFltPortOsGetMacAddress pThis=%p\n", pThis));
    2862 
    2863     RTMAC EmptyMac;
    2864     bzero(&EmptyMac, sizeof(EmptyMac));
    2865     if (!bcmp(&pThis->u.s.Mac, &EmptyMac, sizeof(EmptyMac)))    /* This should never happen... */
    2866     {
    2867         /* Bummer, Mac address is not copied yet. */
    2868         LogRel((DEVICE_NAME ":vboxNetFltPortOsGetMacAddress: Mac address not cached yet!\n"));
    2869         return;
    2870     }
    2871 
    28722851    *pMac = pThis->u.s.Mac;
    28732852}
     
    29952974
    29962975                vboxNetFltSolarisQueueLoopback(pThis, pPromiscStream, pMsg);
    2997 
    2998 #if 0
    2999                 /*
    3000                  * Too bad we can't keep this, though it "works"....
    3001                  */
    3002                 pMsg->b_flag |= MSGNOLOOP;
    3003 #endif
    30042976                putnext(WR(pPromiscStream->Stream.pReadQueue), pMsg);
    30052977            }
     
    30353007
    30363008                    vboxnetflt_stream_t *pArpStream = ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pvArpStream);
    3037                     if (RT_LIKELY(pArpStream))
     3009                    if (pArpStream)
    30383010                    {
    30393011                        queue_t *pArpReadQueue = pArpStream->pReadQueue;
     
    30413013                    }
    30423014                    else
    3043                         rc = VERR_INVALID_POINTER;
     3015                    {
     3016                        /*
     3017                         * For unplumbed interfaces we may not be bound to ARP.
     3018                         */
     3019                        freemsg(pMsg);
     3020                    }
    30443021                }
    30453022                else
     
    30573034                LogFlow((DEVICE_NAME ":vboxNetFltPortOsXmit INTNETTRUNKDIR_HOST\n"));
    30583035
    3059                 pMsg->b_rptr += sizeof(RTNETETHERHDR);
    3060 
    30613036                vboxnetflt_stream_t *pIpStream = ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pvIpStream);
    3062                 if (RT_LIKELY(pIpStream))
     3037                if (pIpStream)
    30633038                {
     3039                    pMsg->b_rptr += sizeof(RTNETETHERHDR);
    30643040                    queue_t *pIpReadQueue = pIpStream->pReadQueue;
    30653041                    putnext(pIpReadQueue, pMsg);
    30663042                }
    30673043                else
    3068                     rc = VERR_INVALID_POINTER;                   
     3044                {
     3045                    /*
     3046                     * For unplumbed interfaces we may not be bound to IP.
     3047                     */
     3048                    freemsg(pMsg);
     3049                }
    30693050            }
    30703051        }
Note: See TracChangeset for help on using the changeset viewer.

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