VirtualBox

Changeset 54869 in vbox for trunk/src


Ignore:
Timestamp:
Mar 20, 2015 1:55:12 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99080
Message:

NetIf-solaris: fix listing of link names that don't have the same name as the driver.

Location:
trunk/src/VBox/Main/src-server/solaris
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.cpp

    r48955 r54869  
    2828 * and symbols have been successfully loaded.
    2929 */
    30 static RTLDRMOD g_hLibDlpi = NULL;
     30static RTLDRMOD g_hLibDlpi = NIL_RTLDRMOD;
    3131
    3232/**
     
    4141 */
    4242int (*g_pfnLibDlpiWalk)(dlpi_walkfunc_t *, void *, uint_t);
     43int (*g_pfnLibDlpiOpen)(const char *, dlpi_handle_t *, uint_t);
     44void (*g_pfnLibDlpiClose)(dlpi_handle_t);
    4345/** @} */
    4446
     
    4749    RTLDRMOD hLibDlpi;
    4850
    49     if (g_hLibDlpi && g_fCheckedForLibDlpi)
    50         return true;
    5151    if (g_fCheckedForLibDlpi)
    52         return false;
    53     if (!RT_SUCCESS(RTLdrLoad(LIB_DLPI, &hLibDlpi)))
    54         return false;
    55     /*
    56      * Unfortunately; we cannot make use of dlpi_get_physaddr because it requires us to
    57      * open the VNIC/link which requires root permissions :/
    58      */
    59     if (RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_walk", (void **)&g_pfnLibDlpiWalk)))
     52        return g_hLibDlpi != NIL_RTLDRMOD;
     53    g_fCheckedForLibDlpi = true;
     54    int rc = RTLdrLoad(LIB_DLPI, &hLibDlpi);
     55    if (RT_SUCCESS(rc))
    6056    {
    61         g_hLibDlpi = hLibDlpi;
    62         g_fCheckedForLibDlpi = true;
    63         return true;
     57        /*
     58         * Unfortunately; we cannot make use of dlpi_get_physaddr because it requires us to
     59         * open the VNIC/link which requires root permissions :/
     60         */
     61        rc  = RTLdrGetSymbol(hLibDlpi, "dlpi_walk", (void **)&g_pfnLibDlpiWalk);
     62        rc |= RTLdrGetSymbol(hLibDlpi, "dlpi_close", (void **)&g_pfnLibDlpiClose);
     63        rc |= RTLdrGetSymbol(hLibDlpi, "dlpi_open", (void **)&g_pfnLibDlpiOpen);
     64        if (RT_SUCCESS(rc))
     65        {
     66            g_hLibDlpi = hLibDlpi;
     67            return true;
     68        }
     69
     70        RTLdrClose(hLibDlpi);
    6471    }
    65     else
    66     {
    67         RTLdrClose(hLibDlpi);
    68         g_fCheckedForLibDlpi = true;
    69         return false;
    70     }
     72    hLibDlpi = NIL_RTLDRMOD;
     73    return false;
    7174}
    7275
  • trunk/src/VBox/Main/src-server/solaris/NetIf-solaris.cpp

    r54838 r54869  
    176176        SolarisNICMap.insert(NICPair("spwr", "SMC EtherPower II 10/100 (9432) Ethernet"));
    177177        SolarisNICMap.insert(NICPair("vboxnet", "VirtualBox Host Ethernet"));
    178         SolarisNICMap.insert(NICPair(VBOXBOW_VNIC_TEMPLATE_NAME, "VirtualBox Virtual Network Interface Template"));
     178        SolarisNICMap.insert(NICPair(VBOXBOW_VNIC_TEMPLATE_NAME, "VirtualBox VNIC Template"));
    179179        SolarisNICMap.insert(NICPair("vlan", "Virtual LAN Ethernet"));
    180180        SolarisNICMap.insert(NICPair("vr", "VIA Rhine Fast Ethernet"));
     
    384384    NOREF(Minor);
    385385
     386    char *pszDriverName = di_driver_name(Node);
     387    int   Instance      = di_instance(Node);
     388
    386389    /*
    387390     * Skip aggregations.
    388391     */
    389     if (!strcmp(di_driver_name(Node), "aggr"))
     392    if (!strcmp(pszDriverName, "aggr"))
    390393        return DI_WALK_CONTINUE;
    391394
     
    393396     * Skip softmacs.
    394397     */
    395     if (!strcmp(di_driver_name(Node), "softmac"))
     398    if (!strcmp(pszDriverName, "softmac"))
    396399        return DI_WALK_CONTINUE;
    397400
    398     vboxSolarisAddHostIface(di_driver_name(Node), di_instance(Node), pvHostNetworkInterfaceList);
     401    /*
     402     * Driver names doesn't always imply the same link name probably since
     403     * S11's vanity names by default (e.g. highly descriptive "net0") names
     404     * was introduced. Try opening the link to find out if it really exists.
     405     */
     406    if (VBoxSolarisLibDlpiFound())
     407    {
     408        /** @todo should we try also opening "linkname+instance"? */
     409        dlpi_handle_t hLink;
     410        if (g_pfnLibDlpiOpen(pszDriverName, &hLink, 0) != DLPI_SUCCESS)
     411            return DI_WALK_CONTINUE;
     412        g_pfnLibDlpiClose(hLink);
     413    }
     414
     415    vboxSolarisAddHostIface(pszDriverName, Instance, pvHostNetworkInterfaceList);
    399416    return DI_WALK_CONTINUE;
    400417}
     
    402419int NetIfList(std::list <ComObjPtr<HostNetworkInterface> > &list)
    403420{
    404 
    405421    /*
    406422     * Use libdevinfo for determining all physical interfaces.
     
    410426    if (Root != DI_NODE_NIL)
    411427    {
    412         di_walk_minor(Root, DDI_NT_NET, 0, &list, vboxSolarisAddPhysHostIface);
     428        di_walk_minor(Root, DDI_NT_NET, 0 /* flag */, &list, vboxSolarisAddPhysHostIface);
    413429        di_fini(Root);
    414430    }
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