summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2008-08-24 00:02:18 +0000
committerDenis Vlasenko2008-08-24 00:02:18 +0000
commit577071558802573119ad5e0695dc6263d81a06fb (patch)
treef0d8fea7343fc1d691e9fcd787b1e7d080c7b62d
parent15f2fdb2b9ba0d397babe0922ae28f84e91505f9 (diff)
downloadbusybox-577071558802573119ad5e0695dc6263d81a06fb.zip
busybox-577071558802573119ad5e0695dc6263d81a06fb.tar.gz
ping: SO_RCVBUF must be bigger than packet size,
otherwise large ping packets might fail to be received.
-rw-r--r--networking/ping.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/networking/ping.c b/networking/ping.c
index 5def8c3..7cccfbf 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -576,8 +576,9 @@ static void ping4(len_and_sockaddr *lsa)
/* enable broadcast pings */
setsockopt_broadcast(pingsock);
- /* set recv buf for broadcast pings */
- sockopt = 48 * 1024; /* explain why 48k? */
+ /* set recv buf (needed if we can get lots of responses: flood ping,
+ * broadcast ping etc) */
+ sockopt = (datalen * 2) + 7 * 1024; /* giving it a bit of extra room */
setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt));
signal(SIGINT, print_stats_and_exit);
@@ -640,8 +641,9 @@ static void ping6(len_and_sockaddr *lsa)
/* enable broadcast pings */
setsockopt_broadcast(pingsock);
- /* set recv buf for broadcast pings */
- sockopt = 48 * 1024; /* explain why 48k? */
+ /* set recv buf (needed if we can get lots of responses: flood ping,
+ * broadcast ping etc) */
+ sockopt = (datalen * 2) + 7 * 1024; /* giving it a bit of extra room */
setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt));
sockopt = offsetof(struct icmp6_hdr, icmp6_cksum);