VirtualBox

Changeset 58254 in vbox


Ignore:
Timestamp:
Oct 14, 2015 5:15:56 PM (9 years ago)
Author:
vboxsync
Message:

VBoxNetAdp/linux, VBoxNetFlt/linux: treat presence of VBoxNetFlt as
the "carrier" for VBoxNetAdp (as we already do for tap), so that
host-only interface is IF_OPER_UP only when the filter is attached.
Adjust link-state check in VBoxNetFlt to call netif_carrier_on() for
host-only interfaces too.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c

    r58222 r58254  
    262262
    263263            /*
    264              * To get proper operstate transition to IF_OPER_UP we
    265              * need to call netif_carrier_on(), which triggers netlink
    266              * notifications that do the work.  But first we need to
    267              * turn it off here, otherwise that call will do nothing
    268              * and we will be stuck in IF_OPER_UNKNOWN.
     264             * We treat presence of VBoxNetFlt filter as our "carrier",
     265             * see vboxNetFltSetLinkState().
    269266             *
    270              * Do this before registration so that only the state bit
    271              * is set, but no state change notifications are generated.
     267             * operstates.txt: "On device allocation, networking core
     268             * sets the flags equivalent to netif_carrier_ok() and
     269             * !netif_dormant()" - so turn carrier off here.
    272270             */
    273271            netif_carrier_off(pNetDev);
     
    279277                pThis->szName[sizeof(pThis->szName) - 1] = '\0';
    280278                pThis->u.s.pNetDev = pNetDev;
    281 
    282                 /*
    283                  * TODO: We might want to set carrier only when
    284                  * VBoxNetFlt attaches the intnet to us.
    285                  */
    286                 netif_carrier_on(pNetDev);
    287 
    288279                Log2(("vboxNetAdpOsCreate: pThis=%p pThis->szName = %p\n", pThis, pThis->szName));
    289280                return VINF_SUCCESS;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r57401 r58254  
    15541554}
    15551555
    1556 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
    1557 /**
    1558  * Helper for detecting TAP devices.
    1559  */
    1560 static bool vboxNetFltIsTapDevice(PVBOXNETFLTINS pThis, struct net_device *pDev)
     1556/**
     1557 * Does this device needs link state change signaled?
     1558 * Currently we need it for our own VBoxNetAdp and TAP.
     1559 */
     1560static bool vboxNetFltNeedsLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev)
    15611561{
    15621562    if (pDev->ethtool_ops && pDev->ethtool_ops->get_drvinfo)
     
    15671567        Info.cmd = ETHTOOL_GDRVINFO;
    15681568        pDev->ethtool_ops->get_drvinfo(pDev, &Info);
    1569         Log3(("vboxNetFltIsTapDevice: driver=%s version=%s bus_info=%s\n",
    1570               Info.driver, Info.version, Info.bus_info));
    1571 
     1569        Log3(("%s: driver=%.*s version=%.*s bus_info=%.*s\n",
     1570              __FUNCTION__,
     1571              sizeof(Info.driver),   Info.driver,
     1572              sizeof(Info.version),  Info.version,
     1573              sizeof(Info.bus_info), Info.bus_info));
     1574
     1575        if (!strncmp(Info.driver, "vboxnet", sizeof(Info.driver)))
     1576            return true;
     1577
     1578#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) /* TAP started doing carrier */
    15721579        return !strncmp(Info.driver,   "tun", 4)
    15731580            && !strncmp(Info.bus_info, "tap", 4);
     1581#endif
    15741582    }
    15751583
     
    15781586
    15791587/**
    1580  * Helper for updating the link state of TAP devices.
    1581  * Only TAP devices are affected.
    1582  */
    1583 static void vboxNetFltSetTapLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp)
    1584 {
    1585     if (vboxNetFltIsTapDevice(pThis, pDev))
    1586     {
    1587         Log3(("vboxNetFltSetTapLinkState: bringing %s tap device link state\n",
    1588               fLinkUp ? "up" : "down"));
     1588 * Some devices need link state change when filter attaches/detaches
     1589 * since the filter is their link in a sense.
     1590 */
     1591static void vboxNetFltSetLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp)
     1592{
     1593    if (vboxNetFltNeedsLinkState(pThis, pDev))
     1594    {
     1595        Log3(("%s: bringing device link %s\n",
     1596              __FUNCTION__, fLinkUp ? "up" : "down"));
    15891597        netif_tx_lock_bh(pDev);
    15901598        if (fLinkUp)
     
    15951603    }
    15961604}
    1597 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */
    1598 DECLINLINE(void) vboxNetFltSetTapLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp)
    1599 {
    1600     /* Nothing to do for pre-2.6.36 kernels. */
    1601 }
    1602 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */
    16031605
    16041606/**
     
    16541656
    16551657    /*
    1656      * If attaching to TAP interface we need to bring the link state up
    1657      * starting from 2.6.36 kernel.
    1658      */
    1659     vboxNetFltSetTapLinkState(pThis, pDev, true);
     1658     * Are we the "carrier" for this device (e.g. vboxnet or tap)?
     1659     */
     1660    vboxNetFltSetLinkState(pThis, pDev, true);
    16601661
    16611662    /*
     
    22612262    if (fRegistered)
    22622263    {
    2263         vboxNetFltSetTapLinkState(pThis, pDev, false);
     2264        vboxNetFltSetLinkState(pThis, pDev, false);
    22642265
    22652266#ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE
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