Changeset 35554 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Jan 14, 2011 8:46:18 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r35382 r35554 828 828 #ifdef VBOXNETFLT_WITH_FILTER_HOST2GUEST_SKBS_EXPERIMENT 829 829 830 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 831 832 # include <linux/ethtool.h> 833 834 typedef struct ethtool_ops OVR_OPSTYPE; 835 # define OVR_OPS ethtool_ops 836 # define OVR_XMIT pfnStartXmit 837 838 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */ 839 840 typedef struct net_device_ops OVR_OPSTYPE; 841 # define OVR_OPS netdev_ops 842 # define OVR_XMIT pOrgOps->ndo_start_xmit 843 844 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */ 845 830 846 /** 831 847 * The overridden net_device_ops of the device we're attached to. 832 848 * 833 * Requires Linux 2.6.29 or later. 849 * As there is no net_device_ops structure in pre-2.6.29 kernels we override 850 * ethtool_ops instead along with hard_start_xmit callback in net_device 851 * structure. 834 852 * 835 * This is a very dirty hack that was create to explore how much we can improve 836 * the host to guest transfers by not CC'ing the NIC. 853 * This is a very dirty hack that was created to explore how much we can improve 854 * the host to guest transfers by not CC'ing the NIC. It turns out to be 855 * the only way to filter outgoing packets for devices without TX queue. 837 856 */ 838 857 typedef struct VBoxNetDeviceOpsOverride 839 858 { 840 859 /** Our overridden ops. */ 841 struct net_device_opsOps;860 OVR_OPSTYPE Ops; 842 861 /** Magic word. */ 843 862 uint32_t u32Magic; 844 863 /** Pointer to the original ops. */ 845 struct net_device_ops const *pOrgOps; 864 OVR_OPSTYPE const *pOrgOps; 865 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 866 /** Pointer to the original hard_start_xmit function. */ 867 int (*pfnStartXmit)(struct sk_buff *pSkb, struct net_device *pDev); 868 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */ 846 869 /** Pointer to the net filter instance. */ 847 870 PVBOXNETFLTINS pVBoxNetFlt; … … 864 887 static int vboxNetFltLinuxStartXmitFilter(struct sk_buff *pSkb, struct net_device *pDev) 865 888 { 866 PVBOXNETDEVICEOPSOVERRIDE pOverride = (PVBOXNETDEVICEOPSOVERRIDE)pDev-> netdev_ops;889 PVBOXNETDEVICEOPSOVERRIDE pOverride = (PVBOXNETDEVICEOPSOVERRIDE)pDev->OVR_OPS; 867 890 uint8_t abHdrBuf[sizeof(RTNETETHERHDR) + sizeof(uint32_t) + RTNETIPV4_MIN_LEN]; 868 891 PCRTNETETHERHDR pEtherHdr; … … 916 939 } 917 940 918 return pOverride-> pOrgOps->ndo_start_xmit(pSkb, pDev);941 return pOverride->OVR_XMIT(pSkb, pDev); 919 942 } 920 943 … … 933 956 if (!pOverride) 934 957 return; 935 pOverride->pOrgOps = pDev->netdev_ops; 936 pOverride->Ops = *pDev->netdev_ops; 958 pOverride->pOrgOps = pDev->OVR_OPS; 959 pOverride->Ops = *pDev->OVR_OPS; 960 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 961 pOverride->pfnStartXmit = pDev->hard_start_xmit; 962 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */ 937 963 pOverride->Ops.ndo_start_xmit = vboxNetFltLinuxStartXmitFilter; 964 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */ 938 965 pOverride->u32Magic = VBOXNETDEVICEOPSOVERRIDE_MAGIC; 939 966 pOverride->cTotal = 0; … … 942 969 943 970 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); /* (this isn't necessary, but so what) */ 944 ASMAtomicWritePtr((void * volatile *)&pDev->netdev_ops, pOverride); 971 ASMAtomicWritePtr((void * volatile *)&pDev->OVR_OPS, pOverride); 972 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 973 ASMAtomicXchgPtr((void * volatile *)&pDev->hard_start_xmit, vboxNetFltLinuxStartXmitFilter); 974 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */ 945 975 RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp); 946 976 } … … 963 993 if (VALID_PTR(pDev)) 964 994 { 965 pOverride = (PVBOXNETDEVICEOPSOVERRIDE)pDev-> netdev_ops;995 pOverride = (PVBOXNETDEVICEOPSOVERRIDE)pDev->OVR_OPS; 966 996 if ( VALID_PTR(pOverride) 967 997 && pOverride->u32Magic == VBOXNETDEVICEOPSOVERRIDE_MAGIC … … 969 999 ) 970 1000 { 971 ASMAtomicWritePtr((void * volatile *)&pDev->netdev_ops, pOverride->pOrgOps); 1001 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 1002 ASMAtomicWritePtr((void * volatile *)&pDev->hard_start_xmit, pOverride->pfnStartXmit); 1003 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */ 1004 ASMAtomicWritePtr((void * volatile *)&pDev->OVR_OPS, pOverride->pOrgOps); 972 1005 ASMAtomicWriteU32(&pOverride->u32Magic, 0); 973 1006 }
Note:
See TracChangeset
for help on using the changeset viewer.