mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 16:54:21 +00:00 
			
		
		
		
	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, fib_multipath_hash ends up being called with that skb. However, as that skb contains no information beyond the protocol type, the calculated hash does not match the one we would see for a real packet. There is currently no way to fix this for layer 4 hashing, as RTM_GETROUTE doesn't have the necessary information to create layer 4 headers. To fix this for layer 3 hashing, set appropriate saddr/daddrs in the skb and also change the protocol to UDP to avoid special treatment for ICMP. Signed-off-by: Florian Larysch <fl@n621.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									6f551bd5fb
								
							
						
					
					
						commit
						bbadb9a222
					
				
					 1 changed files with 9 additions and 4 deletions
				
			
		|  | @ -2667,10 +2667,6 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh) | |||
| 	skb_reset_mac_header(skb); | ||||
| 	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; | ||||
| 	skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr)); | ||||
| 
 | ||||
| 	src = tb[RTA_SRC] ? nla_get_in_addr(tb[RTA_SRC]) : 0; | ||||
| 	dst = tb[RTA_DST] ? nla_get_in_addr(tb[RTA_DST]) : 0; | ||||
| 	iif = tb[RTA_IIF] ? nla_get_u32(tb[RTA_IIF]) : 0; | ||||
|  | @ -2680,6 +2676,15 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh) | |||
| 	else | ||||
| 		uid = (iif ? INVALID_UID : current_uid()); | ||||
| 
 | ||||
| 	/* Bugfix: need to give ip_route_input enough of an IP header to
 | ||||
| 	 * not gag. | ||||
| 	 */ | ||||
| 	ip_hdr(skb)->protocol = IPPROTO_UDP; | ||||
| 	ip_hdr(skb)->saddr = src; | ||||
| 	ip_hdr(skb)->daddr = dst; | ||||
| 
 | ||||
| 	skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr)); | ||||
| 
 | ||||
| 	memset(&fl4, 0, sizeof(fl4)); | ||||
| 	fl4.daddr = dst; | ||||
| 	fl4.saddr = src; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Florian Larysch
						Florian Larysch