Skip to content

Commit 1dfa763

Browse files
dsaherndavem330
authored andcommitted
net: ipv4: add check for l3slave for index returned in IP_PKTINFO
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4f04256 commit 1dfa763

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/ip_sockglue.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
12071207
void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
12081208
{
12091209
struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
1210+
bool l3slave = ipv4_l3mdev_skb(IPCB(skb)->flags);
12101211
bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
12111212
ipv6_sk_rxinfo(sk);
12121213

@@ -1220,7 +1221,7 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
12201221
* (e.g., process binds socket to eth0 for Tx which is
12211222
* redirected to loopback in the rtable/dst).
12221223
*/
1223-
if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX)
1224+
if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX || l3slave)
12241225
pktinfo->ipi_ifindex = inet_iif(skb);
12251226

12261227
pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);

0 commit comments

Comments
 (0)