aboutsummaryrefslogtreecommitdiff
path: root/src/net.c
AgeCommit message (Collapse)Author
2018-02-12Make --cport work without --bind (#697).Bruce A. Mah
This commit also adds SCTP support for --cport. Fixes #616.
2018-01-26Fix large values of -p on FreeBSD by setting a large listen(2) backlog. (#693)Bruce A. Mah
Might be useful for other platforms as well (no effects on Linux because the semantics of listen(2) are subtly different there). Submitted by Matt Macy. Fixes #691.
2017-11-14Add missing saved_errno dance around some close(2) calls. (#669)Todd C. Miller
2017-11-14Remove unused functions (#668)Todd C. Miller
Namely, getsock_tcp_mss(), set_tcp_options() and iperf_test_reset(). Also fix a typo in the libiperf manual; iperf_test_reset() was listed instead of iperf_reset_test().
2017-11-08Fix 3.3 build warnings (#664)Philip Prindeville
* Fix warnings about _GNU_SOURCE being redefined. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> * Fix warnings of format-specified mismatching type Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> * Simplify endianness checks Linux can be built with too many types of C run-time library and it's not reasonable to have to enumerate all of them, especially since at least one of them (MUSL) goes out of its way to not be easily detectable. Instead, leverage autoconf better for Linux/BSD to detect either <endian.h> or <sys/endian.h> directly. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> * Sys headers should not be included directly There's usually a top-level header which then includes the sys/ descendent. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-05-23Fix another compiler warning.Bruce A. Mah
2017-05-17Issue 216 (#581)Bruce A. Mah
* Add configurable timeout for the setup of the control connection. This is specified using the new --connect-timeout option, with an integer parameter in ms. The iperf3 client will wait for this amount of time for the setup of the control connection to the server. If this option is not given, the OS default for TCP connection setup is used. Specifying a smaller connection timeout allows faster detection of a down / unresponsive iperf3 server. The implementation uses a variation on the timeout_connect() function from OpenBSD's netcat utility. Fixes #216.
2015-09-19Fixes a smashing stack problem as described in ↵Matthieu Coudron
https://bugzilla.kernel.org/show_bug.cgi?id=104601
2015-05-21Handle the case where EAGAIN != EWOULDBLOCKBruce A. Mah
Fixes #268, suggested by @tvastri.
2015-01-02Merge branch 'candlerb-multisend' of https://github.com/candlerb/iperf into ↵Bruce A. Mah
candlerb-candlerb-multisend
2014-12-23Drop out of multisend loop if none of the streams are accepting dataBrian Candler
2014-12-22Fix calculation of sendfile throughput on OSXBrian Candler
Note that sendfile can return -1 for EINTR whilst having already sent partial results; these were not being counted previously.
2014-09-29Update license and copyright text to conform to LBNL standards.Bruce A. Mah
Note that the license remains a 3-clause BSD license; the only license changes were to add the name of the program and to add some punctuation.
2014-09-15specify client-side port: UDP supportKevin Constantine
--cport can be specified for udp connections Signed-off-by: Kevin Constantine <kevin.constantine@gmail.com>
2014-06-16Don't try to do IPV6_V6ONLY on OpenBSD either.Bruce A. Mah
setsockopt(3) returns an error if passing 0 to this option (which we do if no address family is specified when we bind to the wildcard address, say by invoking "iperf3 -s" with no other options). This is because OpenBSD explicitly does not support IPv4-mapped addresses, so even though the IPV6_V6ONLY socket options exists, it only works with a non-zero argument. Fixes #196.
2014-07-21Only do the IPV6_V6ONLY setsockopt(3) stuff if that option is available.Bruce A. Mah
Should fix #177, in which compilation failed on older Solaris systems that didn't have it. This is a different approach than a patch suggested in that issue. Weakly regression-tested on other platforms (test this by specifying -6, -4, or neither to the server when binding to the wildcard address, and seeing if a client can connect with various of -6, -4, or neither).
2014-07-17Fix a problem with binding to the wildcard address.Bruce A. Mah
On CentOS 6 and MacOS, if no address family was specified, we'd get back an IPv4 address from getaddrinfo(3), with the result that we couldn't accept IPv6 connections in the default server configuration. There was an earlier attempt at fixing this problem that caused Issue #193. This change is a follow-up fix to that issue. While here, put lots of comments around the fix so we remember why we're doing these shenanigans.
2014-07-17Fix two related bugs with -B and IPv4 addresses.Bruce A. Mah
If specifying -B with an IPv4 literal address or with an FQDN that resolved to an IPv4 address, but we had not explicitly specified an address family with -4, we failed to set up the socket correctly because we assumed binding to an IPv6 address, and instead (after some error spewage) wound up binding to wildcard address. The fix in this commit has multiple parts: First, if the address family hasn't been explictly specified, don't force AF_INET6 in the hints to getaddrinfo(3). AF_UNSPEC should generate the correct (according to RFC 6724) behavior. Second, iperf_reset_test() should not discard members that were passed from command-line parameters, because that alters the behavior of the iperf3 when it tries to recreate the listening socket. In the failure situation described in this issue (and possibly other as well), the value of -B gets discarded, so on subsequent attempts to set up the listening socket it just binds to the wildcard address. While here, fix on-line help related to the -B option to match reality. Note that we're not completely in compliance with RFC 6724, which states that we should actually try all of the addresses in returned by getaddrinfo(3), rather than just the first one. Fixes Issue #193.
2014-05-05fix sendfile ifdef checkcarlsborg
2014-04-16Commit a version of the patch for #125 for testing.Bruce A. Mah
Originally submitted by: @i2aaron
2014-04-15Fix build on systems without sendfile(2).Bruce A. Mah
Tested on: OpenBSD 5.4
2014-04-14Fix potential compile error observed on MacOS 10.8.Bruce A. Mah
2014-04-14Better sendfile / zerocopy detection.Bruce A. Mah
There's still a bunch of OS-dependent fu because every platform that supports sendfile(2) does it differently.
2013-12-18Make "iperf3 -s" accept both IPv4 and IPv6 connections on FreeBSD.Bruce A. Mah
(Formerly it was just accepting IPv6.) The problem here was that FreeBSD by default wasn't allowing IPv4 mapped addresses on IPv6 sockets, whereas other platforms (specifically Linux and OS X) both do permit this. We tried to turn on mapped addresses via a setsockopt(IPV6_V6ONLY) call, but this call was broken because the level argument was incorrect. We didn't know about this because we never checked the return value. Fix this by providing the correct argument to setsockopt(). Add some error checking to this and one other setsockopt() call, so we at least don't fail silently in similar situations. Issue: 126 (FreeBSD: iperf3 -s only accepts IPv6 connections)
2013-12-12Better error checking in net.cJef Poskanzer
2013-11-09Fixed some memory & fd leaks in error cases of various network setupJef Poskanzer
routines.
2013-08-19Crash fix from Aaron Brown.Jef Poskanzer
2013-06-07Better ifdefs for sendfile on OS/X.Jef Poskanzer
2013-06-07Added an ifdef for Mac OS/X version, to better protect the sendfile code.Jef Poskanzer
2013-03-29Dual-stack operation - IPv4 and IP46 in the same server.Jef Poskanzer
Also added -4 flag to force IPv4.
2013-03-12Improved setnonblocking() to set the flag on or off instead of just on.Jef Poskanzer
2013-03-04Slight change to net.c routines to better handle writes/sendfilesJef Poskanzer
to a full socket.
2013-03-04A bunch of changes mixed together in this commit, but the significantJef Poskanzer
one is the new -Z flag. - Fixed potential bug in net.c's Nread and Nwrite routines. If they had ever needed to loop they would have read/written the wrong address, due to incorrect pointer arithmetic - sizeof(void) is not 1. Fix was to change the type of the buffer pointer to char*, which also meant adding casts to some callers. - Better checking for conflicts between command-line flags - now they should no longer be order-dependent. - Added a new -Z / --zerocopy flag, to use a "zero copy" method of sending data, such as sendfile(2) instead of the usual write(2). - Renumbered error enum to make inserting new ones easier.
2013-02-28Improved version of setnonblocking() - still not used.Jef Poskanzer
2013-02-22Added "burst mode" to send a bunch of packets in a row withoutJef Poskanzer
intervening select() calls. This increases performance quite a bit.
2012-12-13Allow API client to provide an fd for the client-side control socket.Jef Poskanzer
2012-12-11Switched to using a new timer package, adapted from thttpd and http_load.Jef Poskanzer
2012-12-05Move non-timer routines from timer.[hc] to iperf_util.[hc]Jef Poskanzer
2011-04-20update license info for all source filesJon Dugan
2010-09-20update autoconf goo to accomodate Solaris; minor tweaks to includes for SolarisJon Dugan
2010-07-27Added support for IPv6 mode (-6)sethdelliott
2010-07-27Exchanged gethostbyname for getaddrinfosethdelliott
2010-07-26Added support for binding (-B) to a specific interfacesethdelliott
2010-07-22Made the protocol implementation better. Lots of code clean upsethdelliott
2010-07-22Added support for adding new protocols. Slightly modified iperf_error()sethdelliott
2010-07-20All error handling is now handled by iperf_error. Also cleaned up some codesethdelliott
2010-07-20All client side error handling is now handled by iperf_errorsethdelliott
2010-07-14Added support for UDP mode (-b mode not yet supported). Added htonll/ntohll ↵sethdelliott
functions. Cleaned up code.
2010-06-30The server now runs until terminated by the user. Also fixed several memory ↵sethdelliott
leaks.
2010-06-28Updates to Nread/Nwrite in net.csethdelliott