OSDN Git Service

net: ipv4: add check for l3slave for index returned in IP_PKTINFO
authorDavid Ahern <dsahern@gmail.com>
Sat, 12 Aug 2017 00:11:15 +0000 (17:11 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 Aug 2017 03:05:13 +0000 (20:05 -0700)
Similar to the loopback device, for packets sent through a VRF device
the index returned in ipi_ifindex needs to be the saved index in
rt_iif.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_sockglue.c

index dd68a9e..e558e4f 100644 (file)
@@ -1207,6 +1207,7 @@ e_inval:
 void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
 {
        struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
+       bool l3slave = ipv4_l3mdev_skb(IPCB(skb)->flags);
        bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
                       ipv6_sk_rxinfo(sk);
 
@@ -1220,7 +1221,7 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
                 * (e.g., process binds socket to eth0 for Tx which is
                 * redirected to loopback in the rtable/dst).
                 */
-               if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX)
+               if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX || l3slave)
                        pktinfo->ipi_ifindex = inet_iif(skb);
 
                pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);