summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* swrap: add support for SOCKET_WRAPPER_IPV4_NETWORK=10.53.57.0Stefan Metzmacher2020-03-211-6/+21
| | | | | | | | | | | | | | With this 10.53.57.XX/8 addresses are used instead of 127.0.0.XX/8. Note the broadcast address is 127.255.255.255 or 10.255.255.255 (and not 10.53.57.255!). Some applications, e.g. Samba have some special behavior for loopback addresses. This allows more realistic tests and triggers the more common code paths. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: implement swrap_ipv4_{net,bcast,iface}() helper functionsStefan Metzmacher2020-03-211-9/+96
| | | | | | | This makes it easier to implement SOCKET_WRAPPER_IPV4_NETWORK in the next step. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: provide _{socket,close,connect,...} symbols on FreeBSDStefan Metzmacher2020-03-191-0/+51
| | | | | | | Maybe that's not FreeBSD only, but at least this fixes the interaction of resolv_wrapper and socket_wrapper on FreeBSD 12. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: detect stale fd for socket(PF_UNIX) and accept()Stefan Metzmacher2020-03-191-1/+22
| | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: trace the SOCKET_WRAPPER_PCAP_FILE locationStefan Metzmacher2020-03-191-0/+1
| | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Do not leak buf in swrap_sendmsg()socket_wrapper-1.2.3Andreas Schneider2019-03-211-0/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Add missing NULL checks to socket_wrapper_dir()Andreas Schneider2019-03-211-0/+19
| | | | | | | | This return either malloc'ed memory or NULL. Make sure there is no problem. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Print a warning if SOCKET_WRAPPER_DIR is not setAndreas Schneider2019-03-211-0/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Add paranoia NULL checksAndreas Schneider2019-03-211-0/+10
| | | | | | | csbuild complains about missing NULL checks here. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Fix strict aliasing issues in swrap_pcap_packet_init()Andreas Schneider2019-03-211-51/+61
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Fix "Value stored never used" warningAnoop C S2019-03-211-1/+0
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Do not use FALL_THROUGH for empty case statementsAmitay Isaacs2019-03-061-2/+0
| | | | | Signed-off-by: Amitay Isaacs <amitay@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* cmake: Use GNUInstallDirsAndreas Schneider2019-02-201-6/+4
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix a TODOAnoop C S2019-02-121-19/+54
| | | | | | | | Use realpath(3) instead of strncmp(3) Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Add env variable to disable deep bindingAndreas Schneider2019-02-121-5/+15
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Use #ifdef instead of #if for config.h definitionsAndreas Schneider2019-01-111-6/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* swrap: Add an overflow checkVolker Lendecke2019-01-111-0/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Do not log if we are over the limit in find_socket_info_index()Andreas Schneider2018-11-131-4/+16
| | | | | | | | | | | | | There are applications which do: for (fd = 0; fd <= getdtablesize(); fd++) { close(fd) }; This produced millions of error messsages. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Also log the fd in swrap_socket()Andreas Schneider2018-11-131-2/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Fix comparison of different signednessAndreas Schneider2018-11-131-2/+2
| | | | | | | Found by csbuild. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Also log the process nameAndreas Schneider2018-11-131-2/+24
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Better handling for default values in socket_wrapper_max_sockets()Andreas Schneider2018-11-131-5/+15
| | | | | | | Pair-Programmed-With: Anoop C S <anoopcs@redhat.com> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Always allocate the socket fd array to the maximumAndreas Schneider2018-11-131-9/+16
| | | | | | | | | | This will allow that we can deal with duplicates if the default value is used. Pair-Programmed-With: Anoop C S <anoopcs@redhat.com> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Rename global variable for max socketsAndreas Schneider2018-11-131-6/+8
| | | | | | | | | We also need a mutex to protect access to it. Pair-Programmed-With: Anoop C S <anoopcs@redhat.com> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Set LINK_FLAGS for socket_wrapperAndreas Schneider2018-11-071-9/+10
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Protect IPv6 case in swrap_socket()Andreas Schneider2018-11-061-0/+2
| | | | | | | Fixes the build on OmniOS Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Fix coverity issuesAnoop C S2018-10-291-4/+2
| | | | | | | | | CID 184220 CID 184221 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Don't do a deep bind if we run with libasanAndreas Schneider2018-10-231-1/+9
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Add a mutex for resetting socket indexAndreas Schneider2018-10-231-2/+22
| | | | | | | Fixes a helgrind error. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Fix helgrind errorsAnoop C S2018-10-231-4/+32
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Use target_include_directories()Andreas Schneider2018-10-231-3/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Improve checks for compiler flagsAndreas Schneider2018-10-231-0/+4
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Suppress helgrind race condition warning we created on purposeAndreas Schneider2018-10-231-0/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* swrap: Add error check around pthread mutex locksAnoop C S2018-08-091-52/+114
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Fix thread deadlock found by Coverity scanAnoop C S2018-08-091-2/+4
| | | | | | | | | CID 175897 CID 175898 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Update headerAndreas Schneider2018-08-091-4/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Replace socket_fds linked list with an arrayAnoop C S2018-06-141-192/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following bug: As we are using a doubly linked list, we need a mutex which needs to be locked when we are reading it that we do not end up with invalid pointers. The following can happen: We are in swrap_close() which calls find_socket_info_fd() this locks the mutex for the linked list. Now we get a singal SIGCHILD and the signal handler is called. The signal handler calls swrap_write() and we try to find out if the socket is managed by socket_wrapper calling find_socket_info_fd() again -> DEADLOCK! By moving to an array to handle the socket fds and using the fd as the array access, we do not need a mutex for reading anymore. All we need is a memory barrier. This change also improves the performance as we move from the a linked list to a hash table! Pair-Programmed-With: Andreas Schneider <asn@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* swrap: Update free-list only when refcount is zeroAnoop C S2018-05-021-5/+6
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Move metadata into socket_info_meta structureMichael Adam2018-05-021-10/+16
| | | | | | | | | | | Separating out the metadata related information to another sub-structure to make it more clean and structured. Pair-Programmed-With: Anoop C S <anoopcs@redhat.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Implement thread safety using pthread mutexesAnoop C S2018-05-021-38/+235
| | | | | | | | | | | | | | | | | | | Added a new mutex variable to socket_info structure along with new macros for locking and unlocking mutex corresponding to each socket_info entry. Apart from individual mutex defined in socket_info structure, 4 new mutexes are added to protect the concurrent access of globally used swrap parameters from different threads. All other individual wrappers and helper routines are also made capable of acquiring relevant mutex locks before operating on such global parameters. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Rearrange swrap_remove_staleAnoop C S2018-05-021-6/+8
| | | | | | | | | In preparation to implement thread safety, re-ordering lines of code to properly align to lockign calls Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Rearrange swrap_closeAnoop C S2018-05-021-5/+6
| | | | | | | | | In preparation to implement thread safety, re-ordering lines of code to properly align to locking calls. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Remove swrap_first_free_indexAnoop C S2018-05-021-22/+0
| | | | | | | | | swrap_first_free_index is no longer used as the whole logic now implemented within swrap_create_socket. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Use swrap_create_socket within swrap_acceptAnoop C S2018-05-021-28/+12
| | | | | | | | | Replace the current logic of socket creation within swrap_accept with more cleaner version using swrap_create_socket. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Use swrap_create_socket within swrap_socketAnoop C S2018-05-021-27/+5
| | | | | | | | | Replace the current logic of socket creation within swrap_socket with more cleaner version using swrap_create_socket. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Add new routines to handle socket creationAnoop C S2018-05-021-0/+50
| | | | | | | | | | | A new function named swrap_create_socket is introduced which cleanly performs all stuff related to creation of new socket file descriptors and updation of relevant metadata including the free-list and reference counter. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Internal reorganization of core socket_info structuresMichael Adam2018-05-021-14/+29
| | | | | | | | | | | | | | | | The change basically splits socket_info structure into two structures, namely, - socket_info: to store the core information corresponding to a socket entry. - socket_info_container: wrapping structure to hold the socket_info data as well as metadata(currently refcount and next_free). Pair-Programmed-With: Anoop C S <anoopcs@redhat.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Reorder code inside swrap_socketMichael Adam2018-05-021-16/+18
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: Use swrap_get_socket_info inside socket_wrapper_first_free_indexMichael Adam2018-05-021-3/+5
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: set errno to ENFILE if there is no more free socket_infoMichael Adam2018-05-021-2/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>