1 #ifndef __LINUX_GSO_WRAPPER_H
2 #define __LINUX_GSO_WRAPPER_H
4 #include <linux/version.h>
5 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) || \
6 !defined USE_UPSTREAM_VXLAN
8 #include <linux/netdevice.h>
9 #include <linux/skbuff.h>
10 #include <net/protocol.h>
13 typedef void (*gso_fix_segment_t)(struct sk_buff *);
16 struct ovs_skb_cb dp_cb;
17 gso_fix_segment_t fix_segment;
18 sk_buff_data_t inner_mac_header; /* Offset from skb->head */
19 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
20 __be16 inner_protocol;
22 u16 inner_network_header; /* Offset from
25 #define OVS_GSO_CB(skb) ((struct ovs_gso_cb *)(skb)->cb)
27 #define skb_inner_network_header rpl_skb_inner_network_header
29 #ifdef NET_SKBUFF_DATA_USES_OFFSET
30 #define skb_inner_mac_header rpl_skb_inner_mac_header
31 static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
33 return skb->head + OVS_GSO_CB(skb)->inner_mac_header;
38 #define skb_inner_mac_header rpl_skb_inner_mac_header
39 static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
41 return OVS_GSO_CB(skb)->inner_mac_header;
46 #define skb_inner_network_header rpl_skb_inner_network_header
47 static inline unsigned char *skb_inner_network_header(const struct sk_buff *skb)
49 return skb_inner_mac_header(skb) +
50 OVS_GSO_CB(skb)->inner_network_header;
53 #define skb_inner_network_offset rpl_skb_inner_network_offset
54 static inline int skb_inner_network_offset(const struct sk_buff *skb)
56 return skb_inner_network_header(skb) - skb->data;
59 #define skb_reset_inner_headers rpl_skb_reset_inner_headers
60 static inline void skb_reset_inner_headers(struct sk_buff *skb)
62 BUILD_BUG_ON(sizeof(struct ovs_gso_cb) > FIELD_SIZEOF(struct sk_buff, cb));
63 OVS_GSO_CB(skb)->inner_network_header = skb->network_header -
65 OVS_GSO_CB(skb)->inner_mac_header = skb->mac_header;
67 OVS_GSO_CB(skb)->fix_segment = NULL;
70 struct sk_buff *ovs_iptunnel_handle_offloads(struct sk_buff *skb,
72 gso_fix_segment_t fix_segment);
75 #endif /* 3.12 || !USE_UPSTREAM_VXLAN */
77 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
78 #define ip_local_out rpl_ip_local_out
79 int ip_local_out(struct sk_buff *skb);
81 #define skb_inner_mac_offset rpl_skb_inner_mac_offset
82 static inline int skb_inner_mac_offset(const struct sk_buff *skb)
84 return skb_inner_mac_header(skb) - skb->data;
88 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
89 static inline void ovs_skb_init_inner_protocol(struct sk_buff *skb) {
90 OVS_GSO_CB(skb)->inner_protocol = htons(0);
93 static inline void ovs_skb_set_inner_protocol(struct sk_buff *skb,
95 OVS_GSO_CB(skb)->inner_protocol = ethertype;
98 static inline __be16 ovs_skb_get_inner_protocol(struct sk_buff *skb)
100 return OVS_GSO_CB(skb)->inner_protocol;
105 static inline void ovs_skb_init_inner_protocol(struct sk_buff *skb) {
106 /* Nothing to do. The inner_protocol is either zero or
107 * has been set to a value by another user.
108 * Either way it may be considered initialised.
112 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
113 static inline void ovs_skb_set_inner_protocol(struct sk_buff *skb,
116 skb->inner_protocol = ethertype;
119 static inline void ovs_skb_set_inner_protocol(struct sk_buff *skb,
122 skb_set_inner_protocol(skb, ethertype);
126 static inline __be16 ovs_skb_get_inner_protocol(struct sk_buff *skb)
128 return skb->inner_protocol;