1 #ifndef __LINUX_NETDEVICE_WRAPPER_H
2 #define __LINUX_NETDEVICE_WRAPPER_H 1
4 #include_next <linux/netdevice.h>
8 #include <linux/version.h>
11 #define to_net_dev(class) container_of(class, struct net_device, NETDEV_DEV_MEMBER)
14 #ifdef HAVE_RHEL_OVS_HOOK
15 extern struct sk_buff *(*openvswitch_handle_frame_hook)(struct sk_buff *skb);
16 extern int nr_bridges;
19 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
20 extern void unregister_netdevice_queue(struct net_device *dev,
21 struct list_head *head);
22 extern void unregister_netdevice_many(struct list_head *head);
25 #ifndef HAVE_DEV_DISABLE_LRO
26 extern void dev_disable_lro(struct net_device *dev);
29 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) || \
30 defined HAVE_RHEL_OVS_HOOK
31 static inline int netdev_rx_handler_register(struct net_device *dev,
33 void *rx_handler_data)
35 #ifdef HAVE_RHEL_OVS_HOOK
36 rcu_assign_pointer(dev->ax25_ptr, rx_handler_data);
38 rcu_assign_pointer(openvswitch_handle_frame_hook, rx_handler);
42 rcu_assign_pointer(dev->br_port, rx_handler_data);
46 static inline void netdev_rx_handler_unregister(struct net_device *dev)
48 #ifdef HAVE_RHEL_OVS_HOOK
49 rcu_assign_pointer(dev->ax25_ptr, NULL);
51 if (--nr_bridges <= 0)
52 rcu_assign_pointer(openvswitch_handle_frame_hook, NULL);
54 rcu_assign_pointer(dev->br_port, NULL);
59 #ifndef HAVE_DEV_GET_BY_INDEX_RCU
60 static inline struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
62 struct net_device *dev;
64 read_lock(&dev_base_lock);
65 dev = __dev_get_by_index(net, ifindex);
66 read_unlock(&dev_base_lock);
76 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
77 #define skb_gso_segment rpl_skb_gso_segment
78 struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, u32 features);
80 #define netif_skb_features rpl_netif_skb_features
81 u32 rpl_netif_skb_features(struct sk_buff *skb);
83 #define netif_needs_gso rpl_netif_needs_gso
84 static inline int rpl_netif_needs_gso(struct sk_buff *skb, int features)
86 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
87 unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
91 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
92 typedef u32 netdev_features_t;
95 #ifndef HAVE___SKB_GSO_SEGMENT
96 static inline struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
97 netdev_features_t features,
100 return skb_gso_segment(skb, features);
104 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
106 /* XEN dom0 networking assumes dev->master is bond device
107 * and it tries to access bond private structure from dev->master
108 * ptr on receive path. This causes panic. Therefore it is better
109 * not to backport this API.
111 static inline int netdev_master_upper_dev_link(struct net_device *dev,
112 struct net_device *upper_dev)
117 static inline void netdev_upper_dev_unlink(struct net_device *dev,
118 struct net_device *upper_dev)
123 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
124 #define dev_queue_xmit rpl_dev_queue_xmit
125 int dev_queue_xmit(struct sk_buff *skb);