aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2017-09-13 20:11:37 -0400
committerDavid S. Miller <davem@davemloft.net>2017-09-15 17:27:51 -0400
commitcbea8f02069533ea2ad4e5b3bfbcdb0894c20354 (patch)
tree76214a42f705f5c745b735046942b6e672fdbcf8 /net
parent2aa70f864955bf02362e3fb3008e4208d7a17a98 (diff)
net: ipv4: fix l3slave check for index returned in IP_PKTINFO
rt_iif is only set to the actual egress device for the output path. The recent change to consider the l3slave flag when returning IP_PKTINFO works for local traffic (the correct device index is returned), but it broke the more typical use case of packets received from a remote host always returning the VRF index rather than the original ingress device. Update the fixup to consider l3slave and rt_iif actually getting set. Fixes: 1dfa76390bf05 ("net: ipv4: add check for l3slave for index returned in IP_PKTINFO") Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_sockglue.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index e558e4f9597b..a599aa83fdad 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1207,7 +1207,6 @@ e_inval:
1207void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb) 1207void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1208{ 1208{
1209 struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb); 1209 struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
1210 bool l3slave = ipv4_l3mdev_skb(IPCB(skb)->flags);
1211 bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) || 1210 bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
1212 ipv6_sk_rxinfo(sk); 1211 ipv6_sk_rxinfo(sk);
1213 1212
@@ -1221,8 +1220,13 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1221 * (e.g., process binds socket to eth0 for Tx which is 1220 * (e.g., process binds socket to eth0 for Tx which is
1222 * redirected to loopback in the rtable/dst). 1221 * redirected to loopback in the rtable/dst).
1223 */ 1222 */
1224 if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX || l3slave) 1223 struct rtable *rt = skb_rtable(skb);
1224 bool l3slave = ipv4_l3mdev_skb(IPCB(skb)->flags);
1225
1226 if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX)
1225 pktinfo->ipi_ifindex = inet_iif(skb); 1227 pktinfo->ipi_ifindex = inet_iif(skb);
1228 else if (l3slave && rt && rt->rt_iif)
1229 pktinfo->ipi_ifindex = rt->rt_iif;
1226 1230
1227 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb); 1231 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
1228 } else { 1232 } else {