]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ping: fix the sk_bound_dev_if match in ping_lookup
authorXin Long <lucien.xin@gmail.com>
Sat, 22 Jan 2022 11:40:56 +0000 (06:40 -0500)
committerPaolo Pisati <paolo.pisati@canonical.com>
Thu, 3 Feb 2022 09:28:50 +0000 (10:28 +0100)
commitccf187e55d9658a936179adc2da8b02e0e8b0f86
tree552cca38f0b2ef41e0f0f392180c859545cf652b
parentb07c8f46e3daf7f1431290f27f11c0ab1399f037
ping: fix the sk_bound_dev_if match in ping_lookup

BugLink: https://bugs.launchpad.net/bugs/1959879
commit 2afc3b5a31f9edf3ef0f374f5d70610c79c93a42 upstream.

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: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
Reported-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
net/ipv4/ping.c