VirtualBox

Changeset 93652 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Feb 8, 2022 11:26:14 AM (3 years ago)
Author:
vboxsync
Message:

VMM/PDMDriver,DrvIntNet,DrvNetShaper: Properly disable all ring-0 driver stuff. bugref:10094

Location:
trunk/src/VBox/Devices/Network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvIntNet.cpp

    r93115 r93652  
    5353*   Defined Constants And Macros                                                                                                 *
    5454*********************************************************************************************************************************/
     55#if 0
    5556/** Enables the ring-0 part. */
    5657#define VBOX_WITH_DRVINTNET_IN_R0
     58#endif
    5759
    5860
     
    9395    /** Pointer to the communication buffer (ring-3). */
    9496    R3PTRTYPE(PINTNETBUF)           pBufR3;
     97#ifdef VBOX_WITH_DRVINTNET_IN_R0
    9598    /** Ring-3 base interface for the ring-0 context. */
    9699    PDMIBASER0                      IBaseR0;
     
    111114    PPDMDRVINSRC                    pDrvInsRC;
    112115    RTRCPTR                         RCPtrAlignment;
     116#endif
    113117
    114118    /** The transmit lock. */
     
    925929
    926930
     931#ifdef VBOX_WITH_DRVINTNET_IN_R0
     932
    927933/* -=-=-=-=- PDMIBASERC -=-=-=-=- */
    928934
     
    933939{
    934940    PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, IBaseRC);
    935 
    936941#if 0
    937942    PDMIBASERC_RETURN_INTERFACE(pThis->pDrvInsR3, pszIID, PDMINETWORKUP, &pThis->INetworkUpRC);
     
    951956{
    952957    PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, IBaseR0);
    953 #ifdef VBOX_WITH_DRVINTNET_IN_R0
    954958    PDMIBASER0_RETURN_INTERFACE(pThis->pDrvInsR3, pszIID, PDMINETWORKUP, &pThis->INetworkUpR0);
    955 #endif
    956959    return NIL_RTR0PTR;
    957960}
    958961
     962#endif /* VBOX_WITH_DRVINTNET_IN_R0 */
    959963
    960964/* -=-=-=-=- PDMIBASE -=-=-=-=- */
     965
    961966
    962967/**
     
    969974
    970975    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
     976#ifdef VBOX_WITH_DRVINTNET_IN_R0
    971977    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASER0, &pThis->IBaseR0);
    972978    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASERC, &pThis->IBaseRC);
     979#endif
    973980    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKUP, &pThis->INetworkUpR3);
    974981    return NULL;
     
    13781385    /* IBase* */
    13791386    pDrvIns->IBase.pfnQueryInterface                = drvR3IntNetIBase_QueryInterface;
     1387#ifdef VBOX_WITH_DRVINTNET_IN_R0
    13801388    pThis->IBaseR0.pfnQueryInterface                = drvR3IntNetIBaseR0_QueryInterface;
    13811389    pThis->IBaseRC.pfnQueryInterface                = drvR3IntNetIBaseRC_QueryInterface;
     1390#endif
    13821391    /* INetworkUp */
    13831392    pThis->INetworkUpR3.pfnBeginXmit                = drvIntNetUp_BeginXmit;
     
    17921801    AssertRelease(RT_VALID_PTR(GetBufferPtrsReq.pRing3Buf));
    17931802    pThis->pBufR3 = GetBufferPtrsReq.pRing3Buf;
     1803#ifdef VBOX_WITH_DRVINTNET_IN_R0
    17941804    pThis->pBufR0 = GetBufferPtrsReq.pRing0Buf;
     1805#endif
    17951806
    17961807    /*
  • trunk/src/VBox/Devices/Network/DrvNetShaper.cpp

    r93628 r93652  
    3636
    3737/*********************************************************************************************************************************
     38*   Defined Constants And Macros                                                                                                 *
     39*********************************************************************************************************************************/
     40#if 0
     41#define VBOX_WITH_DRVNETSHAPER_IN_R0
     42#endif
     43
     44
     45/*********************************************************************************************************************************
    3846*   Structures and Typedefs                                                                                                      *
    3947*********************************************************************************************************************************/
     
    5462    PPDMINETWORKUP          pIBelowNetR3;
    5563
     64#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    5665    /** Pointer to the driver instance. */
    5766    PPDMDRVINSR0            pDrvInsR0;
     
    6574    /** Ring-3 base interface for the raw-mode context. */
    6675    PDMIBASERC              IBaseRC;
     76#endif
    6777
    6878    /** For when we're the leaf driver. */
     
    292302
    293303
     304#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
     305
    294306/**
    295307 * @interface_method_impl{PDMIBASER0,pfnQueryInterface}
     
    317329}
    318330
     331#endif
     332
    319333/**
    320334 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     
    325339    PDRVNETSHAPER  pThis   = PDMINS_2_DATA(pDrvIns, PDRVNETSHAPER);
    326340    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
     341#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    327342    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASER0, &pThis->IBaseR0);
    328343    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASERC, &pThis->IBaseRC);
     344#endif
    329345    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKUP, &pThis->INetworkUpR3);
    330346    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown);
     
    345361    PDMDrvHlpCritSectEnter(pDrvIns, &pThis->XmitLock, VERR_IGNORED);
    346362    pThis->pIBelowNetR3 = NULL;
     363#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    347364    pThis->pIBelowNetR0 = NIL_RTR0PTR;
     365#endif
    348366    PDMDrvHlpCritSectLeave(pDrvIns, &pThis->XmitLock);
    349367}
     
    368386    {
    369387        pThis->pIBelowNetR3 = NULL;
     388#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    370389        pThis->pIBelowNetR0 = NIL_RTR0PTR;
     390#endif
    371391        rc = VINF_SUCCESS;
    372392    }
     
    376396        if (pThis->pIBelowNetR3)
    377397        {
     398#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    378399            PPDMIBASER0 pBaseR0  = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMIBASER0);
    379400            pThis->pIBelowNetR0 = pBaseR0 ? pBaseR0->pfnQueryInterface(pBaseR0, PDMINETWORKUP_IID) : NIL_RTR0PTR;
     401#endif
    380402            rc = VINF_SUCCESS;
    381403        }
     
    425447     */
    426448    pThis->pDrvInsR3                                = pDrvIns;
     449#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    427450    pThis->pDrvInsR0                                = PDMDRVINS_2_R0PTR(pDrvIns);
     451#endif
    428452    /* IBase */
    429453    pDrvIns->IBase.pfnQueryInterface                = drvR3NetShaperIBase_QueryInterface;
     454#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    430455    pThis->IBaseR0.pfnQueryInterface                = drvR3NetShaperIBaseR0_QueryInterface;
    431456    pThis->IBaseRC.pfnQueryInterface                = drvR3NetShaperIBaseRC_QueryInterface;
     457#endif
    432458    /* INetworkUp */
    433459    pThis->INetworkUpR3.pfnBeginXmit                = drvNetShaperUp_BeginXmit;
     
    438464    pThis->INetworkUpR3.pfnSetPromiscuousMode       = drvNetShaperUp_SetPromiscuousMode;
    439465    pThis->INetworkUpR3.pfnNotifyLinkChanged        = drvR3NetShaperUp_NotifyLinkChanged;
     466#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    440467    /* Resolve the ring-0 context interface addresses. */
    441     int rc = pDrvIns->pHlpR3->pfnLdrGetR0InterfaceSymbols(pDrvIns, &pThis->INetworkUpR0,
    442                                                           sizeof(pThis->INetworkUpR0),
    443                                                           "drvNetShaperUp_", PDMINETWORKUP_SYM_LIST);
    444     AssertLogRelRCReturn(rc, rc);
     468    if (true)
     469    {
     470        int rc = pDrvIns->pHlpR3->pfnLdrGetR0InterfaceSymbols(pDrvIns, &pThis->INetworkUpR0, sizeof(pThis->INetworkUpR0),
     471                                                              "drvNetShaperUp_", PDMINETWORKUP_SYM_LIST);
     472        AssertLogRelRCReturn(rc, rc);
     473    }
     474#endif
    445475    /* INetworkDown */
    446476    pThis->INetworkDown.pfnWaitReceiveAvail         = drvR3NetShaperDown_WaitReceiveAvail;
     
    456486     * Create the locks.
    457487     */
    458     rc = PDMDrvHlpCritSectInit(pDrvIns, &pThis->XmitLock, RT_SRC_POS, "NetShaper");
     488    int rc = PDMDrvHlpCritSectInit(pDrvIns, &pThis->XmitLock, RT_SRC_POS, "NetShaper");
    459489    AssertRCReturn(rc, rc);
    460490
     
    469499    rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "BwGroup", &pThis->pszBwGroup);
    470500    if (RT_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND)
    471     {
    472         rc = PDMDRV_SET_ERROR(pDrvIns, rc,
    473                               N_("DrvNetShaper: Configuration error: Querying \"BwGroup\" as string failed"));
    474         return rc;
    475     }
    476     else
    477         rc = VINF_SUCCESS;
     501        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("DrvNetShaper: Configuration error: Querying \"BwGroup\" as string failed"));
    478502
    479503    pThis->Filter.pIDrvNetR3 = &pThis->INetworkDown;
    480504    rc = PDMDrvHlpNetShaperAttach(pDrvIns, pThis->pszBwGroup, &pThis->Filter);
    481505    if (RT_FAILURE(rc))
    482     {
    483         rc = PDMDRV_SET_ERROR(pDrvIns, rc,
    484                               N_("DrvNetShaper: Configuration error: Failed to attach to bandwidth group"));
    485         return rc;
    486     }
     506        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("DrvNetShaper: Configuration error: Failed to attach to bandwidth group"));
    487507
    488508    /*
     
    509529     * Query the network connector interface.
    510530     */
    511     PPDMIBASE   pBaseDown;
     531    PPDMIBASE pBaseDown = NULL;
    512532    rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pBaseDown);
    513533    if (   rc == VERR_PDM_NO_ATTACHED_DRIVER
     
    515535    {
    516536        pThis->pIBelowNetR3 = NULL;
     537#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    517538        pThis->pIBelowNetR0 = NIL_RTR0PTR;
     539#endif
    518540    }
    519541    else if (RT_SUCCESS(rc))
     
    525547            return VERR_PDM_MISSING_INTERFACE_BELOW;
    526548        }
     549#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    527550        PPDMIBASER0 pBaseR0  = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMIBASER0);
    528551        pThis->pIBelowNetR0 = pBaseR0 ? pBaseR0->pfnQueryInterface(pBaseR0, PDMINETWORKUP_IID) : NIL_RTR0PTR;
     552#endif
    529553    }
    530554    else
     
    567591    "Network Shaper Filter Driver",
    568592    /* fFlags */
     593#ifdef VBOX_WITH_DRVNETSHAPER_IN_R0
    569594    PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DRVREG_FLAGS_R0,
     595#else
     596    PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
     597#endif
    570598    /* fClass. */
    571599    PDM_DRVREG_CLASS_NETWORK,
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