Changeset 33506 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/linux
- Timestamp:
- Oct 27, 2010 1:27:08 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r32856 r33506 1906 1906 } 1907 1907 1908 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) 1909 /** 1910 * Helper for detecting TAP devices. 1911 */ 1912 static bool vboxNetFltIsTapDevice(PVBOXNETFLTINS pThis, struct net_device *pDev) 1913 { 1914 if (pDev->ethtool_ops && pDev->ethtool_ops->get_drvinfo) 1915 { 1916 struct ethtool_drvinfo Info; 1917 1918 memset(&Info, 0, sizeof(Info)); 1919 Info.cmd = ETHTOOL_GDRVINFO; 1920 pDev->ethtool_ops->get_drvinfo(pDev, &Info); 1921 Log3(("vboxNetFltIsTapDevice: driver=%s version=%s bus_info=%s\n", 1922 Info.driver, Info.version, Info.bus_info)); 1923 1924 return !strncmp(Info.driver, "tun", 4) 1925 && !strncmp(Info.bus_info, "tap", 4); 1926 } 1927 1928 return false; 1929 } 1930 1931 /** 1932 * Helper for updating the link state of TAP devices. 1933 * Only TAP devices are affected. 1934 */ 1935 static void vboxNetFltSetTapLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp) 1936 { 1937 if (vboxNetFltIsTapDevice(pThis, pDev)) 1938 { 1939 Log3(("vboxNetFltSetTapLinkState: bringing %s tap device link state\n", 1940 fLinkUp ? "up" : "down")); 1941 netif_tx_lock_bh(pDev); 1942 if (fLinkUp) 1943 netif_carrier_on(pDev); 1944 else 1945 netif_carrier_off(pDev); 1946 netif_tx_unlock_bh(pDev); 1947 } 1948 } 1949 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */ 1950 DECLINLINE(void) vboxNetFltSetTapLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp) 1951 { 1952 /* Nothing to do for pre-2.6.36 kernels. */ 1953 } 1954 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */ 1955 1908 1956 /** 1909 1957 * Internal worker for vboxNetFltLinuxNotifierCallback. … … 1948 1996 vboxNetFltLinuxQdiscInstall(pThis, pDev); 1949 1997 #endif /* VBOXNETFLT_WITH_QDISC */ 1998 1999 /* 2000 * If attaching to TAP interface we need to bring the link state up 2001 * starting from 2.6.36 kernel. 2002 */ 2003 vboxNetFltSetTapLinkState(pThis, pDev, true); 1950 2004 1951 2005 /* … … 2321 2375 if (fRegistered) 2322 2376 { 2377 vboxNetFltSetTapLinkState(pThis, pDev, false); 2378 2323 2379 #ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE 2324 2380 skb_queue_purge(&pThis->u.s.XmitQueue);
Note:
See TracChangeset
for help on using the changeset viewer.