* [PATCH net-next] ip6_tunnel: collect_md xmit: Use ip_tunnel_key's provided src address
@ 2018-08-06 12:00 Shmulik Ladkani
2018-08-07 19:37 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Shmulik Ladkani @ 2018-08-06 12:00 UTC (permalink / raw)
To: David S . Miller; +Cc: Alexei Starovoitov, netdev, shmulik, Shmulik Ladkani
When using an ip6tnl device in collect_md mode, the xmit methods ignore
the ipv6.src field present in skb_tunnel_info's key, both for route
calculation purposes (flowi6 construction) and for assigning the
packet's final ipv6h->saddr.
This makes it impossible specifying a desired ipv6 local address in the
encapsulating header (for example, when using tc action tunnel_key).
This is also not aligned with behavior of ipip (ipv4) in collect_md
mode, where the key->u.ipv4.src gets used.
Fix, by assigning fl6.saddr with given key->u.ipv6.src.
In case ipv6.src is not specified, ip6_tnl_xmit uses existing saddr
selection code.
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
Fixes: 8d79266bc48c ("ip6_tunnel: add collect_md mode to IPv6 tunnels")
---
net/ipv6/ip6_tunnel.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 00e138a44cbb..820cebe0c687 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1113,7 +1113,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
dst = NULL;
goto tx_err_link_failure;
}
- if (t->parms.collect_md &&
+ if (t->parms.collect_md && ipv6_addr_any(&fl6->saddr) &&
ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
&fl6->daddr, 0, &fl6->saddr))
goto tx_err_link_failure;
@@ -1255,6 +1255,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
key = &tun_info->key;
memset(&fl6, 0, sizeof(fl6));
fl6.flowi6_proto = IPPROTO_IPIP;
+ fl6.saddr = key->u.ipv6.src;
fl6.daddr = key->u.ipv6.dst;
fl6.flowlabel = key->label;
dsfield = key->tos;
@@ -1326,6 +1327,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
key = &tun_info->key;
memset(&fl6, 0, sizeof(fl6));
fl6.flowi6_proto = IPPROTO_IPV6;
+ fl6.saddr = key->u.ipv6.src;
fl6.daddr = key->u.ipv6.dst;
fl6.flowlabel = key->label;
dsfield = key->tos;
--
2.18.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] ip6_tunnel: collect_md xmit: Use ip_tunnel_key's provided src address
2018-08-06 12:00 [PATCH net-next] ip6_tunnel: collect_md xmit: Use ip_tunnel_key's provided src address Shmulik Ladkani
@ 2018-08-07 19:37 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-08-07 19:37 UTC (permalink / raw)
To: shmulik; +Cc: ast, netdev, shmulik.ladkani
From: Shmulik Ladkani <shmulik@metanetworks.com>
Date: Mon, 6 Aug 2018 15:00:59 +0300
> When using an ip6tnl device in collect_md mode, the xmit methods ignore
> the ipv6.src field present in skb_tunnel_info's key, both for route
> calculation purposes (flowi6 construction) and for assigning the
> packet's final ipv6h->saddr.
>
> This makes it impossible specifying a desired ipv6 local address in the
> encapsulating header (for example, when using tc action tunnel_key).
>
> This is also not aligned with behavior of ipip (ipv4) in collect_md
> mode, where the key->u.ipv4.src gets used.
>
> Fix, by assigning fl6.saddr with given key->u.ipv6.src.
> In case ipv6.src is not specified, ip6_tnl_xmit uses existing saddr
> selection code.
Applied, thanks.
> Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
> Fixes: 8d79266bc48c ("ip6_tunnel: add collect_md mode to IPv6 tunnels")
Please place the Fixes: tag first in the set of tags in the future,
thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-07 21:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-06 12:00 [PATCH net-next] ip6_tunnel: collect_md xmit: Use ip_tunnel_key's provided src address Shmulik Ladkani
2018-08-07 19:37 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox