netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: Do not drop to make_route if oif is l3mdev
@ 2015-10-07 15:40 David Ahern
  2015-10-08 12:19 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: David Ahern @ 2015-10-07 15:40 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, David Ahern

Commit deaa0a6a930 ("net: Lookup actual route when oif is VRF device")
exposed a bug in __ip_route_output_key_hash for VRF devices: on FIB lookup
failure if the oif is specified the current logic drops to make_route on
the assumption that the route tables are wrong. For VRF/L3 master devices
this leads to wrong dst entries and route lookups. For example:
    $ ip route ls table vrf-red
    unreachable default
    broadcast 10.2.1.0 dev eth1  proto kernel  scope link  src 10.2.1.2
    10.2.1.0/24 dev eth1  proto kernel  scope link  src 10.2.1.2
    local 10.2.1.2 dev eth1  proto kernel  scope host  src 10.2.1.2
    broadcast 10.2.1.255 dev eth1  proto kernel  scope link  src 10.2.1.2

    $ ip route get oif vrf-red 1.1.1.1
    1.1.1.1 dev vrf-red  src 10.0.0.2
        cache

With this patch:
    $  ip route get oif vrf-red 1.1.1.1
    RTNETLINK answers: No route to host

which is the correct response based on the default route

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
 net/ipv4/route.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index bf1486bd7e81..f10ad88bfb89 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2196,7 +2196,8 @@ struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
 	if (err) {
 		res.fi = NULL;
 		res.table = NULL;
-		if (fl4->flowi4_oif) {
+		if (fl4->flowi4_oif &&
+		    !netif_index_is_l3_master(net, fl4->flowi4_oif)) {
 			/* Apparently, routing tables are wrong. Assume,
 			   that the destination is on link.
 
-- 
1.9.1

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

* Re: [PATCH net-next] net: Do not drop to make_route if oif is l3mdev
  2015-10-07 15:40 [PATCH net-next] net: Do not drop to make_route if oif is l3mdev David Ahern
@ 2015-10-08 12:19 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-10-08 12:19 UTC (permalink / raw)
  To: dsa; +Cc: netdev, dsahern

From: David Ahern <dsa@cumulusnetworks.com>
Date: Wed,  7 Oct 2015 08:40:13 -0700

> Commit deaa0a6a930 ("net: Lookup actual route when oif is VRF device")
> exposed a bug in __ip_route_output_key_hash for VRF devices: on FIB lookup
> failure if the oif is specified the current logic drops to make_route on
> the assumption that the route tables are wrong. For VRF/L3 master devices
> this leads to wrong dst entries and route lookups. For example:
>     $ ip route ls table vrf-red
>     unreachable default
>     broadcast 10.2.1.0 dev eth1  proto kernel  scope link  src 10.2.1.2
>     10.2.1.0/24 dev eth1  proto kernel  scope link  src 10.2.1.2
>     local 10.2.1.2 dev eth1  proto kernel  scope host  src 10.2.1.2
>     broadcast 10.2.1.255 dev eth1  proto kernel  scope link  src 10.2.1.2
> 
>     $ ip route get oif vrf-red 1.1.1.1
>     1.1.1.1 dev vrf-red  src 10.0.0.2
>         cache
> 
> With this patch:
>     $  ip route get oif vrf-red 1.1.1.1
>     RTNETLINK answers: No route to host
> 
> which is the correct response based on the default route
> 
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>

Applied, thanks.

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

end of thread, other threads:[~2015-10-08 12:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-07 15:40 [PATCH net-next] net: Do not drop to make_route if oif is l3mdev David Ahern
2015-10-08 12:19 ` David Miller

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).