aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/common/inet_drv.c
AgeCommit message (Collapse)Author
2011-12-02Merge branch 'ta/sendfile/OTP-9240'Lukas Larsson
* ta/sendfile/OTP-9240: (31 commits) Add sendfile server printouts Skip recv/send during tests for fallback platforms Remove header/trailer support Remove windows implementation Expand sendfile documentation Only allow tcp sockets as target for sendfile Move sendfile api to file module Preliminary work on header/trailer Use free_sendfile explicitly for non-async Remove debug printouts Add tests for send/recv/sendfile interactions Remove tests for file_server sendfile sendfile caller now has to be the controlling_process Remove support for file_server, sendfile has to be raw Set chunk size to 3 GB Change type of fd to be ErlDrvEvent Add ifdef's for HAVE_SENDFILE Fix freebsd support for sendfile Change nbytes to 64 bit Implement ignorefd for TCP ...
2011-12-01Implement ignorefd for TCPLukas Larsson
Ignore fd is a feature used by sendfile to temporarily remove all driver_select calls on that fd so that another driver can select on it. It also delays all actions which sends or receives data in that fd until in the fd is no longer ignored. Only the controlling_process should use the feature as it is otherwise possible that the ignore will never be cleaned up and hence create a memory leak in the driver. An ignored driver will not detect that an fd has been closed until it is unignored.
2011-11-30Merge branch 'tn/inet_drv-fix'Raimo Niskanen
* tn/inet_drv-fix: Cleanup - remove unnecesary bracket level and configure for ifreq.ifr_enaddr Work around gcc linking with own view of default libs on Solaris Use libdlpi to get physical address
2011-11-29Cleanup - remove unnecesary bracket level and configure for ifreq.ifr_enaddrRaimo Niskanen
2011-11-29Work around gcc linking with own view of default libs on SolarisRaimo Niskanen
Also use 64-bit lib when necessary, specify runtime lib path for secondary dependency libs, and better check before using SIOCGIFHWADDR.
2011-11-28erts: Fix faulty udp-buffer handlingSverker Eriksson
Caused core dump with gen_udp_SUITE on halfword vm.
2011-11-24Use libdlpi to get physical addressTrond Norbye
2011-11-18Merge branch 'pan/binary_match_scope/OTP-9701'Patrik Nyblom
* pan/binary_match_scope/OTP-9701: Remove remaining gcc 4.6 assigned-but-not-used warnings from erts Remove GCC 4.6 set-but-not-used warning from erl_bif_binary Make binary:match with scope return correct values
2011-11-17Merge branch 'raimo/sctp-dev/OTP-9239'Raimo Niskanen
* raimo/sctp-dev/OTP-9239: (21 commits) erts: Possible bugfix for error chunk on old Solaris 10 kernel: Documented gen_sctp:peeloff/2 kernel: Adjust SCTP test to SuSE quirk erts: Fixes for SCTP on old Solaris 10 Update preloaded files erts,kernel: Return eprotonosupport when SCTP is not supported kernel: Adjust SCTP tests to Solaris quirks erts: Fix SCTP decoding byteorder bug for adaptation_ind kernel: Rewrite SCTP test socket handler kernel: Fix SCTP tests for the FreeBSD protocol stack kernel: Bugfix - SCTP connect with sndrcvinfo in assoc_change event erts: Default enable SCTP in configure Update primary bootstrap and preloaded files erts: Use SCTP functions in default libs erts: Improve SCTP message defragmenting erts,kernel: Bugfix - collect fragmented SCTP messages on recv kernel: Add tests for gen_sctp:peeloff/2 erts,kernel: Implement gen_sctp:peeloff/2 kernel: Add tests for SCTP stream sockets erts,kernel: Add type stream sockets to SCTP ...
2011-11-17erts: Possible bugfix for error chunk on old Solaris 10Raimo Niskanen
2011-11-17Merge branch 'sverker/valgrind-fixing'Sverker Eriksson
* sverker/valgrind-fixing: erts: valgrind suppressions for prebuilt terms in os_info_init Fix dlopen-leak of drivers with incorrect version erts: Add valgrind suppression files erts: Remove valgrind limit for erts_alloc_permanent_cache_aligned erts: Fix write-after-free bug in inet driver ETS: Fix faulty size calculation SIZEOF_EXTSEG ETS: Fix valgrind PossiblyLost in ETS hash tables
2011-11-17erts: Fixes for SCTP on old Solaris 10Raimo Niskanen
2011-11-17erts: Fix SCTP decoding byteorder bug for adaptation_indRaimo Niskanen
2011-11-17erts: Use SCTP functions in default libsRaimo Niskanen
On e.g FreeBSD the functions sctp_bindx() and sctp_peeloff() do not require any extra linkage library flags and there is no dynamic lib to load for them; use configure to find them.
2011-11-17erts: Improve SCTP message defragmentingRaimo Niskanen
Receive several fragments within the same receive loop if possible.
2011-11-17erts,kernel: Bugfix - collect fragmented SCTP messages on recvRaimo Niskanen
2011-11-17erts,kernel: Implement gen_sctp:peeloff/2Raimo Niskanen
2011-11-17erts,kernel: Add type stream sockets to SCTPRaimo Niskanen
2011-11-16Remove remaining gcc 4.6 assigned-but-not-used warnings from ertsPatrik Nyblom
2011-11-16erts,kernel: Rename operations common to TCP and SCTPRaimo Niskanen
2011-10-11Merge branch 'bjorn/some-configure-clean-ups'Björn Gustavsson
* bjorn/some-configure-clean-ups: erts/configure.in: Remove test for reversed setvbuf() arguments erts/configure.in: Remove broken support for System V erts/configure.in: Don't check for the presence of mach-o/dyld.h erts/configure.in: Remove useless --disable-fixalloc option
2011-10-06erts: Fix write-after-free bug in inet driverSverker Eriksson
Bug caught by valgrind but never confirmed as cause of a real problem. Triggered by emulator_test/distribution_SUITE:bad_dist_structure when bad data is received to a distribution port. Port is closed by erts_net_message() and the freed port data is then later used when returning to inet_drv. Everything happens in the same call to tcp_inet_input(). ==32592== Invalid read of size 8 ==32592== at 0x5B6D8C: tcp_deliver (inet_drv.c:8536) ==32592== by 0x5B720E: tcp_recv (inet_drv.c:8652) ==32592== by 0x5B7753: tcp_inet_input (inet_drv.c:8990) ==32592== by 0x5B7FA5: tcp_inet_drv_input (inet_drv.c:9257) ==32592== by 0x4B900C: erts_port_task_execute (erl_port_task.c:856) ==32592== by 0x4AC873: schedule (erl_process.c:5511) ==32592== by 0x5527CA: process_main (beam_emu.c:1225) ==32592== by 0x4A9958: sched_thread_func (erl_process.c:3789) ==32592== by 0x5E2971: thr_wrapper (ethread.c:106) ==32592== by 0x4FEA142: start_thread (in /lib64/libpthread-2.4.so) ==32592== by 0x52C374C: clone (in /lib64/libc-2.4.so) ==32592== Address 0x9b13ea8 is 440 bytes inside a block of size 488 free'd ==32592== at 0x4A1FE94: free (vg_replace_malloc.c:366) ==32592== by 0x58AE69: erts_sys_free (sys.c:2588) ==32592== by 0x48E54F: erts_free (erl_alloc.h:218) ==32592== by 0x497390: driver_free (io.c:3527) ==32592== by 0x5B2E77: inet_stop (inet_drv.c:7152) ==32592== by 0x5B502F: tcp_inet_stop (inet_drv.c:7855) ==32592== by 0x492E60: terminate_port (io.c:1849) ==32592== by 0x493971: erts_do_exit_port (io.c:2059) ==32592== by 0x4CEE01: erts_net_message (dist.c:1508) ==32592== by 0x496AC1: driver_output2 (io.c:3294) ==32592== by 0x5AAA69: inet_port_data (inet_drv.c:1894) ==32592== by 0x5AD57E: tcp_reply_data (inet_drv.c:3181) ==32592== by 0x5B6D84: tcp_deliver (inet_drv.c:8533) ==32592== by 0x5B720E: tcp_recv (inet_drv.c:8652) ==32592== by 0x5B7753: tcp_inet_input (inet_drv.c:8990) Fixed by checking the negative return code earlier in tcp_deliver().
2011-09-28Merge branch 'raimo/sctp-getsetopts-dev/OTP-9544' into devRaimo Niskanen
* raimo/sctp-getsetopts-dev/OTP-9544: erts,kernel: Bugfix - read SCTP socket options from right protocol layer erts: Fix bug SCTP send can only be called from controlling process
2011-09-19Merge branch 'raimo/sctp-getsetopts/OTP-9544' into ↵Raimo Niskanen
raimo/sctp-getsetopts-dev/OTP-9544 Conflicts: erts/emulator/drivers/common/inet_drv.c lib/kernel/test/gen_sctp_SUITE.erl
2011-09-19erts,kernel: Bugfix - read SCTP socket options from right protocol layerRaimo Niskanen
Socket options 'sndbuf', 'recbuf' and 'linger were read from the SCTP protocol layer instead of from the socket protocol layer. Conflicts: lib/kernel/test/gen_sctp_SUITE.erl
2011-09-19erts: Fix bug SCTP send can only be called from controlling processRaimo Niskanen
Conflicts: lib/kernel/test/gen_sctp_SUITE.erl
2011-09-15Fix misspelling of successfulTuncer Ayaz
2011-09-08erts/configure.in: Remove broken support for System VBjörn Gustavsson
If we are compiling on System V, the symbols NO_WEAK_PRAGMA and SOCKOPT_CONNECT_STAT are defined, but they are never used.
2011-05-24inet: error if fd does not match socket domainMichael Santos
If an IPv4 fd is opened as an IPv6 socket, unexpected behaviour can occur. For example, if an IPv4 UDP socket is opened and passed into Erlang as an IPv6 socket, the first 3 bytes (corresponding to 1 byte representing the protocol family, 2 bytes set to the port) are stripped from the payload. The cause of the UDP payload truncation happens in inet_drv.c:packet_inet_input when a call to inet_get_address fails silently because the family is set to PF_INET6 but the buffer len is the size of an IPv4 struct sockaddr_in. Prevent this behaviour by checking that the protocol family of the file descriptor matches the family of the requested Erlang socket. {ok, S1} = gen_udp:open(0, [binary, inet]), {ok, FD} = inet:getfd(S1), {ok, Port} = inet:port(S1), {ok, S} = gen_udp:open(Port, [binary, {fd, FD}, inet6]), {ok, C} = gen_udp:open(0, [binary]), Msg = <<1,2,3,4,5>>, gen_udp:send(C, "127.0.0.1", Port, Msg), receive {udp, S, _, _, Msg} -> ok; {udp, S, _, _, NewMsg} -> {error, Msg, NewMsg} end. This test results in: {error,<<1,2,3,4,5>>,<<4,5>>} Thanks to Andrew Tunnell-Jones for finding the bug and the test case!
2011-05-17Remove compiler warnings in inet_drvBjörn-Egil Dahlberg
2011-05-02inet_drv: remove unused tcp request idTuncer Ayaz
2011-05-02inet_drv: remove gratuitous assignmentTuncer Ayaz
2011-03-21Teach tcp_recv not to cancel send timerPatrik Nyblom
2011-02-21Add patch from Per HedelandPatrik Nyblom
Per H @ Tail-f: The original code here had problems that possibly only occur if you abuse it for non-INET sockets, but anyway: a) If the getsockopt for SO_PRIORITY or IP_TOS failed, the actual requested setsockopt was never even attempted. b) If {get,set}sockopt for one of IP_TOS and SO_PRIORITY failed, but ditto for the other worked and that was actually the requested option, failure was still reported to erlang.
2011-02-21Ignore permission error when implicitly setting SO_PRIORITYPatrik Nyblom
2010-12-14Fix segfault for NULL return value fields from getifaddrs()Raimo Niskanen
2010-12-03Merge branch 'pan/inet6_corrections/OTP-8969' into devRaimo Niskanen
* pan/inet6_corrections/OTP-8969: Stop using uncertain flags for getaddrinfo() Teach inet_test_lib to understand enetunreach Make windows inet_gethost work for ipv6
2010-12-02Stop using uncertain flags for getaddrinfo()Raimo Niskanen
The AI_V4MAPPED flag is falling out of grace in modern IPv6 stacks, for security reasons, e.g. FreeBSD do not document it any longer. The AI_ADDRCONFIG flag have got unclear semantics on the same OS.
2010-11-30Adapt inet_drv to Visual Studio 2008Patrik Nyblom
2010-11-22Merge branch 'rickard/thr-spec-inet-buf/OTP-8916' into devRickard Green
* rickard/thr-spec-inet-buf/OTP-8916: Remove tight restrictions on some options Thread specific inet driver buffer stack
2010-11-18Remove tight restrictions on some optionsRickard Green
Remove tight restrictions on the high_watermark, low_watermark, and buffer options.
2010-11-18Thread specific inet driver buffer stackRickard Green
The inet driver internal buffer stack implementation has been rewritten in order to reduce lock contention.
2010-11-09Delete decommented codeRaimo Niskanen
2010-11-09Implement inet:getifaddrs/0 on WindowsRaimo Niskanen
2010-11-09Implement basic inet:getifaddrs/0Raimo Niskanen
2010-11-09Fix building error of SCTP in FreeBSD 7.1 and laterKenji Rikitake
This patch fixes building error of SCTP in FreeBSD 7.1 and later. See http://www.erlang.org/cgi-bin/ezmlm-cgi?2:mss:1257:200904:hppnfialjjdlgecdiehe for the details. R13A patch for solving a compilation error when building erts/emulator/drivers/common/inet_drv.c by Kenji Rikitake 12-APR-2009 Symptom solved by this patch: When building R13A in FreeBSD 7.1-RELEASE, the compiler flag HAVE_STRUCT_SCTP_PADDRPARAMS_SPP_SACKDELAY is NOT enabled. Some code in erts/emulator/drivers/common/inet_drv.c incorrectly assumes HAVE_STRUCT_SCTP_PADDRPARAMS_SPP_SACKDELAY is always true when HAVE_STRUCT_SCTP_PADDRPARAMS_SPP_FLAGS is true in config.h. This assumption causes a compilation error.
2010-09-09Make gen_tcp:recv/2 consistent with ssl:recv/2Björn Gustavsson
When the HTTP packet mode has been enabled for a socket, the ssl and gen_tcp modules have different error indications when there is an error while parsing the HTTP header: ssl:recv(SSLSocket, 0) -> {ok, {http_error, _Str}} gen_tcp:recv(Socket, 0) -> {error, {http_error, _Str}} We have decided to change gen_tcp:recv/2 to behave the same way as ssl:recv/2. That means that there will be always be an ok tuple if data could be succefully read from the socket, and an error tuple if there was a read error at the socket level.
2010-09-06Merge branch 'ms/inet-bug-fixes' into devBjörn Gustavsson
* ms/inet-bug-fixes: inet: support retrieving MAC address on BSD inet: fix getservbyname buffer overflow inet: fix ifr_name buffer overflow inet: null terminate ifr_name buffer OTP-8816
2010-09-03inet: support retrieving MAC address on BSDMichael Santos
On systems supporting getaddrinfo(), support looking up the MAC address from inet:ifget/2. The results have the same quirks as with Linux: if the MAC address is longer than 6 bytes (e.g., fw0 under Mac OS X), the address is truncated; if the interface does not have a MAC address (e.g., lo0), an address consisting of 0's is returned.
2010-09-02Merge branch 'rani/sctp-sndrcvinfo/OTP-8795' into devRaimo Niskanen
* rani/sctp-sndrcvinfo/OTP-8795: Fix xfer_active close expection for Solaris behaviour Keep default #sctp_sndrcvinfo{} fields on gen_sctp:send/4 Fill in sinfo_assoc_id in struct sctp_sndrcvinfo for getopt() Conflicts: lib/kernel/test/gen_sctp_SUITE.erl