Commit 1158632b authored by Brian Russell's avatar Brian Russell Committed by David S. Miller

vxlan: don't allow overwrite of config src addr

When using IPv6 transport and a default dst, a pointer to the configured
source address is passed into the route lookup. If no source address is
configured, then the value is overwritten.

IPv6 route lookup ignores egress ifindex match if the source address is set,
so if egress ifindex match is desired, the source address must be passed
as any. The overwrite breaks this for subsequent lookups.

Avoid this by copying the configured address to an existing stack variable
and pass a pointer to that instead.

Fixes: 272d96a5 ("net: vxlan: lwt: Use source ip address during route lookup.")
Signed-off-by: default avatarBrian Russell <brussell@brocade.com>
Acked-by: default avatarJiri Benc <jbenc@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7dcdf941
...@@ -2035,7 +2035,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2035,7 +2035,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
const struct iphdr *old_iph = ip_hdr(skb); const struct iphdr *old_iph = ip_hdr(skb);
union vxlan_addr *dst; union vxlan_addr *dst;
union vxlan_addr remote_ip, local_ip; union vxlan_addr remote_ip, local_ip;
union vxlan_addr *src;
struct vxlan_metadata _md; struct vxlan_metadata _md;
struct vxlan_metadata *md = &_md; struct vxlan_metadata *md = &_md;
__be16 src_port = 0, dst_port; __be16 src_port = 0, dst_port;
...@@ -2062,7 +2061,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2062,7 +2061,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port; dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port;
vni = (rdst->remote_vni) ? : default_vni; vni = (rdst->remote_vni) ? : default_vni;
src = &vxlan->cfg.saddr; local_ip = vxlan->cfg.saddr;
dst_cache = &rdst->dst_cache; dst_cache = &rdst->dst_cache;
md->gbp = skb->mark; md->gbp = skb->mark;
ttl = vxlan->cfg.ttl; ttl = vxlan->cfg.ttl;
...@@ -2095,7 +2094,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2095,7 +2094,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
dst = &remote_ip; dst = &remote_ip;
dst_port = info->key.tp_dst ? : vxlan->cfg.dst_port; dst_port = info->key.tp_dst ? : vxlan->cfg.dst_port;
vni = tunnel_id_to_key32(info->key.tun_id); vni = tunnel_id_to_key32(info->key.tun_id);
src = &local_ip;
dst_cache = &info->dst_cache; dst_cache = &info->dst_cache;
if (info->options_len) if (info->options_len)
md = ip_tunnel_info_opts(info); md = ip_tunnel_info_opts(info);
...@@ -2115,7 +2113,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2115,7 +2113,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
rt = vxlan_get_route(vxlan, dev, sock4, skb, rt = vxlan_get_route(vxlan, dev, sock4, skb,
rdst ? rdst->remote_ifindex : 0, tos, rdst ? rdst->remote_ifindex : 0, tos,
dst->sin.sin_addr.s_addr, dst->sin.sin_addr.s_addr,
&src->sin.sin_addr.s_addr, &local_ip.sin.sin_addr.s_addr,
dst_port, src_port, dst_port, src_port,
dst_cache, info); dst_cache, info);
if (IS_ERR(rt)) { if (IS_ERR(rt)) {
...@@ -2142,7 +2140,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2142,7 +2140,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
if (err < 0) if (err < 0)
goto tx_error; goto tx_error;
udp_tunnel_xmit_skb(rt, sock4->sock->sk, skb, src->sin.sin_addr.s_addr, udp_tunnel_xmit_skb(rt, sock4->sock->sk, skb, local_ip.sin.sin_addr.s_addr,
dst->sin.sin_addr.s_addr, tos, ttl, df, dst->sin.sin_addr.s_addr, tos, ttl, df,
src_port, dst_port, xnet, !udp_sum); src_port, dst_port, xnet, !udp_sum);
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
...@@ -2152,7 +2150,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2152,7 +2150,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
ndst = vxlan6_get_route(vxlan, dev, sock6, skb, ndst = vxlan6_get_route(vxlan, dev, sock6, 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, &local_ip.sin6.sin6_addr,
dst_port, src_port, dst_port, src_port,
dst_cache, info); dst_cache, info);
if (IS_ERR(ndst)) { if (IS_ERR(ndst)) {
...@@ -2180,7 +2178,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2180,7 +2178,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
goto tx_error; goto tx_error;
udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev, udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev,
&src->sin6.sin6_addr, &local_ip.sin6.sin6_addr,
&dst->sin6.sin6_addr, tos, ttl, &dst->sin6.sin6_addr, tos, ttl,
label, src_port, dst_port, !udp_sum); label, src_port, dst_port, !udp_sum);
#endif #endif
......
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