Changeset 58254 in vbox
- Timestamp:
- Oct 14, 2015 5:15:56 PM (9 years ago)
- Location:
- trunk/src/VBox/HostDrivers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
r58222 r58254 262 262 263 263 /* 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(). 269 266 * 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. 272 270 */ 273 271 netif_carrier_off(pNetDev); … … 279 277 pThis->szName[sizeof(pThis->szName) - 1] = '\0'; 280 278 pThis->u.s.pNetDev = pNetDev; 281 282 /*283 * TODO: We might want to set carrier only when284 * VBoxNetFlt attaches the intnet to us.285 */286 netif_carrier_on(pNetDev);287 288 279 Log2(("vboxNetAdpOsCreate: pThis=%p pThis->szName = %p\n", pThis, pThis->szName)); 289 280 return VINF_SUCCESS; -
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r57401 r58254 1554 1554 } 1555 1555 1556 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) 1557 /** 1558 * Helper for detecting TAP devices.1559 */ 1560 static bool vboxNetFlt IsTapDevice(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 */ 1560 static bool vboxNetFltNeedsLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev) 1561 1561 { 1562 1562 if (pDev->ethtool_ops && pDev->ethtool_ops->get_drvinfo) … … 1567 1567 Info.cmd = ETHTOOL_GDRVINFO; 1568 1568 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 */ 1572 1579 return !strncmp(Info.driver, "tun", 4) 1573 1580 && !strncmp(Info.bus_info, "tap", 4); 1581 #endif 1574 1582 } 1575 1583 … … 1578 1586 1579 1587 /** 1580 * Helper for updating the link state of TAP devices.1581 * Only TAP devices are affected.1582 */ 1583 static void vboxNetFltSet TapLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp)1584 { 1585 if (vboxNetFlt IsTapDevice(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 */ 1591 static 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")); 1589 1597 netif_tx_lock_bh(pDev); 1590 1598 if (fLinkUp) … … 1595 1603 } 1596 1604 } 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) */1603 1605 1604 1606 /** … … 1654 1656 1655 1657 /* 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); 1660 1661 1661 1662 /* … … 2261 2262 if (fRegistered) 2262 2263 { 2263 vboxNetFltSet TapLinkState(pThis, pDev, false);2264 vboxNetFltSetLinkState(pThis, pDev, false); 2264 2265 2265 2266 #ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE
Note:
See TracChangeset
for help on using the changeset viewer.