]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
ping: fix the dif and sdif check in ping_lookup
authorXin Long <lucien.xin@gmail.com>
Wed, 16 Feb 2022 05:20:52 +0000 (00:20 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 14 Apr 2022 09:32:21 +0000 (11:32 +0200)
commitc28e39e21a57ff43bf09d8899fda1cd526e9a08c
tree41584b240b3d0d605767b0402dac7bad95f509a4
parent3cbee2648ce825c00f1ccb096cfa24dfd570ab24
ping: fix the dif and sdif check in ping_lookup

BugLink: https://bugs.launchpad.net/bugs/1967582
commit 35a79e64de29e8d57a5989aac57611c0cd29e13e upstream.

When 'ping' changes to use PING socket instead of RAW socket by:

   # sysctl -w net.ipv4.ping_group_range="0 100"

There is another regression caused when matching sk_bound_dev_if
and dif, RAW socket is using inet_iif() while PING socket lookup
is using skb->dev->ifindex, the cmd below fails due to this:

  # ip link add dummy0 type dummy
  # ip link set dummy0 up
  # ip addr add 192.168.111.1/24 dev dummy0
  # ping -I dummy0 192.168.111.1 -c1

The issue was also reported on:

  https://github.com/iputils/iputils/issues/104

But fixed in iputils in a wrong way by not binding to device when
destination IP is on device, and it will cause some of kselftests
to fail, as Jianlin noticed.

This patch is to use inet(6)_iif and inet(6)_sdif to get dif and
sdif for PING socket, and keep consistent with RAW socket.

Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
Reported-by: Jianlin Shi <jishi@redhat.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: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/ipv4/ping.c