diff options
author | Amir Vadai <amir@vadai.me> | 2016-09-08 09:23:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-09-10 23:53:55 -0400 |
commit | d817f432c2ab7639a4f69de73eafdc55e57c45ad (patch) | |
tree | fc378fb961d465b15248076fc884e3c90fb228f6 /include/net/ip_tunnels.h | |
parent | e808bb6ed042020d3a15cb6e85ca646bc7c9eda8 (diff) |
net/ip_tunnels: Introduce tunnel_id_to_key32() and key32_to_tunnel_id()
Add utility functions to convert a 32 bits key into a 64 bits tunnel and
vice versa.
These functions will be used instead of cloning code in GRE and VXLAN,
and in tc act_iptunnel which will be introduced in a following patch in
this patchset.
Signed-off-by: Amir Vadai <amir@vadai.me>
Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Jiri Pirko <jiri@mellanox.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.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index a5e7035fb93f..e598c639aa6f 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h | |||
@@ -222,6 +222,25 @@ static inline unsigned short ip_tunnel_info_af(const struct ip_tunnel_info | |||
222 | return tun_info->mode & IP_TUNNEL_INFO_IPV6 ? AF_INET6 : AF_INET; | 222 | return tun_info->mode & IP_TUNNEL_INFO_IPV6 ? AF_INET6 : AF_INET; |
223 | } | 223 | } |
224 | 224 | ||
225 | static inline __be64 key32_to_tunnel_id(__be32 key) | ||
226 | { | ||
227 | #ifdef __BIG_ENDIAN | ||
228 | return (__force __be64)key; | ||
229 | #else | ||
230 | return (__force __be64)((__force u64)key << 32); | ||
231 | #endif | ||
232 | } | ||
233 | |||
234 | /* Returns the least-significant 32 bits of a __be64. */ | ||
235 | static inline __be32 tunnel_id_to_key32(__be64 tun_id) | ||
236 | { | ||
237 | #ifdef __BIG_ENDIAN | ||
238 | return (__force __be32)tun_id; | ||
239 | #else | ||
240 | return (__force __be32)((__force u64)tun_id >> 32); | ||
241 | #endif | ||
242 | } | ||
243 | |||
225 | #ifdef CONFIG_INET | 244 | #ifdef CONFIG_INET |
226 | 245 | ||
227 | int ip_tunnel_init(struct net_device *dev); | 246 | int ip_tunnel_init(struct net_device *dev); |