diff options
author | 2001-10-03 19:36:49 +0000 | |
---|---|---|
committer | 2001-10-03 19:36:49 +0000 | |
commit | 3f945d7e2df0df0242beb552020c359e55507c6b (patch) | |
tree | 7b743d7b96c318aa3a17ae6920b6af36f861e7f5 | |
parent | build apm and apmd on macppc (diff) | |
download | wireguard-openbsd-3f945d7e2df0df0242beb552020c359e55507c6b.tar.xz wireguard-openbsd-3f945d7e2df0df0242beb552020c359e55507c6b.zip |
try to increase receive buffer size, <ft@pi.se>. ok deraadt@
-rw-r--r-- | sbin/ping/ping.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 0f2cd1f7121..e8a933d9696 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.44 2001/01/12 20:07:05 deraadt Exp $ */ +/* $OpenBSD: ping.c,v 1.45 2001/10/03 19:36:49 jakob Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: ping.c,v 1.44 2001/01/12 20:07:05 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ping.c,v 1.45 2001/10/03 19:36:49 jakob Exp $"; #endif #endif /* not lint */ @@ -170,6 +170,9 @@ quad_t tsumsq = 0; /* sum of all times squared, for std. dev. */ int reset_kerninfo; #endif +#define DEFAULT_BUFSPACE 60*1024 /* default read buffer size */ +int bufspace = DEFAULT_BUFSPACE; + void fill __P((char *, char *)); void catcher(), prtsig(), finish(), summary(int); int in_cksum __P((u_short *, int)); @@ -459,7 +462,14 @@ main(argc, argv) * ethernet, or just want to fill the arp cache to get some stuff for * /etc/ethers. */ - (void)setsockopt(s, SOL_SOCKET, SO_RCVBUF, &packlen, sizeof(packlen)); + while (setsockopt(s, SOL_SOCKET, SO_RCVBUF, + (void*)&bufspace, sizeof(bufspace)) < 0) { + if ((bufspace -= 1024) <= 0) + err(1, "Cannot set the receive buffer size"); + } + if (bufspace < DEFAULT_BUFSPACE) + warnx("Could only allocate a receive buffer of %i bytes (default %i)\n", + bufspace, DEFAULT_BUFSPACE); if (to->sin_family == AF_INET) (void)printf("PING %s (%s): %d data bytes\n", hostname, |