Skip to contentSkip to conversation

net: ipv4: fix multipath RTM_GETROUTE behavior when iif is given

PATCH In review Florian Larysch 3 participants 4 messages Apr 3, 2017 – Apr 6, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ipv4: fix multipath RTM_GETROUTE behavior when iif is given

inet_rtm_getroute synthesizes a skeletal ICMP skb, which is passed to ip_route_input when iif is given. If a multipath route is present for the designated destination, ip_multipath_icmp_hash ends up being called, which uses the source/destination addresses within the skb to calculate a hash. However, those are not set in the synthetic skb, causing it to return an arbitrary and incorrect result.

Instead, use UDP, which gets no such special treatment.

---
 net/ipv4/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
index 8471dd116771..acd69cfe2951 100644
@@ -2620,7 +2620,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 	skb_reset_network_header(skb);
 
 	/* Bugfix: need to give ip_route_input enough of an IP header to not gag. */
-	ip_hdr(skb)->protocol = IPPROTO_ICMP;
+	ip_hdr(skb)->protocol = IPPROTO_UDP;
 	skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr));
 
 	src = tb[RTA_SRC] ? nla_get_in_addr(tb[RTA_SRC]) : 0;
Signature · 1 line
2.12.0
#1 lore raw
Quoted 3 lines · Florian Larysch

inet_rtm_getroute synthesizes a skeletal ICMP skb, which is passed to ip_route_input when iif is given. If a multipath route is present for the designated destination, ip_multipath_icmp_hash ends up being called,

that function no longer exists since Nik's recent work (bf4e0a3db97eb882368fd82980b3b1fa0b5b9778)

So does the problem you noted still exist?

#2 lore raw
Quoted 2 lines · David Ahern

that function no longer exists since Nik's recent work (bf4e0a3db97eb882368fd82980b3b1fa0b5b9778)

Didn't notice that as I was looking at Linus' tree. Thanks.

Quoted 1 line

So does the problem you noted still exist?

Yes. And in fact, that change invalidates the fix I proposed. I'll submit something new for net-next.

Florian

maintainer
#3 lore raw
In reply to Florian Larysch

From: Florian Larysch <[email protected]>
Date: Mon, 3 Apr 2017 16:46:09 +0200

Quoted 10 lines

inet_rtm_getroute synthesizes a skeletal ICMP skb, which is passed to ip_route_input when iif is given. If a multipath route is present for the designated destination, ip_multipath_icmp_hash ends up being called, which uses the source/destination addresses within the skb to calculate a hash. However, those are not set in the synthetic skb, causing it to return an arbitrary and incorrect result.

Instead, use UDP, which gets no such special treatment.

Applied and queued up for -stable.

Please submit the net-next variant you mentioned, thank you.