summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/net.cc
Commit message (Collapse)AuthorAgeFilesLines
* Fix trace output for getdomainname()Anton Lavrentiev via Cygwin-patches2020-12-071-1/+1
|
* Cygwin: fix formatting: drop trailing whitespaceCorinna Vinschen2020-03-111-5/+5
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix formatting: collapse whitespace-only linesCorinna Vinschen2020-03-111-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix formatting: drop spaces leading tabsCorinna Vinschen2020-03-111-4/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: AF_LOCAL: set appropriate errno on system callsKen Brown2020-01-301-4/+15
| | | | | | | | | | | | | | | | | | | If an AF_LOCAL socket is opened with O_PATH, all socket system calls that take a file descriptor argument fail on the resulting descriptor. Make sure that errno is set as on Linux for those calls that are implemented on Linux. In almost all cases it is ENOTSOCK. There are two exceptions: - sockatatmark(3); errno is EBADF. - bindresvport(3); errno is EAFNOSUPPORT if the second argument sin (of type struct sockaddr_in *) is non-NULL and satisfies sin->sin_family == AF_INET. Finally, there are two BSD socket system calls implemented on Cygwin but not Linux: getpeereid(3) and bindresvport_sa(3). Set errno to ENOTSOCK for these for consistency with the majority of the other calls.
* Minor improvements to socket error handling:Erik M. Bray2019-04-231-1/+4
| | | | | | | | | * Change default fallback for failed winsock error -> POSIX error mappings to EACCES, which is a valid errno for more socket-related syscalls. * Added a few previously missing entries to the wsock_errmap table that have obvious POSIX errno.h analogues.
* Cygwin: net: unify gethostname/getdomainnameCorinna Vinschen2019-01-241-41/+36
| | | | | | | Use info from same source (GetNetworkParams). Also move getdomainname near gethostname in source. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: gethostname: fix fetching hostname from non-winsock functionCorinna Vinschen2019-01-241-1/+1
| | | | | | | | | If gethostname() fails we call GetComputerNameEx with ComputerNameDnsFullyQualified. This is wrong, gethostname should return the hostname only, not the FQDN. Fix this by calling GetComputerNameEx with ComputerNameDnsHostname. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: minor cleanupsCorinna Vinschen2019-01-131-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix memory corruption/SEGV if certain socket functions failCorinna Vinschen2018-10-291-10/+2
| | | | | | | | | | | | | | | | | | Regression introduced with 2.11.0: The failure paths in socket, socketpair and accept4 functions and methods accidentally release *unused* cygheap_fdmanip objects. The subsequently called dtable::release method was designed to be called for *used* cygheap_fdmanip objects only. Using them on unused objects leads to NULL pointer member dereferencing. Worse, the inet/local accept4 methods only release the cygheap_fdmanip object but neglect to delete the just created fhandler_socket_* object. Fix this by removing the erroneous release calls in the aforementioned failure paths and delete the fhandler_socket_* object in accept4 instead. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Allow to build without experimental AF_UNIX code by defaultCorinna Vinschen2018-06-261-0/+8
| | | | | | Introduce __WITH_AF_UNIX preprocessor flag to enable the new code Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix socketpair prototypeCorinna Vinschen2018-03-091-3/+3
| | | | | | Last parameter is a vector of 2 ints, not a pointer to int Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: cleanup header including within network-releated filesCorinna Vinschen2018-02-281-20/+4
| | | | | | | | | | | * Rearrange includes and drop unneccessary ones. * Don't pull in cygwin/socket.h into sys/un.h just to get sa_family_t. Include sys/types.h and use __sa_family_t instead. * start including Windows headers using the w32api/ path prefix Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: sockets: Add missing cleanup if socket/socketpair creation failsCorinna Vinschen2018-02-261-1/+6
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: sockets: move type and proto checks into fhandler_socket classesCorinna Vinschen2018-02-261-25/+0
| | | | | | Encapsulation required Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fhandler_socket: define socketpair as virtual functionCorinna Vinschen2018-02-261-3/+3
| | | | | | | ...in preparation of moving the type and protocol test into the actual classes. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Create empty fhandler_socket_unixCorinna Vinschen2018-02-231-2/+4
| | | | | | | | | * Make distinct from AF_LOCAL for testing purposes. This will have to be reverted as soon as fhandler_socket_unix goes life. * Move saw_reuseaddr flag back to fhandler_socket status Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: encapsulate Winsock based fhandler_socket classesCorinna Vinschen2018-02-231-2/+1
| | | | | | | | | | | | | | | | | | | Insert another class fhandler_socket_wsock between fhandler_socket and fhandler_socket_inet/fhandler_socket_local. Also, add a new method fhandler::is_wsock_socket to allow asking for sockets in general (is_socket) vs. Winsock-based sockets (is_wsock_socket). This allows to develop a new handler_socket_unix class as derived class from fhandler_socket without any trace of wsock code left in fhandler_socket. While this is basically a temporary measure at this time, it may prove useful for later interoperability with the upcoming Windows 10 AF_UNIX implementation at one point. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: drop unused device nodes and clean up socket devicesCorinna Vinschen2018-02-231-3/+3
| | | | | | | | * Rename DEV_TCP_MAJOR to DEV_SOCK_MAJOR * Drop FH_TCP, FH_UDP, FH_ICMP in favor of single FH_INET * Drop FH_UNIX, FH_STREAM, FH_DGRAM in favor of single FH_LOCAL Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: make socketpair an AF_LOCAL-only methodCorinna Vinschen2018-02-221-15/+3
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: split out fhandler_socket into inet and local classesCorinna Vinschen2018-02-211-140/+0
| | | | | | | | | | | | | First cut, still incomplete * fhandler_socket is now base class for other socket classes * fhandler_socket_inet handles AF_INET and AF_INET6 sockets * fhandler_socket_local handles AF_LOCAL/AF_UNIX sockets * finally get rid of fdsock by using set_socket_handle in accept4 * align file-related calls (fstat, fstatvfs, fchown, fchmod, facl) to Linux. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: net.cc: drop redundant declarationsCorinna Vinschen2018-02-201-4/+1
| | | | | | Replace cygwin_inet_aton call with cygwin_inet_pton Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: set/getsockopt: Move implementation into fhandler_socket classCorinna Vinschen2018-02-201-334/+13
| | | | | | This requires to export find_winsock_errno from net.cc. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: clean error mappingCorinna Vinschen2018-02-201-14/+7
| | | | | | | | | - Move definition of windows to POSIX error mapping struct into cygerrno.h - Move declaration of winsock errno functions to cygerrno.h - Input to error mapping functions is DWORD Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: net: Improve standars conformance commentsCorinna Vinschen2018-02-161-30/+35
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: socketpair: Move socketpair creation inside fhandler_socket classCorinna Vinschen2018-02-161-174/+71
| | | | | | | | Add fhandler_socket::socketpair method Deliberately disable AF_INET socketpairs for now Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: socket: move socket creation inside fhandler_socket classCorinna Vinschen2018-02-141-46/+44
| | | | | | | | Add fhandler_socket::socket method Add fhandler_socket::set_socket_handle method, basically duplicating what fdsock is doing. This is the first step in getting rid of fdsock. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Drop HZ usage in favor of MSPERSEC and CLOCKS_PER_SECCorinna Vinschen2018-02-121-2/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: sockets: Handle SO_RCVTIMEO and SO_SNDTIMEOCorinna Vinschen2018-02-071-0/+42
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: setsockopt/getsockopt: Add missing optlen checksCorinna Vinschen2018-02-071-2/+21
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: setsockopt/getsockopt: Clean up codeCorinna Vinschen2018-02-061-118/+207
| | | | | | | | | Rearrange setsockopt/getsockopt into per level/per optname preprocessing switch, actual call, per level/per optname postprocessing switch for better readability as well as extensibility. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: bindresvport: Try hard to find unused portCorinna Vinschen2018-02-051-8/+82
| | | | | | | | | | Workaround the problem that bind doesn't fail with EADDRINUSE if a socket with the same local address is still in TIME_WAIT. Use IP Helper functions to check if such a socket exist and don't even try this port, if so. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: bindresvport: check correctness of address familyCorinna Vinschen2018-02-051-1/+10
| | | | | | | | | | | | Assuming the address parameter is non-NULL, the test in cygwin_bindresvport_sa only tests if the address family is supported at all, which is insufficient. Check if the incoming address family matches the socket address family and for being AF_INET in cygwin_bindresvport since the latter doesn't support any other family. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: bindresvport_sa: Ignore incoming port numberCorinna Vinschen2018-02-051-12/+4
| | | | | | | Ignore port number just like glibc, otherwise suffer EADDRINUSE in subsequent connect calls. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cygwin: fix gethostbyaddr argument typesYaakov Selkowitz2017-10-101-2/+2
| | | | | | | | The first argument of gethostbyaddr needs to accept a generic pointer to be compatible with e.g. struct in_addr *. This caused an issue compiling krb5-1.15. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
* Fix limited Internet speeds caused by inappropriate socket bufferingCorinna Vinschen2017-02-031-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't set SO_RCVBUF/SO_SNDBUF to fixed values, thus disabling autotuning. Patch modeled after a patch suggestion from Daniel Havey <dhavey@gmail.com> in https://cygwin.com/ml/cygwin-patches/2017-q1/msg00010.html: At Windows we love what you are doing with Cygwin. However, we have been getting reports from our hardware vendors that iperf is slow on Windows. Iperf is of course compiled against the cygwin1.dll and we believe we have traced the problem down to the function fdsock in net.cc. SO_RCVBUF and SO_SNDBUF are being manually set. The comments indicate that the idea was to increase the buffer size, but, this code must have been written long ago because Windows has used autotuning for a very long time now. Please do not manually set SO_RCVBUF or SO_SNDBUF as this will limit your internet speed. I am providing a patch, an STC and my cygcheck -svr output. Hope we can fix this. Please let me know if I can help further. Simple Test Case: I have a script that pings 4 times and then iperfs for 10 seconds to debit.k-net.fr With patch $ bash buffer_test.sh 178.250.209.22 usage: bash buffer_test.sh <iperf server name> Pinging 178.250.209.22 with 32 bytes of data: Reply from 178.250.209.22: bytes=32 time=167ms TTL=34 Reply from 178.250.209.22: bytes=32 time=173ms TTL=34 Reply from 178.250.209.22: bytes=32 time=173ms TTL=34 Reply from 178.250.209.22: bytes=32 time=169ms TTL=34 Ping statistics for 178.250.209.22: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 167ms, Maximum = 173ms, Average = 170ms ------------------------------------------------------------ Client connecting to 178.250.209.22, TCP port 5001 TCP window size: 64.0 KByte (default) ------------------------------------------------------------ [ 3] local 10.137.196.108 port 58512 connected with 178.250.209.22 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0- 1.0 sec 768 KBytes 6.29 Mbits/sec [ 3] 1.0- 2.0 sec 9.25 MBytes 77.6 Mbits/sec [ 3] 2.0- 3.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 3.0- 4.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 4.0- 5.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 5.0- 6.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 6.0- 7.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 7.0- 8.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 8.0- 9.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 9.0-10.0 sec 18.0 MBytes 151 Mbits/sec [ 3] 0.0-10.0 sec 154 MBytes 129 Mbits/sec Without patch: dahavey@DMH-DESKTOP ~ $ bash buffer_test.sh 178.250.209.22 Pinging 178.250.209.22 with 32 bytes of data: Reply from 178.250.209.22: bytes=32 time=168ms TTL=34 Reply from 178.250.209.22: bytes=32 time=167ms TTL=34 Reply from 178.250.209.22: bytes=32 time=170ms TTL=34 Reply from 178.250.209.22: bytes=32 time=169ms TTL=34 Ping statistics for 178.250.209.22: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 167ms, Maximum = 170ms, Average = 168ms ------------------------------------------------------------ Client connecting to 178.250.209.22, TCP port 5001 TCP window size: 208 KByte (default) ------------------------------------------------------------ [ 3] local 10.137.196.108 port 58443 connected with 178.250.209.22 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0- 1.0 sec 512 KBytes 4.19 Mbits/sec [ 3] 1.0- 2.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 2.0- 3.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 3.0- 4.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 4.0- 5.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 5.0- 6.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 6.0- 7.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 7.0- 8.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 8.0- 9.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 9.0-10.0 sec 1.50 MBytes 12.6 Mbits/sec [ 3] 0.0-10.1 sec 14.1 MBytes 11.7 Mbits/sec The output shows that the RTT from my machine to the iperf server is similar in both cases (about 170ms) however with the patch the throughput averages 129 Mbps while without the patch the throughput only averages 11.7 Mbps. If we calculate the maximum throughput using Bandwidth = Queue/RTT we get (212992 * 8)/0.170 = 10.0231 Mbps. This is just about what iperf is showing us without the patch since the buffer size is set to 212992 I believe that the buffer size is limiting the throughput. With the patch we have no buffer limitation (autotuning) and can develop the full potential bandwidth on the link. If you want to duplicate the STC you will have to find an iperf server (I found an extreme case) that has a large enough RTT distance from you and try a few times. I get varying results depending on Internet traffic but without the patch never exceed the limit caused by the buffering. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Return the correct value for getsockopt(SO_REUSEADDR) after setting ↵Erik M. Bray2017-01-091-0/+8
| | | | setsockopt(SO_REUSEADDR, 1).
* Send thread names to debuggerJon Turney2016-08-231-0/+1
| | | | | | | | | | | | | | | | | | GDB since commit 24cdb46e [1] can report and use these names. Add utility function SetThreadName(), which sends a thread name to the debugger. Use that: - to set the default thread name for main thread and newly created pthreads. - in pthread_setname_np() for user thread names. - for helper thread names in cygthread::create() - for helper threads which are created directly with CreateThread. Note that there can still be anonymous threads, created by system or injected DLLs. [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24cdb46e9f0a694b4fbc11085e094857f08c0419
* Remove CYGWIN=detect_bloda optionCorinna Vinschen2016-06-251-12/+0
|
* Fix various OS-related commentsCorinna Vinschen2016-06-241-5/+5
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* net.cc (fdsock): Fix commentCorinna Vinschen2016-06-241-12/+9
|
* Rename if_indextoname to cygwin_if_indextoname (analag for if_nametoindex)Corinna Vinschen2016-06-241-66/+4
| | | | Just call OS functions
* Drop supports_all_posix_ai_flagsCorinna Vinschen2016-06-231-75/+2
|
* Drop has_gaa_on_link_prefix flag and remove obsolete functions thuslyCorinna Vinschen2016-06-231-155/+3
|
* Handle up to 63 partitions per driveCorinna Vinschen2016-06-231-1/+1
| | | | | | | | | | | | | | Revamp device parsing code. Introducing support for more partitions into the shilka-generated parser has the unfortunate side-effect of raising the size of the DLL by almost 2 Megs. Therefore we split out the handling for /dev/sdXY devices into a tiny bit of hand-written code. While at it, remove some unused cruft from devices.* and generally clean up the device class to provide access methods instead of direct access to members. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout optioncygwin-2_5_2-releaseCorinna Vinschen2016-06-231-3/+0
| | | | | | | | | | | | | | Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause. Everything else stays under GPLv3+. New Linking Exception exempts resulting executables from LGPLv3 section 4. Add CONTRIBUTORS file to keep track of licensing. Remove 'Copyright Red Hat Inc' comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Throughout Cygwin, use u_intN_t or uintN_tCorinna Vinschen2016-03-241-28/+27
| | | | | | | | | | Don't use u_char, u_short, u_int or u_long in Cygwin, unless it refers to the Winsock types. Use u_intN_t in BSD-based sources, unsigned char where strings are concerned, uintN_t otherwise. Also: * net.cc: Fix comment, we're not using u_long anymore. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix return type of get_routedstCorinna Vinschen2016-03-241-1/+1
| | | | | | * net.cc (get_routedst): Correctly return in_addr_t. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Remove unused function convert_ifr_flagsCorinna Vinschen2016-03-241-14/+0
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cygwin_getaddrinfo: workaround Winsock getaddrinfo issue with broken DNSCorinna Vinschen2016-03-141-1/+10
| | | | | | | | | | | | | | | | | | Add experimental code to workaround the issue described in the thread starting at https://cygwin.com/ml/cygwin/2015-07/msg00350.html There's a hint in https://communities.vmware.com/message/2577858#2577858 that this problem is related to using the AI_ALL flag. This patch checks if GetAddrInfoW returned with WSANO_RECOVERY and if the AI_ALL flag was set, it retries GetAddrInfo without the AI_ALL flag. * net.cc (cygwin_getaddrinfo): Add experimental code to retry GetAddrInfoW without AI_ALL flag if it returned with WSANO_RECOVERY. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>