From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Stefano Brivio <sbrivio@redhat.com>,
Marcelo Ricardo Leitner <mleitner@redhat.com>,
David Ahern <dsahern@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCH net] ipv4/route: do not check saddr dev if iif is LOOPBACK_IFINDEX
Date: Thu, 1 Aug 2019 16:29:00 +0800 [thread overview]
Message-ID: <20190801082900.27216-1-liuhangbin@gmail.com> (raw)
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
While IPv6 would get the default route
\# ip -6 route get 1111::1 from 2222::2
1111::1 from 2222::2 via fe80:52:0:4982::1fe dev eth0 proto ra src \
2620::2cf:e2ff:fe40:37 metric 1024 hoplimit 64 pref medium
Fix it by disabling the __ip_dev_find() check if iif is LOOPBACK_IFINDEX.
Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.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 517300d587a7..1be78e8f9e3c 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2512,7 +2512,8 @@ struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
goto make_route;
}
- if (!(fl4->flowi4_flags & FLOWI_FLAG_ANYSRC)) {
+ if (!(fl4->flowi4_flags & FLOWI_FLAG_ANYSRC) &&
+ fl4->flowi4_iif != LOOPBACK_IFINDEX) {
/* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
if (!__ip_dev_find(net, fl4->saddr, false))
goto out;
--
2.19.2
next reply other threads:[~2019-08-01 8:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 8:29 Hangbin Liu [this message]
2019-08-01 19:51 ` [PATCH net] ipv4/route: do not check saddr dev if iif is LOOPBACK_IFINDEX David Ahern
2019-08-02 4:13 ` Hangbin Liu
2019-08-02 4:16 ` David Ahern
2019-08-12 3:49 ` David Miller
2019-08-12 22:58 ` Stefano Brivio
2019-08-13 0:23 ` David Ahern
2019-08-02 20:35 ` Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190801082900.27216-1-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=mleitner@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).