netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Forcing the output interface using ip6_route_output doesn't work
@ 2015-09-25 13:56 Wolfgang Nothdurft
  2015-09-25 21:13 ` David Ahern
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Nothdurft @ 2015-09-25 13:56 UTC (permalink / raw)
  To: netdev

It seems that the ip6_route_output(net, sk, fl6) kernel function ignores 
the fl6.flowi6_oif parameter for the routing decision.

Is this intended?
Should it possible to force the output device for ipv6 routing just as 
for ipv4?

Here the example shown with the ip command:

With ipv4, I'm able to get the default route when using oif (force the 
output interface).

# ip r

default via 192.168.0.1 dev enp3s0 proto static
192.0.2.0/24 dev enp2s0 proto kernel scope link src 192.0.2.163
192.168.0.0/24 dev enp3s0 proto kernel scope link src 192.168.0.163

# ip r get 192.0.2.10
192.0.2.10 dev enp2s0  src 192.0.2.163
     cache

# ip r get 192.0.2.10 oif enp3s0
192.0.2.10 via 192.168.0.1 dev enp3s0  src 192.168.0.163
     cache

With ipv6, ip -6 route get always returns the specific route.

# ip -6 r
2001:db8:e2::1 dev enp2s0  proto kernel  metric 256
2001:db8:e2::/64 dev enp2s0  metric 1024
2001:db8:e3::1 dev enp3s0  proto kernel  metric 256
2001:db8:e3::/64 dev enp3s0  metric 1024
fe80::/64 dev enp3s0  proto kernel  metric 256
default via 2001:db8:e3::255 dev enp3s0  metric 1024

ip -6 r get 2001:db8:e2::100
2001:db8:e2::100 from :: dev enp2s0  src 2001:db8:e3::1  metric 0
     cache

# ip -6 r get 2001:db8:e2::100 oif enp3s0
2001:db8:e2::100 from :: dev enp2s0  src 2001:db8:e3::1  metric 0
     cache

The detailed problem is described here, because I got the problem 
initially when trying a ipsec Host-2-Host connection with libreswan/klips.

https://bugs.libreswan.org/show_bug.cgi?id=237

Thanks
Wolfgang

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Forcing the output interface using ip6_route_output doesn't work
  2015-09-25 13:56 Forcing the output interface using ip6_route_output doesn't work Wolfgang Nothdurft
@ 2015-09-25 21:13 ` David Ahern
  2015-09-26 15:51   ` Wolfgang Nothdurft
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2015-09-25 21:13 UTC (permalink / raw)
  To: Wolfgang Nothdurft, netdev

[-- Attachment #1: Type: text/plain, Size: 286 bytes --]

On 9/25/15 7:56 AM, Wolfgang Nothdurft wrote:
> It seems that the ip6_route_output(net, sk, fl6) kernel function ignores
> the fl6.flowi6_oif parameter for the routing decision.

It is considered, but a mismatch is not considered fatal.

I think the attached should fix your problem.



[-- Attachment #2: ip6-rt-get-with-oif.patch --]
[-- Type: text/plain, Size: 503 bytes --]

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 118f8fa1a809..cc52458f7226 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1169,7 +1169,8 @@ struct dst_entry *ip6_route_output(struct net *net, const struct sock *sk,
 
 	fl6->flowi6_iif = LOOPBACK_IFINDEX;
 
-	if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr))
+	if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr) ||
+	     fl6->flowi6_oif)
 		flags |= RT6_LOOKUP_F_IFACE;
 
 	if (!ipv6_addr_any(&fl6->saddr))

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Forcing the output interface using ip6_route_output doesn't work
  2015-09-25 21:13 ` David Ahern
@ 2015-09-26 15:51   ` Wolfgang Nothdurft
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Nothdurft @ 2015-09-26 15:51 UTC (permalink / raw)
  To: David Ahern, netdev

Am 25.09.2015 um 23:13 schrieb David Ahern:
> On 9/25/15 7:56 AM, Wolfgang Nothdurft wrote:
>> It seems that the ip6_route_output(net, sk, fl6) kernel function ignores
>> the fl6.flowi6_oif parameter for the routing decision.
>
> It is considered, but a mismatch is not considered fatal.
>
> I think the attached should fix your problem.
>
>

Thanks, now it works as expected. :)

Wolfgang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-26 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-25 13:56 Forcing the output interface using ip6_route_output doesn't work Wolfgang Nothdurft
2015-09-25 21:13 ` David Ahern
2015-09-26 15:51   ` Wolfgang Nothdurft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).