Patch "net: ipv4: Make "ip route get" match iif lo rules again." has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
net: ipv4: Make "ip route get" match iif lo rules again.
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
net-ipv4-make-ip-route-get-match-iif-lo-rules-again.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Sun Jan 28 17:35:08 CET 2018
From: Lorenzo Colitti <[email protected]>
Date: Thu, 11 Jan 2018 18:36:26 +0900
Subject: net: ipv4: Make "ip route get" match iif lo rules again.
From: Lorenzo Colitti <[email protected]>
[ Upstream commit 6503a30440962f1e1ccb8868816b4e18201218d4 ]
Commit 3765d35ed8b9 ("net: ipv4: Convert inet_rtm_getroute to rcu versions of route lookup") broke "ip route get" in the presence of rules that specify iif lo.
Host-originated traffic always has iif lo, because ip_route_output_key_hash and ip6_route_output_flags set the flow iif to LOOPBACK_IFINDEX. Thus, putting "iif lo" in an ip rule is a convenient way to select only originated traffic and not forwarded traffic.
inet_rtm_getroute used to match these rules correctly because even though it sets the flow iif to 0, it called ip_route_output_key which overwrites iif with LOOPBACK_IFINDEX. But now that it calls ip_route_output_key_hash_rcu, the ifindex will remain 0 and not match the iif lo in the rule. As a result, "ip route get" will return ENETUNREACH.
Tested: https://android.googlesource.com/kernel/tests/+/master/net/test/multinetwork_test.py passes again
--- net/ipv4/route.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/route.c +1 -0
@@ -2762,6 +2762,7 @@ static int inet_rtm_getroute(struct sk_bif (err ==0 && rt->dst.error) err = -rt->dst.error; }else { + fl4.flowi4_iif =LOOPBACK_IFINDEX ; rt =ip_route_output_key_hash_rcu (net, &fl4, &res, skb); err =0 ;if (IS_ERR (rt))
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/net-ipv4-make-ip-route-get-match-iif-lo-rules-again.patch