Actually implement the socket option. --- tests/Makefile.am | 2 ++ server/sockets.c | 12 +++++++++++ tests/test-tfo-unix.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+)
diff --git a/tests/Makefile.am b/tests/Makefile.am index 4bf9a4568f..dc5b6c9a6c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -313,6 +313,7 @@ TESTS += \ test-timeout-cancel.sh \ test-keepalive.sh \ test-tfo-default.sh \ + test-tfo-unix.sh \ $(NULL) if !IS_WINDOWS TESTS += \ @@ -371,6 +372,7 @@ EXTRA_DIST += \ test-stdio.sh \ test-swap.sh \ test-tfo-default.sh \ + test-tfo-unix.sh \ test-timeout.sh \ test-timeout.py \ test-timeout-cancel.sh \ diff --git a/server/sockets.c b/server/sockets.c index 348da029a9..07b0cf4787 100644 --- a/server/sockets.c +++ b/server/sockets.c @@ -229,6 +229,18 @@ bind_tcpip_socket (sockets *socks) if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) == -1) perror ("setsockopt: SO_REUSEADDR"); + if (fastopen) { + /* 5 is what dnsmasq uses. I've also seen 1 being used here. + * The manpages documentation says this is the maximum length of + * the SYN packet, which is wrong. + */ + const int qlen = 5; + + if (setsockopt (sock, IPPROTO_TCP, TCP_FASTOPEN, + &qlen, sizeof qlen) == -1) + perror ("setsockopt: TCP_FASTOPEN"); + } + #ifdef IPV6_V6ONLY if (a->ai_family == PF_INET6) { if (setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof opt) == -1) diff --git a/tests/test-tfo-unix.sh b/tests/test-tfo-unix.sh new file mode 100755 index 0000000000..36306d8b6d --- /dev/null +++ b/tests/test-tfo-unix.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# nbdkit +# Copyright Red Hat +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Red Hat nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +# Test the --tfo and --no-tfo options do nothing for non-supported +# Unix sockets. + +source ./functions.sh +set -e +set -x + +requires_run +requires_plugin null +requires_nbdinfo + +nbdkit --tfo null --run 'nbdinfo "$uri"' +nbdkit --no-tfo null --run 'nbdinfo "$uri"' -- 2.46.0 _______________________________________________ Libguestfs mailing list -- guestfs@lists.libguestfs.org To unsubscribe send an email to guestfs-le...@lists.libguestfs.org