diff mbox

[net-next] net: Fix vti use case with oif in dst lookups for IPv6

Message ID 56267E80.5030500@cumulusnetworks.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

David Ahern Oct. 20, 2015, 5:48 p.m. UTC
On 10/20/15 6:31 AM, Hajime Tazaki wrote:
> yes, this sendmsg uses non-zero flowi6_oif.
>
>
> the conditions are
>
> - sendmsg () with INET6/RAW socket (with IPPROTO_MH)
> - ip6_pktinfo.ipi6_addr (fl6.saddr) and ipi6_oif
>    (fl6.flowi6_oif) are non-NULL.
> => ipi6_addr (fl6.saddr) is not the IP address of oif, but
>      another interfaces (home address of mip6)

interesting. so forcing a send out of interface X but using the source 
address of interface Y.

Does the attached patch work for you?

Comments

Hajime Tazaki Oct. 21, 2015, 2:38 a.m. UTC | #1
At Tue, 20 Oct 2015 11:48:48 -0600,
David Ahern wrote:

> > the conditions are
> >
> > - sendmsg () with INET6/RAW socket (with IPPROTO_MH)
> > - ip6_pktinfo.ipi6_addr (fl6.saddr) and ipi6_oif
> >    (fl6.flowi6_oif) are non-NULL.
> > => ipi6_addr (fl6.saddr) is not the IP address of oif, but
> >      another interfaces (home address of mip6)
> 
> interesting. so forcing a send out of interface X but using the source 
> address of interface Y.
> 
> Does the attached patch work for you?

this patch works fine for the above case.
other tests of mine are also fine.

many thanks !

-- Hajime
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d0619632723a..2701cb3d88e9 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1171,6 +1171,7 @@  struct dst_entry *ip6_route_output(struct net *net, const struct sock *sk,
 {
 	struct dst_entry *dst;
 	int flags = 0;
+	bool any_src;
 
 	dst = l3mdev_rt6_dst_by_oif(net, fl6);
 	if (dst)
@@ -1178,11 +1179,12 @@  struct dst_entry *ip6_route_output(struct net *net, const struct sock *sk,
 
 	fl6->flowi6_iif = LOOPBACK_IFINDEX;
 
+	any_src = ipv6_addr_any(&fl6->saddr);
 	if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr) ||
-	    fl6->flowi6_oif)
+	    (fl6->flowi6_oif && any_src))
 		flags |= RT6_LOOKUP_F_IFACE;
 
-	if (!ipv6_addr_any(&fl6->saddr))
+	if (!any_src)
 		flags |= RT6_LOOKUP_F_HAS_SADDR;
 	else if (sk)
 		flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs);