[ovs-dev] [PATCH v4 20/28] datapath: compat: get rid of OVS_CB inner header offsets.

Pravin B Shelar pshelar at ovn.org
Fri Jul 8 00:24:14 UTC 2016


OVS has GSO compat functionality which needs inner offset
of the packet to segment a packet. older kernel did not
include these offsets in skb, therefore these were stored
in OVS_GSO_CB. Now OVS has dropped support for these
old kernel, So none of the supported kernel needs this
comapt code. Following patch removes it.

Signed-off-by: Pravin B Shelar <pshelar at ovn.org>
Acked-by: Jesse Gross <jesse at kernel.org>
---
 acinclude.m4                                 |  3 +-
 datapath/linux/compat/gso.h                  | 70 +---------------------------
 datapath/linux/compat/include/linux/skbuff.h |  7 +++
 datapath/linux/compat/skbuff-openvswitch.c   |  2 +-
 4 files changed, 10 insertions(+), 72 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index ddec993..bb0d90a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -522,8 +522,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_checksum_start_offset])
   OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [inner_protocol])
   OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [inner_protocol_type])
-  OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [inner_mac_header])
-  OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [inner_network_header])
+  OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_inner_transport_offset])
   OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [kfree_skb_list])
   OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_scrub_packet.*xnet],
 		  [OVS_DEFINE([HAVE_SKB_SCRUB_PACKET_XNET])])
diff --git a/datapath/linux/compat/gso.h b/datapath/linux/compat/gso.h
index 9a38a19..83e888c 100644
--- a/datapath/linux/compat/gso.h
+++ b/datapath/linux/compat/gso.h
@@ -17,12 +17,6 @@ struct ovs_gso_cb {
 #ifndef HAVE_INNER_PROTOCOL
 	__be16		inner_protocol;
 #endif
-#ifndef HAVE_INNER_MAC_HEADER
-	unsigned int	inner_mac_header;
-#endif
-#ifndef HAVE_INNER_NETWORK_HEADER
-	unsigned int	inner_network_header;
-#endif
 	bool ipv6;
 };
 #define OVS_GSO_CB(skb) ((struct ovs_gso_cb *)(skb)->cb)
@@ -44,59 +38,6 @@ static inline void skb_clear_ovs_gso_cb(struct sk_buff *skb)
 }
 #endif
 
-#ifndef HAVE_INNER_MAC_HEADER
-static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
-{
-	return skb->head + OVS_GSO_CB(skb)->inner_mac_header;
-}
-
-static inline void skb_set_inner_mac_header(const struct sk_buff *skb,
-					    int offset)
-{
-	OVS_GSO_CB(skb)->inner_mac_header = (skb->data - skb->head) + offset;
-}
-#endif /* HAVE_INNER_MAC_HEADER */
-
-#ifndef HAVE_INNER_NETWORK_HEADER
-static inline unsigned char *skb_inner_network_header(const struct sk_buff *skb)
-{
-	return skb->head + OVS_GSO_CB(skb)->inner_network_header;
-}
-
-static inline int skb_inner_network_offset(const struct sk_buff *skb)
-{
-	return skb_inner_network_header(skb) - skb->data;
-}
-
-/* We don't actually store the transport offset on backports because
- * we don't use it anywhere. Slightly rename this version to avoid
- * future users from picking it up accidentially.
- */
-static inline int ovs_skb_inner_transport_offset(const struct sk_buff *skb)
-{
-	return 0;
-}
-
-static inline void skb_set_inner_network_header(const struct sk_buff *skb,
-						int offset)
-{
-	OVS_GSO_CB(skb)->inner_network_header = (skb->data - skb->head)
-						+ offset;
-}
-
-static inline void skb_set_inner_transport_header(const struct sk_buff *skb,
-						  int offset)
-{ }
-
-#else
-
-static inline int ovs_skb_inner_transport_offset(const struct sk_buff *skb)
-{
-	return skb_inner_transport_header(skb) - skb->data;
-}
-
-#endif /* HAVE_INNER_NETWORK_HEADER */
-
 #ifndef HAVE_INNER_PROTOCOL
 static inline void ovs_skb_init_inner_protocol(struct sk_buff *skb)
 {
@@ -138,7 +79,7 @@ static inline void ovs_skb_set_inner_protocol(struct sk_buff *skb,
 	skb->inner_protocol = ethertype;
 }
 #endif /* ENCAP_TYPE_ETHER */
-#endif /* 3.11 */
+#endif /* HAVE_INNER_PROTOCOL */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
 #define ip_local_out rpl_ip_local_out
@@ -151,15 +92,6 @@ static inline int skb_inner_mac_offset(const struct sk_buff *skb)
 
 #define ip6_local_out rpl_ip6_local_out
 int rpl_ip6_local_out(struct sk_buff *skb);
-
-#define skb_reset_inner_headers rpl_skb_reset_inner_headers
-static inline void skb_reset_inner_headers(struct sk_buff *skb)
-{
-	BUILD_BUG_ON(sizeof(struct ovs_gso_cb) > FIELD_SIZEOF(struct sk_buff, cb));
-	skb_set_inner_mac_header(skb, skb_mac_header(skb) - skb->data);
-	skb_set_inner_network_header(skb, skb_network_offset(skb));
-	skb_set_inner_transport_header(skb, skb_transport_offset(skb));
-}
 #endif /* 3.18 */
 
 #ifndef USE_UPSTREAM_TUNNEL
diff --git a/datapath/linux/compat/include/linux/skbuff.h b/datapath/linux/compat/include/linux/skbuff.h
index c0abe72..16e3590 100644
--- a/datapath/linux/compat/include/linux/skbuff.h
+++ b/datapath/linux/compat/include/linux/skbuff.h
@@ -39,6 +39,13 @@ static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
 
 #endif	/* !HAVE_SKB_COPY_FROM_LINEAR_DATA_OFFSET */
 
+#ifndef HAVE_SKB_INNER_TRANSPORT_OFFSET
+static inline int skb_inner_transport_offset(const struct sk_buff *skb)
+{
+	return skb_inner_transport_header(skb) - skb->data;
+}
+#endif
+
 #ifndef HAVE_SKB_RESET_TAIL_POINTER
 static inline void skb_reset_tail_pointer(struct sk_buff *skb)
 {
diff --git a/datapath/linux/compat/skbuff-openvswitch.c b/datapath/linux/compat/skbuff-openvswitch.c
index 5c32f81..3a76823 100644
--- a/datapath/linux/compat/skbuff-openvswitch.c
+++ b/datapath/linux/compat/skbuff-openvswitch.c
@@ -248,7 +248,7 @@ int rpl_pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 
 	inner_mac_offset = skb_inner_mac_offset(skb);
 	inner_nw_offset = skb_inner_network_offset(skb);
-	inner_transport_offset = ovs_skb_inner_transport_offset(skb);
+	inner_transport_offset = skb_inner_transport_offset(skb);
 
 #undef pskb_expand_head
 	err = pskb_expand_head(skb, nhead, ntail, gfp_mask);
-- 
1.9.1




More information about the dev mailing list