aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_tunnels.h
diff options
context:
space:
mode:
authorPravin B Shelar <pshelar@nicira.com>2015-08-30 21:09:38 -0400
committerDavid S. Miller <davem@davemloft.net>2015-08-31 15:28:56 -0400
commit4c22279848c531fc7f555d463daf3d0df963bd41 (patch)
tree38315c4715393860962cc00a19f47fa1554b6add /include/net/ip_tunnels.h
parentd1bfc62591a0a5144dc380976e737fbbb4f40f4f (diff)
ip-tunnel: Use API to access tunnel metadata options.
Currently tun-info options pointer is used in few cases to pass options around. But tunnel options can be accessed using ip_tunnel_info_opts() API without using the pointer. Following patch removes the redundant pointer and consistently make use of API. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Thomas Graf <tgraf@suug.ch> Reviewed-by: Jesse Gross <jesse@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ip_tunnels.h')
-rw-r--r--include/net/ip_tunnels.h67
1 files changed, 31 insertions, 36 deletions
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 2b4fa06e91bd..9a6a3ba888e8 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -57,7 +57,6 @@ struct ip_tunnel_key {
57 57
58struct ip_tunnel_info { 58struct ip_tunnel_info {
59 struct ip_tunnel_key key; 59 struct ip_tunnel_key key;
60 const void *options;
61 u8 options_len; 60 u8 options_len;
62 u8 mode; 61 u8 mode;
63}; 62};
@@ -180,49 +179,32 @@ int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op,
180int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op, 179int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
181 unsigned int num); 180 unsigned int num);
182 181
183static inline void __ip_tunnel_info_init(struct ip_tunnel_info *tun_info, 182static inline void ip_tunnel_key_init(struct ip_tunnel_key *key,
184 __be32 saddr, __be32 daddr, 183 __be32 saddr, __be32 daddr,
185 u8 tos, u8 ttl, 184 u8 tos, u8 ttl,
186 __be16 tp_src, __be16 tp_dst, 185 __be16 tp_src, __be16 tp_dst,
187 __be64 tun_id, __be16 tun_flags, 186 __be64 tun_id, __be16 tun_flags)
188 const void *opts, u8 opts_len)
189{ 187{
190 tun_info->key.tun_id = tun_id; 188 key->tun_id = tun_id;
191 tun_info->key.u.ipv4.src = saddr; 189 key->u.ipv4.src = saddr;
192 tun_info->key.u.ipv4.dst = daddr; 190 key->u.ipv4.dst = daddr;
193 memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_IPV4_PAD, 191 memset((unsigned char *)key + IP_TUNNEL_KEY_IPV4_PAD,
194 0, IP_TUNNEL_KEY_IPV4_PAD_LEN); 192 0, IP_TUNNEL_KEY_IPV4_PAD_LEN);
195 tun_info->key.tos = tos; 193 key->tos = tos;
196 tun_info->key.ttl = ttl; 194 key->ttl = ttl;
197 tun_info->key.tun_flags = tun_flags; 195 key->tun_flags = tun_flags;
198 196
199 /* For the tunnel types on the top of IPsec, the tp_src and tp_dst of 197 /* For the tunnel types on the top of IPsec, the tp_src and tp_dst of
200 * the upper tunnel are used. 198 * the upper tunnel are used.
201 * E.g: GRE over IPSEC, the tp_src and tp_port are zero. 199 * E.g: GRE over IPSEC, the tp_src and tp_port are zero.
202 */ 200 */
203 tun_info->key.tp_src = tp_src; 201 key->tp_src = tp_src;
204 tun_info->key.tp_dst = tp_dst; 202 key->tp_dst = tp_dst;
205 203
206 /* Clear struct padding. */ 204 /* Clear struct padding. */
207 if (sizeof(tun_info->key) != IP_TUNNEL_KEY_SIZE) 205 if (sizeof(*key) != IP_TUNNEL_KEY_SIZE)
208 memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_SIZE, 206 memset((unsigned char *)key + IP_TUNNEL_KEY_SIZE,
209 0, sizeof(tun_info->key) - IP_TUNNEL_KEY_SIZE); 207 0, sizeof(*key) - IP_TUNNEL_KEY_SIZE);
210
211 tun_info->options = opts;
212 tun_info->options_len = opts_len;
213
214 tun_info->mode = 0;
215}
216
217static inline void ip_tunnel_info_init(struct ip_tunnel_info *tun_info,
218 const struct iphdr *iph,
219 __be16 tp_src, __be16 tp_dst,
220 __be64 tun_id, __be16 tun_flags,
221 const void *opts, u8 opts_len)
222{
223 __ip_tunnel_info_init(tun_info, iph->saddr, iph->daddr,
224 iph->tos, iph->ttl, tp_src, tp_dst,
225 tun_id, tun_flags, opts, opts_len);
226} 208}
227 209
228static inline unsigned short ip_tunnel_info_af(const struct ip_tunnel_info 210static inline unsigned short ip_tunnel_info_af(const struct ip_tunnel_info
@@ -317,11 +299,24 @@ static inline void iptunnel_xmit_stats(int err,
317 } 299 }
318} 300}
319 301
320static inline void *ip_tunnel_info_opts(struct ip_tunnel_info *info, size_t n) 302static inline void *ip_tunnel_info_opts(struct ip_tunnel_info *info)
321{ 303{
322 return info + 1; 304 return info + 1;
323} 305}
324 306
307static inline void ip_tunnel_info_opts_get(void *to,
308 const struct ip_tunnel_info *info)
309{
310 memcpy(to, info + 1, info->options_len);
311}
312
313static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
314 const void *from, int len)
315{
316 memcpy(ip_tunnel_info_opts(info), from, len);
317 info->options_len = len;
318}
319
325static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate) 320static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
326{ 321{
327 return (struct ip_tunnel_info *)lwtstate->data; 322 return (struct ip_tunnel_info *)lwtstate->data;