VirtualBox

Ignore:
Timestamp:
Jul 25, 2011 10:01:03 AM (13 years ago)
Author:
vboxsync
Message:

Solaris/VBoxNetBow: fix for using multiple host NICs, caused by using duplicate VNIC IDs.

Location:
trunk/src/VBox/HostDrivers/VBoxNetFlt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h

    r36956 r38140  
    184184            /** Handle to list of created VNICs. */
    185185            list_t hVNICs;
    186             /** Instance number while creating VNICs. */
    187             uint64_t uInstance;
    188186            /** The MAC address of the host interface. */
    189187            RTMAC MacAddr;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFltBow-solaris.c

    r37766 r38140  
    242242/** The (common) global data. */
    243243static VBOXNETFLTGLOBALS g_VBoxNetFltSolarisGlobals;
     244/** Global next-free VNIC Id (never decrements). */
     245static volatile uint64_t g_VBoxNetFltSolarisVNICId = 0;
    244246
    245247
     
    254256LOCAL int vboxNetFltSolarisReportInfo(PVBOXNETFLTINS pThis, mac_handle_t hInterface, bool fIsVNIC);
    255257LOCAL int vboxNetFltSolarisInitVNIC(PVBOXNETFLTINS pThis, PVBOXNETFLTVNIC pVNIC);
    256 LOCAL int vboxNetFltSolarisInitVNICTemplate(PVBOXNETFLTINS pThis, PVBOXNETFLTVNIC pVNIC, PVBOXNETFLTVNICTEMPLATE pVNICTemplate);
     258LOCAL int vboxNetFltSolarisInitVNICTemplate(PVBOXNETFLTINS pThis, PVBOXNETFLTVNICTEMPLATE pVNICTemplate);
    257259LOCAL PVBOXNETFLTVNIC vboxNetFltSolarisAllocVNIC(void);
    258260LOCAL void vboxNetFltSolarisFreeVNIC(PVBOXNETFLTVNIC pVNIC);
     
    876878 *
    877879 * @param   pThis           The VM connection instance.
    878  * @param   pVNIC           Pointer to the VNIC.
    879880 * @param   pVNICTemplate   Pointer to a VNIC template to initialize.
    880881 *
    881882 * @returns VBox status code.
    882883 */
    883 LOCAL int vboxNetFltSolarisInitVNICTemplate(PVBOXNETFLTINS pThis, PVBOXNETFLTVNIC pVNIC, PVBOXNETFLTVNICTEMPLATE pVNICTemplate)
     884LOCAL int vboxNetFltSolarisInitVNICTemplate(PVBOXNETFLTINS pThis, PVBOXNETFLTVNICTEMPLATE pVNICTemplate)
    884885{
    885886    LogFlow((DEVICE_NAME ":vboxNetFltSolarisInitVNICTemplate pThis=%p pVNIC=%p pVNICTemplate=%p\n", pThis, pVNIC, pVNICTemplate));
     
    10611062    AssertReturn(ppVNIC, VERR_INVALID_POINTER);
    10621063
     1064    int rc = VERR_INVALID_STATE;
    10631065    PVBOXNETFLTVNIC pVNIC = vboxNetFltSolarisAllocVNIC();
    10641066    if (RT_UNLIKELY(!pVNIC))
    10651067        return VERR_NO_MEMORY;
    1066 
    1067     RTStrPrintf(pVNIC->szName, sizeof(pVNIC->szName), "%s%RU64", VBOXBOW_VNIC_NAME, pThis->u.s.uInstance);
    10681068
    10691069    /*
     
    10861086    int MacLen                    = sizeof(GuestMac);
    10871087    uint32_t fFlags               = 0;
    1088     int rc                        = VERR_INVALID_STATE;
    10891088
    10901089    if (pThis->u.s.fIsVNICTemplate)
     
    11001099         * Initialize the VNIC template.
    11011100         */
    1102         rc = vboxNetFltSolarisInitVNICTemplate(pThis, pVNIC, pVNIC->pVNICTemplate);
     1101        rc = vboxNetFltSolarisInitVNICTemplate(pThis, pVNIC->pVNICTemplate);
    11031102        if (RT_FAILURE(rc))
    11041103        {
     
    11241123     * be a physical interface.
    11251124     */
     1125    rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx); AssertRC(rc);
     1126    RTStrPrintf(pVNIC->szName, sizeof(pVNIC->szName), "%s%RU64", VBOXBOW_VNIC_NAME, g_VBoxNetFltSolarisVNICId);
    11261127    rc = vnic_create(pVNIC->szName, pszLinkName, &AddrType, &MacLen, GuestMac.au8, &MacSlot, 0 /* Mac-Prefix Length */, uVLANId,
    11271128                        fFlags, &pVNIC->hLinkId, &Diag, NULL /* Reserved */);
     
    11291130    {
    11301131        pVNIC->fCreated = true;
     1132        ASMAtomicIncU64(&g_VBoxNetFltSolarisVNICId);
     1133        RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);
    11311134
    11321135        /*
     
    11421145            if (RT_SUCCESS(rc))
    11431146            {
    1144                 pThis->u.s.uInstance++;
    11451147                LogFlow((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC successfully created VNIC '%s' over '%s' with random mac %.6Rhxs\n",
    11461148                         pVNIC->szName, pszLinkName, &GuestMac));
     
    11651167    else
    11661168    {
     1169        RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);
     1170
    11671171        LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC failed to create VNIC '%s' over '%s' rc=%d Diag=%d\n", pVNIC->szName,
    11681172                    pszLinkName, rc, Diag));
     
    13251329    pThis->u.s.fIsVNICTemplate = false;
    13261330    list_create(&pThis->u.s.hVNICs, sizeof(VBOXNETFLTVNIC), offsetof(VBOXNETFLTVNIC, hNode));
    1327     pThis->u.s.uInstance       = 0;
    13281331    pThis->u.s.hNotify         = NULL;
    13291332    RT_ZERO(pThis->u.s.MacAddr);
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