aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_tunnels.h
diff options
context:
space:
mode:
authorJiri Benc <jbenc@redhat.com>2015-08-20 07:56:23 -0400
committerDavid S. Miller <davem@davemloft.net>2015-08-20 18:42:36 -0400
commitc1ea5d672aaff08da337dee735dbb548e3415585 (patch)
tree7e5e9a74d7e55be37c1ecea8c0cdeb1211791586 /include/net/ip_tunnels.h
parent376534a3d17002d608985bd67c3b0880eacadd14 (diff)
ip_tunnels: add IPv6 addresses to ip_tunnel_key
Add the IPv6 addresses as an union with IPv4 ones. When using IPv4, the newly introduced padding after the IPv4 addresses needs to be zeroed out. Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Thomas Graf <tgraf@suug.ch> Acked-by: Alexei Starovoitov <ast@plumgrid.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.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index cc3b39e9010b..6a51371dad00 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -25,10 +25,24 @@
25/* Used to memset ip_tunnel padding. */ 25/* Used to memset ip_tunnel padding. */
26#define IP_TUNNEL_KEY_SIZE offsetofend(struct ip_tunnel_key, tp_dst) 26#define IP_TUNNEL_KEY_SIZE offsetofend(struct ip_tunnel_key, tp_dst)
27 27
28/* Used to memset ipv4 address padding. */
29#define IP_TUNNEL_KEY_IPV4_PAD offsetofend(struct ip_tunnel_key, u.ipv4.dst)
30#define IP_TUNNEL_KEY_IPV4_PAD_LEN \
31 (FIELD_SIZEOF(struct ip_tunnel_key, u) - \
32 FIELD_SIZEOF(struct ip_tunnel_key, u.ipv4))
33
28struct ip_tunnel_key { 34struct ip_tunnel_key {
29 __be64 tun_id; 35 __be64 tun_id;
30 __be32 ipv4_src; 36 union {
31 __be32 ipv4_dst; 37 struct {
38 __be32 src;
39 __be32 dst;
40 } ipv4;
41 struct {
42 struct in6_addr src;
43 struct in6_addr dst;
44 } ipv6;
45 } u;
32 __be16 tun_flags; 46 __be16 tun_flags;
33 u8 ipv4_tos; 47 u8 ipv4_tos;
34 u8 ipv4_ttl; 48 u8 ipv4_ttl;
@@ -177,8 +191,10 @@ static inline void __ip_tunnel_info_init(struct ip_tunnel_info *tun_info,
177 const void *opts, u8 opts_len) 191 const void *opts, u8 opts_len)
178{ 192{
179 tun_info->key.tun_id = tun_id; 193 tun_info->key.tun_id = tun_id;
180 tun_info->key.ipv4_src = saddr; 194 tun_info->key.u.ipv4.src = saddr;
181 tun_info->key.ipv4_dst = daddr; 195 tun_info->key.u.ipv4.dst = daddr;
196 memset((unsigned char *)&tun_info->key + IP_TUNNEL_KEY_IPV4_PAD,
197 0, IP_TUNNEL_KEY_IPV4_PAD_LEN);
182 tun_info->key.ipv4_tos = tos; 198 tun_info->key.ipv4_tos = tos;
183 tun_info->key.ipv4_ttl = ttl; 199 tun_info->key.ipv4_ttl = ttl;
184 tun_info->key.tun_flags = tun_flags; 200 tun_info->key.tun_flags = tun_flags;