icmp: Warn on receive errors from ping sockets

Currently we silently ignore an errors receiving a packet from a ping
socket.  We don't expect that to happen, so it's probably worth reporting
if it does.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2024-01-16 16:16:16 +11:00 committed by Stefano Brivio
parent a325121759
commit 6e86511f59

5
icmp.c
View file

@ -81,8 +81,11 @@ void icmp_sock_handler(const struct ctx *c, int af, union epoll_ref ref)
return; return;
n = recvfrom(ref.fd, buf, sizeof(buf), 0, &sr.sa, &sl); n = recvfrom(ref.fd, buf, sizeof(buf), 0, &sr.sa, &sl);
if (n < 0) if (n < 0) {
warn("%s: recvfrom() error on ping socket: %s",
pname, strerror(errno));
return; return;
}
if (af == AF_INET) { if (af == AF_INET) {
struct icmphdr *ih4 = (struct icmphdr *)buf; struct icmphdr *ih4 = (struct icmphdr *)buf;