socket_wrapper.git
4 weeks agoswrap: Do not leak buf in swrap_sendmsg() master socket_wrapper-1.2.3
Andreas Schneider [Thu, 21 Mar 2019 13:59:30 +0000 (14:59 +0100)]
swrap: Do not leak buf in swrap_sendmsg()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agoBump version to 1.2.3
Andreas Schneider [Thu, 21 Mar 2019 13:18:12 +0000 (14:18 +0100)]
Bump version to 1.2.3

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agoswrap: Add missing NULL checks to socket_wrapper_dir()
Andreas Schneider [Thu, 21 Mar 2019 13:09:37 +0000 (14:09 +0100)]
swrap: Add missing NULL checks to socket_wrapper_dir()

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>
4 weeks agoswrap: Print a warning if SOCKET_WRAPPER_DIR is not set
Andreas Schneider [Thu, 21 Mar 2019 13:09:19 +0000 (14:09 +0100)]
swrap: Print a warning if SOCKET_WRAPPER_DIR is not set

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agoBump version to 1.2.2 socket_wrapper-1.2.2
Andreas Schneider [Thu, 21 Mar 2019 07:47:24 +0000 (08:47 +0100)]
Bump version to 1.2.2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agoswrap: Add paranoia NULL checks
Andreas Schneider [Fri, 15 Mar 2019 13:59:14 +0000 (14:59 +0100)]
swrap: Add paranoia NULL checks

csbuild complains about missing NULL checks here.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agoswrap: Fix strict aliasing issues in swrap_pcap_packet_init()
Andreas Schneider [Thu, 28 Feb 2019 12:00:40 +0000 (13:00 +0100)]
swrap: Fix strict aliasing issues in swrap_pcap_packet_init()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agoswrap: Fix "Value stored never used" warning
Anoop C S [Fri, 15 Mar 2019 13:18:40 +0000 (18:48 +0530)]
swrap: Fix "Value stored never used" warning

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agotests: Fix typo in echo_srv help
Andreas Schneider [Thu, 28 Feb 2019 12:02:35 +0000 (13:02 +0100)]
tests: Fix typo in echo_srv help

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 weeks agodoc: Fix some typos in the manpage
Andreas Schneider [Thu, 28 Feb 2019 12:02:08 +0000 (13:02 +0100)]
doc: Fix some typos in the manpage

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
6 weeks agoswrap: Do not use FALL_THROUGH for empty case statements
Amitay Isaacs [Thu, 21 Feb 2019 03:04:21 +0000 (14:04 +1100)]
swrap: Do not use FALL_THROUGH for empty case statements

Signed-off-by: Amitay Isaacs <amitay@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
8 weeks agoREADME: Create a markdown file
Andreas Schneider [Tue, 19 Feb 2019 15:18:10 +0000 (16:18 +0100)]
README: Create a markdown file

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 weeks agogitlab-ci: Check last 20 commits on force push
Andreas Schneider [Tue, 19 Feb 2019 15:10:16 +0000 (16:10 +0100)]
gitlab-ci: Check last 20 commits on force push

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 weeks agocmake: Remove unused config.h variables
Andreas Schneider [Wed, 20 Feb 2019 09:34:04 +0000 (10:34 +0100)]
cmake: Remove unused config.h variables

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 weeks agocmake: Use GNUInstallDirs
Andreas Schneider [Fri, 15 Feb 2019 12:09:28 +0000 (13:09 +0100)]
cmake: Use GNUInstallDirs

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 months agoswrap: Fix a TODO
Anoop C S [Thu, 6 Dec 2018 05:46:15 +0000 (11:16 +0530)]
swrap: Fix a TODO

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>
2 months agoRemove thread-safety task from TODO
Anoop C S [Thu, 6 Dec 2018 05:45:46 +0000 (11:15 +0530)]
Remove thread-safety task from TODO

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 months agocmake: Disable deep binding for helgrind
Andreas Schneider [Wed, 28 Nov 2018 08:23:52 +0000 (09:23 +0100)]
cmake: Disable deep binding for helgrind

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 months agoswrap: Add env variable to disable deep binding
Andreas Schneider [Wed, 28 Nov 2018 08:20:58 +0000 (09:20 +0100)]
swrap: Add env variable to disable deep binding

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 months agoswrap: Use #ifdef instead of #if for config.h definitions
Andreas Schneider [Tue, 20 Nov 2018 13:16:17 +0000 (14:16 +0100)]
swrap: Use #ifdef instead of #if for config.h definitions

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
3 months agoswrap: Add an overflow check
Volker Lendecke [Sat, 29 Dec 2018 19:20:13 +0000 (20:20 +0100)]
swrap: Add an overflow check

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 months agoBump version to 1.2.1 socket_wrapper-1.2.1
Andreas Schneider [Wed, 14 Nov 2018 07:04:42 +0000 (08:04 +0100)]
Bump version to 1.2.1

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Karolin Seeger <kseeger@samba.org>
5 months agoswrap: Do not log if we are over the limit in find_socket_info_index()
Andreas Schneider [Tue, 13 Nov 2018 17:44:39 +0000 (18:44 +0100)]
swrap: Do not log if we are over the limit in find_socket_info_index()

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>
5 months agoswrap: Also log the fd in swrap_socket()
Andreas Schneider [Tue, 13 Nov 2018 17:18:22 +0000 (18:18 +0100)]
swrap: Also log the fd in swrap_socket()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoswrap: Fix comparison of different signedness
Andreas Schneider [Tue, 13 Nov 2018 13:28:17 +0000 (14:28 +0100)]
swrap: Fix comparison of different signedness

Found by csbuild.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoBump version to 1.2.0 socket_wrapper-1.2.0
Andreas Schneider [Mon, 12 Nov 2018 10:14:20 +0000 (11:14 +0100)]
Bump version to 1.2.0

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoswrap: Also log the process name
Andreas Schneider [Mon, 12 Nov 2018 14:22:35 +0000 (15:22 +0100)]
swrap: Also log the process name

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoswrap: Better handling for default values in socket_wrapper_max_sockets()
Andreas Schneider [Tue, 13 Nov 2018 07:31:43 +0000 (08:31 +0100)]
swrap: Better handling for default values in socket_wrapper_max_sockets()

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>
5 months agoswrap: Always allocate the socket fd array to the maximum
Andreas Schneider [Mon, 12 Nov 2018 16:34:08 +0000 (17:34 +0100)]
swrap: Always allocate the socket fd array to the maximum

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>
5 months agoswrap: Rename global variable for max sockets
Andreas Schneider [Mon, 12 Nov 2018 16:00:09 +0000 (17:00 +0100)]
swrap: Rename global variable for max sockets

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>
5 months agotests: Enable threaded test cases on FreeBSD
Anoop C S [Sat, 10 Nov 2018 05:27:27 +0000 (10:57 +0530)]
tests: Enable threaded test cases on FreeBSD

It was previously judged as a bug which now turned to be due to
wrong backlog count set in echo_srv while listening on socket.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Increase backlog count for listen() in echo_srv
Anoop C S [Sat, 10 Nov 2018 05:26:24 +0000 (10:56 +0530)]
tests: Increase backlog count for listen() in echo_srv

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agogitlab-ci: Add csbuild
Andreas Schneider [Wed, 7 Nov 2018 07:31:50 +0000 (08:31 +0100)]
gitlab-ci: Add csbuild

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Protect IPv6 in st_echo_tcp_get_peer_sock_name
Andreas Schneider [Wed, 7 Nov 2018 08:05:30 +0000 (09:05 +0100)]
tests: Protect IPv6 in st_echo_tcp_get_peer_sock_name

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: SWRAP_REQUIRED_LIBRARIES should be a list
Andreas Schneider [Wed, 7 Nov 2018 08:02:35 +0000 (09:02 +0100)]
cmake: SWRAP_REQUIRED_LIBRARIES should be a list

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Set LINK_FLAGS for echo_srv
Andreas Schneider [Wed, 7 Nov 2018 08:14:40 +0000 (09:14 +0100)]
cmake: Set LINK_FLAGS for echo_srv

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Set LINK_FLAGS for socket_wrapper
Andreas Schneider [Wed, 7 Nov 2018 08:13:26 +0000 (09:13 +0100)]
cmake: Set LINK_FLAGS for socket_wrapper

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Only set default flags if they have been detected
Andreas Schneider [Wed, 7 Nov 2018 08:25:54 +0000 (09:25 +0100)]
cmake: Only set default flags if they have been detected

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Disable stack protector on Solaris
Andreas Schneider [Wed, 7 Nov 2018 08:27:38 +0000 (09:27 +0100)]
cmake: Disable stack protector on Solaris

They don't work.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agogitlab-ci: Enable freebsd runner
Andreas Schneider [Tue, 30 Oct 2018 12:01:27 +0000 (13:01 +0100)]
gitlab-ci: Enable freebsd runner

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Disable failing tests as on FreeBSD
Andreas Schneider [Tue, 30 Oct 2018 12:00:51 +0000 (13:00 +0100)]
tests: Disable failing tests as on FreeBSD

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Create a list with required libraries
Andreas Schneider [Wed, 31 Oct 2018 07:07:17 +0000 (08:07 +0100)]
cmake: Create a list with required libraries

This should fix the build on OmniOS.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Protect IPv6 function in setup_echo_srv_tcp_ipv6
Andreas Schneider [Mon, 5 Nov 2018 07:29:25 +0000 (08:29 +0100)]
tests: Protect IPv6 function in setup_echo_srv_tcp_ipv6

Fixes the build on OmniOS.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Protect IPv6 case in echo_srv
Andreas Schneider [Wed, 31 Oct 2018 07:04:03 +0000 (08:04 +0100)]
tests: Protect IPv6 case in echo_srv

This fixes the build on OmniOS.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoswrap: Protect IPv6 case in swrap_socket()
Andreas Schneider [Wed, 31 Oct 2018 07:02:25 +0000 (08:02 +0100)]
swrap: Protect IPv6 case in swrap_socket()

Fixes the build on OmniOS

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Don't use string PREPEND
Andreas Schneider [Wed, 24 Oct 2018 06:44:19 +0000 (08:44 +0200)]
cmake: Don't use string PREPEND

This is only supported in cmake >= 3.10.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
5 months agoswrap: Fix coverity issues
Anoop C S [Fri, 26 Oct 2018 10:14:53 +0000 (15:44 +0530)]
swrap: Fix coverity issues

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>
5 months agogitlab-ci: Disable the FreeBSD runner
Andreas Schneider [Tue, 2 Oct 2018 14:40:16 +0000 (16:40 +0200)]
gitlab-ci: Disable the FreeBSD runner

There is a threading race condition in FreeBSD.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agogitlab-ci: Add helgrind tests
Andreas Schneider [Thu, 27 Sep 2018 19:10:45 +0000 (21:10 +0200)]
gitlab-ci: Add helgrind tests

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agogitlab-ci: Add runners and toolchain files
Andreas Schneider [Thu, 27 Sep 2018 15:56:11 +0000 (17:56 +0200)]
gitlab-ci: Add runners and toolchain files

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Init in_addr only once in test_tcp_socket_overwrite
Andreas Schneider [Mon, 1 Oct 2018 19:34:44 +0000 (21:34 +0200)]
tests: Init in_addr only once in test_tcp_socket_overwrite

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Return an error if setenv() fails in test_max_sockets
Andreas Schneider [Mon, 1 Oct 2018 19:28:27 +0000 (21:28 +0200)]
tests: Return an error if setenv() fails in test_max_sockets

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Check the correct return code in test_thread_echo_tcp_write_read
Andreas Schneider [Mon, 1 Oct 2018 19:28:06 +0000 (21:28 +0200)]
tests: Check the correct return code in test_thread_echo_tcp_write_read

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Check return code of connect in test_thread_echo_tcp_sendmsg_recvmsg
Andreas Schneider [Mon, 1 Oct 2018 19:27:40 +0000 (21:27 +0200)]
tests: Check return code of connect in test_thread_echo_tcp_sendmsg_recvmsg

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Check the return code of connect in test_echo_udp_sendmsg_recvmsg
Andreas Schneider [Mon, 1 Oct 2018 19:31:19 +0000 (21:31 +0200)]
tests: Check the return code of connect in test_echo_udp_sendmsg_recvmsg

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Check return code of connnect in test_echo_tcp_sendmsg_recvmsg
Andreas Schneider [Mon, 1 Oct 2018 19:27:14 +0000 (21:27 +0200)]
tests: Check return code of connnect in test_echo_tcp_sendmsg_recvmsg

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoecho_srv: Check for a valid pidfile pointer
Andreas Schneider [Mon, 1 Oct 2018 19:23:31 +0000 (21:23 +0200)]
echo_srv: Check for a valid pidfile pointer

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoecho_srv: Only use 128K as buffer size instead of 4MB
Andreas Schneider [Mon, 1 Oct 2018 08:54:53 +0000 (10:54 +0200)]
echo_srv: Only use 128K as buffer size instead of 4MB

This produced errors built with clang.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotorture: Wait longer for echo_srv startup
Andreas Schneider [Thu, 27 Sep 2018 16:19:42 +0000 (18:19 +0200)]
torture: Wait longer for echo_srv startup

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoecho_srv: Do not close bogus file descriptors
Andreas Schneider [Fri, 28 Sep 2018 10:55:49 +0000 (12:55 +0200)]
echo_srv: Do not close bogus file descriptors

==1564== Warning: invalid file descriptor 1048564 in syscall close()
==1564==    at 0x4D18534: close (in /lib64/libc-2.27.so)
==1564==    by 0x4046A74: libc_close (socket_wrapper.c:760)
==1564==    by 0x405105C: swrap_close (socket_wrapper.c:5933)
==1564==    by 0x40511F5: close (socket_wrapper.c:5979)
==1564==    by 0x401679: become_daemon (echo_srv.c:202)
==1564==    by 0x402D44: main (echo_srv.c:896)
==1563==

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoswrap: Don't do a deep bind if we run with libasan
Andreas Schneider [Sat, 1 Sep 2018 17:36:19 +0000 (19:36 +0200)]
swrap: Don't do a deep bind if we run with libasan

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoswrap: Add a mutex for resetting socket index
Andreas Schneider [Fri, 28 Sep 2018 10:46:30 +0000 (12:46 +0200)]
swrap: Add a mutex for resetting socket index

Fixes a helgrind error.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agoswrap: Fix helgrind errors
Anoop C S [Wed, 19 Sep 2018 08:11:49 +0000 (13:41 +0530)]
swrap: Fix helgrind errors

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Use assert_return_code() to get errno
Andreas Schneider [Fri, 28 Sep 2018 06:11:57 +0000 (08:11 +0200)]
tests: Use assert_return_code() to get errno

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Avoid -Wcast-align warning
Anoop C S [Wed, 29 Aug 2018 23:18:30 +0000 (04:48 +0530)]
tests: Avoid -Wcast-align warning

warning: cast from 'struct sockaddr *' to 'struct sockaddr_in *'
                increases required alignment from 2 to 4 [-Wcast-align]
        struct sockaddr_in *sinp = (struct sockaddr_in *)to; ^~~~~~~~~~~~~~~~~~~~~~~~

Above warning can be avoided by making use of sockaddr_in available
within torture_address from the caller of echo_udp_recv_from_to().
Following that sa_socklen from torture_address can be used instead of
passing sa_socklen explicitly to echo_udp_recv_from_to().

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agotests: Fix -Wformat gcc warning
Anoop C S [Tue, 28 Aug 2018 16:41:31 +0000 (22:11 +0530)]
tests: Fix -Wformat gcc warning

test_fork_thread_deadlock.c:48:25: warning: format ‘%d’ expects argument
    of type ‘int’, but argument 3 has type ‘pid_t {aka long int}’ [-Wformat=]

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Fix checking for required system libraries
Andreas Schneider [Thu, 27 Sep 2018 16:31:26 +0000 (18:31 +0200)]
cmake: Fix checking for required system libraries

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Use target_include_directories()
Andreas Schneider [Thu, 27 Sep 2018 15:52:19 +0000 (17:52 +0200)]
cmake: Use target_include_directories()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Require modern cmake version
Andreas Schneider [Mon, 10 Sep 2018 06:34:03 +0000 (08:34 +0200)]
cmake: Require modern cmake version

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Update AddCMockaTest
Andreas Schneider [Thu, 27 Sep 2018 15:22:57 +0000 (17:22 +0200)]
cmake: Update AddCMockaTest

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Update cmocka requirement
Andreas Schneider [Thu, 27 Sep 2018 15:50:02 +0000 (17:50 +0200)]
cmake: Update cmocka requirement

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Support running the tests with AddressSanitizer
Andreas Schneider [Sat, 1 Sep 2018 18:46:52 +0000 (20:46 +0200)]
cmake: Support running the tests with AddressSanitizer

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Add CFLAGS for AddressSanitizer and UndefinedSanitizer
Andreas Schneider [Wed, 5 Sep 2018 13:39:35 +0000 (15:39 +0200)]
cmake: Add CFLAGS for AddressSanitizer and UndefinedSanitizer

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Move Compiler flags to new file
Andreas Schneider [Wed, 5 Sep 2018 13:38:37 +0000 (15:38 +0200)]
cmake: Move Compiler flags to new file

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Remove obsolete DefineCompilerFlags.cmake
Andreas Schneider [Sun, 2 Sep 2018 09:18:45 +0000 (11:18 +0200)]
cmake: Remove obsolete DefineCompilerFlags.cmake

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Improve checks for compiler flags
Andreas Schneider [Sun, 2 Sep 2018 09:18:09 +0000 (11:18 +0200)]
cmake: Improve checks for compiler flags

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Update CMake defaults
Andreas Schneider [Tue, 2 Oct 2018 14:37:43 +0000 (16:37 +0200)]
cmake: Update CMake defaults

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Suppress helgrind race condition warning we created on purpose
Andreas Schneider [Fri, 28 Sep 2018 09:01:15 +0000 (11:01 +0200)]
cmake: Suppress helgrind race condition warning we created on purpose

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Create an error if helgrind finds a bug
Andreas Schneider [Thu, 27 Sep 2018 19:08:23 +0000 (21:08 +0200)]
cmake: Create an error if helgrind finds a bug

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Write helgrind logs to stderr so we can see them
Andreas Schneider [Thu, 6 Sep 2018 16:40:17 +0000 (18:40 +0200)]
cmake: Write helgrind logs to stderr so we can see them

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 months agocmake: Don't misuse CMAKE_REQUIRED_LIBRARIES
Andreas Schneider [Sat, 1 Sep 2018 18:32:04 +0000 (20:32 +0200)]
cmake: Don't misuse CMAKE_REQUIRED_LIBRARIES

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agotests: Update valgrind suppression file
Andreas Schneider [Tue, 14 Aug 2018 09:42:38 +0000 (11:42 +0200)]
tests: Update valgrind suppression file

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agocmake: Require at least cmake 3.2.0
Andreas Schneider [Thu, 9 Aug 2018 09:16:29 +0000 (11:16 +0200)]
cmake: Require at least cmake 3.2.0

This allows us to modernize the CMakeLists.txt

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoctest: Move to new dashboard
Andreas Schneider [Thu, 5 Jul 2018 08:14:14 +0000 (10:14 +0200)]
ctest: Move to new dashboard

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoswrap: Add error check around pthread mutex locks
Anoop C S [Tue, 12 Jun 2018 14:49:34 +0000 (20:19 +0530)]
swrap: Add error check around pthread mutex locks

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agotests: Prevent child process falling to defunct state
Anoop C S [Wed, 27 Jun 2018 18:05:28 +0000 (23:35 +0530)]
tests: Prevent child process falling to defunct state

Parent process does not wait for child process(which gets forked after
accepting a client connection) to exit inside echo server which in turn
puts child into defunct state. Even though those defunct childs are
cleaned up during parent exit it is better to wait from parent process
itself.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agodoc: Add SOCKET_WRAPPER_MAX_SOCKETS to manual page
Anoop C S [Mon, 25 Jun 2018 13:45:44 +0000 (19:15 +0530)]
doc: Add SOCKET_WRAPPER_MAX_SOCKETS to manual page

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoswrap: Fix thread deadlock found by Coverity scan
Anoop C S [Fri, 15 Jun 2018 07:06:54 +0000 (12:36 +0530)]
swrap: Fix thread deadlock found by Coverity scan

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>
8 months agotests: Add missing header for IPPROTO_TCP
Andreas Schneider [Fri, 29 Jun 2018 13:17:10 +0000 (15:17 +0200)]
tests: Add missing header for IPPROTO_TCP

This fixes the build on FreeBSD.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoswrap: Update header
Andreas Schneider [Fri, 22 Jun 2018 06:47:08 +0000 (08:47 +0200)]
swrap: Update header

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoUpdate LICENSE
Andreas Schneider [Fri, 22 Jun 2018 06:42:06 +0000 (08:42 +0200)]
Update LICENSE

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoRename COPYING to LICENSE
Andreas Schneider [Fri, 22 Jun 2018 06:38:04 +0000 (08:38 +0200)]
Rename COPYING to LICENSE

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agocpack: Do not package build dirs in source tarball
Andreas Schneider [Fri, 22 Jun 2018 07:01:19 +0000 (09:01 +0200)]
cpack: Do not package build dirs in source tarball

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
10 months agoswrap: Replace socket_fds linked list with an array
Anoop C S [Sun, 10 Jun 2018 07:49:14 +0000 (13:19 +0530)]
swrap: Replace socket_fds linked list with an array

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>
11 months agotests: Fix resouce leak in echo_srv tcp handling
Andreas Schneider [Fri, 4 May 2018 06:01:29 +0000 (08:01 +0200)]
tests: Fix resouce leak in echo_srv tcp handling

CID 175587

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
11 months agocmake: Run threaded tests with helgrind
Andreas Schneider [Wed, 2 May 2018 15:05:21 +0000 (17:05 +0200)]
cmake: Run threaded tests with helgrind

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests: Add test case to validate free-list indexes
Anoop C S [Wed, 31 Jan 2018 17:13:21 +0000 (22:43 +0530)]
tests: Add test case to validate free-list indexes

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agoswrap: Update free-list only when refcount is zero
Anoop C S [Wed, 31 Jan 2018 17:16:23 +0000 (22:46 +0530)]
swrap: Update free-list only when refcount is zero

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agoswrap: Move metadata into socket_info_meta structure
Michael Adam [Wed, 12 Jul 2017 23:25:19 +0000 (01:25 +0200)]
swrap: Move metadata into socket_info_meta structure

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>
11 months agotests: New threaded test cases
Anoop C S [Thu, 2 Mar 2017 07:26:20 +0000 (07:26 +0000)]
tests: New threaded test cases

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>