Commit 03dc52a8 authored by pravin shelar's avatar pravin shelar Committed by David S. Miller

vxlan: avoid checking socket multiple times.

Check the vxlan socket in vxlan6_getroute().
Signed-off-by: default avatarPravin B Shelar <pshelar@ovn.org>
Acked-by: default avatarJiri Benc <jbenc@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a4f86cc
...@@ -1832,6 +1832,7 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, ...@@ -1832,6 +1832,7 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan,
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
struct vxlan_sock *sock6,
struct sk_buff *skb, int oif, u8 tos, struct sk_buff *skb, int oif, u8 tos,
__be32 label, __be32 label,
const struct in6_addr *daddr, const struct in6_addr *daddr,
...@@ -1839,7 +1840,6 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, ...@@ -1839,7 +1840,6 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
struct dst_cache *dst_cache, struct dst_cache *dst_cache,
const struct ip_tunnel_info *info) const struct ip_tunnel_info *info)
{ {
struct vxlan_sock *sock6 = rcu_dereference(vxlan->vn6_sock);
bool use_cache = ip_tunnel_dst_cache_usable(skb, info); bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
struct dst_entry *ndst; struct dst_entry *ndst;
struct flowi6 fl6; struct flowi6 fl6;
...@@ -2071,11 +2071,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2071,11 +2071,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
struct dst_entry *ndst; struct dst_entry *ndst;
u32 rt6i_flags; u32 rt6i_flags;
if (!sock6) ndst = vxlan6_get_route(vxlan, sock6, skb,
goto drop;
sk = sock6->sock->sk;
ndst = vxlan6_get_route(vxlan, skb,
rdst ? rdst->remote_ifindex : 0, tos, rdst ? rdst->remote_ifindex : 0, tos,
label, &dst->sin6.sin6_addr, label, &dst->sin6.sin6_addr,
&src->sin6.sin6_addr, &src->sin6.sin6_addr,
...@@ -2095,6 +2091,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2095,6 +2091,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
goto tx_error; goto tx_error;
} }
sk = sock6->sock->sk;
/* Bypass encapsulation if the destination is local */ /* Bypass encapsulation if the destination is local */
rt6i_flags = ((struct rt6_info *)ndst)->rt6i_flags; rt6i_flags = ((struct rt6_info *)ndst)->rt6i_flags;
if (!info && rt6i_flags & RTF_LOCAL && if (!info && rt6i_flags & RTF_LOCAL &&
...@@ -2434,9 +2431,10 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) ...@@ -2434,9 +2431,10 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
ip_rt_put(rt); ip_rt_put(rt);
} else { } else {
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
struct vxlan_sock *sock6 = rcu_dereference(vxlan->vn6_sock);
struct dst_entry *ndst; struct dst_entry *ndst;
ndst = vxlan6_get_route(vxlan, skb, 0, info->key.tos, ndst = vxlan6_get_route(vxlan, sock6, skb, 0, info->key.tos,
info->key.label, &info->key.u.ipv6.dst, info->key.label, &info->key.u.ipv6.dst,
&info->key.u.ipv6.src, NULL, info); &info->key.u.ipv6.src, NULL, info);
if (IS_ERR(ndst)) if (IS_ERR(ndst))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment