From c88d216f221e49031f8fa6f924a9b1e8dffa1463 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 9 Jun 2018 13:10:29 -0500 Subject: Show workaround for the kernel bug when ping hits it. Patches were submitted upstream to fix it at https://patchwork.kernel.org/patch/9847017/ and http://lkml.iu.edu/hypermail/linux/kernel/1710.3/04715.html to no effect. --- toys/pending/ping.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/toys/pending/ping.c b/toys/pending/ping.c index 3802918d..c29fb9df 100644 --- a/toys/pending/ping.c +++ b/toys/pending/ping.c @@ -149,8 +149,16 @@ void ping_main(void) // Open DGRAM socket sa->sa_family = ai->ai_family; - TT.sock = xsocket(ai->ai_family, SOCK_DGRAM, - (ai->ai_family == AF_INET) ? IPPROTO_ICMP : IPPROTO_ICMPV6); + TT.sock = socket(ai->ai_family, SOCK_DGRAM, + len = (ai->ai_family == AF_INET) ? IPPROTO_ICMP : IPPROTO_ICMPV6); + if (TT.sock == -1) { + perror_msg("socket SOCK_DGRAM %x", len); + if (errno == EACCES) { + fprintf(stderr, "Kernel bug workaround (as root):\n"); + fprintf(stderr, "echo 0 9999999 > /proc/sys/net/ipv4/ping_group_range\n"); + } + xexit(); + } if (TT.I && bind(TT.sock, sa, sizeof(src_addr))) perror_exit("bind"); if (TT.t) { -- cgit v1.2.3