Subject: Re: [PATCH net] ipv4/route: do not check saddr dev if iif is LOOPBACK_IFINDEX

From: Stefano Brivio <[email-masked]>
Date: Fri, 2 Aug 2019 22:35:49 +0200

David,

On Thu, 1 Aug 2019 13:51:25 -0600
David Ahern <[email-masked]> wrote:

> On 8/1/19 2:29 AM, Hangbin Liu wrote:
> > Jianlin reported a bug that for IPv4, ip route get from src_addr would fail
> > if src_addr is not an address on local system.
> > 
> > \# ip route get 1.1.1.1 from 2.2.2.2
> > RTNETLINK answers: Invalid argument  
> 
> so this is a forwarding lookup in which case iif should be set.

On actual forwarding, yes, it will be set.

But if we are just doing a lookup for a route (iif is
LOOPBACK_IFINDEX), I think this should still give us the matching route,
which is what IPv6 already does and what this patch fixes for IPv4.

Otherwise, we have no way to fetch that route, no matter if source
routing is configured. So I think this patch is correct and to some
extent necessary.

-- 
Stefano