Update openstack refs to opendev
[apex.git] / build / patches / ovs-fix-build-on-RHEL-7.3.patch
1 From 6ccf21ca77ec092aa63b3daff66dc9f0d0e1be93 Mon Sep 17 00:00:00 2001
2 From: Yi-Hung Wei <yihung.wei@gmail.com>
3 Date: Thu, 8 Dec 2016 18:34:05 -0800
4 Subject: [PATCH] datapath: compat: Fix build on RHEL 7.3
5
6 RHEL 7.3 provides upstream tunnel but it does not support name_assign_type
7 attribute in net-device. This patch fixes the build problem by backporting
8 functions with name_assign_type, and using proper flags in acinclude.m4 to
9 invoke backport functions.
10
11 Tested on RHEL 7.3 with kernel 3.10.0-514.el7.x86_64
12
13 Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
14 Signed-off-by: Joe Stringer <joe@ovn.org>
15 ---
16  acinclude.m4                                    |  7 +++++++
17  datapath/linux/compat/include/linux/netdevice.h |  3 ++-
18  datapath/linux/compat/include/net/geneve.h      | 10 ++++++++++
19  datapath/linux/compat/include/net/gre.h         | 10 ++++++++++
20  datapath/linux/compat/include/net/inet_frag.h   |  9 ++++++---
21  datapath/linux/compat/include/net/vxlan.h       | 11 +++++++++++
22  datapath/vport-internal_dev.c                   |  4 ++++
23  7 files changed, 50 insertions(+), 4 deletions(-)
24
25 diff --git a/acinclude.m4 b/acinclude.m4
26 index bea49d2..e8b64b5 100644
27 --- a/acinclude.m4
28 +++ b/acinclude.m4
29 @@ -458,6 +458,11 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
30    OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_queue],
31                          [list_evictor])
32    OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_lru_move])
33 +  OVS_FIND_PARAM_IFELSE([$KSRC/include/net/inet_frag.h],
34 +                        [sub_frag_mem_limit], [struct.netns_frags],
35 +                        [OVS_DEFINE([HAVE_SUB_FRAG_MEM_LIMIT_ARG_STRUCT_NETNS_FRAGS])])
36 +  OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [void.*inet_frags_init],
37 +                  [OVS_DEFINE([HAVE_VOID_INET_FRAGS_INIT])])
38    OVS_GREP_IFELSE([$KSRC/include/net/inetpeer.h], [vif],
39                    [OVS_DEFINE([HAVE_INETPEER_VIF_SUPPORT])])
40  
41 @@ -500,6 +505,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
42                    [OVS_DEFINE([HAVE_UDP_OFFLOAD_ARG_UOFF])])
43    OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [gro_remcsum])
44    OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [IFF_PHONY_HEADROOM])
45 +  OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netdevice.h], [net_device_ops],
46 +                        [extended])
47    OVS_FIND_PARAM_IFELSE([$KSRC/include/linux/netdevice.h],
48                          [netdev_master_upper_dev_link], [upper_priv],
49                          [OVS_DEFINE([HAVE_NETDEV_MASTER_UPPER_DEV_LINK_PRIV])])
50 diff --git a/datapath/linux/compat/include/linux/netdevice.h b/datapath/linux/compat/include/linux/netdevice.h
51 index dd028f6..9982fd7 100644
52 --- a/datapath/linux/compat/include/linux/netdevice.h
53 +++ b/datapath/linux/compat/include/linux/netdevice.h
54 @@ -122,10 +122,11 @@ int rpl_dev_queue_xmit(struct sk_buff *skb);
55  #endif
56  
57  #if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
58 -static inline struct net_device *netdev_notifier_info_to_dev(void *info)
59 +static inline struct net_device *rpl_netdev_notifier_info_to_dev(void *info)
60  {
61         return info;
62  }
63 +#define netdev_notifier_info_to_dev rpl_netdev_notifier_info_to_dev
64  #endif
65  
66  #ifndef HAVE_PCPU_SW_NETSTATS
67 diff --git a/datapath/linux/compat/include/net/geneve.h b/datapath/linux/compat/include/net/geneve.h
68 index 857c6d7..d9c9f0b 100644
69 --- a/datapath/linux/compat/include/net/geneve.h
70 +++ b/datapath/linux/compat/include/net/geneve.h
71 @@ -18,6 +18,16 @@ static inline void rpl_geneve_cleanup_module(void)
72  
73  #define geneve_xmit dev_queue_xmit
74  
75 +#ifdef CONFIG_INET
76 +#ifndef HAVE_NAME_ASSIGN_TYPE
77 +static inline struct net_device *rpl_geneve_dev_create_fb(
78 +       struct net *net, const char *name, u8 name_assign_type, u16 dst_port) {
79 +       return geneve_dev_create_fb(net, name, dst_port);
80 +}
81 +#define geneve_dev_create_fb rpl_geneve_dev_create_fb
82 +#endif
83 +#endif
84 +
85  #else
86  /* Geneve Header:
87   *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88 diff --git a/datapath/linux/compat/include/net/gre.h b/datapath/linux/compat/include/net/gre.h
89 index 4a78fe8..764b9f1 100644
90 --- a/datapath/linux/compat/include/net/gre.h
91 +++ b/datapath/linux/compat/include/net/gre.h
92 @@ -17,6 +17,16 @@ static inline void rpl_ipgre_fini(void)
93  
94  #define gre_fb_xmit dev_queue_xmit
95  
96 +#ifdef CONFIG_INET
97 +#ifndef HAVE_NAME_ASSIGN_TYPE
98 +static inline struct net_device *rpl_gretap_fb_dev_create(
99 +       struct net *net, const char *name, u8 name_assign_type) {
100 +       return gretap_fb_dev_create(net, name);
101 +}
102 +#define gretap_fb_dev_create rpl_gretap_fb_dev_create
103 +#endif
104 +#endif
105 +
106  #else
107  
108  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) || \
109 diff --git a/datapath/linux/compat/include/net/inet_frag.h b/datapath/linux/compat/include/net/inet_frag.h
110 index c37bc84..01d79ad 100644
111 --- a/datapath/linux/compat/include/net/inet_frag.h
112 +++ b/datapath/linux/compat/include/net/inet_frag.h
113 @@ -29,7 +29,7 @@ static inline bool inet_frag_evicting(struct inet_frag_queue *q)
114  #define inet_frag_lru_move(q)
115  #endif
116  
117 -#ifndef HAVE_CORRECT_MRU_HANDLING
118 +#ifndef HAVE_SUB_FRAG_MEM_LIMIT_ARG_STRUCT_NETNS_FRAGS
119  static inline void rpl_sub_frag_mem_limit(struct netns_frags *nf, int i)
120  {
121         __percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
122 @@ -41,14 +41,18 @@ static inline void rpl_add_frag_mem_limit(struct netns_frags *nf, int i)
123         __percpu_counter_add(&nf->mem, i, frag_percpu_counter_batch);
124  }
125  #define add_frag_mem_limit rpl_add_frag_mem_limit
126 +#endif
127  
128 +#ifdef HAVE_VOID_INET_FRAGS_INIT
129  static inline int rpl_inet_frags_init(struct inet_frags *frags)
130  {
131         inet_frags_init(frags);
132         return 0;
133  }
134  #define inet_frags_init rpl_inet_frags_init
135 +#endif
136  
137 +#ifndef HAVE_CORRECT_MRU_HANDLING
138  /* We reuse the upstream inet_fragment.c common code for managing fragment
139   * stores, However we actually store the fragments within our own 'inet_frags'
140   * structures (in {ip_fragment,nf_conntrack_reasm}.c). When unloading the OVS
141 @@ -64,7 +68,6 @@ static inline int rpl_inet_frags_init(struct inet_frags *frags)
142   */
143  void rpl_inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
144  #define inet_frags_exit_net rpl_inet_frags_exit_net
145 -
146 -#endif /* !HAVE_CORRECT_MRU_HANDLING */
147 +#endif
148  
149  #endif /* inet_frag.h */
150 diff --git a/datapath/linux/compat/include/net/vxlan.h b/datapath/linux/compat/include/net/vxlan.h
151 index 5bc8969..460fbf2 100644
152 --- a/datapath/linux/compat/include/net/vxlan.h
153 +++ b/datapath/linux/compat/include/net/vxlan.h
154 @@ -17,6 +17,17 @@ static inline void rpl_vxlan_cleanup_module(void)
155  
156  #define vxlan_xmit dev_queue_xmit
157  
158 +#ifdef CONFIG_INET
159 +#ifndef HAVE_NAME_ASSIGN_TYPE
160 +static inline struct net_device *rpl_vxlan_dev_create(
161 +       struct net *net, const char *name, u8 name_assign_type,
162 +       struct vxlan_config *conf) {
163 +       return vxlan_dev_create(net, name, conf);
164 +}
165 +#define vxlan_dev_create rpl_vxlan_dev_create
166 +#endif
167 +#endif
168 +
169  #else /* USE_UPSTREAM_TUNNEL */
170  
171  #include <linux/ip.h>
172 diff --git a/datapath/vport-internal_dev.c b/datapath/vport-internal_dev.c
173 index 482af37..cc01c9c 100644
174 --- a/datapath/vport-internal_dev.c
175 +++ b/datapath/vport-internal_dev.c
176 @@ -153,7 +153,11 @@ static const struct net_device_ops internal_dev_netdev_ops = {
177         .ndo_change_mtu = internal_dev_change_mtu,
178         .ndo_get_stats64 = internal_get_stats,
179  #ifdef HAVE_IFF_PHONY_HEADROOM
180 +#ifndef HAVE_NET_DEVICE_OPS_WITH_EXTENDED
181         .ndo_set_rx_headroom = internal_set_rx_headroom,
182 +#else
183 +       .extended.ndo_set_rx_headroom = internal_set_rx_headroom,
184 +#endif
185  #endif
186  };
187  
188 -- 
189 2.1.0
190