VirtualBox

Ignore:
Timestamp:
Sep 26, 2008 2:54:09 PM (16 years ago)
Author:
vboxsync
Message:

Solaris/vboxnetflt: Fixed loopback handling.

File:
1 edited

Legend:

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

    r12731 r12770  
    858858
    859859    bool fSendUpstream = true;
    860     bool fActive = false;
    861     bool fRetained = false;
    862860    vboxnetflt_stream_t *pStream = pQueue->q_ptr;
    863861    PVBOXNETFLTINS pThis = NULL;
     
    881879            RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    882880            RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    883             fActive = ASMAtomicUoReadBool(&pThis->fActive);
     881            const bool fActive = ASMAtomicUoReadBool(&pThis->fActive);
    884882            vboxNetFltRetain(pThis, true);
    885             fRetained = true;
    886883            RTSpinlockRelease(pThis->hSpinlock, &Tmp);
    887884
     
    988985                }
    989986            }
     987
     988            vboxNetFltRelease(pThis, true);       
    990989        }
    991990        else
     
    10071006            putbq(pQueue, pMsg);
    10081007    }
    1009 
    1010     if (fRetained)
    1011         vboxNetFltRelease(pThis, true);
    10121008
    10131009    return 0;
     
    23772373        return VERR_NET_MSG_SIZE;
    23782374
     2375    int rc = RTSemFastMutexRequest(pThis->u.s.hFastMtx);
     2376    AssertRCReturn(rc, rc);
     2377
    23792378    PVBOXNETFLTPACKETID pCur = NULL;
    2380     int rc = VINF_SUCCESS;
    23812379    if (pPromiscStream->cLoopback < VBOXNETFLT_LOOPBACK_SIZE)
    23822380    {
     
    24462444        pPromiscStream->pTail->pNext = pCur;
    24472445        pPromiscStream->pTail = pCur;
     2446        pCur->pNext = NULL;
     2447        pCur->cbPacket = 0;
     2448        pPromiscStream->cLoopback--;
    24482449
    24492450        vboxNetFltSolarisInitPacketId(pCur, pMsg);
     
    24512452                pPromiscStream->cLoopback));
    24522453    }
     2454
     2455    RTSemFastMutexRelease(pThis->u.s.hFastMtx);
    24532456
    24542457    return rc;
     
    24832486        return false;
    24842487
     2488    int rc = RTSemFastMutexRequest(pThis->u.s.hFastMtx);
     2489    AssertRCReturn(rc, rc);
     2490
    24852491    PVBOXNETFLTPACKETID pPrev = NULL;
    24862492    PVBOXNETFLTPACKETID pCur = pPromiscStream->pHead;
    2487     bool fIsOur = false;
     2493    bool fIsOurPacket = false;
    24882494    while (pCur)
    24892495    {
     
    25292535        }
    25302536        pPromiscStream->cLoopback--;
     2537        fIsOurPacket = true;
    25312538
    25322539        LogFlow((DEVICE_NAME ":vboxNetFltSolarisIsOurMBlk found packet %p cLoopback=%d\n", pMsg, pPromiscStream->cLoopback));
    2533         return true;
    2534     }
    2535 
    2536     NOREF(pThis);
    2537     return false;
     2540        break;
     2541    }
     2542
     2543    RTSemFastMutexRelease(pThis->u.s.hFastMtx);
     2544    return fIsOurPacket;
    25382545}
    25392546
     
    25662573     * Don't loopback packets we transmit to the wire.
    25672574     */
    2568 #if 0
    2569     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2570     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    2571     bool fOurPacket = vboxNetFltSolarisIsOurMBlk(pThis, pPromiscStream, pMsg);
    2572     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
    2573 
    2574     if (fOurPacket)
     2575    if (vboxNetFltSolarisIsOurMBlk(pThis, pPromiscStream, pMsg))
    25752576    {
    25762577        LogFlow((DEVICE_NAME ":Avoiding packet loopback.\n"));
     
    25782579        return VINF_SUCCESS;
    25792580    }
    2580 #endif
     2581
     2582#if 0
     2583    /*
     2584     * Yeah, I wish.
     2585     */
    25812586    if (pMsg->b_flag & MSGNOLOOP)
    25822587    {
     
    25842589        return VINF_SUCCESS;
    25852590    }
     2591#endif
    25862592
    25872593    /*
     
    29172923    LogFlow((DEVICE_NAME ":vboxNetFltOsDeleteInstance pThis=%p\n"));
    29182924    vboxNetFltSolarisDetachFromInterface(pThis);
     2925
     2926    if (pThis->u.s.hFastMtx != NIL_RTSEMFASTMUTEX)
     2927    {
     2928        RTSemFastMutexDestroy(pThis->u.s.hFastMtx);
     2929        pThis->u.s.hFastMtx = NIL_RTSEMFASTMUTEX;
     2930    }
    29192931}
    29202932
     
    29232935{
    29242936    LogFlow((DEVICE_NAME ":vboxNetFltOsInitInstance pThis=%p\n"));
    2925     return vboxNetFltSolarisAttachToInterface(pThis);
     2937
     2938    /*
     2939     * Mutex used for loopback lockouts.
     2940     */
     2941    int rc = RTSemFastMutexCreate(&pThis->u.s.hFastMtx);
     2942    if (RT_SUCCESS(rc))
     2943    {
     2944        rc = vboxNetFltSolarisAttachToInterface(pThis);
     2945        if (RT_SUCCESS(rc))
     2946            return rc;
     2947   
     2948        LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed. rc=%Vrc\n", rc));
     2949        RTSemFastMutexDestroy(pThis->u.s.hFastMtx);
     2950        pThis->u.s.hFastMtx = NIL_RTSEMFASTMUTEX;
     2951    }
     2952
     2953    return rc;
    29262954}
    29272955
     
    29352963    pThis->u.s.pvArpStream = NULL;
    29362964    pThis->u.s.pvPromiscStream = NULL;
     2965    pThis->u.s.hFastMtx = NIL_RTSEMFASTMUTEX;
    29372966    bzero(&pThis->u.s.Mac, sizeof(pThis->u.s.Mac));
    29382967    return VINF_SUCCESS;
     
    29652994                LogFlow((DEVICE_NAME ":vboxNetFltPortOsXmit INTNETTRUNKDIR_WIRE\n"));
    29662995
     2996                vboxNetFltSolarisQueueLoopback(pThis, pPromiscStream, pMsg);
     2997
    29672998#if 0
    2968                 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2969                 RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    2970 
    2971                 vboxNetFltSolarisQueueLoopback(pThis, pPromiscStream, pMsg);
    2972 
    2973                 RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     2999                /*
     3000                 * Too bad we can't keep this, though it "works"....
     3001                 */
     3002                pMsg->b_flag |= MSGNOLOOP;
    29743003#endif
    2975 
    2976                 pMsg->b_flag |= MSGNOLOOP;
    29773004                putnext(WR(pPromiscStream->Stream.pReadQueue), pMsg);
    29783005            }
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