diff mbox

[ovs-dev,3/3] datapath: compat: Block upstream ip_tunnels functions.

Message ID 1449806581-28010-3-git-send-email-pshelar@nicira.com
State Accepted
Headers show

Commit Message

Pravin B Shelar Dec. 11, 2015, 4:03 a.m. UTC
Since upstream and compat ip_tunnel structures are not same, we can not
use exported upstream functions.
Following patch blocks definitions which used ip_tunnel internal
structure. Function which do not depend on these structures are
allows by explicitly by defining it in the header files. e.g.
iptunnel_handle_offloads(), iptunnel_pull_header(). etc.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
 datapath/linux/compat/include/net/gre.h        |  3 ++-
 datapath/linux/compat/include/net/ip_tunnels.h | 27 ++++++++++++++++++++------
 2 files changed, 23 insertions(+), 7 deletions(-)

Comments

Jesse Gross Dec. 11, 2015, 9:33 p.m. UTC | #1
On Thu, Dec 10, 2015 at 8:03 PM, Pravin B Shelar <pshelar@nicira.com> wrote:
> diff --git a/datapath/linux/compat/include/net/ip_tunnels.h b/datapath/linux/compat/include/net/ip_tunnels.h
> index 7083372..3d952d4 100644
> --- a/datapath/linux/compat/include/net/ip_tunnels.h
> +++ b/datapath/linux/compat/include/net/ip_tunnels.h
[...]
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
>  struct sk_buff *ovs_iptunnel_handle_offloads(struct sk_buff *skb,
>                                              bool csum_help, int gso_type_mask,
>                                              void (*fix_segment)(struct sk_buff *));
> @@ -36,8 +36,21 @@ int rpl_iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_prot
>  #define ovs_iptunnel_handle_offloads(skb, csum_help, gso_type_mask, fix_segment) \
>         iptunnel_handle_offloads(skb, csum_help, gso_type_mask)
>
> +/* This macro is to make OVS build happy about declared functions name. */
> +#define rpl_iptunnel_pull_header iptunnel_pull_header
> +int rpl_iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
> +
> +#define rpl_iptunnel_xmit iptunnel_xmit
> +int rpl_iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
> +                     __be32 src, __be32 dst, __u8 proto, __u8 tos, __u8 ttl,
> +                     __be16 df, bool xnet);
> +
>  #endif /* 3.18 */
>
> +#define rpl_iptunnel_handle_offloads iptunnel_handle_offloads
> +struct sk_buff *rpl_iptunnel_handle_offloads(struct sk_buff *skb, bool gre_csum,
> +                                        int gso_type_mask);

I think we could move this up into the >=3.18 block since it looks
like that is the only place where we call the raw
iptunnel_handle_offloads().

Acked-by: Jesse Gross <jesse@kernel.org>
Pravin B Shelar Dec. 11, 2015, 9:52 p.m. UTC | #2
On Fri, Dec 11, 2015 at 1:33 PM, Jesse Gross <jesse@kernel.org> wrote:
> On Thu, Dec 10, 2015 at 8:03 PM, Pravin B Shelar <pshelar@nicira.com> wrote:
>> diff --git a/datapath/linux/compat/include/net/ip_tunnels.h b/datapath/linux/compat/include/net/ip_tunnels.h
>> index 7083372..3d952d4 100644
>> --- a/datapath/linux/compat/include/net/ip_tunnels.h
>> +++ b/datapath/linux/compat/include/net/ip_tunnels.h
> [...]
>> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
>>  struct sk_buff *ovs_iptunnel_handle_offloads(struct sk_buff *skb,
>>                                              bool csum_help, int gso_type_mask,
>>                                              void (*fix_segment)(struct sk_buff *));
>> @@ -36,8 +36,21 @@ int rpl_iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_prot
>>  #define ovs_iptunnel_handle_offloads(skb, csum_help, gso_type_mask, fix_segment) \
>>         iptunnel_handle_offloads(skb, csum_help, gso_type_mask)
>>
>> +/* This macro is to make OVS build happy about declared functions name. */
>> +#define rpl_iptunnel_pull_header iptunnel_pull_header
>> +int rpl_iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
>> +
>> +#define rpl_iptunnel_xmit iptunnel_xmit
>> +int rpl_iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
>> +                     __be32 src, __be32 dst, __u8 proto, __u8 tos, __u8 ttl,
>> +                     __be16 df, bool xnet);
>> +
>>  #endif /* 3.18 */
>>
>> +#define rpl_iptunnel_handle_offloads iptunnel_handle_offloads
>> +struct sk_buff *rpl_iptunnel_handle_offloads(struct sk_buff *skb, bool gre_csum,
>> +                                        int gso_type_mask);
>
> I think we could move this up into the >=3.18 block since it looks
> like that is the only place where we call the raw
> iptunnel_handle_offloads().
>

