Skip to contentSkip to conversation

net/ipv4: Set oif in fib_compute_spec_dst

PATCH In review [email protected] 2 participants 2 messages Jul 7, 2018 – Jul 8, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 net/ipv4: Set oif in fib_compute_spec_dst

From: David Ahern <[email protected]>

Xin reported that icmp replies may not use the address on the device the echo request is received if the destination address is broadcast. Instead a route lookup is done without considering VRF context. Fix by setting oif in flow struct to the master device if it is enslaved. That directs the lookup to the VRF table. If the device is not enslaved, oif is still 0 so no affect.

Fixes cd2fbe1b6b51 ("net: Use VRF device index for lookups on RX")
---
 net/ipv4/fib_frontend.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/fib_frontend.c +1 -0
index b21833651394..e46cdd310e5f 100644
@@ -300,6 +300,7 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
 	if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
 		struct flowi4 fl4 = {
 			.flowi4_iif = LOOPBACK_IFINDEX,
+			.flowi4_oif = l3mdev_master_ifindex_rcu(dev),
 			.daddr = ip_hdr(skb)->saddr,
 			.flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
 			.flowi4_scope = scope,
Signature · 1 line
2.11.0
maintainer
#1 lore raw

From: [email protected]
Date: Sat, 7 Jul 2018 16:15:26 -0700

Quoted 9 lines

From: David Ahern <[email protected]>

Xin reported that icmp replies may not use the address on the device the echo request is received if the destination address is broadcast. Instead a route lookup is done without considering VRF context. Fix by setting oif in flow struct to the master device if it is enslaved. That directs the lookup to the VRF table. If the device is not enslaved, oif is still 0 so no affect.

Quoted 3 lines
Fixes cd2fbe1b6b51 ("net: Use VRF device index for lookups on RX")

Applied and queued up for -stable, thanks David.