Skip to content

Commit 2afc3b5

Browse files
lxindavem330
authored andcommitted
ping: fix the sk_bound_dev_if match in ping_lookup
When 'ping' changes to use PING socket instead of RAW socket by: # sysctl -w net.ipv4.ping_group_range="0 100" the selftests 'router_broadcast.sh' will fail, as such command # ip vrf exec vrf-h1 ping -I veth0 198.51.100.255 -b can't receive the response skb by the PING socket. It's caused by mismatch of sk_bound_dev_if and dif in ping_rcv() when looking up the PING socket, as dif is vrf-h1 if dif's master was set to vrf-h1. This patch is to fix this regression by also checking the sk_bound_dev_if against sdif so that the packets can stil be received even if the socket is not bound to the vrf device but to the real iif. Fixes: c319b4d ("net: ipv4: add IPPROTO_ICMP socket kind") Reported-by: Hangbin Liu <[email protected]> Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c0bf3d8 commit 2afc3b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/ping.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident)
220220
continue;
221221
}
222222

223-
if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)
223+
if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif &&
224+
sk->sk_bound_dev_if != inet_sdif(skb))
224225
continue;
225226

226227
sock_hold(sk);

0 commit comments

Comments
 (0)