mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]> Signed-off-by: Hadar Hen Zion <[email protected]> Reviewed-by: Shmulik Ladkani <[email protected]> Acked-by: Jiri Benc <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
e808bb6ed0
commit
d817f432c2
4 changed files with 23 additions and 41 deletions
|
|
@ -246,25 +246,6 @@ static void gre_err(struct sk_buff *skb, u32 info)
|
|||
ipgre_err(skb, info, &tpi);
|
||||
}
|
||||
|
||||
static __be64 key_to_tunnel_id(__be32 key)
|
||||
{
|
||||
#ifdef __BIG_ENDIAN
|
||||
return (__force __be64)((__force u32)key);
|
||||
#else
|
||||
return (__force __be64)((__force u64)key << 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Returns the least-significant 32 bits of a __be64. */
|
||||
static __be32 tunnel_id_to_key(__be64 x)
|
||||
{
|
||||
#ifdef __BIG_ENDIAN
|
||||
return (__force __be32)x;
|
||||
#else
|
||||
return (__force __be32)((__force u64)x >> 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
|
||||
struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)
|
||||
{
|
||||
|
|
@ -290,7 +271,7 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
|
|||
__be64 tun_id;
|
||||
|
||||
flags = tpi->flags & (TUNNEL_CSUM | TUNNEL_KEY);
|
||||
tun_id = key_to_tunnel_id(tpi->key);
|
||||
tun_id = key32_to_tunnel_id(tpi->key);
|
||||
tun_dst = ip_tun_rx_dst(skb, flags, tun_id, 0);
|
||||
if (!tun_dst)
|
||||
return PACKET_REJECT;
|
||||
|
|
@ -446,7 +427,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
|
|||
|
||||
flags = tun_info->key.tun_flags & (TUNNEL_CSUM | TUNNEL_KEY);
|
||||
gre_build_header(skb, tunnel_hlen, flags, proto,
|
||||
tunnel_id_to_key(tun_info->key.tun_id), 0);
|
||||
tunnel_id_to_key32(tun_info->key.tun_id), 0);
|
||||
|
||||
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue