Changeset 105163 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Jul 5, 2024 2:26:46 PM (7 months ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h
r99828 r105163 203 203 struct work_struct XmitTask; 204 204 # endif 205 /** Unique identifier of network namespace of device to attach to. */ 206 uint32_t uNamespaceInode; 205 207 /** @} */ 206 208 # elif defined(RT_OS_SOLARIS) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r104927 r105163 47 47 #if RTLNX_VER_MIN(2,6,24) 48 48 # include <linux/nsproxy.h> 49 #endif 50 #if RTLNX_VER_MIN(3,10,0) /* proc_ns introduced */ 51 # define VBOXNETFLT_LINUX_NAMESPACE_SUPPORT 52 # include <linux/proc_ns.h> 49 53 #endif 50 54 #if RTLNX_VER_MIN(6,4,10) || RTLNX_RHEL_RANGE(9,4, 9,99) || RTLNX_SUSE_MAJ_PREREQ(15, 6) … … 1842 1846 static int vboxNetFltLinuxAttachToInterface(PVBOXNETFLTINS pThis, struct net_device *pDev) 1843 1847 { 1848 bool fAlreadyAttached = false; 1844 1849 LogFlow(("vboxNetFltLinuxAttachToInterface: pThis=%p (%s)\n", pThis, pThis->szName)); 1845 1850 … … 1850 1855 1851 1856 RTSpinlockAcquire(pThis->hSpinlock); 1852 ASMAtomicUoWritePtr(&pThis->u.s.pDev, pDev); 1857 if (ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *)) 1858 fAlreadyAttached = true; /* Do not attach multiple times! */ 1859 else 1860 ASMAtomicUoWritePtr(&pThis->u.s.pDev, pDev); 1853 1861 RTSpinlockRelease(pThis->hSpinlock); 1862 1863 if (fAlreadyAttached) 1864 { 1865 dev_put(pDev); 1866 Log(("vboxNetFltLinuxAttachToInterface: Not attaching to %p(%s), already attached to %p(%s).\n", 1867 pDev, pDev->name, pThis->u.s.pDev, pThis->u.s.pDev->name)); 1868 return VINF_ALREADY_INITIALIZED; 1869 } 1854 1870 1855 1871 Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) retained. ref=%d\n", … … 2063 2079 if (ulEventType == NETDEV_REGISTER) 2064 2080 { 2081 #ifdef VBOXNETFLT_LINUX_NAMESPACE_SUPPORT 2082 # if RTLNX_VER_MIN(3,19,0) /* ns_common introduced */ 2083 # define VBOX_DEV_NET_NS_INUM(dev) dev_net(dev)->ns.inum 2084 # else 2085 # define VBOX_DEV_NET_NS_INUM(dev) dev_net(dev)->proc_inum 2086 # endif 2087 if (pThis->u.s.uNamespaceInode == 0 || pThis->u.s.uNamespaceInode == VBOX_DEV_NET_NS_INUM(pDev)) 2088 { 2089 /* Skip namespace if it is present */ 2090 const char *pcszIfName = strchr(pThis->szName, '/'); 2091 if (pcszIfName) 2092 ++pcszIfName; 2093 else 2094 pcszIfName = pThis->szName; 2095 if (strcmp(pDev->name, pcszIfName) == 0) 2096 vboxNetFltLinuxAttachToInterface(pThis, pDev); 2097 else 2098 Log(("VBoxNetFlt: not attaching to '%s' as it does not match '%s'\n", pDev->name, pcszIfName)); 2099 } 2100 else 2101 Log(("VBoxNetFlt: ignoring '%s' in wrong namespace (%u, expected %u)\n", pDev->name, 2102 VBOX_DEV_NET_NS_INUM(pDev), pThis->u.s.uNamespaceInode)); 2103 #else /* !VBOXNETFLT_LINUX_NAMESPACE_SUPPORT */ 2065 2104 #if RTLNX_VER_MIN(2,6,24) /* cgroups/namespaces introduced */ 2066 2105 # if RTLNX_VER_MIN(2,6,26) … … 2082 2121 } 2083 2122 } 2123 #endif /* !VBOXNETFLT_LINUX_NAMESPACE_SUPPORT */ 2084 2124 } 2085 2125 else … … 2580 2620 pThis->u.s.fPacketHandler = false; 2581 2621 memset(&pThis->u.s.PacketType, 0, sizeof(pThis->u.s.PacketType)); 2622 #ifdef VBOXNETFLT_LINUX_NAMESPACE_SUPPORT 2623 /* We should get the interface name in the form <namespace>/<ifname>, parse it. */ 2624 pThis->u.s.uNamespaceInode = RTStrToUInt32(pThis->szName); 2625 #else /* !VBOXNETFLT_LINUX_NAMESPACE_SUPPORT */ 2626 pThis->u.s.uNamespaceInode = 0; 2627 #endif /* !VBOXNETFLT_LINUX_NAMESPACE_SUPPORT */ 2582 2628 #ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE 2583 2629 skb_queue_head_init(&pThis->u.s.XmitQueue);
Note:
See TracChangeset
for help on using the changeset viewer.