I had it there. But on older kernel gre_handle_offloads() is defined
in gre.h needs this definition. I added a comment about this in
ip_tunnels.h header file.

> Acked-by: Jesse Gross <jesse@kernel.org>

Thanks for all reviews.
I pushed this series to master and branch-2.5.
diff mbox

Patch

diff --git a/datapath/linux/compat/include/net/gre.h b/datapath/linux/compat/include/net/gre.h
index 09053b5..60618df 100644
--- a/datapath/linux/compat/include/net/gre.h
+++ b/datapath/linux/compat/include/net/gre.h
@@ -1,8 +1,10 @@ 
 #ifndef __LINUX_GRE_WRAPPER_H
 #define __LINUX_GRE_WRAPPER_H
 
+#include <linux/version.h>
 #include <linux/skbuff.h>
 #include <net/ip_tunnels.h>
+
 #ifdef HAVE_METADATA_DST
 #include_next <net/gre.h>
 
@@ -17,7 +19,6 @@  static inline void rpl_ipgre_fini(void)
 
 #else
 
-#include <linux/version.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) || \
    defined(HAVE_GRE_CISCO_REGISTER)
 #include_next <net/gre.h>
diff --git a/datapath/linux/compat/include/net/ip_tunnels.h b/datapath/linux/compat/include/net/ip_tunnels.h
index 7083372..3d952d4 100644
--- a/datapath/linux/compat/include/net/ip_tunnels.h
+++ b/datapath/linux/compat/include/net/ip_tunnels.h
@@ -3,15 +3,14 @@ 
 
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+#ifdef HAVE_METADATA_DST
+/* Block all ip_tunnel functions.
+ * Only function that do not depend on ip_tunnel structure can
+ * be used. Those needs to be explicitly defined in this header file. */
 #include_next <net/ip_tunnels.h>
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
-
 #include <linux/if_tunnel.h>
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
 #include <linux/types.h>
 #include <net/dsfield.h>
 #include <net/flow.h>
@@ -19,6 +18,7 @@ 
 #include <net/ip.h>
 #include <net/rtnetlink.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
 struct sk_buff *ovs_iptunnel_handle_offloads(struct sk_buff *skb,
 					     bool csum_help, int gso_type_mask,
 					     void (*fix_segment)(struct sk_buff *));
@@ -36,8 +36,21 @@  int rpl_iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_prot
 #define ovs_iptunnel_handle_offloads(skb, csum_help, gso_type_mask, fix_segment) \
 	iptunnel_handle_offloads(skb, csum_help, gso_type_mask)
 
+/* This macro is to make OVS build happy about declared functions name. */
+#define rpl_iptunnel_pull_header iptunnel_pull_header
+int rpl_iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
+
+#define rpl_iptunnel_xmit iptunnel_xmit
+int rpl_iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
+		      __be32 src, __be32 dst, __u8 proto, __u8 tos, __u8 ttl,
+		      __be16 df, bool xnet);
+
 #endif /* 3.18 */
 
+#define rpl_iptunnel_handle_offloads iptunnel_handle_offloads
+struct sk_buff *rpl_iptunnel_handle_offloads(struct sk_buff *skb, bool gre_csum,
+					 int gso_type_mask);
+
 #ifndef TUNNEL_CSUM
 #define TUNNEL_CSUM	__cpu_to_be16(0x01)
 #define TUNNEL_ROUTING	__cpu_to_be16(0x02)
@@ -211,9 +224,11 @@  struct ip_tunnel_net {
 
 #ifndef HAVE_PCPU_SW_NETSTATS
 #define ip_tunnel_get_stats64 rpl_ip_tunnel_get_stats64
+#else
+#define rpl_ip_tunnel_get_stats64 ip_tunnel_get_stats64
+#endif
 struct rtnl_link_stats64 *rpl_ip_tunnel_get_stats64(struct net_device *dev,
 						    struct rtnl_link_stats64 *tot);
-#endif
 
 #define ip_tunnel_get_dsfield rpl_ip_tunnel_get_dsfield
 static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph,