]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoBUG/MEDIUM: htx: fix typo in htx_replace_stline() making it fail all the time
Willy Tarreau [Fri, 7 Dec 2018 16:12:22 +0000 (17:12 +0100)] 
BUG/MEDIUM: htx: fix typo in htx_replace_stline() making it fail all the time

A typo in the block type check makes this function fail all the time,
which has impact on anything rewriting a start line (set-uri, set-path
etc).

No backport needed.

6 years agoMINOR: sample: add bc_http_major
Jérôme Magnin [Fri, 7 Dec 2018 08:03:11 +0000 (09:03 +0100)] 
MINOR: sample: add bc_http_major

This adds the sample fetch bc_http_major. It returns the backend connection's HTTP
version encoding, which may be 1 for HTTP/0.9 to HTTP/1.1 or 2 for HTTP/2.0. It is
based on the on-wire encoding, and not the version present in the request header.

6 years agoBUG/MEDIUM: sample: Don't treat SMP_T_METH as SMP_T_STR.
Olivier Houchard [Fri, 7 Dec 2018 14:23:41 +0000 (15:23 +0100)] 
BUG/MEDIUM: sample: Don't treat SMP_T_METH as SMP_T_STR.

In smp_dup(), don't consider a SMP_T_METH with an unknown method the same as
SMP_T_STR. The string and string length aren't stored at the same place.

This should be backported to 1.8.

6 years agoREGTEST: add a basic test for HTTP rules manipulating headers
Willy Tarreau [Fri, 7 Dec 2018 14:18:54 +0000 (15:18 +0100)] 
REGTEST: add a basic test for HTTP rules manipulating headers

There is always a risk of breaking HTTP processing when performing certain
code changes. This test modifies a request's start line, uses variables,
adds and modifies headers, interleaves them with the start-line changes,
and makes use of different header formats involving duplicated names,
duplicated values, empty fields and spaces around values. These operations
are performed both in the frontend and in the backend, for both the request
and the response. A CRC is computed on the concatenation of all the values,
and the concatenations are sent as individual header fields as well to help
debugging when the test fails.

The test reliably works since 1.6, implying that the HTTP processing did
not change. It currently fails on HTX.

6 years agoREGTEST: fix the Lua test file name in test lua/h00002 :-)
Willy Tarreau [Fri, 7 Dec 2018 14:25:26 +0000 (15:25 +0100)] 
REGTEST: fix the Lua test file name in test lua/h00002 :-)

The file was moved but the lua file was not renamed in the VTC, leading
to a failure when launched from a clean tree.

6 years agoBUG/MINOR: stream-int: Process read0 even if no data was received in si_cs_recv
Christopher Faulet [Fri, 7 Dec 2018 13:51:20 +0000 (14:51 +0100)] 
BUG/MINOR: stream-int: Process read0 even if no data was received in si_cs_recv

The flag CS_FL_EOS can be set while no data was received. So the flas
CS_FL_RCV_MORE is not set. In this case, the read0 was never processed by the
stream interface. To be sure to process it, the test on CS_FL_RCV_MORE has been
moved after the one on CS_FL_EOS.

6 years agoMINOR: mux-h1: Set CS_FL_EOS when read0 is detected and no data are pending
Christopher Faulet [Fri, 7 Dec 2018 10:39:55 +0000 (11:39 +0100)] 
MINOR: mux-h1: Set CS_FL_EOS when read0 is detected and no data are pending

In h1_process(), instead of setting CS_FL_REOS in this case, it is more accurate
to set CS_FL_EOS.

6 years agoMINOR: htx: switch to case sensitive search of lower case header names
Willy Tarreau [Fri, 7 Dec 2018 10:38:03 +0000 (11:38 +0100)] 
MINOR: htx: switch to case sensitive search of lower case header names

Now that we know that htx only contains lower case header names, there
is no need anymore for looking them up in a case-insensitive manner.

Note that http_find_header() still does it because header names to
compare against may come from everywhere there.

6 years agoMEDIUM: ist: use local conversion arrays to case conversion
Willy Tarreau [Fri, 7 Dec 2018 08:40:01 +0000 (09:40 +0100)] 
MEDIUM: ist: use local conversion arrays to case conversion

Calling tolower/toupper for each character is slow, a lookup into a
256-byte table is cheaper, especially for common characters used in
header field names which all fit into a cache line. Let's create these
two variables marked weak so that they're included only once.

6 years agoMINOR: h2: don't turn HTX header names to lower case anymore
Willy Tarreau [Fri, 7 Dec 2018 07:57:20 +0000 (08:57 +0100)] 
MINOR: h2: don't turn HTX header names to lower case anymore

Since HTX stores header names in lower case already, we don't need to
do it again anymore. This increased H2 performance by 2.7% on quick
tests, now making H2 overr HTX about 5.5% faster than H2 over H1.

6 years agoMEDIUM: ist: always turn header names to lower case
Willy Tarreau [Fri, 7 Dec 2018 07:47:45 +0000 (08:47 +0100)] 
MEDIUM: ist: always turn header names to lower case

HTTP/2 and above require header names to be lower cased, while HTTP/1
doesn't care. By making lower case the standard way to store header
names in HTX, we can significantly simplify all operations applying to
header names retrieved from HTX (including, but not limited to, lookups
and lower case checks which are not needed anymore).

As a side effect of replacing memcpy() with ist2bin_lc(), a small increase
of the request rate performance of about 0.5-1% was noticed on keep-alive
traffic, very likely due to memcpy() being overkill for tiny strings.

This trivial patch was marked medium because it may have a visible end-user
impact (e.g. non-HTTP compliant agent, etc).

6 years agoMINOR: ist: add functions to copy/uppercase/lowercase into a buffer or string
Willy Tarreau [Fri, 7 Dec 2018 07:35:07 +0000 (08:35 +0100)] 
MINOR: ist: add functions to copy/uppercase/lowercase into a buffer or string

The ist functions were missing functions to copy an IST into a target
buffer, making some code have to resort to memcpy(), which tends to be
overkill for small strings, that the compiler cannot guess. In addition
sometimes there is a need to turn a string to lower or upper case so it
had to be overwritten after the operation.

This patch adds 6 functions to copy an ist to a buffer, as binary or as a
string (i.e. a zero is or is not appended), and optionally to apply a
lower case or upper case transformation on the fly.

A number of tests were performed to optimize the processing for small
strings. The loops are marked unlikely to dissuade the compilers from
over-optimizing them and switching to SIMD instructions. The lower case
or upper case transformations used to rely on external functions for
each character and to crappify the code due to clobbered registers,
which is not acceptable when we know that only a certain class of chars
has to be transformed, so the test was open-coded.

6 years agoREGTEST: Move LUA reg test 4 to level 1.
Frédéric Lécaille [Fri, 7 Dec 2018 10:16:35 +0000 (11:16 +0100)] 
REGTEST: Move LUA reg test 4 to level 1.

This Pieter script deserves to be moved to level 1 (feature test).

6 years agoBUG/MEDIUM: mux-h1: Be sure to have a conn_stream to set CS_FL_REOS in h1_recv
Christopher Faulet [Fri, 7 Dec 2018 08:42:49 +0000 (09:42 +0100)] 
BUG/MEDIUM: mux-h1: Be sure to have a conn_stream to set CS_FL_REOS in h1_recv

In the commit 6a2d33481 ("BUG/MEDIUM: h1: Set CS_FL_REOS if we had a read0."),
We set the flag CS_FL_REOS on the conn_stream when a read0 is detected. But we
must be sure to have a conn_stream first.

6 years agoBUG/MEDIUM: h1: Set CS_FL_REOS if we had a read0.
Olivier Houchard [Thu, 6 Dec 2018 16:41:26 +0000 (17:41 +0100)] 
BUG/MEDIUM: h1: Set CS_FL_REOS if we had a read0.

In h1_recv(), if we get a read0, let the conn_stream know by setting the
CS_FL_REOS flag, or it may never be aware we did hit EOS.

This should not be backported.

6 years agoBUG/MEDIUM: h1: Don't free the connection if it's an outgoing connection.
Olivier Houchard [Thu, 6 Dec 2018 17:54:54 +0000 (18:54 +0100)] 
BUG/MEDIUM: h1: Don't free the connection if it's an outgoing connection.

In h1_process(), don't release the connection if it is an outgoing connection
and we don't have an h1s associated, if it is so it is probably just in
a pool.

6 years agoBUG/MEDIUM: connections: Split CS_FL_RCV_MORE into 2 flags.
Olivier Houchard [Thu, 6 Dec 2018 15:22:29 +0000 (16:22 +0100)] 
BUG/MEDIUM: connections: Split CS_FL_RCV_MORE into 2 flags.

CS_FL_RCV_MORE is used in two cases, to let the conn_stream
know there may be more data available, and to let it know that
it needs more room. We can't easily differentiate between the
two, and that may leads to hangs, so split it into two flags,
CS_FL_RCV_MORE, that means there may be more data, and
CS_FL_WANT_ROOM, that means we need more room.

This should not be backported.

6 years agoSCRIPTS/REGTEST: merge grep+sed into sed in run-regtests
Willy Tarreau [Thu, 6 Dec 2018 14:49:27 +0000 (15:49 +0100)] 
SCRIPTS/REGTEST: merge grep+sed into sed in run-regtests

Some commands chain grep and sed while sed already does grep by
default, let's simply use sed. In addition to being more intuitive,
it saves up to 150ms per run on the 13 tests covered by level 4.

6 years agoBUG/MEDIUM: mworker: fix several typos in mworker_cleantasks()
William Lallemand [Thu, 6 Dec 2018 14:14:37 +0000 (15:14 +0100)] 
BUG/MEDIUM: mworker: fix several typos in mworker_cleantasks()

Commit 27f3fa5 ("BUG/MEDIUM: mworker: stop every tasks in the master")
used MAX_THREADS as a mask instead of MAX_THREADS_MASK to clean the
global run queue, and used rq_next (global variable) instead of next_rq.

Renamed next_rq as tmp_rq and next_wq as tmp_wq to avoid confusion.

No backport needed.

6 years agoBUG/MEDIUM: lua: block on remote connection establishment
Willy Tarreau [Thu, 6 Dec 2018 14:29:50 +0000 (15:29 +0100)] 
BUG/MEDIUM: lua: block on remote connection establishment

We used to wait for the other side to be connected, but the blocking
flags were inaccurate. It used to work fine almost by accident before
the stream interface changes. Now we use the new RXBLK_CONN flag to
explicitly subscribe to this event.

Thanks to Adis for reporting the issue, PiBaNL for the test case,
and Olivier for the diagnostic.

No backport is needed.

6 years agoBUG/MEDIUM: stream-int: don't attempt to receive if the connection is not established
Willy Tarreau [Thu, 6 Dec 2018 14:25:58 +0000 (15:25 +0100)] 
BUG/MEDIUM: stream-int: don't attempt to receive if the connection is not established

If we try to receive before the connection is established, we lose the
send event and are not woken up anymore once the connection is established.
This was diagnosed by Olivier.

No backport is needed.

6 years agoMINOR: stream-int: add a new blocking condition on the remote connection
Willy Tarreau [Thu, 6 Dec 2018 14:24:01 +0000 (15:24 +0100)] 
MINOR: stream-int: add a new blocking condition on the remote connection

There are some situations where we need to wait for the other side to
be connected. None of the current blocking flags support this. It used
to work more or less by accident using the old flags. Let's add a new
flag to mention we're blocking on this, it's removed by si_chk_rcv()
when a connection is established. It should be enough for now.

6 years agoBUG/MEDIUM: connections: Reuse an already attached conn_stream.
Olivier Houchard [Wed, 5 Dec 2018 16:08:55 +0000 (17:08 +0100)] 
BUG/MEDIUM: connections: Reuse an already attached conn_stream.

In connect_server(), if we already have a conn_stream, reuse it
instead of trying to create a new one. http_proxy and LUA both
manually create a conn_stream and a connection, and we want
to use it.

6 years agoBUG/MEDIUM: stream: Don't dereference s->txn when it is not there yet.
Olivier Houchard [Thu, 6 Dec 2018 12:28:30 +0000 (13:28 +0100)] 
BUG/MEDIUM: stream: Don't dereference s->txn when it is not there yet.

Test if s->txn is non-NULL before attempting to dereference it, it was lost
during the transition to HTX.

6 years agoBUG/MEDIUM: htx: Set the right start-line offset after a defrag
Christopher Faulet [Thu, 6 Dec 2018 13:31:12 +0000 (14:31 +0100)] 
BUG/MEDIUM: htx: Set the right start-line offset after a defrag

The offset was always wrong after an HTX defragmentation because the wrong
address was used and because the update could occcur several time on the same
defragmentation.

6 years agoBUG/MEDIUM: mworker: stop every tasks in the master
William Lallemand [Thu, 6 Dec 2018 13:05:20 +0000 (14:05 +0100)] 
BUG/MEDIUM: mworker: stop every tasks in the master

The master is not supposed to run (at the moment) any task before the
polling loop, the created tasks should be run only in the workers but in
the master they should be disabled or removed.

No backport needed.

6 years agoMINOR: mux-h1: Drain obuf if the output is closed after sending data
Christopher Faulet [Thu, 6 Dec 2018 09:56:20 +0000 (10:56 +0100)] 
MINOR: mux-h1: Drain obuf if the output is closed after sending data

It avoids to subscribe to send events because some may remain in the output
buffer. If the output is closed or if an error occurred, there is no way to send
these data anyway, so it is safe to drain them.

6 years agoBUG/MEDIUM: mux-h2: stop sending using HTX on errors
Willy Tarreau [Thu, 6 Dec 2018 13:09:09 +0000 (14:09 +0100)] 
BUG/MEDIUM: mux-h2: stop sending using HTX on errors

We didn't take care of the stream error in the HTX send loop, causing
some errors (like buffer full) to provoke 100% CPU.

No backport is needed.

6 years agoBUG/MEDIUM: mux-h2: use the correct offset for the HTX start line
Willy Tarreau [Thu, 6 Dec 2018 13:07:27 +0000 (14:07 +0100)] 
BUG/MEDIUM: mux-h2: use the correct offset for the HTX start line

Due to a thinko, I used sl_off as the start line index number but it's
not it, it's its offset. The first index is obtained using htx_get_head(),
and the start line is obtained using htx_get_sline(). This caused crashes
to happen when forwarding HTX traffic via the H2 mux once the HTX buffer
started to wrap.

No backport is needed.

6 years agoMINOR: mux-h1: Allow partial data consumption during outgoing data processing
Christopher Faulet [Thu, 6 Dec 2018 10:39:49 +0000 (11:39 +0100)] 
MINOR: mux-h1: Allow partial data consumption during outgoing data processing

In h1_process_output(), instead of waiting to have enough data to send to
consume a full block of data, we are now able consume partially these blocks.

6 years agoCLEANUP: htx: Fix indentation here and there in HTX files
Christopher Faulet [Wed, 5 Dec 2018 15:20:40 +0000 (16:20 +0100)] 
CLEANUP: htx: Fix indentation here and there in HTX files

6 years agoMINOR: mux-h1: Don't adjust anymore the amount of data sent in h1_snd_buf()
Christopher Faulet [Wed, 5 Dec 2018 14:53:38 +0000 (15:53 +0100)] 
MINOR: mux-h1: Don't adjust anymore the amount of data sent in h1_snd_buf()

Because the infinite forward is now HTX aware, it is now useless to tinker with
the number of bytes really sent.

6 years agoMEDIUM: channel/htx: Add functions for forward HTX data
Christopher Faulet [Wed, 5 Dec 2018 10:56:15 +0000 (11:56 +0100)] 
MEDIUM: channel/htx: Add functions for forward HTX data

To ease the fast forwarding and the infinte forwarding on HTX proxies, 2
functions have been added to let the channel be almost aware of the way data are
stored in its buffer. By calling these functions instead of legacy ones, we are
sure to forward the right amount of data.

6 years agoMEDIUM: htx: Rework conversion from a buffer to an htx structure
Christopher Faulet [Wed, 5 Dec 2018 10:53:24 +0000 (11:53 +0100)] 
MEDIUM: htx: Rework conversion from a buffer to an htx structure

Now, the function htx_from_buf() will set the buffer's length to its size
automatically. In return, the caller should call htx_to_buf() at the end to be
sure to leave the buffer hosting the HTX message in the right state. When the
caller can use the function htxbuf() to get the HTX message without any update
on the underlying buffer.

6 years agoBUG/MINOR: mux-h1: Check h1m flags to set the server conn_mode on request path
Christopher Faulet [Wed, 5 Dec 2018 12:50:11 +0000 (13:50 +0100)] 
BUG/MINOR: mux-h1: Check h1m flags to set the server conn_mode on request path

On the server side, we must test the request headers to deduce if we able to do
keepalive or not. Otherwise, by default, the keepalive will be enabled on the
server's connection, whatever the client said.

6 years agoBUG/MEDIUM: stream-int: don't mark as blocked an empty buffer on Rx
Willy Tarreau [Wed, 5 Dec 2018 12:45:41 +0000 (13:45 +0100)] 
BUG/MEDIUM: stream-int: don't mark as blocked an empty buffer on Rx

After 8706c8131 ("BUG/MEDIUM: mux_pt: Always set CS_FL_RCV_MORE."), a
side effect caused failed receives to mark the buffer as missing room,
a flag that no other place can remove since it's empty. Ideally we need
a separate flag to mean "failed to deliver data by lack of room", but
in the mean time at the very least we must not mark as blocked an
empty buffer.

No backport is needed.

6 years agoMEDIUM: mux-h1: avoid a double copy on the Tx path whenever possible
Willy Tarreau [Wed, 5 Dec 2018 10:19:27 +0000 (11:19 +0100)] 
MEDIUM: mux-h1: avoid a double copy on the Tx path whenever possible

In order to properly deal with unaligned contents, the output data are
currently copied into a temporary buffer, to be copied into the mux's
output buffer at the end. The new buffer API allows several buffers to
share the same data area, so we're using this here to make the temporary
buffer point to the same area as the output buffer when that one is
empty. This is enough to avoid the copy at the end, only pointers and
lengths have to be adjusted. In addition the output buffer's head is
advanced by the HTX header size so that the remaining copy is aligned.

By doing this we improve the large object performance by an extra 10%,
which is 64% above the 1.9-dev9 state. It's worth noting that there are
no more calls to __memcpy_sse2_unaligned() now.

Since this code deals with various block types, it appears difficult to
adjust it to be smart enough to even avoid the first copy. However a
distinct approach could consist in trying to detect a single blocked
HTX and jump to dedicated code in this case.

6 years agoMEDIUM: mux-h1: attempt to zero-copy Rx DATA transfers
Willy Tarreau [Wed, 5 Dec 2018 09:02:39 +0000 (10:02 +0100)] 
MEDIUM: mux-h1: attempt to zero-copy Rx DATA transfers

When transferring large objects, most calls are made between a full
buffer and an empty buffer. In this case there is a large opportunity
for performing zero-copy calls, with a few exceptions : the input data
must fit into the output buffer, and the data need to be properly
aligned and formated to let the HTX header fit before and the HTX
block(s) fit after.

This patch does two things :

1) it makes sure that we prepare an empty input buffer before an recv()
   call so that it appears as holding an HTX block at the front, which is
   removed afterwards. This way the data received using recv() are placed
   exactly at the target position in the input buffer for a later cast to
   HTX.

2) when receiving data in h1_process_data(), if it appears that the input
   buffer can be cast to an HTX buffer and the target buffer is empty,
   then the buffers are swapped, an HTX block is prepended in front of the
   data area, and the HTX block is appended to reference this data block.

In practice, this ensures that in most cases when transferring large files,
calls to h1_rcv_buf() are made using zero copy and a little bit of buffer
preparation (~40 bytes to be written).

Doing this adds an extra 13% performance boost on top of previous patch,
resulting in a total of 50% speed up on large transfers.

6 years agoMEDIUM: mux-h1: make use of buf_room_for_htx_data() instead of b_room()
Willy Tarreau [Wed, 5 Dec 2018 06:59:27 +0000 (07:59 +0100)] 
MEDIUM: mux-h1: make use of buf_room_for_htx_data() instead of b_room()

Just by using this buffer room estimation for the demux buffer, the large
object performance has increased by up to 33%. This is mostly due to less
recv() calls and unaligned copies.

6 years agoMINOR: htx: add buf_room_for_htx_data() to help optimize buffer transfers
Willy Tarreau [Wed, 5 Dec 2018 06:56:25 +0000 (07:56 +0100)] 
MINOR: htx: add buf_room_for_htx_data() to help optimize buffer transfers

The small HTX overhead is enough to make the system perform multiple
reads and unaligned memory copies. Here we provide a function whose
purpose is to reduce the apparent room in a buffer by the size of the
overhead for DATA blocks, which is the struct htx plus 2 blocks (one
for DATA, one for the end of message so that small blocks can fit at
once). The muxes using HTX will be encouraged to use this one instead
of b_room() to compute the available buffer room and avoid filling
their demux buf with more data than can fit at once into the HTX
buffer.

6 years agoMINOR: htx: make htx_from_buf() adjust the size only on new buffers
Willy Tarreau [Wed, 5 Dec 2018 08:47:34 +0000 (09:47 +0100)] 
MINOR: htx: make htx_from_buf() adjust the size only on new buffers

This one is used a lot during transfers, let's avoid resetting its
size when there are already data in the buffer since it implies the
size is correct.

6 years agoBUG/MEDIUM: mux_pt: Always set CS_FL_RCV_MORE.
Olivier Houchard [Tue, 4 Dec 2018 18:17:25 +0000 (19:17 +0100)] 
BUG/MEDIUM: mux_pt: Always set CS_FL_RCV_MORE.

When using the mux_pt, as we can't know if there's more data to be read,
always set CS_FL_RCV_MORE, and only remove it if we got an error or a shutr
and rcv_buf() returned 0.

6 years agoMEDIUM: h1: Realign the ibuf before calling rcv_buf if needed.
Olivier Houchard [Tue, 4 Dec 2018 17:16:45 +0000 (18:16 +0100)] 
MEDIUM: h1: Realign the ibuf before calling rcv_buf if needed.

If the ibuf only contains a small amount of data, realign it
before calling rcv_buf(), as it's probably going to be cheaper
to do so than to do 2 calls to recv().

6 years agoBUG/MEDIUM: h1: Correctly report used data with no len.
Olivier Houchard [Tue, 4 Dec 2018 16:41:58 +0000 (17:41 +0100)] 
BUG/MEDIUM: h1: Correctly report used data with no len.

When we have no content-length, and not in chunk mode, correctly
report the used data. We really used "ret", and not "max".

6 years agoMINOR: mux-h2: stop on non-DATA and non-EOM HTX blocks
Willy Tarreau [Tue, 4 Dec 2018 14:28:03 +0000 (15:28 +0100)] 
MINOR: mux-h2: stop on non-DATA and non-EOM HTX blocks

We don't want to send such blocks as DATA frames if they were ever to
appear, let's quit when meeting them.

6 years agoBUG/MEDIUM: mux-h2: don't send more HTX data than requested
Willy Tarreau [Tue, 4 Dec 2018 14:25:57 +0000 (15:25 +0100)] 
BUG/MEDIUM: mux-h2: don't send more HTX data than requested

It's incorrect to send more bytes than requested, because some filters
(e.g. compression) might intentionally hold on some blocks, so DATA
blocks must not be processed past the advertised byte count. It is not
the case for headers however.

No backport is needed.

6 years agoBUG/MEDIUM: mux-h2: stop sending HTX once the mux is blocked
Willy Tarreau [Tue, 4 Dec 2018 14:23:57 +0000 (15:23 +0100)] 
BUG/MEDIUM: mux-h2: stop sending HTX once the mux is blocked

If we're blocking on mux full, mux busy or whatever, we must get out of
the loop. In legacy mode this problem doesn't exist as we can normally
return 0 but here it's not a sufficient condition to stop sending, so
we must inspect the blocking flags as well.

No backport is needed.

6 years agoBUG/MEDIUM: mux-h2: make sure to always report HTX EOM when consumed by headers
Willy Tarreau [Tue, 4 Dec 2018 14:21:35 +0000 (15:21 +0100)] 
BUG/MEDIUM: mux-h2: make sure to always report HTX EOM when consumed by headers

The way htx_xfer_blks() was used is wrong, if we receive data, we must
report everything we found, not just the headers blocks. This ways causing
the EOM to be postponed and some fast responses (or errors) to be incorrectly
delayed.

No backport is needed.

6 years agoBUG/MEDIUM: mux-h2: properly update the window size in HTX mode
Willy Tarreau [Tue, 4 Dec 2018 14:20:11 +0000 (15:20 +0100)] 
BUG/MEDIUM: mux-h2: properly update the window size in HTX mode

When sending data in HTX mode, we forgot to update the window size, it
was the cause of the limitation to 1 GB in testing.

No backport is needed.

6 years agoBUG/MEDIUM: h2: When sending in HTX, make sure the caller knows we sent all.
Olivier Houchard [Mon, 3 Dec 2018 18:13:29 +0000 (19:13 +0100)] 
BUG/MEDIUM: h2: When sending in HTX, make sure the caller knows we sent all.

In h2_snd_buf(), when running with htx, make sure we return the amount of
data the caller specified, if we emptied the buffer, as it is what the
caller expects, and will lead to him properly consider the buffer to be
empty.

6 years agoBUG/MINOR: proto_htx: Truncate the request when an error is detected
Christopher Faulet [Tue, 4 Dec 2018 15:23:54 +0000 (16:23 +0100)] 
BUG/MINOR: proto_htx: Truncate the request when an error is detected

When HTTP_MSGF_ERROR is set on a channel (the request or the response), the
request must be truncated, not the response.

6 years agoBUG/MEDIUM: mux-h1: Release the mux H1 in h1_process() if there is no h1s
Christopher Faulet [Tue, 4 Dec 2018 15:10:44 +0000 (16:10 +0100)] 
BUG/MEDIUM: mux-h1: Release the mux H1 in h1_process() if there is no h1s

With the current design, there is always an H1 stream attached to the mux. So
after the conn_stream is detached, if we don't create a new H1 stream in
h1_process(), it is important to release the mux.

6 years agoMINOR: mux-h1: Make sure to return 1 in h1_recv() when needed
Christopher Faulet [Tue, 4 Dec 2018 15:06:28 +0000 (16:06 +0100)] 
MINOR: mux-h1: Make sure to return 1 in h1_recv() when needed

In h1_recv(), return 1 if we have data available, or if h1_recv_allowed()
failed, to be sure h1_process() is called. Also don't subscribe if our buffer
is full.

6 years agoBUG/MEDIUM: mux-h1: Always set CS_FL_RCV_MORE when data are received in h1_recv()
Christopher Faulet [Tue, 4 Dec 2018 14:54:12 +0000 (15:54 +0100)] 
BUG/MEDIUM: mux-h1: Always set CS_FL_RCV_MORE when data are received in h1_recv()

It is a warranty that the data will be handled by the stream, even if an error
is reported on the connection or on the conn_stream.

6 years agoMEDIUM: mux-h1: Revamp the way subscriptions are handled.
Olivier Houchard [Mon, 3 Dec 2018 17:46:09 +0000 (18:46 +0100)] 
MEDIUM: mux-h1: Revamp the way subscriptions are handled.

Don't always wake the tasklets subscribed to recv or send events as soon as
we had any I/O event, and don't call the wake() method if there were no
subscription, instead, wake the recv tasklet if we received data in h2_recv(),
and wake the send tasklet if we were able to send data in h2_send(), and the
buffer is not full anymore.
Only call the data_cb->wake() method if we get an error/a read 0, just in
case the stream was not subscribed to receive events.

6 years agoBUG/MEDIUM: stream_interface: Make REALLY sure we read all the data.
Olivier Houchard [Tue, 4 Dec 2018 14:46:16 +0000 (15:46 +0100)] 
BUG/MEDIUM: stream_interface: Make REALLY sure we read all the data.

In si_cs_recv(), try inconditionally to recv as long as the CS_FL_RCV_MORE is
set on the conn_stream, or we will miss some data.

6 years agoBUG/MINOR: flt_trace/compression: Use the right flag to add the HTX support
Christopher Faulet [Mon, 3 Dec 2018 21:43:41 +0000 (22:43 +0100)] 
BUG/MINOR: flt_trace/compression: Use the right flag to add the HTX support

Of course, the flag FLT_CFG_FL_HTX must be used and not
STRM_FLT_FL_HAS_FILTERS. "Fortunately", these 2 flags have the same value, so
everything worked as expected.

6 years agoBUG/MEDIUM: h2: Don't forget to wake the tasklet after shutr/shutw.
Olivier Houchard [Mon, 3 Dec 2018 17:43:16 +0000 (18:43 +0100)] 
BUG/MEDIUM: h2: Don't forget to wake the tasklet after shutr/shutw.

When reaching h2_shutr/h2_shutw, as we may have generated an empty frame,
a goaway or a rst, make sure we wake the I/O tasklet, or we may not send
what we just generated.
Also in h2_shutw(), don't forget to return if all went well, we don't want
to subscribe the h2s to wait events.

6 years agoBUG/MEDIUM: h1: Destroy a connection after detach if it has no owner.
Olivier Houchard [Mon, 3 Dec 2018 15:33:19 +0000 (16:33 +0100)] 
BUG/MEDIUM: h1: Destroy a connection after detach if it has no owner.

Destroy the connection while detaching, even if it has keep alive, if it has
no owner, or nobody else will be able to do so.

6 years agoBUG/MEDIUM: mworker: stop proxies which have no listener in the master
William Lallemand [Mon, 3 Dec 2018 19:34:44 +0000 (20:34 +0100)] 
BUG/MEDIUM: mworker: stop proxies which have no listener in the master

The previous code was only stopping the listeners in the master, not the
entire proxy.

Since we now have a polling loop in the master, there might be some side
effects, indeed some things that are still initialized. For example the
checks were still running.

6 years agoBUG/MINOR: fix ssl_fc_alpn and actually add ssl_bc_alpn
Jérôme Magnin [Mon, 3 Dec 2018 21:21:04 +0000 (22:21 +0100)] 
BUG/MINOR: fix ssl_fc_alpn and actually add ssl_bc_alpn

When ssl_bc_alpn was meant to be added, a typo slipped in and as a result ssl_fc_alpn behaved as ssl_bc_alpn,
and ssl_bc_alpn was not a valid keyword. this patch aims at fixing this.

6 years agoBUG/MINOR: htx: Force HTTP/1.1 on H1 formatting when version is 1.1 or above
Christopher Faulet [Mon, 3 Dec 2018 13:05:01 +0000 (14:05 +0100)] 
BUG/MINOR: htx: Force HTTP/1.1 on H1 formatting when version is 1.1 or above

This only happens for connections using the h1 mux. We must be sure to force the
version to HTTP/1.1 when the version of the message is 1.1 or above. It is
important for H2 messages to not send an invalid version string (HTTP/2.0) to
peers.

6 years agoMINOR: htx: Rename functions htx_*_to_str() to be H1 specific
Christopher Faulet [Mon, 3 Dec 2018 12:58:44 +0000 (13:58 +0100)] 
MINOR: htx: Rename functions htx_*_to_str() to be H1 specific

"_to_h1" suffix is now used because these function produce H1 strings. It avoids
any ambiguity on the output format.

6 years ago[RELEASE] Released version 1.9-dev9 v1.9-dev9
Willy Tarreau [Sun, 2 Dec 2018 18:31:37 +0000 (19:31 +0100)] 
[RELEASE] Released version 1.9-dev9

Released version 1.9-dev9 with the following main changes :
    - BUILD/MINOR: ssl: fix build with non-alpn/non-npn libssl
    - BUG/MINOR: mworker: Do not attempt to close(2) fd -1
    - BUILD: compression: fix build error with DEFAULT_MAXZLIBMEM
    - MINOR: compression: always create the compression pool
    - BUG/MEDIUM: mworker: fix FD leak upon reload
    - BUILD: htx: fix fprintf format inconsistency on 32-bit platforms
    - BUILD: buffers: buf.h requires unistd to get ssize_t on libmusl
    - MINOR: initcall: introduce a way to register init functions to call at boot
    - MINOR: init: process all initcalls in order at boot time
    - MEDIUM: init: convert all trivial registration calls to initcalls
    - MINOR: thread: provide a set of lock initialisers
    - MINOR: threads: add new macros to declare self-initializing locks
    - MEDIUM: init: use self-initializing spinlocks and rwlocks
    - MINOR: initcall: apply initcall to all register_build_opts() calls
    - MINOR: initcall: use initcalls for most post_{check,deinit} and per_thread*
    - MINOR: initcall: use initcalls for section parsers
    - MINOR: memory: add a callback function to create a pool
    - MEDIUM: init: use initcall for all fixed size pool creations
    - MEDIUM: memory: use pool_destroy_all() to destroy all pools on deinit()
    - MEDIUM: initcall: use initcalls for a few initialization functions
    - MEDIUM: memory: make the pool cache an array and not a thread_local
    - MINOR: ssl: free ctx when libssl doesn't support NPN
    - BUG/MINOR: proto_htx: only mark connections private if NTLM is detected
    - MINOR: h2: make struct h2_ops static
    - BUG/MEDIUM: mworker: avoid leak of client socket
    - REORG: mworker: declare master variable in global.h
    - BUG/MEDIUM: listeners: CLOEXEC flag is not correctly set
    - CLEANUP: http: Fix typo in init_http's comment
    - BUILD: Makefile: Disable -Wcast-function-type if it exists.
    - BUG/MEDIUM: h2: Don't bogusly error if the previous stream was closed.
    - REGTEST/MINOR: script: add run-regtests.sh script
    - REGTEST: Add a basic test for the cache.
    - BUG/MEDIUM: mux_pt: Don't forget to unsubscribe() on attach.
    - BUG/MINOR: ssl: ssl_sock_parse_clienthello ignores session id
    - BUG/MEDIUM: connections: Wake the stream once the mux is chosen.
    - BUG/MEDIUM: connections: Don't forget to detach the connection from the SI.
    - BUG/MEDIUM: stream_interface: Don't check if the handshake is done.
    - BUG/MEDIUM: stream_interface: Make sure we read all the data available.
    - BUG/MEDIUM: h2: Call h2_process() if there's an error on the connection.
    - REGTEST: Fix several issues.
    - REGTEST: lua: check socket functionality from a lua-task
    - BUG/MEDIUM: session: Remove the session from the session_list in session_free.
    - BUG/MEDIUM: streams: Don't assume we have a CS in sess_update_st_con_tcp.
    - BUG/MEDIUM: connections: Don't assume we have a mux in connect_server().
    - BUG/MEDIUM: connections: Remove the connection from the idle list before destroy.
    - BUG/MEDIUM: session: properly clean the outgoing connection before freeing.
    - BUG/MEDIUM: mux_pt: Don't try to send if handshake is not done.
    - MEDIUM: connections: Put H2 connections in the idle list if http-reuse always.
    - MEDIUM: h2: Destroy a connection with no stream if it has no owner.
    - MAJOR: sessions: Store multiple outgoing connections in the session.
    - MEDIUM: session: Steal owner-less connections on end of transaction.
    - MEDIUM: server: Be smarter about deciding to reuse the last server.
    - BUG/MEDIUM: Special-case http_proxy when dealing with outgoing connections.
    - BUG/MINOR: cfgparse: Fix transition between 2 sections with the same name
    - BUG/MINOR: http: Use out buffer instead of trash to display error snapshot
    - BUG/MINOR: htx: Fix block size calculation when a start-line is added/replaced
    - BUG/MINOR: mux-h1: Fix processing of "Connection: " header on outgoing messages
    - BUG/MEDIUM: mux-h1: Reset the H1 parser when an outgoing message is processed
    - BUG/MINOR: proto_htx: Send outgoing data to client to start response processing
    - BUG/MINOR: htx: Stop a header or a start line lookup on the first EOH or EOM
    - BUG/MINOR: connection: report mux modes when HTX is supported
    - MINOR: htx: add a function to cut the beginning of a DATA block
    - MEDIUM: conn_stream: Add a way to get mux's info on a CS from the upper layer
    - MINOR: mux-h1: Implement get_cs_info() callback
    - MINOR: stream: Rely on CS's info if it exists and fallback on session's ones
    - MINOR: proto_htx: Use conn_stream's info to set t_idle duration when possible
    - MINOR: mux-h1: Don't rely on the stream anymore in h1_set_srv_conn_mode()
    - MINOR: mux-h1: Write last chunk and trailers if not found in the HTX message
    - MINOR: mux-h1: Be prepare to fail when EOM is added during trailers parsing
    - MINOR: mux-h1: Subscribe to send in h1_snd_buf() when not all data have been sent
    - MINOR: mux-h1: Consume channel's data in a loop in h1_snd_buf()
    - MEDIUM: mux-h1: Add keep-alive outgoing connections in connections list
    - MINOR: htx: Add function to add an HTX block just before another one
    - MINOR: htx: Add function to iterate on an HTX message using HTX blocks
    - MINOR: htx: Add a function to find the HTX block corresponding to a data offset
    - MINOR: stats: Don't add end-of-data marker and trailers in the HTX response
    - MEDIUM: htx: Change htx_sl to be a struct instead of an union
    - MINOR: htx: Add the start-line offset for the HTX message in the HTX structure
    - MEDIUM: htx: Don't rely on h1_sl anymore except during H1 header parsing
    - MINOR: proto-htx: Use the start-line flags to set the HTTP messsage ones
    - MINOR: htx: Add BODYLESS flags on the HTX start-line and the HTTP message
    - MINOR: proto_htx: Use full HTX messages to send 100-Continue responses
    - MINOR: proto_htx: Use full HTX messages to send 103-Early-Hints responses
    - MINOR: proto_htx: Use full HTX messages to send 401 and 407 responses
    - MINOR: proto_htx: Send valid HTX message when redir mode is enabled on a server
    - MINOR: proto_htx: Send valid HTX message to send 30x responses
    - MEDIUM: proto_htx: Convert all HTTP error messages into HTX
    - MINOR: mux-h1: Process conn_mode on the EOH when no connection header is found
    - MINOR: mux-h1: Change client conn_mode on an explicit close for the response
    - MINOR: mux-h1: Capture bad H1 messages
    - MAJOR: filters: Adapt filters API to be compatible with the HTX represenation
    - MEDIUM: proto_htx/filters: Add data filtering during the forwarding
    - MINOR: flt_trace: Adapt to be compatible with the HTX representation
    - MEDIUM: compression: Adapt to be compatible with the HTX representation
    - MINOR: h2: implement H2->HTX request header frame transcoding
    - MEDIUM: mux-h2: register mux for both HTTP and HTX modes
    - MEDIUM: mux-h2: make h2_rcv_buf() support HTX transfers
    - MEDIUM: mux-h2: make h2_snd_buf() HTX-aware
    - MEDIUM: mux-h2: add basic H2->HTX transcoding support for headers
    - MEDIUM: mux-h2: implement emission of H2 headers frames from HTX blocks
    - MEDIUM: mux-h2: implement the emission of DATA frames from HTX DATA blocks
    - MEDIUM: mux-h2: support passing H2 DATA frames to HTX blocks
    - BUG/MINOR: cfgparse: Fix the call to post parser of the last sections parsed
    - BUG/MEDIUM: mux-h2: don't lose the first response header in HTX mode
    - BUG/MEDIUM: mux-h2: remove the HTX EOM block on H2 response headers
    - MINOR: listener: the mux_proto entry in the bind_conf is const
    - MINOR: connection: create conn_get_best_mux_entry()
    - MINOR: server: the mux_proto entry in the server is const
    - MINOR: config: make sure to associate the proper mux to bind and servers
    - MINOR: hpack: add ":path" to the list of common header fields
    - MINOR: h2: add new functions to produce an HTX message from an H2 response
    - MINOR: mux-h2: mention that the mux is compatible with both sides
    - MINOR: mux-h2: implement an outgoing stream allocator : h2c_bck_stream_new()
    - MEDIUM: mux-h2: start to create the outgoing mux
    - MEDIUM: mux-h2: implement encoding of H2 request on the backend side
    - MEDIUM: mux-h2: make h2_frt_decode_headers() direction-agnostic
    - MEDIUM: mux-h2: make h2_process_demux() capable of processing responses as well
    - MEDIUM: mux-h2: Implement h2_attach().
    - MEDIUM: mux-h2: Don't bother flagging outgoing connections as TOOMANY.
    - REGTEST: Fix LEVEL 4 script 0 of "connection" module.
    - MINOR: connection: Fix a comment.
    - MINOR: mux: add a "max_streams" method.
    - MEDIUM: servers: Add a way to keep idle connections alive.
    - CLEANUP: fix typos in the htx subsystem
    - CLEANUP: Fix typo in the chunk headers file
    - CLEANUP: Fix typos in the h1 subsystem
    - CLEANUP: Fix typos in the h2 subsystem
    - CLEANUP: Fix a typo in the mini-clist header
    - CLEANUP: Fix a typo in the proto_htx subsystem
    - CLEANUP: Fix typos in the proto_tcp subsystem
    - CLEANUP: Fix a typo in the signal subsystem
    - CLEANUP: Fix a typo in the session subsystem
    - CLEANUP: Fix a typo in the queue subsystem
    - CLEANUP: Fix typos in the shctx subsystem
    - CLEANUP: Fix typos in the socket pair protocol subsystem
    - CLEANUP: Fix typos in the map management functions
    - CLEANUP: Fix typo in the fwrr subsystem
    - CLEANUP: Fix typos in the cli subsystem
    - CLEANUP: Fix typo in the 51d subsystem
    - CLEANUP: Fix a typo in the base64 subsystem
    - CLEANUP: Fix a typo in the connection subsystem
    - CLEANUP: Fix a typo in the protocol header file
    - CLEANUP: Fix a typo in the checks header file
    - CLEANUP: Fix typos in the file descriptor subsystem
    - CLEANUP: Fix a typo in the listener subsystem
    - BUG/MINOR: lb-map: fix unprotected update to server's score
    - BUILD: threads: fix minor build warnings when threads are disabled

6 years agoBUILD: threads: fix minor build warnings when threads are disabled
Willy Tarreau [Sun, 2 Dec 2018 18:28:41 +0000 (19:28 +0100)] 
BUILD: threads: fix minor build warnings when threads are disabled

These potential null-deref warnings are emitted on gcc 7 and above
when threads are disabled due to the use of objt_server() after an
existing validity test. Let's switch to __objt_server() since we
know the pointer is valid, it will not confuse the compiler.

Some of these may be backported to 1.8.

6 years agoBUG/MINOR: lb-map: fix unprotected update to server's score
Willy Tarreau [Sun, 2 Dec 2018 18:22:55 +0000 (19:22 +0100)] 
BUG/MINOR: lb-map: fix unprotected update to server's score

The loop trying to figure the best server is theorically capable of
finishing the loop with best == NULL, causing the HA_ATOMIC_SUB()
to fail there. However for this to happen the list should be empty,
which is avoided at the beginning of the function. As it is, the
function still remains at risk so better address this now.

This patch should be backported to 1.8.

6 years agoCLEANUP: Fix a typo in the listener subsystem
Joseph Herlant [Sun, 25 Nov 2018 21:36:58 +0000 (13:36 -0800)] 
CLEANUP: Fix a typo in the listener subsystem

Fixes a typo in the code comment of the listener subsystem.

6 years agoCLEANUP: Fix typos in the file descriptor subsystem
Joseph Herlant [Sun, 25 Nov 2018 21:34:43 +0000 (13:34 -0800)] 
CLEANUP: Fix typos in the file descriptor subsystem

Fixes 2 typos in the code comment of the file descriptor subsystem.

6 years agoCLEANUP: Fix a typo in the checks header file
Joseph Herlant [Sun, 25 Nov 2018 21:28:30 +0000 (13:28 -0800)] 
CLEANUP: Fix a typo in the checks header file

Fixes a typo in the code comments of the checks header file.

6 years agoCLEANUP: Fix a typo in the protocol header file
Joseph Herlant [Sun, 25 Nov 2018 21:26:40 +0000 (13:26 -0800)] 
CLEANUP: Fix a typo in the protocol header file

Fixes a typo in the code comments of the header file holding the general
protocol primitives.

6 years agoCLEANUP: Fix a typo in the connection subsystem
Joseph Herlant [Sun, 25 Nov 2018 21:21:12 +0000 (13:21 -0800)] 
CLEANUP: Fix a typo in the connection subsystem

Fixes a typo in the code comments of the connection subsystem.

6 years agoCLEANUP: Fix a typo in the base64 subsystem
Joseph Herlant [Sun, 25 Nov 2018 21:16:35 +0000 (13:16 -0800)] 
CLEANUP: Fix a typo in the base64 subsystem

Fixes a typo in the code comments of the base64 subsystem.

6 years agoCLEANUP: Fix typo in the 51d subsystem
Joseph Herlant [Sun, 25 Nov 2018 21:15:13 +0000 (13:15 -0800)] 
CLEANUP: Fix typo in the 51d subsystem

Fixes a typo in the code comments of the 51d subsystem.

6 years agoCLEANUP: Fix typos in the cli subsystem
Joseph Herlant [Sun, 25 Nov 2018 20:51:45 +0000 (12:51 -0800)] 
CLEANUP: Fix typos in the cli subsystem

Fixes typos in the code comments of the cli subsystem.

6 years agoCLEANUP: Fix typo in the fwrr subsystem
Joseph Herlant [Sun, 25 Nov 2018 20:44:37 +0000 (12:44 -0800)] 
CLEANUP: Fix typo in the fwrr subsystem

Fixes a typo in the code comment of the fwrr subsystem.

6 years agoCLEANUP: Fix typos in the map management functions
Joseph Herlant [Sun, 25 Nov 2018 19:48:18 +0000 (11:48 -0800)] 
CLEANUP: Fix typos in the map management functions

Fixes typos in the code comments of the MAP management functions.

6 years agoCLEANUP: Fix typos in the socket pair protocol subsystem
Joseph Herlant [Sun, 25 Nov 2018 19:43:27 +0000 (11:43 -0800)] 
CLEANUP: Fix typos in the socket pair protocol subsystem

Fixes typos in the code comments of the socket pair protocol subsystem.

6 years agoCLEANUP: Fix typos in the shctx subsystem
Joseph Herlant [Sun, 25 Nov 2018 19:31:31 +0000 (11:31 -0800)] 
CLEANUP: Fix typos in the shctx subsystem

Fixes typos in the code comments of the shctx subsystem.

6 years agoCLEANUP: Fix a typo in the queue subsystem
Joseph Herlant [Sun, 25 Nov 2018 19:26:48 +0000 (11:26 -0800)] 
CLEANUP: Fix a typo in the queue subsystem

Fixes a typo in the code comments of the queue subsystem.

6 years agoCLEANUP: Fix a typo in the session subsystem
Joseph Herlant [Sun, 25 Nov 2018 19:22:10 +0000 (11:22 -0800)] 
CLEANUP: Fix a typo in the session subsystem

Fixes a typo in the code comments of the session subsystem.

6 years agoCLEANUP: Fix a typo in the signal subsystem
Joseph Herlant [Sun, 25 Nov 2018 19:19:40 +0000 (11:19 -0800)] 
CLEANUP: Fix a typo in the signal subsystem

Fixes a typo in the code comments of the signal subsystem.

6 years agoCLEANUP: Fix typos in the proto_tcp subsystem
Joseph Herlant [Sun, 25 Nov 2018 20:59:12 +0000 (12:59 -0800)] 
CLEANUP: Fix typos in the proto_tcp subsystem

Fixes typos in the code comments of the proto_tcp subsystem.

6 years agoCLEANUP: Fix a typo in the proto_htx subsystem
Joseph Herlant [Sun, 25 Nov 2018 19:00:25 +0000 (11:00 -0800)] 
CLEANUP: Fix a typo in the proto_htx subsystem

Fixes a typo in the code comments of the proto_htx subsystem.

6 years agoCLEANUP: Fix a typo in the mini-clist header
Joseph Herlant [Sun, 25 Nov 2018 18:57:13 +0000 (10:57 -0800)] 
CLEANUP: Fix a typo in the mini-clist header

Fixes a typo in the code comments of the mini-clist header.

6 years agoCLEANUP: Fix typos in the h2 subsystem
Joseph Herlant [Sun, 25 Nov 2018 18:54:45 +0000 (10:54 -0800)] 
CLEANUP: Fix typos in the h2 subsystem

Fixes typos in the code comments of the h2 subsystem.

6 years agoCLEANUP: Fix typos in the h1 subsystem
Joseph Herlant [Sun, 25 Nov 2018 18:52:20 +0000 (10:52 -0800)] 
CLEANUP: Fix typos in the h1 subsystem

Fixes typos in the code comments of the h1 subsystem.

6 years agoCLEANUP: Fix typo in the chunk headers file
Joseph Herlant [Sun, 25 Nov 2018 18:49:51 +0000 (10:49 -0800)] 
CLEANUP: Fix typo in the chunk headers file

Fix a typo detected in the chunk.h header file's code comments.

6 years agoCLEANUP: fix typos in the htx subsystem
Joseph Herlant [Sun, 25 Nov 2018 18:43:27 +0000 (10:43 -0800)] 
CLEANUP: fix typos in the htx subsystem

Fix typos detected in the code comments of the htx subsystem.

6 years agoMEDIUM: servers: Add a way to keep idle connections alive.
Olivier Houchard [Sun, 2 Dec 2018 13:11:41 +0000 (14:11 +0100)] 
MEDIUM: servers: Add a way to keep idle connections alive.

Add a new keyword for servers, "idle-timeout". If set, unused connections are
kept alive until the timeout happens, and will be picked for reuse if no
other connection is available.

6 years agoMINOR: mux: add a "max_streams" method.
Olivier Houchard [Sun, 2 Dec 2018 00:31:17 +0000 (01:31 +0100)] 
MINOR: mux: add a "max_streams" method.

Add a new method to muxes, "max_streams", that returns the max number of
streams the mux can handle. This will be used to know if a mux is in use
or not.

6 years agoMINOR: connection: Fix a comment.
Olivier Houchard [Sat, 1 Dec 2018 23:35:08 +0000 (00:35 +0100)] 
MINOR: connection: Fix a comment.

Connections can now have an owner for outgoing connections, so update
the comment tu reflect that.

6 years agoREGTEST: Fix LEVEL 4 script 0 of "connection" module.
Frédéric Lécaille [Thu, 29 Nov 2018 13:23:32 +0000 (14:23 +0100)] 
REGTEST: Fix LEVEL 4 script 0 of "connection" module.

Prevent this script from creating a UNIX socket in ${testdir} which
is the parent directory of the script. Prefer use ${tmpdir} which
is the temporary working directory for the script.

6 years agoMEDIUM: mux-h2: Don't bother flagging outgoing connections as TOOMANY.
Olivier Houchard [Wed, 28 Nov 2018 14:41:48 +0000 (15:41 +0100)] 
MEDIUM: mux-h2: Don't bother flagging outgoing connections as TOOMANY.

When creating a new stream, don't bother flagging a connection with
H2_CF_DEM_TOOMANY if we created the last available stream. We won't create
any other anyway, because h2_avail_streams() would return 0 available streams,
and has it is a blocking flag, it prevents us from reading data after.

6 years agoMEDIUM: mux-h2: Implement h2_attach().
Olivier Houchard [Tue, 27 Nov 2018 16:36:33 +0000 (17:36 +0100)] 
MEDIUM: mux-h2: Implement h2_attach().

Implement h2_attach(), so that we can have multiple streams in one outgoin
h2 connection.

6 years agoMEDIUM: mux-h2: make h2_process_demux() capable of processing responses as well
Willy Tarreau [Mon, 8 Oct 2018 12:53:27 +0000 (14:53 +0200)] 
MEDIUM: mux-h2: make h2_process_demux() capable of processing responses as well

The function now calls h2c_bck_handle_headers() or h2c_frt_handle_headers()
depending on the connection's side. The former doesn't create a new stream
but feeds an existing one. At this point it's possible to forward an H2
request to a backend server and retrieve the response headers.

6 years agoMEDIUM: mux-h2: make h2_frt_decode_headers() direction-agnostic
Willy Tarreau [Mon, 8 Oct 2018 12:51:56 +0000 (14:51 +0200)] 
MEDIUM: mux-h2: make h2_frt_decode_headers() direction-agnostic

This function does not really depend on the request, all it does is
also valid for H2 responses found on the backend side, so this patch
renames it and makes it call the appropriate decoder based on the
direction.

6 years agoMEDIUM: mux-h2: implement encoding of H2 request on the backend side
Willy Tarreau [Fri, 5 Oct 2018 09:35:57 +0000 (11:35 +0200)] 
MEDIUM: mux-h2: implement encoding of H2 request on the backend side

This creates an H2 HEADERS frame from an HTX request. The code is
very similar to the response encoding, so probably that in the future
we'll have to factor these functions differently. The HTX's start line
type is used to decide on the direction. We also purposely error out
when trying to encode an H2 request from an H1 message since it's not
implemented.

6 years agoMEDIUM: mux-h2: start to create the outgoing mux
Willy Tarreau [Wed, 3 Oct 2018 12:26:37 +0000 (14:26 +0200)] 
MEDIUM: mux-h2: start to create the outgoing mux

For now it reports an immediate error when trying to encode the request
since it doesn't parse as a response. We take care of sending the preface
and settings frame with the outgoing connection, and not to wait for a
preface during the H2_CS_PREFACE phase for outgoing connections.

6 years agoMINOR: mux-h2: implement an outgoing stream allocator : h2c_bck_stream_new()
Willy Tarreau [Fri, 5 Oct 2018 07:35:00 +0000 (09:35 +0200)] 
MINOR: mux-h2: implement an outgoing stream allocator : h2c_bck_stream_new()

For the backend we'll need to allocate streams as well. Let's do this
with h2c_bck_stream_new(). The stream ID allocator was split from it
so that the caller can decide whether or not to stay on the same
connection or create a new one. It possibly isn't the best way to do
this as once we're on the mux it's too late to give up creation of a
new stream. Another approach would possibly consist in detaching muxes
that reached their connection count limit before they can be reused.

Instead of choosing the stream id as soon as the stream is created, wait
until data is about to be sent. If we don't do that, the stream may send
data out of order, and so the stream 3 may send data before the stream 1,
and then when the stream 1 will try to send data, the other end will
consider that an error, as stream ids should always be increased.

Cc: Olivier Houchard <ohouchard@haproxy.com>
6 years agoMINOR: mux-h2: mention that the mux is compatible with both sides
Willy Tarreau [Wed, 3 Oct 2018 08:25:20 +0000 (10:25 +0200)] 
MINOR: mux-h2: mention that the mux is compatible with both sides

We declare two configurations for the H2 mux. One supporting only
the frontend in HTTP mode and one supporting both sides in HTX mode.

This is only to ease development at this point. Trying to assign an h2
mux on the server side will still fail during h2_init() anyway instead
of at config parsing time.