]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoBUG/MEDIUM: lua: dead lock when Lua tasks are trigerred
Thierry FOURNIER [Sun, 6 Jan 2019 18:04:24 +0000 (19:04 +0100)] 
BUG/MEDIUM: lua: dead lock when Lua tasks are trigerred

When a task is created from Lua context out of initialisation,
the hlua_ctx_init() function can be called from safe environement,
so we must not initialise it. While the support of threads appear,
the safe environment set a lock to ensure only one Lua execution
at a time. If we initialize safe environment in another safe
environmenet, we have a dead lock.

this patch adds the support of the idicator "already_safe" whoch
indicates if the context is initialized form safe Lua fonction.

thank to Flakebi for the report

This patch must be backported to haproxy-1.9 and haproxy-1.8

6 years agoBUG/MINOR: lua: bad args are returned for Lua actions
Thierry FOURNIER [Sun, 6 Jan 2019 18:38:49 +0000 (19:38 +0100)] 
BUG/MINOR: lua: bad args are returned for Lua actions

In tcp actions case, the argument n - 1 is returned. For example:

  http-request lua.script stuff

display "stuff" as first arg

  tcp-request content lua.script stuff

display "lua.script" as first arg

The action parser doesn't use the *cur_arg value.

Thanks to Andy Franks for the bug report.

This patch mist be backported in haproxy-1.8 and haproxy-1.9

6 years agoMINOR: stream/cli: report more info about the HTTP messages on "show sess all"
Willy Tarreau [Mon, 7 Jan 2019 09:38:10 +0000 (10:38 +0100)] 
MINOR: stream/cli: report more info about the HTTP messages on "show sess all"

The "show sess all" command didn't allow to detect whether compression
is in use for a given stream, which is sometimes annoying. Let's add a
few more info about the HTTP messages, namely the flags, body len, chunk
len and the "next" pointer.

6 years agoMINOR: stream/cli: fix the location of the waiting flag in "show sess all"
Willy Tarreau [Mon, 7 Jan 2019 09:10:07 +0000 (10:10 +0100)] 
MINOR: stream/cli: fix the location of the waiting flag in "show sess all"

The "waiting" flag indicates if the stream is waiting for some memory,
and was placed on the same output line as the txn for ease of reading.
But since 1.6 the txn is not part of the stream anymore so this output
was placed under a condition, resulting in "waiting" to appear only
when a txn is present. Let's move it upper, closer to the stream's
flags to fix this.

This may safely be backported though it has little value for older
versions.

6 years agoMINOR: stream/htx: add the HTX flags output in "show sess all"
Willy Tarreau [Mon, 7 Jan 2019 09:01:34 +0000 (10:01 +0100)] 
MINOR: stream/htx: add the HTX flags output in "show sess all"

Commit b9af88151 ("MINOR: stream/htx: Add info about the HTX structs in
"show sess all" command") accidently forgot the flags on the request
path, it was only on the response path.

It makes sense to backport this to 1.9 so that both outputs are the same.

6 years agoBUILD: add a new file "version.c" to carry version updates
Willy Tarreau [Fri, 4 Jan 2019 17:20:32 +0000 (18:20 +0100)] 
BUILD: add a new file "version.c" to carry version updates

While testing fixes, it's sometimes confusing to rebuild only one C file
(e.g. a mux) and not to have the correct commit ID reported in "haproxy -v"
nor on the stats page.

This patch adds a new "version.c" file which is always rebuilt. It's
very small and contains only 3 variables derived from the various
version strings. These variables are used instead of the macros at the
few places showing the version. This way the output version of the
running code is always correct for the parts that were rebuilt.

6 years agoBUG/MEDIUM: cli: make "show sess" really thread-safe
Willy Tarreau [Fri, 4 Jan 2019 16:42:57 +0000 (17:42 +0100)] 
BUG/MEDIUM: cli: make "show sess" really thread-safe

This one used to rely on a few spin locks around lists manipulations
only but 1) there were still a few races (e.g. when aborting, or
between STAT_ST_INIT and STAT_ST_LIST), and 2) after last commit
which dumps htx info it became obvious that dereferencing the buffer
contents is not safe at all.

This patch uses the thread isolation from the rendez-vous point
instead, to guarantee that nothing moves during the dump. It may
make the dump a bit slower but it will be 100% safe.

This fix must be backported to 1.9, and possibly to 1.8 which likely
suffers from the short races above, eventhough they're extremely
hard to trigger.

6 years agoMINOR: connections: Remove a stall comment.
Olivier Houchard [Fri, 4 Jan 2019 16:22:51 +0000 (17:22 +0100)] 
MINOR: connections: Remove a stall comment.

Remove the comment that pretends 0x40000000 is unused, it's not true anymore.

6 years agoBUG/MEDIUM: server: Defer the mux init until after xprt has been initialized.
Olivier Houchard [Fri, 4 Jan 2019 14:52:26 +0000 (15:52 +0100)] 
BUG/MEDIUM: server: Defer the mux init until after xprt has been initialized.

In connect_server(), if we're using a new connection, and we have to
initialize the mux right away, only do it so after si_connect() has been
called. si_connect() is responsible for initializing the xprt, and the
mux initialization may depend on the xprt being usable, as it may try to
receive data. Otherwise, the connection will be flagged as having an error,
and we will have to try to connect a second time.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: h1: In h1_init(), wake the tasklet instead of calling h1_recv().
Olivier Houchard [Fri, 4 Jan 2019 15:51:40 +0000 (16:51 +0100)] 
BUG/MEDIUM: h1: In h1_init(), wake the tasklet instead of calling h1_recv().

In h1_init(), instead of calling h1_recv() directly, just wake the tasklet,
so that the receive will be done later.
h1_init() might be called from connect_server(), which is itself called
indirectly from process_stream(), and if the receive fails, we may call
si_cs_process(), which may destroy the channel buffers while process_stream()
still expects them to exist.

This should be backported to 1.9.

6 years agoBUG/MINOR: cache/htx: Be sure to count partial trailers
Christopher Faulet [Fri, 4 Jan 2019 15:15:34 +0000 (16:15 +0100)] 
BUG/MINOR: cache/htx: Be sure to count partial trailers

When a chunked object is served from the cache, If the trailers are not pushed
in the channel's buffer in one time, we still have to count them in the total
written bytes in the buffer.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: h1: Get the h1m state when restarting the headers parsing
Christopher Faulet [Fri, 4 Jan 2019 15:06:48 +0000 (16:06 +0100)] 
BUG/MEDIUM: h1: Get the h1m state when restarting the headers parsing

Since the commit 0f8fb6b7f ("MINOR: h1: make the H1 headers block parser able to
parse headers only"), when headers are not received in one time, a parsing error
is returned because the local state in the function h1_headers_to_hdr_list() was
not initialized with the previous one (in fact, it was not initialized at all).

So now, we start the parsing of headers with the state H1_MSG_HDR_FIRST when the
flag H1_MF_HDRS_ONLY is set. Otherwise, we always get it from the h1m.

This patch must be backported to 1.9.

6 years agoMINOR: mux-h1: Add the subscription events in "show fd" command
Christopher Faulet [Fri, 4 Jan 2019 14:16:06 +0000 (15:16 +0100)] 
MINOR: mux-h1: Add the subscription events in "show fd" command

It could be helpful to debug frozen connections.

The patch may be backported to 1.9.

6 years agoMINOR: stream: Add the subscription events of SIs in "show sess all" command
Christopher Faulet [Fri, 4 Jan 2019 14:06:13 +0000 (15:06 +0100)] 
MINOR: stream: Add the subscription events of SIs in "show sess all" command

It could be helpful to debug frozen sessions.

The patch may be backported to 1.9.

6 years agoMINOR: stream/htx: Add info about the HTX structs in "show sess all" command
Christopher Faulet [Fri, 4 Jan 2019 13:30:44 +0000 (14:30 +0100)] 
MINOR: stream/htx: Add info about the HTX structs in "show sess all" command

For HTX streams, info about the HTX structure is now dumped for the request and
the response channels in "show sess all" command.

The patch may be backported to 1.9.

6 years agoMEDIUM: mux-h2: emit HEADERS frames when facing HTX trailers blocks
Willy Tarreau [Fri, 4 Jan 2019 09:56:26 +0000 (10:56 +0100)] 
MEDIUM: mux-h2: emit HEADERS frames when facing HTX trailers blocks

Now the H2 mux will parse and encode the HTX trailers blocks and send
the corresponding HEADERS frame. Since these blocks contain pure H1
trailers which may be fragmented on line boundaries, if first needs
to collect all of them, parse them using the H1 parser, build a list
and finally encode all of them at once once the EOM is met. Note that
this HEADERS frame always carries the end-of-headers and end-of-stream
flags.

This was tested using the helloworld examples from the grpc project,
as well as with the h2c tools. It doesn't seem possible at the moment
to test tailers using varnishtest though.

6 years agoMINOR: h1: make the H1 headers block parser able to parse headers only
Willy Tarreau [Fri, 4 Jan 2019 09:48:03 +0000 (10:48 +0100)] 
MINOR: h1: make the H1 headers block parser able to parse headers only

Currently the H1 headers parser works for either a request or a response
because it starts from the start line. It is also able to resume its
processing when it was interrupted, but in this case it doesn't update
the list.

Make it support a new flag, H1_MF_HDRS_ONLY so that the caller can
indicate it's only interested in the headers list and not the start
line. This will be convenient to parse H1 trailers.

6 years agoMINOR: mux-h2: make HTX_BLK_EOM processing idempotent
Willy Tarreau [Fri, 4 Jan 2019 08:28:17 +0000 (09:28 +0100)] 
MINOR: mux-h2: make HTX_BLK_EOM processing idempotent

We want to make sure we won't emit another empty DATA frame if we meet
HTX_BLK_EOM after and end of stream was already sent. For now it cannot
happen as far as HTX is respected, but with trailers it may become
ambiguous.

6 years agoBUG/MEDIUM: mux-h1: don't enforce chunked encoding on requests
Willy Tarreau [Thu, 3 Jan 2019 20:27:19 +0000 (21:27 +0100)] 
BUG/MEDIUM: mux-h1: don't enforce chunked encoding on requests

Recent commit 4710d20 ("BUG/MEDIUM: mux-h1: make HTX chunking
consistent with H2") tried to address chunking inconsistencies between
H1/HTX/H2 and has enforced it on every outgoing message carrying
H1_MF_XFER_LEN without H1_MF_CLEN nor H1_MF_CHNK. But it also does it
on requests, which is not appropriate since a request by default
doesn't have a message body unless explicitly mentioned. Also make
sure we only do this on HTTP/1.1 messages.

The problem is to guarantee the highest level of compatibility between
H1/H1, H1/H2, H2/H1 in each direction regarding the lack of content-
length. We have this truth table (a star '*' indicates which one can
pass trailers) :

  H1 client -> H1 server :
     request:
        CL=0 TE=0 XL=1 -> CL=0 TE=0
        CL=0 TE=1 XL=1 -> CL=0 TE=1 *
        CL=1 TE=0 XL=1 -> CL=1 TE=0
        CL=1 TE=1 XL=1 -> CL=1 TE=1 *

     response:
        CL=0 TE=0 XL=0 -> CL=0 TE=0
        CL=0 TE=1 XL=1 -> CL=0 TE=1 *
        CL=1 TE=0 XL=1 -> CL=1 TE=0
        CL=1 TE=1 XL=1 -> CL=1 TE=1 *

  H2 client -> H1 server : (H2 messages always carry XFER_LEN)
     request:
        CL=0 XL=1 -> CL=0 TE=0
        CL=1 XL=1 -> CL=1 TE=0

     response:
        CL=0 TE=0 XL=0 -> CL=0
        CL=0 TE=1 XL=1 -> CL=0 *
        CL=1 TE=0 XL=1 -> CL=1
        CL=1 TE=1 XL=1 -> CL=1 *

  H1 client -> H2 server : (H2 messages always carry XFER_LEN)
     request:
        CL=0 TE=0 XL=1 -> CL=0
        CL=0 TE=1 XL=1 -> CL=0 *
        CL=1 TE=0 XL=1 -> CL=1
        CL=1 TE=1 XL=1 -> CL=1 *

     response:
        CL=0 XL=1 -> CL=0 TE=1 *
        CL=1 XL=1 -> CL=1 TE=0

For H1 client to H2 server, it will be possible to rely on the presence
of "TE: trailers"  in the H1 request to automatically switch to chunks
in the response, and be able to pass trailers at the end. For now this
check is not implemented so an H2 response missing a content-length to
an H1 request will always have a transfer-encoding header added and
trailers will be forwarded if any.

This patch depends on previous commit "MINOR: mux-h1: parse the
content-length header on output and set H1_MF_CLEN" to work properly.

Since the aforementioned commit is scheduled for backport to 1.9 this
commit must also be backported to 1.9.

6 years agoMINOR: mux-h1: parse the content-length header on output and set H1_MF_CLEN
Willy Tarreau [Thu, 3 Jan 2019 20:52:42 +0000 (21:52 +0100)] 
MINOR: mux-h1: parse the content-length header on output and set H1_MF_CLEN

The H1_MF_CLEN flag is needed to figure whether a content-length header is
present or not when producing a request, so let's check it on output just
like we already check the transfer-encoding header.

6 years agoMEDIUM: mux-h2: pass trailers to HTX
Willy Tarreau [Thu, 3 Jan 2019 17:41:05 +0000 (18:41 +0100)] 
MEDIUM: mux-h2: pass trailers to HTX

When receiving an H2 message in HTX mode, trailers present in chunked
messages are now properly appended to the HTX block.

6 years agoMINOR: h2: add h2_make_htx_trailers to turn H2 headers to HTX trailers
Willy Tarreau [Thu, 3 Jan 2019 17:39:54 +0000 (18:39 +0100)] 
MINOR: h2: add h2_make_htx_trailers to turn H2 headers to HTX trailers

This function is usable to transform a list of H2 header fields to a
HTX trailers block. It takes care of rejecting forbidden headers and
pseudo-headers when performing the conversion. It also emits the
trailing CRLF that is currently needed in the HTX trailers block.

6 years agoMINOR: htx: add a new function to add a block without filling it
Willy Tarreau [Thu, 3 Jan 2019 17:26:17 +0000 (18:26 +0100)] 
MINOR: htx: add a new function to add a block without filling it

htx_add_blk_type_size() creates a block of a specified type and size
and returns it. The caller can then fill it.

6 years agoMEDIUM: mux-h2: pass trailers to H1 (legacy mode)
Willy Tarreau [Thu, 3 Jan 2019 15:18:34 +0000 (16:18 +0100)] 
MEDIUM: mux-h2: pass trailers to H1 (legacy mode)

When forwarding an H2 request to an H1 server, if the request doesn't
have a content-length header field, it is chunked. In this case it is
possible to send trailers to the server, which is what this patch does.
If the transfer is performed without chunking, then the trailers are
silently discarded.

6 years agoMINOR: h2: add h2_make_h1_trailers to turn H2 headers to H1 trailers
Willy Tarreau [Thu, 3 Jan 2019 15:18:14 +0000 (16:18 +0100)] 
MINOR: h2: add h2_make_h1_trailers to turn H2 headers to H1 trailers

This function is usable to transform a list of H2 header fields to a
H1 trailers block. It takes care of rejecting forbidden headers and
pseudo-headers when performing the conversion.

6 years agoBUG/MEDIUM: mux-h2: decode trailers in HEADERS frames
Willy Tarreau [Wed, 2 Jan 2019 18:38:14 +0000 (19:38 +0100)] 
BUG/MEDIUM: mux-h2: decode trailers in HEADERS frames

This is not exactly a bug but a long-time design limitation. We used not
to decode trailers in H2, resulting in broken connections each time a
trailer was sent, since it was impossible to keep the HPACK decompressor
synchronized. Now that the sequencing of operations permits it, we must
make sure to at least properly decode them.

What we try to do is to identify if a HEADERS frame was already seen and
use this indication to know if it's a headers or a trailers. For this,
h2c_decode_headers() checks if the stream indicates that a HEADERS frame
was already received. If so, it decodes it and emits the trailing
0 CRLF CRLF in case of H1, or the HTX_EOD + HTX_EOM blocks in case of HTX,
to terminate the data stream.

The trailers contents are still deleted for now but the request works, and
the connection remains synchronized and usable for subsequent streams.

The correctness may be tested using a simple config and h2spec :

    h2spec -o 1000 -v -t -S -k -h 127.0.0.1 -p 4443 generic/4/4

This should definitely be backported to 1.9 given the low impact for the
benefit. However it cannot be backported to 1.8 since the operations cannot
be resumed. The following patches are also needed with this one :

   MINOR: mux-h2: make h2c_decode_headers() return a status, not a count
   MINOR: mux-h2: add a new dummy stream : h2_error_stream
   MEDIUM: mux-h2: make h2c_decode_headers() support recoverable errors
   BUG/MINOR: mux-h2: detect when the HTX EOM block cannot be added after headers
   MINOR: mux-h2: check for too many streams only for idle streams
   MINOR: mux-h2: set H2_SF_HEADERS_RCVD when a HEADERS frame was decoded

6 years agoMINOR: mux-h2: set H2_SF_HEADERS_RCVD when a HEADERS frame was decoded
Willy Tarreau [Wed, 2 Jan 2019 14:49:20 +0000 (15:49 +0100)] 
MINOR: mux-h2: set H2_SF_HEADERS_RCVD when a HEADERS frame was decoded

Doing this will be needed to be able to tell the difference between a
headers block and a trailers block.

6 years agoMINOR: mux-h2: check for too many streams only for idle streams
Willy Tarreau [Wed, 2 Jan 2019 12:59:43 +0000 (13:59 +0100)] 
MINOR: mux-h2: check for too many streams only for idle streams

The HEADERS frame parser checks if we still have too many streams, but
this should only be done for idle streams, otherwise it would prevent
us from processing trailer frames.

6 years agoCLEANUP: mux-h2: clean the stream error path on HEADERS frame processing
Willy Tarreau [Thu, 3 Jan 2019 10:48:45 +0000 (11:48 +0100)] 
CLEANUP: mux-h2: clean the stream error path on HEADERS frame processing

In h2c_frt_handle_headers() and h2c_bck_handle_headers() we have an unused
error path made of the strm_err label, while send_rst is used to emit an
RST upon stream error after forcing the stream to h2_refused_stream. Let's
remove this unused strm_err block now.

6 years agoMINOR: mux-h2: remove a misleading and impossible test
Willy Tarreau [Thu, 3 Jan 2019 10:41:50 +0000 (11:41 +0100)] 
MINOR: mux-h2: remove a misleading and impossible test

In h2c_frt_handle_headers(), we test the stream for SS_ERROR just after
setting it to SS_OPEN, this makes no sense and creates confusion in the
error path. Remove this misleading test.

6 years agoBUG/MINOR: mux-h2: detect when the HTX EOM block cannot be added after headers
Willy Tarreau [Thu, 3 Jan 2019 13:50:36 +0000 (14:50 +0100)] 
BUG/MINOR: mux-h2: detect when the HTX EOM block cannot be added after headers

In case we receive a very large HEADERS frame which doesn't leave enough
room to place the EOM block after the decoded headers, we must fail the
stream. This test was missing, resulting in the loss of the EOM, possibly
leaving the stream waiting for a time-out.

Note that we also clear h2c->dfl here so that we don't attempt to clear
it twice when going back to the demux.

If this is backported to 1.9, it also requires that the following patches
are backported as well :

  MINOR: mux-h2: make h2c_decode_headers() return a status, not a count
  MINOR: mux-h2: add a new dummy stream : h2_error_stream
  MEDIUM: mux-h2: make h2c_decode_headers() support recoverable errors

6 years agoMEDIUM: mux-h2: make h2c_decode_headers() support recoverable errors
Willy Tarreau [Thu, 3 Jan 2019 13:48:18 +0000 (14:48 +0100)] 
MEDIUM: mux-h2: make h2c_decode_headers() support recoverable errors

When a decoding error is recoverable, we should emit a stream error and
not a connection error. This patch does this by carefully checking the
connection state before deciding to send a connection error. If only the
stream is in error, an RST_STREAM is sent.

6 years agoMINOR: mux-h2: add a new dummy stream : h2_error_stream
Willy Tarreau [Thu, 3 Jan 2019 11:00:17 +0000 (12:00 +0100)] 
MINOR: mux-h2: add a new dummy stream : h2_error_stream

This dummy stream will be used to send stream errors that must not
be retried, such as undecodable headers frames.

6 years agoMINOR: mux-h2: make h2c_decode_headers() return a status, not a count
Willy Tarreau [Wed, 2 Jan 2019 14:36:11 +0000 (15:36 +0100)] 
MINOR: mux-h2: make h2c_decode_headers() return a status, not a count

This function used to return a byte count for the output produced, or
zero on failure. Not only this value is not used differently than a
boolean, but it prevents us from returning stream errors when a frame
cannot be extracted because it's too large, or from parsing a frame
and producing nothing on output.

This patch modifies its API to return <0 on errors, 0 on inability to
proceed, or >0 on success, irrelevant to the amount of output data.

6 years agoBUG/MEDIUM: mux-h1: Add a task to handle connection timeouts
Christopher Faulet [Thu, 3 Jan 2019 15:27:28 +0000 (16:27 +0100)] 
BUG/MEDIUM: mux-h1: Add a task to handle connection timeouts

The mux h1 mainly depends on the stream to handle errors and timeouts. But,
there is one unhandled case. If a timeout occurred when some outgoing data are
blocked in the output buffer, the stream is detached and the mux waits infinitly
the data are gone before closing the connection. To fix the bug, a task has been
added on the mux to handle connection timeouts. For now, a expiration date is
set only when some outgoing data are blocked. And if a stream is still attached
when the mux's task timed out, an error flag is set on the mux but the
connection is not closed immediatly. We assume the stream will hit the same
timeout just after.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: proto-htx: Set SI_FL_NOHALF on server side when request is done
Christopher Faulet [Wed, 2 Jan 2019 16:44:13 +0000 (17:44 +0100)] 
BUG/MEDIUM: proto-htx: Set SI_FL_NOHALF on server side when request is done

In the function htx_end_request, the flag SI_FL_NOHALF must be set on the server
side once the request is in the state HTTP_MSG_DONE. But the response state was
checked before and the flag was only set when the response was also in the state
HTTP_MSG_DONE. Of course, it is not desirable.

This patch must be backported to 1.9.

6 years agoBUG/MAJOR: stream-int: Update the stream expiration date in stream_int_notify()
Christopher Faulet [Thu, 3 Jan 2019 15:24:54 +0000 (16:24 +0100)] 
BUG/MAJOR: stream-int: Update the stream expiration date in stream_int_notify()

Since a long time, the expiration date of a stream is only updated in
process_stream(). It is calculated, among others, using the channels expiration
dates for reads and writes (.rex and .wex values). But these values are updated
by the stream-interface. So when this happens at the connection layer, the
update is only done if the stream's task is woken up. Otherwise, the stream
expiration date is not immediatly updated. This leads to unexpected
behaviours. Time to time, users reported that the wrong timeout was hitted or
the wrong termination state was reported. This is partly because of this
bug.

Recently, we observed some blocked sessions for a while when big objects are
served from the cache applet. It seems only concern the clients not reading the
response. Because delivered objects are big, not all data can be sent. And
because delivered objects are big, data are fast forwarded (from the input to
the output with no stream wakeup). So in such situation, the stream expiration
date is never updated and no timeout is hitted. The session remains blocked
while the client remains connected.

This bug exists at least since HAProxy 1.5. But recent changes on the connection
layer make it more visible. It must be backported from 1.9 to 1.6. And with more
pain it should be backported to 1.5.

6 years agoBUG/MEDIUM: mux-h1: make HTX chunking consistent with H2
Willy Tarreau [Thu, 3 Jan 2019 16:39:54 +0000 (17:39 +0100)] 
BUG/MEDIUM: mux-h1: make HTX chunking consistent with H2

When transfering from H1 to H1, chunking is always indicated by the
presence of the Transfer-encoding header field. But when a message
comes from H2 there is no such header and only HTX_SL_F_XFER_LEN
ought to be relied on. This one will also result in H1_MF_XFER_LEN
to be set, just like transfer-encoding, so let's always rely on
this latter flag to detect the need for chunking (when CLEN is not
here) and automatically add the transfer-encoding header if it was
not present, as reported by H1_MF_CHNK.

This must be backported to 1.9.

6 years agoBUG/MEDIUM: mux-h1: use per-direction flags to indicate transitions
Willy Tarreau [Thu, 3 Jan 2019 16:46:56 +0000 (17:46 +0100)] 
BUG/MEDIUM: mux-h1: use per-direction flags to indicate transitions

The H1 mux needs to store some information regarding the states that
were met (EOD, trailers, etc) for each direction but currently uses
only one set of flags. This results in failures when both the request
and the response use chunked-encoding because some elements are believed
to have been met already and a trailing 0 CRLF or just a CRLF may be
missing at the end.

The solution here consists in splitting these flags per direction, one
set for input processing and another set for output processing. Only
two flags were affected so this is not a big deal.

This needs to be backported to 1.9.

6 years agoBUG/MINOR: mux-h2: only update rxbuf's length for H1 headers
Willy Tarreau [Thu, 3 Jan 2019 09:26:23 +0000 (10:26 +0100)] 
BUG/MINOR: mux-h2: only update rxbuf's length for H1 headers

In h2c_decode_headers() we update the buffer's length according to the
amount of data produced (outlen). But in case of HTX this outlen value
is not a quantity, just an indicator of success, resulting in the buffer
being added one extra byte and temporarily showing .data > .size, which
is wrong. Fortunately this is overridden when leaving the function by
htx_to_buf() so the impact only exists in step-by-step debugging, but
it definitely needs to be fixed.

This must be backported to 1.9.

6 years agoBUG/MINOR: mux-h2: mark end-of-stream after processing response HEADERS, not before
Willy Tarreau [Thu, 3 Jan 2019 08:32:20 +0000 (09:32 +0100)] 
BUG/MINOR: mux-h2: mark end-of-stream after processing response HEADERS, not before

When dealing with a server's H2 response, we used to set the
end-of-stream flag on the conn_stream and the stream before parsing
the response, which is incorrect since we can fail to process this
response by lack of room, buffer or anything. The extend of this problem
is still limited to a few rare cases, but with trailers it will cause a
systematic failure.

This fix must be backported to 1.9.

6 years agoBUG/MINOR: mux-h2: don't check the CS count in h2c_bck_handle_headers()
Willy Tarreau [Thu, 3 Jan 2019 08:20:05 +0000 (09:20 +0100)] 
BUG/MINOR: mux-h2: don't check the CS count in h2c_bck_handle_headers()

This function handles response HEADERS frames, it is not responsible
for creating new streams thus it must not check if we've reached the
stream count limit, otherwise it could lead to some undesired pauses
which bring no benefit.

This must be backported to 1.9.

6 years agoBUG/MINOR: mux-h2: set the stream-full flag when leaving h2c_decode_headers()
Willy Tarreau [Thu, 3 Jan 2019 07:52:09 +0000 (08:52 +0100)] 
BUG/MINOR: mux-h2: set the stream-full flag when leaving h2c_decode_headers()

If we exit this function because some data are pending in the rxbuf, we
currently don't indicate any blocking flag, which will prevent the operation
from being attempted again. Let's set H2_CF_DEM_SFULL in this case to indicate
there's not enough room in the stream buffer so that the operation may be
attempted again once we make room. It seems that this issue cannot be
triggered right now but it definitely will with trailers.

This fix should be backported to 1.9 for completeness.

6 years agoBUG/MEDIUM: mux-h2: always restart reading if data are available
Willy Tarreau [Thu, 3 Jan 2019 07:27:41 +0000 (08:27 +0100)] 
BUG/MEDIUM: mux-h2: always restart reading if data are available

h2c_restart_reading() is used at various place to resume processing of
demux data, but this one refrains from doing so if the mux is already
subscribed for receiving. It just happens that even if some incoming
frame processing is interrupted, the mux is always subscribed for
receiving, so this condition alone is not enough, it must be combined
with the fact that the demux buffer is empty, otherwise some resume
events are lost. This typically happens when we refrain from processing
some incoming data due to missing room in the stream's rxbuf, and want
to resume in h2c_rcv_buf(). It will become even more visible with trailers
since these ones want to have an empty rxbuf before proceeding.

This must be backported to 1.9.

6 years agoCLEANUP: mux-h2: fix end-of-stream flag name when processing headers
Willy Tarreau [Thu, 3 Jan 2019 07:10:14 +0000 (08:10 +0100)] 
CLEANUP: mux-h2: fix end-of-stream flag name when processing headers

In h2c_decode_headers() we mistakenly check for H2_F_DATA_END_STREAM
while we should check for H2_F_HEADERS_END_STREAM. Both have the same
value (1) but better stick to the correct flag.

6 years agoMINOR: lb: allow redispatch when using consistent hash
Willy Tarreau [Wed, 2 Jan 2019 13:48:31 +0000 (14:48 +0100)] 
MINOR: lb: allow redispatch when using consistent hash

Redispatch traditionally only worked for cookie based persistence.

Adding redispatch support for consistent hash based persistence - also
update docs.

Reported by Oskar Stenman on discourse:
https://discourse.haproxy.org/t/balance-uri-consistent-hashing-redispatch-3-not-redispatching/3344

Should be backported to 1.8.

Cc: Lukas Tribus <lukas@ltri.eu>
6 years agoBUG/MAJOR: htx: Return the good block address after a defrag
Christopher Faulet [Wed, 2 Jan 2019 10:23:44 +0000 (11:23 +0100)] 
BUG/MAJOR: htx: Return the good block address after a defrag

When an HTX structure is defragmented, it is possible to retrieve the new block
corresponding to an old one. This is useful to do a defrag during a loop on
blocks, to be sure to continue looping on the good block. But, instead of
returning the address of the new block in the HTX structure, the one in the
temporary structure used to do the defrag was returned, leading to unexpected
behaviours.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: cache: Be sure to end the forwarding when XFER length is unknown
Christopher Faulet [Wed, 2 Jan 2019 13:10:01 +0000 (14:10 +0100)] 
BUG/MEDIUM: cache: Be sure to end the forwarding when XFER length is unknown

This bug exists in the HTX code and in the legacy one. When the body length is
unknown, the applet hangs. For the legacy code, it hangs because the end of the
cached object is not correctly handled and the applet is never recalled. For the
HTX code, only the begining of the response (the 1st buffer) is sent then the
applet hangs. To work in HTX, The fast forwarding must be correctly handled.

This patch must be backported to 1.9.

[cf: the patch adding the function channel_add_input must be backported with
this one. It does not exist in 1.8 because only responses with a C-L are cached.]

6 years agoMINOR: stats/htx: Call channel_add_input instead of updating channel state by hand
Christopher Faulet [Wed, 2 Jan 2019 13:34:39 +0000 (14:34 +0100)] 
MINOR: stats/htx: Call channel_add_input instead of updating channel state by hand

This way we are sure the channel state is always correctly upadated, especially
the amount of data directly forwarded. For the stats applet, it is not a bug
because the fast forwarding is never used (the response is chunked and the HTX
extra field is always set to 0).

This patch must be backported to 1.9.

6 years agoMINOR: channel: Add the function channel_add_input
Christopher Faulet [Wed, 2 Jan 2019 13:24:35 +0000 (14:24 +0100)] 
MINOR: channel: Add the function channel_add_input

This function must be called when new incoming data are pushed in the channel's
buffer. It updates the channel state and take care of the fast forwarding by
consuming right amount of data and decrementing "->to_forward" accordingly when
necessary. In fact, this patch just moves a part of ci_putblk in a dedicated
function.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: log: don't mark log FDs as non-blocking on terminals
Willy Tarreau [Wed, 2 Jan 2019 19:09:33 +0000 (20:09 +0100)] 
BUG/MEDIUM: log: don't mark log FDs as non-blocking on terminals

With the new ability to log to a terminal, it's convenient to be able
to use "log stdout" in a config file, except that it now results in
setting the terminal to non-blocking mode, breaking every utility
relying on stdin afterwards. Since the only reason for logging to a
terminal is to debug, do not set the FD to non-blocking mode when it's
a terminal.

This fix must be backported to 1.9.

6 years agoMINOR: payload: add sample fetch for TLS ALPN
Alex Zorin [Sun, 30 Dec 2018 02:56:28 +0000 (13:56 +1100)] 
MINOR: payload: add sample fetch for TLS ALPN

Application-Layer Protocol Negotiation (ALPN, RFC7301) is a TLS
extension which allows a client to present a preference for which
protocols it wishes to connect to, when a single port supports multiple
multiple application protocols.
It allows a transparent proxy to take a decision based on the beginning
of an SSL/TLS stream without deciphering it.

The new fetch "req.ssl_alpn" extracts the ALPN protocol names that may
be present in the ClientHello message.

6 years agoMEDIUM: sessions: Keep track of which connections are idle.
Olivier Houchard [Fri, 28 Dec 2018 17:50:57 +0000 (18:50 +0100)] 
MEDIUM: sessions: Keep track of which connections are idle.

Instead of keeping track of the number of connections we're responsible for,
keep track of the number of connections we're responsible for that we are
currently considering idling (ie that we are not using, they may be in use
by other sessions), that way we can actually reuse connections when we have
more connections than the max configured.

6 years agoMEDIUM: servers: Be smarter when switching connections.
Olivier Houchard [Fri, 28 Dec 2018 15:20:25 +0000 (16:20 +0100)] 
MEDIUM: servers: Be smarter when switching connections.

When connecting to a server, and reusing a connection, always attempt to give
the owner of the previous session one of its own connections, so that one
session won't be responsible for too many connections.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: servers: Flag the stream_interface on handshake error.
Olivier Houchard [Thu, 27 Dec 2018 17:59:46 +0000 (18:59 +0100)] 
BUG/MEDIUM: servers: Flag the stream_interface on handshake error.

When creating a new outgoing connection, if we're using ALPN and waiting
for the handshake completion to choose the mux, and for some reason the
handshake failed, add the SI_FL_ERR flag to the stream_interface, so that
process_streams() knows the connection failed, and can attempt to retry,
instead of just hanging.

This should be backported to 1.9.

6 years agoBUG/MAJOR: sessions: Use an unlimited number of servers for the conn list.
Olivier Houchard [Thu, 27 Dec 2018 16:20:54 +0000 (17:20 +0100)] 
BUG/MAJOR: sessions: Use an unlimited number of servers for the conn list.

When a session adds a connection to its connection list, we used to remove
connections for an another server if there were not enough room for our
server. This can't work, because those lists are now the list of connections
we're responsible for, not just the idle connections.
To fix this, allow for an unlimited number of servers, instead of using
an array, we're now using a linked list.

6 years agoBUG/MAJOR: servers: Correctly use LIST_ELEM().
Olivier Houchard [Thu, 27 Dec 2018 14:35:22 +0000 (15:35 +0100)] 
BUG/MAJOR: servers: Correctly use LIST_ELEM().

To access the first element of the list, correctly use LIST_ELEM(), or we
end up getting the head of the list, instead of getting the first connection.

This should be backported to 1.9.

6 years agoBUG/MAJOR: servers: Use the list api correctly to avoid crashes.
Olivier Houchard [Thu, 27 Dec 2018 14:29:53 +0000 (15:29 +0100)] 
BUG/MAJOR: servers: Use the list api correctly to avoid crashes.

In connect_server(), if we looked for an usable connection and failed to
find one, srv_conn won't be NULL at the end of list_for_each_entry(), but
will point to the head of a list, which is not a pointer to a struct
connection, so explicitely set it to NULL.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: servers: Fail if we fail to allocate a conn_stream.
Olivier Houchard [Fri, 28 Dec 2018 13:45:47 +0000 (14:45 +0100)] 
BUG/MEDIUM: servers: Fail if we fail to allocate a conn_stream.

If, for some reason we failed to allocate a conn_stream when reusing an
existing connection, set srv_conn to NULL, so that we fail later, instead
of pretending all is right. This ends up giving a stream_interface with
no endpoint, and so the stream will never end.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: mux_h2: Don't add to the idle list if we're full.
Olivier Houchard [Fri, 28 Dec 2018 13:44:41 +0000 (14:44 +0100)] 
BUG/MEDIUM: mux_h2: Don't add to the idle list if we're full.

In h2_detach(), don't add the connection to the idle list if nb_streams
is at the max. This can happen if we already closed that stream before, so
its slot became available and was used by another stream.

This should be backported to 1.9.

6 years agoBUG/MINOR: htx: send the proper authenticate header when using http-request auth
Jérôme Magnin [Fri, 28 Dec 2018 13:49:08 +0000 (14:49 +0100)] 
BUG/MINOR: htx: send the proper authenticate header when using http-request auth

When we use htx and http-request auth rules, we need to send WWW-Authenticate
with a 401 and Proxy-Authenticate with a 407. We only sent Proxy-Authenticate
regardless of status, with htx enabled.

To be backported to 1.9.

6 years agoBUG/MEDIUM: tasks: Decrement tasks_run_queue in tasklet_free().
Olivier Houchard [Mon, 24 Dec 2018 13:03:10 +0000 (14:03 +0100)] 
BUG/MEDIUM: tasks: Decrement tasks_run_queue in tasklet_free().

If the tasklet is in the list, don't forget to decrement tasks_run_queue
in tasklet_free().

This should be backported to 1.9.

6 years agoBUG/MEDIUM: servers: Don't try to reuse connection if we switched server.
Olivier Houchard [Mon, 24 Dec 2018 12:32:13 +0000 (13:32 +0100)] 
BUG/MEDIUM: servers: Don't try to reuse connection if we switched server.

In connect_server(), don't attempt to reuse the old connection if it's
targetting a different server than the one we're supposed to access, or
we will never be able to connect to a server if the first one we tried failed.

This should be backported to 1.9.

6 years agoCLEANUP: mux-h2: remove misleading comments about CONTINUATION
Willy Tarreau [Mon, 24 Dec 2018 10:40:26 +0000 (11:40 +0100)] 
CLEANUP: mux-h2: remove misleading comments about CONTINUATION

These ones were left-over from copy-pastes that are unrelated to
CONTINUATION frames.

6 years agoMEDIUM: mux-h2: handle decoding of CONTINUATION frames
Willy Tarreau [Sat, 22 Dec 2018 19:19:26 +0000 (20:19 +0100)] 
MEDIUM: mux-h2: handle decoding of CONTINUATION frames

Now that the HEADERS frame decoding is retryable, we can safely try to
fold CONTINUATION frames into a HEADERS frame when the END_OF_HEADERS
flag is missing. In order to do this, h2c_decode_headers() moves the
frames payloads in-situ and leaves a hole that is plugged when leaving
the function. There is no limit to the number of CONTINUATION frames
handled this way provided that all of them fit into the buffer. The
error reported when meeting isolated CONTINUATION frames has now changed
from INTERNAL_ERROR to PROTOCOL_ERROR.

Now there is only one (unrelated) remaining failure in h2spec.

6 years agoMINOR: mux-h2: make h2_peek_frame_hdr() support an offset
Willy Tarreau [Sat, 22 Dec 2018 17:11:41 +0000 (18:11 +0100)] 
MINOR: mux-h2: make h2_peek_frame_hdr() support an offset

This function will be used to parse multiple subsequent frames so it
needs to support an offset.

6 years agoMINOR: buffers: add a new b_move() function
Willy Tarreau [Sat, 22 Dec 2018 18:19:50 +0000 (19:19 +0100)] 
MINOR: buffers: add a new b_move() function

This function will be used to move parts of a buffer to another place
in the same buffer, even if the parts overlap. In order to keep things
under reasonable control, it only uses a length and absolute offsets
for the source and destination, and doesn't consider head nor data.

6 years agoMINOR: mux-h2: fail stream creation more cleanly using RST_STREAM
Willy Tarreau [Sun, 23 Dec 2018 17:30:44 +0000 (18:30 +0100)] 
MINOR: mux-h2: fail stream creation more cleanly using RST_STREAM

The H2 demux only checks for too many streams in h2c_frt_stream_new(),
then refuses to create a new stream and causes the connection to be
aborted by sending a GOAWAY frame. This will also happen if any error
happens during the stream creation (e.g. memory allocation).

RFC7540#5.1.2 says that attempts to create streams in excess should
instead be dealt with using an RST_STREAM frame conveying either the
PROTOCOL_ERROR or REFUSED_STREAM reason (the latter being usable only
if it is guaranteed that the stream was not processed). In theory it
should not happen for well behaving clients, though it may if we
configure a low enough h2.max_concurrent_streams limit. This error
however may definitely happen on memory shortage.

Previously it was not possible to use RST_STREAM due to the fact that
the HPACK decompressor would be desynchronized. But now we first decode
and only then try to allocate the stream, so the decompressor remains
synchronized regardless of policy or resources issues.

With this patch we enforce stream termination with RST_STREAM and
REFUSED_STREAM if this protocol violation happens, as well as if there
is a temporary condition like a memory allocation issue. It will allow
a client to recover cleanly.

This could possibly be backported to 1.9. Note that this requires that
these five previous patches are merged as well :

    MINOR: h2: add a bit-based frame type representation
    MEDIUM: mux-h2: remove padlen during headers phase
    MEDIUM: mux-h2: decode HEADERS frames before allocating the stream
    MINOR: mux-h2: make h2c_send_rst_stream() use the dummy stream's error code
    MINOR: mux-h2: add a new dummy stream for the REFUSED_STREAM error code

6 years agoMINOR: mux-h2: add a new dummy stream for the REFUSED_STREAM error code
Willy Tarreau [Sun, 23 Dec 2018 17:29:12 +0000 (18:29 +0100)] 
MINOR: mux-h2: add a new dummy stream for the REFUSED_STREAM error code

This patch introduces a new dummy stream, h2_refused_stream, in CLOSED
status with the aforementioned error code. It will be usable to reject
unexpected extraneous streams.

6 years agoMINOR: mux-h2: make h2c_send_rst_stream() use the dummy stream's error code
Willy Tarreau [Sun, 23 Dec 2018 17:26:26 +0000 (18:26 +0100)] 
MINOR: mux-h2: make h2c_send_rst_stream() use the dummy stream's error code

We currently have 2 dummy streams allowing us to send an RST_STREAM
message with an error code matching this one. However h2c_send_rst_stream()
still enforces the STREAM_CLOSED error code for these dummy streams,
ignoring their respective errcode fields which however are properly
set.

Let's make the function always use the stream's error code. This will
allow to create other dummy streams for different codes.

6 years agoMEDIUM: mux-h2: decode HEADERS frames before allocating the stream
Willy Tarreau [Sun, 23 Dec 2018 10:30:42 +0000 (11:30 +0100)] 
MEDIUM: mux-h2: decode HEADERS frames before allocating the stream

It's hard to recover from a HEADERS frame decoding error after having
already created the stream, and it's not possible to recover from a
stream allocation error without dropping the connection since we can't
maintain the HPACK context, so let's decode it before allocating the
stream, into a temporary buffer that will then be offered to the newly
created stream.

6 years agoMINOR: mux-h2: remove useless check for empty frame length in h2s_decode_headers()
Willy Tarreau [Mon, 24 Dec 2018 09:21:36 +0000 (10:21 +0100)] 
MINOR: mux-h2: remove useless check for empty frame length in h2s_decode_headers()

This test for an empty frame was already performed in the callers, there
is no need for checking it again.

6 years agoMINOR: h2: add a bit-based frame type representation
Willy Tarreau [Fri, 21 Dec 2018 13:56:57 +0000 (14:56 +0100)] 
MINOR: h2: add a bit-based frame type representation

This will ease checks among sets of frames.

6 years agoMEDIUM: mux-h2: remove padlen during headers phase
Willy Tarreau [Fri, 21 Dec 2018 14:34:50 +0000 (15:34 +0100)] 
MEDIUM: mux-h2: remove padlen during headers phase

Three types of frames may be padded : DATA, HEADERS and PUSH_PROMISE.
Currently, each of these independently deals with padding and needs to
wait for and skip the initial padlen byte. Not only this complicates
frame processing, but it makes it very hard to process CONTINUATION
frames after a padded HEADERS frame, and makes it complicated to perform
atomic calls to h2s_decode_headers(), which are needed if we want to be
able to maintain the HPACK decompressor's context even when dropping
streams.

This patch takes a different approach : the padding is checked when
parsing the frame header, the padlen byte is waited for and parsed,
and the dpl value is updated with this padlen value. This will allow
the frame parsers to decide to overwrite the padding if needed when
merging adjacent frames.

6 years agoBUG/MEDIUM: mux-h2: mark that we have too many CS once we have more than the max
Willy Tarreau [Sun, 23 Dec 2018 19:43:58 +0000 (20:43 +0100)] 
BUG/MEDIUM: mux-h2: mark that we have too many CS once we have more than the max

Since commit f210191 ("BUG/MEDIUM: h2: don't accept new streams if
conn_streams are still in excess") we're refraining from reading input
frames if we've reached the limit of number of CS. The problem is that
it prevents such situations from working fine. The initial purpose was
in fact to prevent from reading new HEADERS frames when this happens,
and causes some occasional transfer hiccups and pauses with large
concurrencies.

Given that we now properly reject extraneous streams before checking
this value, we can be sure never to have too many streams, and that
any higher value is only caused by a scheduling reason and will go
down after the scheduler calls the code.

This fix must be backported to 1.9 and possibly to 1.8. It may be
tested using h2spec this way with an h2spec config :

  while :; do
    h2spec -o 5 -v -t -S -k -h 127.0.0.1 -p 4443 http2/5.1.2
  done

6 years agoBUG/MINOR: mux-h2: make empty HEADERS frame return a connection error
Willy Tarreau [Sun, 23 Dec 2018 07:13:59 +0000 (08:13 +0100)] 
BUG/MINOR: mux-h2: make empty HEADERS frame return a connection error

We were returning a stream error of type PROTOCOL_ERROR on empty HEADERS
frames, but RFC7540#4.2 stipulates that we should instead return a
connection error of type FRAME_SIZE_ERROR.

This may be backported to 1.9 and 1.8 though it's unlikely to have any
real life effect.

6 years agoREGTESTS: remove the expected window updates from H2 handshakes
Willy Tarreau [Sun, 23 Dec 2018 08:58:41 +0000 (09:58 +0100)] 
REGTESTS: remove the expected window updates from H2 handshakes

These ones are not needed anymore since commit 97aaa67 ("MINOR: mux-h2:
only increase the connection window with the first update"). The tests
should now be more reliable. It might be worth simply removing all the
explicit handshake though it doesn't hurt and still serves as documentation.

6 years agoMINOR: mux-h2: only increase the connection window with the first update
Willy Tarreau [Sun, 23 Dec 2018 08:49:04 +0000 (09:49 +0100)] 
MINOR: mux-h2: only increase the connection window with the first update

Commit dc57236 ("BUG/MINOR: mux-h2: advertise a larger connection window
size") caused a WINDOW_UPDATE message to be sent early with the connection
to increase the connection's window size. It turns out that it causes some
minor trouble that need to be worked around :
  - varnishtest cannot transparently cope with the WU frames during the
    handshake, forcing all tests to explicitly declare the handshake
    sequence ;
  - some vtc scripts randomly fail if the WU frame is sent after another
    expected response frame, adding uncertainty to some tests ;
  - h2spec doesn't correctly identify these WU at the connection level
    that it believes are the responses to some purposely erroneous frames
    it sends, resulting in some errors being reported

None of these are a problem with real clients but they add some confusion
during troubleshooting.

Since the fix above was intended to increase the upload bandwidth, we
have another option which is to increase the window size with the first
WU frame sent for the connection. This way, no WU frame is sent until
one is really needed, and this first frame will adjust the window to
the maximum value. It will make the window increase slightly later, so
the client will experience the first round trip when uploading data,
but this should not be perceptible, and is not worth the extra hassle
needed to maintain our debugging abilities. As an extra bonus, a few
extra bytes are saved for each connection until the first attempt to
upload data.

This should possibly be backported to 1.9 and 1.8.

6 years ago[RELEASE] Released version 2.0-dev0 v2.0-dev0
Willy Tarreau [Sat, 22 Dec 2018 10:19:45 +0000 (11:19 +0100)] 
[RELEASE] Released version 2.0-dev0

Released version 2.0-dev0 with the following main changes :
    - BUG/MAJOR: connections: Close the connection before freeing it.
    - REGTEST: Require the option LUA to run lua tests
    - REGTEST: script: Process script arguments before everything else
    - REGTEST: script: Evaluate the varnishtest command to allow quoted parameters
    - REGTEST: script: Add the option --clean to remove previous log direcotries
    - REGTEST: script: Add the option --debug to show logs on standard ouput
    - REGTEST: script: Add the option --keep-logs to keep all log directories
    - REGTEST: script: Add the option --use-htx to enable the HTX in regtests
    - REGTEST: script: Print only errors in the results report
    - REGTEST: Add option to use HTX prefixed by the macro 'no-htx'
    - REGTEST: Make reg-tests target support argument.
    - REGTEST: Fix a typo about barrier type.
    - REGTEST: Be less Linux specific with a syslog regex.
    - REGTEST: Missing enclosing quotes for ${tmpdir} macro.
    - REGTEST: Exclude freebsd target for some reg tests.
    - BUG/MEDIUM: h2: Don't forget to quit the sending_list if SUB_CALL_UNSUBSCRIBE.
    - BUG/MEDIUM: mux-h2: Don't forget to quit the send list on error reports
    - BUG/MEDIUM: dns: Don't prevent reading the last byte of the payload in dns_validate_response()
    - BUG/MEDIUM: dns: overflowed dns name start position causing invalid dns error
    - BUG/MINOR: compression/htx: Don't compress responses with unknown body length
    - BUG/MINOR: compression/htx: Don't add the last block of data if it is empty
    - MEDIUM: mux_h1: Implement h1_show_fd.
    - REGTEST: script: Add support of alternatives in requited options list
    - REGTEST: Add a basic test for the compression
    - BUG/MEDIUM: mux-h2: don't needlessly wake up the demux on short frames
    - REGTEST: A basic test for "http-buffer-request"
    - BUG/MEDIUM: server: Also copy "check-sni" for server templates.
    - MINOR: ssl: Add ssl_sock_set_alpn().
    - MEDIUM: checks: Add check-alpn.

6 years agoMEDIUM: checks: Add check-alpn.
Olivier Houchard [Fri, 21 Dec 2018 18:47:01 +0000 (19:47 +0100)] 
MEDIUM: checks: Add check-alpn.

Add a way to configure the ALPN used by check, with a new "check-alpn"
keyword. By default, the checks will use the server ALPN, but it may not
be convenient, for instance because the server may use HTTP/2, while checks
are unable to do HTTP/2 yet.

6 years agoMINOR: ssl: Add ssl_sock_set_alpn().
Olivier Houchard [Fri, 21 Dec 2018 18:45:40 +0000 (19:45 +0100)] 
MINOR: ssl: Add ssl_sock_set_alpn().

Add a new function, ssl_sock_set_alpn(), to be able to change the ALPN
for a connection, instead of relying of the one defined in the SSL_CTX.

6 years agoBUG/MEDIUM: server: Also copy "check-sni" for server templates.
Olivier Houchard [Fri, 21 Dec 2018 18:42:01 +0000 (19:42 +0100)] 
BUG/MEDIUM: server: Also copy "check-sni" for server templates.

When using server templates, if "check-sni" is used, make sure it shows up
in all the created servers.

This should be backported to 1.8 and 1.9.

6 years agoREGTEST: A basic test for "http-buffer-request"
Frédéric Lécaille [Fri, 21 Dec 2018 10:56:26 +0000 (11:56 +0100)] 
REGTEST: A basic test for "http-buffer-request"

6 years agoBUG/MEDIUM: mux-h2: don't needlessly wake up the demux on short frames
Willy Tarreau [Fri, 21 Dec 2018 15:09:41 +0000 (16:09 +0100)] 
BUG/MEDIUM: mux-h2: don't needlessly wake up the demux on short frames

In some situations, if too short a frame header is received, we may leave
h2_process_demux() waking up the task again without checking that we were
already subscribed.

In order to avoid this once for all, let's introduce an h2_restart_reading()
function which performs the control and calls the task up. This way we won't
needlessly wake the task up if it's already waiting for I/O.

Must be backported to 1.9.

6 years agoREGTEST: Add a basic test for the compression
Christopher Faulet [Fri, 21 Dec 2018 14:24:57 +0000 (15:24 +0100)] 
REGTEST: Add a basic test for the compression

6 years agoREGTEST: script: Add support of alternatives in requited options list
Christopher Faulet [Fri, 21 Dec 2018 14:18:02 +0000 (15:18 +0100)] 
REGTEST: script: Add support of alternatives in requited options list

It is now possible to specify a list of "alternatives" for a required
option. This must be done by separating options by a pipe ('|'). A test will be
executed if at least one of them is available. For instance:

  #REQUIRED_OPTIONS=ZLIB|SLZ,LUA,OPENSSL

The function _findtest() has also been sligthly simplified.

6 years agoMEDIUM: mux_h1: Implement h1_show_fd.
Olivier Houchard [Fri, 21 Dec 2018 14:20:29 +0000 (15:20 +0100)] 
MEDIUM: mux_h1: Implement h1_show_fd.

In the mux_h1, implement h1_show_fd, to give a bit more information about
each H1 stream, when using "show fd".

6 years agoBUG/MINOR: compression/htx: Don't add the last block of data if it is empty
Christopher Faulet [Fri, 21 Dec 2018 14:10:25 +0000 (15:10 +0100)] 
BUG/MINOR: compression/htx: Don't add the last block of data if it is empty

In HTX, when the compression filter analyze the EOM, it flushes the compression
context and add the last block of compressed data. But, this block can be
empty. In this case, we must ignore it.

6 years agoBUG/MINOR: compression/htx: Don't compress responses with unknown body length
Christopher Faulet [Fri, 21 Dec 2018 13:53:54 +0000 (14:53 +0100)] 
BUG/MINOR: compression/htx: Don't compress responses with unknown body length

In HTX, if the body length of a response cannot be determined, we must not try
to compress it.

6 years agoBUG/MEDIUM: dns: overflowed dns name start position causing invalid dns error
Nikhil Agrawal [Thu, 20 Dec 2018 05:20:59 +0000 (10:50 +0530)] 
BUG/MEDIUM: dns: overflowed dns name start position causing invalid dns error

In dns_read_name() when dns name is used with compression and start position of
name is greater than 255 name read is incorrect and causes invalid dns error.
eg: 0xc11b c specifies name compression being used. 11b represent the start
position of name but currently we are using only 1b for start position.

This should be backported as far as 1.7.

6 years agoBUG/MEDIUM: dns: Don't prevent reading the last byte of the payload in dns_validate_r...
Jérôme Magnin [Thu, 20 Dec 2018 15:47:31 +0000 (16:47 +0100)] 
BUG/MEDIUM: dns: Don't prevent reading the last byte of the payload in dns_validate_response()

A regression was introduced with efbbdf72 BUG: dns: Prevent out-of-bounds
read in dns_validate_dns_response() as it prevented from taking into account
the last byte of the payload.  this patch aims at fixing it.

this must be backported in 1.8.

6 years agoBUG/MEDIUM: mux-h2: Don't forget to quit the send list on error reports
Willy Tarreau [Thu, 20 Dec 2018 14:35:57 +0000 (15:35 +0100)] 
BUG/MEDIUM: mux-h2: Don't forget to quit the send list on error reports

Similar to last fix, we need to quit the send list when reporting an
error via the send side.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: h2: Don't forget to quit the sending_list if SUB_CALL_UNSUBSCRIBE.
Olivier Houchard [Thu, 20 Dec 2018 10:56:28 +0000 (11:56 +0100)] 
BUG/MEDIUM: h2: Don't forget to quit the sending_list if SUB_CALL_UNSUBSCRIBE.

In mux_h2_unsubscribe, don't forget to leave the sending_list if
SUB_CALL_UNSUBSCRIBE was set. SUB_CALL_UNSUBSCRIBE means we were about
to be woken up for writing, unless the mux was too full to get more data.
If there's an unsubscribe call in the meanwhile, we should leave the list,
or we may be put back in the send_list.

This should be backported to 1.9.

6 years agoREGTEST: Exclude freebsd target for some reg tests.
Frédéric Lécaille [Thu, 20 Dec 2018 08:55:45 +0000 (09:55 +0100)] 
REGTEST: Exclude freebsd target for some reg tests.

This patch excludes freebsd target for health-checks reg tests
which rely on TCP_DEFER_ACCEPT usage. This is specific to Linux.

6 years agoREGTEST: Missing enclosing quotes for ${tmpdir} macro.
Frédéric Lécaille [Thu, 20 Dec 2018 08:55:44 +0000 (09:55 +0100)] 
REGTEST: Missing enclosing quotes for ${tmpdir} macro.

6 years agoREGTEST: Be less Linux specific with a syslog regex.
Frédéric Lécaille [Thu, 20 Dec 2018 08:55:43 +0000 (09:55 +0100)] 
REGTEST: Be less Linux specific with a syslog regex.

This patch makes at least this test pass on FreeBSD systems.
The regex to be matched with syslog message was too much Linux specific.

6 years agoREGTEST: Fix a typo about barrier type.
Frédéric Lécaille [Thu, 20 Dec 2018 08:55:42 +0000 (09:55 +0100)] 
REGTEST: Fix a typo about barrier type.

Fix a typo, furthermore there is no reason to use a barrier with "sock" as type
which are more varnish cache specific: used to synchronize the VCL.

6 years agoREGTEST: Make reg-tests target support argument.
Frédéric Lécaille [Wed, 19 Dec 2018 15:27:47 +0000 (16:27 +0100)] 
REGTEST: Make reg-tests target support argument.

With this patch we can provide a list of argument to reg-tests target.
Useful to run reg tests for a list of VTC files like that:

    $ VARNISHTEST_PROGRAM=<...> make reg-tests reg-tests/checks/*.vtc

6 years agoREGTEST: Add option to use HTX prefixed by the macro 'no-htx'
Christopher Faulet [Wed, 19 Dec 2018 10:49:39 +0000 (11:49 +0100)] 
REGTEST: Add option to use HTX prefixed by the macro 'no-htx'

So some tests have been removed.

6 years agoREGTEST: script: Print only errors in the results report
Christopher Faulet [Wed, 19 Dec 2018 10:28:49 +0000 (11:28 +0100)] 
REGTEST: script: Print only errors in the results report