VirtualBox

Ignore:
Timestamp:
Apr 27, 2010 2:05:25 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60746
Message:

IntNet,VBoxNetFlt: Cleaned up the locking protocol between IntNet and NetFlt. Eleminated the out-bound trunk lock that IntNet always took when calling NetFlt.

File:
1 edited

Legend:

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

    r28723 r28830  
    316316    bool fActive;
    317317
    318     fActive = ASMAtomicUoReadBool(&pThis->fActive);
     318    fActive = vboxNetFltTryRetainBusyActive(pThis);
    319319
    320320    NGI_GET_M(item, m);
     
    338338        {
    339339            ether_demux(ifp, m);
     340            if (fActive)
     341                vboxNetFltRelease(pThis, true /*fBusy*/);
    340342            return (0);
    341343        }
     
    345347        taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin);
    346348    }
    347     /**
     349    /*
    348350     * Handle mbufs on the outgoing hook, frames going to the interface
    349351     */
     
    351353    {
    352354        if (mtag != NULL || !fActive)
    353             return ether_output_frame(ifp, m);
     355        {
     356            int rc = ether_output_frame(ifp, m);
     357            if (fActive)
     358                vboxNetFltRelease(pThis, true /*fBusy*/);
     359            return rc;
     360        }
    354361        mtx_lock_spin(&pThis->u.s.outq.ifq_mtx);
    355362        _IF_ENQUEUE(&pThis->u.s.outq, m);
     
    361368        m_freem(m);
    362369    }
     370
     371    if (fActive)
     372        vboxNetFltRelease(pThis, true /*fBusy*/);
    363373    return (0);
    364374}
     
    370380
    371381    /* Prevent node shutdown if we're active */
    372     fActive = ASMAtomicUoReadBool(&pThis->fActive);
    373     if (fActive)
     382    if (pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE)
    374383        return (EBUSY);
    375384    NG_NODE_UNREF(node);
     
    548557        return VERR_INTERNAL_ERROR;
    549558
    550     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     559    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     560
    551561    ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.ifp, ifp);
    552562    pThis->u.s.node = node;
     
    564574    TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis);
    565575
    566     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     576    RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    567577
    568578    NG_NODE_SET_PRIVATE(node, pThis);
     
    575585    /** @todo keep these reports up to date, either by polling for changes or
    576586     *        intercept some control flow if possible. */
    577     Assert(pThis->pSwitchPort);
    578     pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr);
    579     pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltFreeBsdIsPromiscuous(pThis));
    580     pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
    581     pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
     587    if (vboxNetFltTryRetainBusyNotDisconnected(pThis))
     588    {
     589        Assert(pThis->pSwitchPort);
     590        pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr);
     591        pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltFreeBsdIsPromiscuous(pThis));
     592        pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
     593        pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
     594        vboxNetFltRelease(pThis, true /*fBusy*/);
     595    }
    582596
    583597    return VINF_SUCCESS;
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