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>
This commit is contained in:

committed by
David S. Miller

parent
e808bb6ed0
commit
d817f432c2
@@ -350,24 +350,6 @@ static inline __be32 vxlan_vni_field(__be32 vni)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline __be32 vxlan_tun_id_to_vni(__be64 tun_id)
|
||||
{
|
||||
#if defined(__BIG_ENDIAN)
|
||||
return (__force __be32)tun_id;
|
||||
#else
|
||||
return (__force __be32)((__force u64)tun_id >> 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline __be64 vxlan_vni_to_tun_id(__be32 vni)
|
||||
{
|
||||
#if defined(__BIG_ENDIAN)
|
||||
return (__force __be64)vni;
|
||||
#else
|
||||
return (__force __be64)((u64)(__force u32)vni << 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline size_t vxlan_rco_start(__be32 vni_field)
|
||||
{
|
||||
return be32_to_cpu(vni_field & VXLAN_RCO_MASK) << VXLAN_RCO_SHIFT;
|
||||
|
Reference in New Issue
Block a user