aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_tunnels.h
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2015-07-21 04:43:54 -0400
committerDavid S. Miller <davem@davemloft.net>2015-07-21 13:39:05 -0400
commit1d8fff907342d2339796dbd27ea47d0e76a6a2d0 (patch)
tree0c8e93fba52efc6e893e7c3ceb2f45091dcdf936 /include/net/ip_tunnels.h
parente3e4712ec0961ed586a8db340bd994c4ad7f5dba (diff)
ip_tunnel: Make ovs_tunnel_info and ovs_key_ipv4_tunnel generic
Rename the tunnel metadata data structures currently internal to OVS and make them generic for use by all IP tunnels. Both structures are kernel internal and will stay that way. Their members are exposed to user space through individual Netlink attributes by OVS. It will therefore be possible to extend/modify these structures without affecting user ABI. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ip_tunnels.h')
-rw-r--r--include/net/ip_tunnels.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index d8214cb88bbc..6b9d559ce5f5 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -22,6 +22,28 @@
22/* Keep error state on tunnel for 30 sec */ 22/* Keep error state on tunnel for 30 sec */
23#define IPTUNNEL_ERR_TIMEO (30*HZ) 23#define IPTUNNEL_ERR_TIMEO (30*HZ)
24 24
25/* Used to memset ip_tunnel padding. */
26#define IP_TUNNEL_KEY_SIZE \
27 (offsetof(struct ip_tunnel_key, tp_dst) + \
28 FIELD_SIZEOF(struct ip_tunnel_key, tp_dst))
29
30struct ip_tunnel_key {
31 __be64 tun_id;
32 __be32 ipv4_src;
33 __be32 ipv4_dst;
34 __be16 tun_flags;
35 __u8 ipv4_tos;
36 __u8 ipv4_ttl;
37 __be16 tp_src;
38 __be16 tp_dst;
39} __packed __aligned(4); /* Minimize padding. */
40
41struct ip_tunnel_info {
42 struct ip_tunnel_key key;
43 const void *options;
44 u8 options_len;
45};
46
25/* 6rd prefix/relay information */ 47/* 6rd prefix/relay information */
26#ifdef CONFIG_IPV6_SIT_6RD 48#ifdef CONFIG_IPV6_SIT_6RD
27struct ip_tunnel_6rd_parm { 49struct ip_tunnel_6rd_parm {
@@ -136,6 +158,47 @@ int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op,
136int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op, 158int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
137 unsigned int num); 159 unsigned int num);
138 160
161static inline void __ip_tunnel_info_init(struct ip_tunnel_info *tun_info,
162 __be32 saddr, __be32 daddr,
163 u8 tos, u8 ttl,
164 __be16 tp_src, __be16 tp_dst,
165 __be64 tun_id, __be16 tun_flags,
166 const void *opts, u8 opts_len)
167{
168 tun_info->key.tun_id = tun_id;
169 tun_info->key.ipv4_src = saddr;
170 tun_info->key.ipv4_dst = daddr;
171 tun_info->key.ipv4_tos = tos;
172 tun_info->key.ipv4_ttl = ttl;
173 tun_info->key.tun_flags = tun_flags;
174
175 /* For the tunnel types on the top of IPsec, the tp_src and tp_dst of
176 * the upper tunnel are used.
177 * E.g: GRE over IPSEC, the tp_src and tp_port are zero.
178 */
179 tun_info->key.tp_src = tp_src;
180 tun_info->key.tp_dst = tp_dst;
181
182 /* Clear struct padding. */
183 if (sizeof(tun_info->key) != IP_TUNNEL_KEY_SIZE)
184 memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_SIZE,
185 0, sizeof(tun_info->key) - IP_TUNNEL_KEY_SIZE);
186
187 tun_info->options = opts;
188 tun_info->options_len = opts_len;
189}
190
191static inline void ip_tunnel_info_init(struct ip_tunnel_info *tun_info,
192 const struct iphdr *iph,
193 __be16 tp_src, __be16 tp_dst,
194 __be64 tun_id, __be16 tun_flags,
195 const void *opts, u8 opts_len)
196{
197 __ip_tunnel_info_init(tun_info, iph->saddr, iph->daddr,
198 iph->tos, iph->ttl, tp_src, tp_dst,
199 tun_id, tun_flags, opts, opts_len);
200}
201
139#ifdef CONFIG_INET 202#ifdef CONFIG_INET
140 203
141int ip_tunnel_init(struct net_device *dev); 204int ip_tunnel_init(struct net_device *dev);