]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
7 years agoBUG/MEDIUM: h2: support uploading partial DATA frames
Willy Tarreau [Mon, 11 Dec 2017 17:27:15 +0000 (18:27 +0100)] 
BUG/MEDIUM: h2: support uploading partial DATA frames

We currently have a problem with DATA frames when they don't fit into
the destination buffer. While it was imagined that in theory this never
happens, in practice it does when "option http-buffer-request" is set,
because the headers don't leave the target buffer before trying to read
so if the frame is full, there's never enough room.

This fix consists in reading what can be read from the frame and advancing
the input buffer. Once the contents left are only the padding, the frame
is completely processed. This also solves another problem we had which is
that it was possible to fill a request buffer beyond its reserve because
the <count> argument was not respected in h2_rcv_buf(). Thus it's possible
that some POST requests sent at once with a headers+body filling exactly a
buffer could result in "400 bad req" when trying to add headers.

This fix must be backported to 1.8.

7 years agoMINOR: h2: store the demux padding length in the h2c struct
Willy Tarreau [Mon, 11 Dec 2017 14:17:36 +0000 (15:17 +0100)] 
MINOR: h2: store the demux padding length in the h2c struct

We'll try to process partial frames and for this we need to know the
padding length. The first step requires to extract it during the parsing
and store it in the demux context in the connection. Till now it was only
processed at once.

7 years agoBUG/MEDIUM: h2: debug incoming traffic in h2_wake()
Willy Tarreau [Thu, 14 Dec 2017 09:34:52 +0000 (10:34 +0100)] 
BUG/MEDIUM: h2: debug incoming traffic in h2_wake()

Even after previous commit ("BUG/MEDIUM: h2: work around a connection
API limitation") there is still a problem with some requests. Sometimes
when polling for more request data while some pending data lies in the
buffer, there's no way to enter h2_recv() because the FD is not marked
ready for reading.

We need to slightly change the approach and make h2_recv() only receive
from the buffer and h2_wake() always attempt to demux if the demux is not
blocked.

However, if the connection is already being polled for reading, it will
not wake up from polling. For this reason we need to cheat and also
pretend a request for sending data, which ensures that as soon as any
direction may move, we can continue to demux. This shows that in the
long term we probably need a better way to resume an interrupted
operation at the mux level.

With this fix, no more hangups happen during uploads. Note that this
time the setup required to provoke the hangups was a bit complex :
  - client is "curl" running on local host, uploading 1.7 MB of
    data via haproxy
  - haproxy running on local host, forwarding to a remote server
    through a 100 Mbps only switch
  - timeouts disabled on haproxy
  - remote server made of thttpd executing a cgi reading request data
    through "dd bs=10" to slow down everything.

With such a setup, around 3-5% of the connections would hang up.

This fix needs to be backported to 1.8.

7 years agoBUG/MEDIUM: h2: work around a connection API limitation
Willy Tarreau [Tue, 12 Dec 2017 10:01:44 +0000 (11:01 +0100)] 
BUG/MEDIUM: h2: work around a connection API limitation

The connection API permits us to enable or disable receiving on a
connection. The underlying FD layer arranges this with the polling
and the fd cache. In practice, if receiving was allowed and an end
of buffer was reached, the FD is subscribed to the polling. If later
we want to process pending data from the buffer, we have to enable
receiving again, but since it's already enabled (in polled mode),
nothing happens and the pending data remain stuck until a new event
happens on the connection to wake the FD up. This is a limitation of
the internal connection API which is not very friendly to the new mux
architecture.

The visible effect is that certain uploads to slow servers experience
truncation on timeout on their last blocks because nothing new comes
from the connection to wake it up while it's being polled.

In order to work around this, there are two solutions :
  - either cheat on the connection so that conn_update_xprt_polling()
    always performs a call to fd_may_recv() after fd_want_recv(), that
    we can trigger from the mux by always calling conn_xprt_stop_recv()
    before conn_xprt_want_recv(), but that's a bit tricky and may have
    side effects on other parts (eg: SSL)

  - or we refrain from receiving in the mux as soon as we're busy on
    anything else, regardless of whether or not some room is available
    in the receive buffer.

This patch takes the second approach above. This way once we read some
data, as soon as we detect that we're stuck, we immediately stop receiving.
This ensures the event doesn't go into polled mode for this period and
that as soon as we're unstuck we can continue. In fact this guarantees
that we can only wait on one side of the mux for a given direction. A
future improvement of the connection layer should make it possible to
resume processing of an interrupted receive operation.

This fix must be backported to 1.8.

7 years agoBUG/MEDIUM: h2: enable recv polling whenever demuxing is possible
Willy Tarreau [Sun, 10 Dec 2017 21:17:57 +0000 (22:17 +0100)] 
BUG/MEDIUM: h2: enable recv polling whenever demuxing is possible

In order to allow demuxing when the dmux buffer is full, we need to
enable data receipt in multiple conditions. Since the conditions are a
bit complex, they have been delegated to a new function h2_recv_allowed()
which follows these rules :

  - if an error or a shutdown was detected on the connection and the buffer
    is empty, we must not attempt to receive
  - if the demux buf failed to be allocated, we must not try to receive and
    we know there is nothing pending
  - if the buffer is not full, we may attempt to receive
  - if no flag indicates a blocking condition, we may attempt to receive
  - otherwise must may not attempt

No more truncated payloads are detected in tests anymore, which seems to
indicate that the issue was worked around. A better connection API will
have to be created for new versions to make this stuff simpler and more
intuitive.

This fix needs to be backported to 1.8 along with the rest of the patches
related to CS_FL_RCV_MORE.

7 years agoBUG/MEDIUM: h2: automatically set CS_FL_RCV_MORE when the output buffer is full
Willy Tarreau [Sun, 10 Dec 2017 20:28:43 +0000 (21:28 +0100)] 
BUG/MEDIUM: h2: automatically set CS_FL_RCV_MORE when the output buffer is full

If we can't demux pending data due to a stream buffer full condition, we
now set CS_FL_RCV_MORE on the conn_stream so that the stream layer knows
it must call back as soon as possible to restart demuxing. Without this,
some uploaded payloads are truncated if the server does not consume them
fast enough and buffers fill up.

Note that this is still not enough to solve the problem, some changes are
required on the recv() and update_poll() paths to allow to restart reading
even with a buffer full condition.

This patch must be backported to 1.8.

7 years agoBUG/MEDIUM: stream-int: always set SI_FL_WAIT_ROOM on CS_FL_RCV_MORE
Willy Tarreau [Sun, 10 Dec 2017 20:19:33 +0000 (21:19 +0100)] 
BUG/MEDIUM: stream-int: always set SI_FL_WAIT_ROOM on CS_FL_RCV_MORE

When a stream interface tries to read data from a mux using rcv_buf(),
sometimes it sees 0 as the return value and concludes that there's no
more data while there are, resulting in the connection being polled for
more data and no new attempt being made at reading these pending data.

Now it will automatically check for flag CS_FL_RCV_MORE to know if the
mux really did not have anything available or was not able to provide
these data by lack of room in the destination buffer, and will set
SI_FL_WAIT_ROOM accordingly. This will ensure that once current data
lying in the buffer are forwarded to the other side, reading chk_rcv()
will be called to re-enable reading.

It's important to note that in practice it will rely on the mux's
update_poll() function to re-enable reading and that where the calls
are placed in the stream interface, it's not possible to perform a
new synchronous rcv_buf() call. Thus a corner case remains where the
mux cannot receive due to a full buffer or any similar condition, but
needs to be able to wake itself up to deliver pending data. This is a
limitation of the current connection/conn_stream API which will likely
need a new event subscription to at least call ->wake() asynchronously
(eg: mux->{kick,restart,touch,update} ?).

For now the affected mux (h2 only) will have to take care of the extra
logic to carefully enable polling to restart processing incoming data.

This patch relies on previous one (MINOR: conn_stream: add new flag
CS_FL_RCV_MORE to indicate pending data) and both must be backported to
1.8.

7 years agoMINOR: conn_stream: add new flag CS_FL_RCV_MORE to indicate pending data
Willy Tarreau [Sun, 10 Dec 2017 20:13:25 +0000 (21:13 +0100)] 
MINOR: conn_stream: add new flag CS_FL_RCV_MORE to indicate pending data

Due to the nature of multiplexed protocols, it will often happen that
some operations are only performed on full frames, preventing any partial
operation from being performed. HTTP/2 is one such example. The current
MUX API causes a problem here because the rcv_buf() function has no way
to let the stream layer know that some data could not be read due to a
lack of room in the buffer, but that data are definitely present. The
problem with this is that the stream layer might not know it needs to
call the function again after it has made some room. And if the frame
in the buffer is not followed by any other, nothing will move anymore.

This patch introduces a new conn_stream flag CS_FL_RCV_MORE whose purpose
is to indicate on the stream that more data than what was received are
already available for reading as soon as more room will be available in
the buffer.

This patch doesn't make use of this flag yet, it only declares it. It is
expected that other similar flags may come in the future, such as reports
of pending end of stream, errors or any such event that might save the
caller from having to poll, or simply let it know that it can take some
actions after having processed data.

7 years agoBUG/MEDIUM: lua/notification: memory leak
Thierry FOURNIER [Sun, 10 Dec 2017 16:10:57 +0000 (17:10 +0100)] 
BUG/MEDIUM: lua/notification: memory leak

The thread patches adds refcount for notifications. The notifications are
used with the Lua cosocket. These refcount free the notifications when
the session is cleared. In the Lua task case, it not have sessions, so
the nofications are never cleraed.

This patch adds a garbage collector for signals. The garbage collector
just clean the notifications for which the end point is disconnected.

This patch should be backported in 1.8

7 years agoDOC: notifications: add precisions about thread usage
Thierry FOURNIER [Sun, 10 Dec 2017 16:14:07 +0000 (17:14 +0100)] 
DOC: notifications: add precisions about thread usage

Precise the terms of use the notification functions.

7 years agoMINOR: systemd: remove comment about HAPROXY_STATS_SOCKET
Vincent Bernat [Sat, 9 Dec 2017 07:32:13 +0000 (08:32 +0100)] 
MINOR: systemd: remove comment about HAPROXY_STATS_SOCKET

This variable was used by the wrapper which was removed in
a6cfa9098e5a. The correct way to do seamless reload is now to enable
"expose-fd listeners" on the stat socket.

7 years agoBUG/MEDIUM: threads/vars: Fix deadlock in register_name
Christopher Faulet [Fri, 8 Dec 2017 08:17:39 +0000 (09:17 +0100)] 
BUG/MEDIUM: threads/vars: Fix deadlock in register_name

In register_name, before locking the var_names array, we check the variable name
validity. So if we try to register an invalid or empty name, we need to return
without unlocking it (because it was never locked).

This patch must be backported in 1.8.

7 years agoBUG/MEDIUM: email-alert: don't set server check status from a email-alert task
PiBa-NL [Wed, 6 Dec 2017 00:35:43 +0000 (01:35 +0100)] 
BUG/MEDIUM: email-alert: don't set server check status from a email-alert task

This avoids possible 100% cpu usage deadlock on a EMAIL_ALERTS_LOCK and
avoids sending lots of emails when 'option log-health-checks' is used.
It is avoided to change the server state and possibly queue a new email
while processing the email alert by setting check->status to
HCHK_STATUS_UNKNOWN which will exit the set_server_check_status(..) early.

This needs to be backported to 1.8.

7 years agoCONTRIB: halog: Add help text for -s switch in halog program
Aleksandar Lazic [Tue, 5 Dec 2017 00:35:21 +0000 (01:35 +0100)] 
CONTRIB: halog: Add help text for -s switch in halog program

It was not documented. May be backported to older releases.

7 years agoMINOR: mworker: Improve wording in `void mworker_wait()`
Tim Duesterhus [Tue, 5 Dec 2017 17:14:13 +0000 (18:14 +0100)] 
MINOR: mworker: Improve wording in `void mworker_wait()`

Replace "left" / "leaving" with "exit" / "exiting".

This should be backported to haproxy 1.8.

7 years agoMINOR: mworker: Update messages referencing exit-on-failure
Tim Duesterhus [Tue, 5 Dec 2017 17:14:12 +0000 (18:14 +0100)] 
MINOR: mworker: Update messages referencing exit-on-failure

Commit 4cfede87a313456fcbce7a185312460b4e1d05b7 removed
`exit-on-failure` in favor of `no-exit-on-failure`, but failed
to update references to the former in user facing messages.

This should be backported to haproxy 1.8.

7 years agoBUG/MEDIUM: h2: fix handling of end of stream again
Willy Tarreau [Thu, 7 Dec 2017 14:59:29 +0000 (15:59 +0100)] 
BUG/MEDIUM: h2: fix handling of end of stream again

Commit 9470d2c ("BUG/MINOR: h2: try to abort closed streams as
soon as possible") tried to address the situations where a stream
is closed by the client, but caused a side effect which is that in
some cases, a regularly closed stream reports an error to the stream
layer. The reason is that we purposely matched H2_SS_CLOSED in the
test for H2_SS_ERROR to report this so that we can check for RST,
but it accidently catches certain end of transfers as well. This
results in valid requests to report flags "CD" in the logs.

Instead, let's roll back to detecting H2_SS_ERROR and explicitly check
for a received RST. This way we can correctly abort transfers without
mistakenly reporting errors in normal situations.

This fix needs to be backported to 1.8 as the fix above was merged into
1.8.1.

7 years agoBUG/MEDIUM: peers: set NOLINGER on the outgoing stream interface
Willy Tarreau [Wed, 6 Dec 2017 16:39:53 +0000 (17:39 +0100)] 
BUG/MEDIUM: peers: set NOLINGER on the outgoing stream interface

Since peers were ported to an applet in 1.5, an issue appeared which
is that certain attempts to close an outgoing connection are a bit
"too nice". Specifically, protocol errors and stream timeouts result
in a clean shutdown to be sent, waiting for the other side to confirm.
This is particularly problematic in the case of timeouts since by
definition the other side will not confirm as it has disappeared.

As found by Fred, this issue was further emphasized in 1.8 by commit
f9ce57e ("MEDIUM: connection: make conn_sock_shutw() aware of
lingering") which causes clean shutdowns not to be sent if the fd is
marked as linger_risk, because now even a clean timeout will not be
sent on an idle peers session, and the other one will have nothing
to respond to.

The solution here is to set NOLINGER on the outgoing stream interface
to ensure we always close whenever we attempt a simple shutdown.

However it is important to keep in mind that this also underlines
some weaknesses of the shutr/shutw processing inside process_stream()
and that all this part needs to be reworked to clearly consider the
abort case, and to stop the confusion between linger_risk and NOLINGER.

This fix needs to be backported as far as 1.5 (all versions are affected).
However, during testing of the backport it was found that 1.5 never tries
to close the peers connection on timeout, so it suffers for another issue.

7 years agoBUG/MEDIUM: checks: a down server going to maint remains definitely stucked on down...
Emeric Brun [Wed, 6 Dec 2017 15:47:17 +0000 (16:47 +0100)] 
BUG/MEDIUM: checks: a down server going to maint remains definitely stucked on down state.

The new admin state was not correctly commited in this case.
Checks were fully disabled but the server was not marked in MAINT state.
It results with a server definitely stucked on the DOWN state.

This patch should be backported on haproxy 1.8

7 years agoBUG/MEDIUM: ssl engines: Fix async engines fds were not considered to fix fd limit...
Emeric Brun [Wed, 6 Dec 2017 12:51:49 +0000 (13:51 +0100)] 
BUG/MEDIUM: ssl engines: Fix async engines fds were not considered to fix fd limit automatically.

The number of async fd is computed considering the maxconn, the number
of sides using ssl and the number of engines using async mode.

This patch should be backported on haproxy 1.8

7 years agoBUG/MEDIUM: mworker: also close peers sockets in the master
Willy Tarreau [Tue, 5 Dec 2017 10:14:12 +0000 (11:14 +0100)] 
BUG/MEDIUM: mworker: also close peers sockets in the master

There's a nasty case related to signaling all processes via SIGUSR1.
Since the master process still holds the peers sockets, the old process
trying to connect to the new one to teach it its tables has a risk to
connect to the master instead, which will not do anything, causing the
old process to hang instead of quitting.

This patch ensures we correctly close the peers in the master process
on startup, just like it is done for proxies. Ultimately we would rather
have a complete list of listeners to avoid such issues. But that's a bit
trickier as it would require using unbind_all() and avoiding side effects
the master could cause to other processes (like unlinking unix sockets).

To be backported to 1.8.

7 years agoBUG/MINOR: ssl: support tune.ssl.cachesize 0 again
William Lallemand [Mon, 4 Dec 2017 17:46:39 +0000 (18:46 +0100)] 
BUG/MINOR: ssl: support tune.ssl.cachesize 0 again

Since the split of the shctx and the ssl cache, we lost the ability to
disable the cache with tune.ssl.cachesize 0.

Worst than that, when using this configuration, haproxy segfaults during
the configuration parsing.

Must be backported to 1.8.

7 years agoBUG/MAJOR: hpack: don't pretend large headers fit in empty table
Willy Tarreau [Mon, 4 Dec 2017 16:58:37 +0000 (17:58 +0100)] 
BUG/MAJOR: hpack: don't pretend large headers fit in empty table

In hpack_dht_make_room(), we try to fulfill this rule form RFC7541#4.4 :

 "It is not an error to attempt to add an entry that is larger than the
  maximum size; an attempt to add an entry larger than the maximum size
  causes the table to be emptied of all existing entries and results in
  an empty table."

Unfortunately it is not consistent with the way it's used in
hpack_dht_insert() as this last one will consider a success as a
confirmation it can copy the header into the table, and a failure as
an indexing error. This results in the two following issues :
  - if a client sends too large a header into an empty table, this
    header may overflow the table. Fortunately, most clients send
    small headers like :authority first, and never mark headers that
    don't fit into the table as indexable since it is counter-productive ;

  - if a client sends too large a header into a populated table, the
    operation fails after the table is totally flushed and the request
    is not processed.

This patch fixes the two issues at once :
  - a header not fitting into an empty table is always a sign that it
    will never fit ;
  - not fitting into the table is not an error

Thanks to Yves Lafon for reporting detailed traces demonstrating this
issue. This fix must be backported to 1.8.

7 years agoBUG/MINOR: action: Don't check http capture rules when no id is defined
Christopher Faulet [Mon, 4 Dec 2017 08:45:15 +0000 (09:45 +0100)] 
BUG/MINOR: action: Don't check http capture rules when no id is defined

This is a regression in the commit 29730ba5 ("MINOR: action: Add a functions to
check http capture rules"). We must check the capture id only when an id is
defined.

This patch must be backported in 1.8.

7 years agoBUG/MINOR: h2: use the H2_F_DATA_* macros for DATA frames
Willy Tarreau [Sun, 3 Dec 2017 20:06:59 +0000 (21:06 +0100)] 
BUG/MINOR: h2: use the H2_F_DATA_* macros for DATA frames

A typo resulted in H2_F_HEADERS_* being used there, but it's harmless
as they are equal. Better fix the confusion though.

Should be backported to 1.8.

7 years agoBUG/MEDIUM: h2: do not accept upper case letters in request header names
Willy Tarreau [Sun, 3 Dec 2017 19:28:13 +0000 (20:28 +0100)] 
BUG/MEDIUM: h2: do not accept upper case letters in request header names

This is explicitly forbidden by 7540#8.1.2, and may be used to bypass
some of the other filters, so they must be blocked early. It removes
another issue reported by h2spec.

To backport to 1.8.

7 years agoBUG/MEDIUM: h2: remove connection-specific headers from request
Willy Tarreau [Sun, 3 Dec 2017 19:15:34 +0000 (20:15 +0100)] 
BUG/MEDIUM: h2: remove connection-specific headers from request

h2spec rightfully outlines that we used not to reject these ones, and
they may cause trouble if presented, especially "upgrade".

Must be backported to 1.8.

7 years agoBUG/MINOR: h2: reject response pseudo-headers from requests
Willy Tarreau [Sun, 3 Dec 2017 19:13:54 +0000 (20:13 +0100)] 
BUG/MINOR: h2: reject response pseudo-headers from requests

At the moment there's only ":status". Let's block it early when parsing
the request. Otherwise it would be blocked by the HTTP/1 code anyway.
This silences another h2spec issue.

To backport to 1.8.

7 years agoBUG/MINOR: h2: properly check PRIORITY frames
Willy Tarreau [Sun, 3 Dec 2017 18:46:19 +0000 (19:46 +0100)] 
BUG/MINOR: h2: properly check PRIORITY frames

We don't use them right now but it's better to ensure they're properly
checked. This removes another 3 warnings in h2spec.

To backport to 1.8.

7 years agoBUG/MINOR: h2: reject incorrect stream dependencies on HEADERS frame
Willy Tarreau [Sun, 3 Dec 2017 18:24:50 +0000 (19:24 +0100)] 
BUG/MINOR: h2: reject incorrect stream dependencies on HEADERS frame

We currently don't use stream dependencies, but as reported by h2spec,
the spec requires that we reject streams that depend on themselves in
HEADERS frames.

To backport to 1.8.

7 years agoBUG/MINOR: h2: do not accept SETTINGS_ENABLE_PUSH other than 0 or 1
Willy Tarreau [Sun, 3 Dec 2017 18:02:28 +0000 (19:02 +0100)] 
BUG/MINOR: h2: do not accept SETTINGS_ENABLE_PUSH other than 0 or 1

We don't use yet it but for correctness, let's enforce the check.

To backport to 1.8.

7 years agoBUG/MEDIUM: h2: enforce the per-connection stream limit
Willy Tarreau [Sun, 3 Dec 2017 17:56:02 +0000 (18:56 +0100)] 
BUG/MEDIUM: h2: enforce the per-connection stream limit

h2spec reports that we unfortunately didn't enforce the per-connection
stream limit that we advertise. It's important to ensure it's never
crossed otherwise it's cheap for a client to create many streams. This
requires the addition of a stream count. The h2c struct could be cleaned
up a bit, just like the h2_detach() function where an "if" block doesn't
make sense anymore since it's always true.

To backport to 1.8.

7 years agoBUG/MINOR: h2: the TE header if present may only contain trailers
Willy Tarreau [Sun, 3 Dec 2017 17:41:31 +0000 (18:41 +0100)] 
BUG/MINOR: h2: the TE header if present may only contain trailers

h2spec reports this issue which has no side effect for now, but is
better cleared.

To backport to 1.8.

7 years agoBUG/MINOR: h2: fix a typo causing PING/ACK to be responded to
Willy Tarreau [Sun, 3 Dec 2017 17:15:56 +0000 (18:15 +0100)] 
BUG/MINOR: h2: fix a typo causing PING/ACK to be responded to

The ACK flag was tested on the frame type instead of the frame flag.

To backport to 1.8.

7 years agoBUG/MINOR: h2: ":path" must not be empty
Willy Tarreau [Sun, 3 Dec 2017 10:51:31 +0000 (11:51 +0100)] 
BUG/MINOR: h2: ":path" must not be empty

As reported by h2spec, the h2->h1 gateway doesn't verify that ":path"
is not empty. This is harmless since the H1 parser will reject such a
request, but better fix it anyway.

To backport to 1.8.

7 years agoBUG/MINOR: h2: try to abort closed streams as soon as possible
Willy Tarreau [Sun, 3 Dec 2017 09:42:59 +0000 (10:42 +0100)] 
BUG/MINOR: h2: try to abort closed streams as soon as possible

The purpose here is to be able to signal receipt of RST_STREAM to
streams when they start to provide a response so that the response
can be aborted ASAP. Given that RST_STREAM immediately switches the
stream to the CLOSED state, we must check for CLOSED in addition to
the existing ERROR check.

To be backported to 1.8.

7 years agoBUG/MINOR: h2: immediately close if receiving GOAWAY after the last stream
Willy Tarreau [Sun, 3 Dec 2017 09:27:47 +0000 (10:27 +0100)] 
BUG/MINOR: h2: immediately close if receiving GOAWAY after the last stream

The h2spec test suite reveals that a GOAWAY frame received after the
last stream doesn't cause an immediate close, because we count on the
last stream to quit to do so. By simply setting the last_sid to the
received value in case it was not set, we can ensure to properly close
an idle connection during h2_wake().

To be backported to 1.8.

7 years agoBUG/MAJOR: h2: correctly check the request length when building an H1 request
Willy Tarreau [Sun, 3 Dec 2017 08:44:50 +0000 (09:44 +0100)] 
BUG/MAJOR: h2: correctly check the request length when building an H1 request

Due to a typo in the request maximum length calculation, we count the
request path twice instead of counting it added to the method's length.
This has two effects, the first one being that a path cannot be larger
than half a buffer, and the second being that the method's length isn't
properly checked. Due to the way the temporary buffers are used internally,
it is quite difficult to meet this condition. In practice, the only
situation where this can cause a problem is when exactly one of either
the method or the path are compressed and the other ones is sent as a
literal.

Thanks to Yves Lafon for providing useful traces exhibiting this issue.

To be backported to 1.8.

7 years agoBUG/MINOR: hpack: dynamic table size updates are only allowed before headers
Willy Tarreau [Sun, 3 Dec 2017 17:09:21 +0000 (18:09 +0100)] 
BUG/MINOR: hpack: dynamic table size updates are only allowed before headers

h2spec reports that we used to support a dynamic table size update
anywhere in the header block but it's only allowed before other
headers (cf RFC7541#4.2.1). In practice we don't use these for now
since we only use literals in responses.

To backport to 1.8.

7 years agoBUG/MINOR: hpack: reject invalid header index
Willy Tarreau [Sun, 3 Dec 2017 11:12:17 +0000 (12:12 +0100)] 
BUG/MINOR: hpack: reject invalid header index

If the hpack decoder sees an invalid header index, it emits value
"### ERR ###" that was used during debugging instead of rejecting the
block. This is harmless, and was detected by h2spec.

To backport to 1.8.

7 years agoBUG/MINOR: hpack: must reject huffman literals padded with more than 7 bits
Willy Tarreau [Sun, 3 Dec 2017 11:00:36 +0000 (12:00 +0100)] 
BUG/MINOR: hpack: must reject huffman literals padded with more than 7 bits

h2spec reported that we didn't check that no more than 7 bits of padding
were left after decoding an huffman-encoded literal. This is harmless but
better fix it now.

To backport to 1.8.

7 years agoBUG/MINOR: hpack: fix debugging output of pseudo header names
Willy Tarreau [Sun, 3 Dec 2017 08:43:38 +0000 (09:43 +0100)] 
BUG/MINOR: hpack: fix debugging output of pseudo header names

When a pseudo header is used, name.ptr is NULL and we must replace it
with hpack_idx_to_name(). This only affects code built with DEBUG_HPACK.

To be backported to 1.8.

7 years agoBUG/MEDIUM: checks: Be sure we have a mux if we created a cs.
Olivier Houchard [Fri, 1 Dec 2017 21:04:05 +0000 (22:04 +0100)] 
BUG/MEDIUM: checks: Be sure we have a mux if we created a cs.

In connect_conn_chk(), there were one case we could return with a new
conn_stream created, but no mux attached. With no mux, cs_destroy() would
segfault. Fix that by setting the mux before we can fail.

This should be backported to 1.8.

7 years agoBUILD: Fix LDFLAGS vs. LIBS re linking order in various makefiles
Christian Ruppert [Thu, 30 Nov 2017 09:11:36 +0000 (10:11 +0100)] 
BUILD: Fix LDFLAGS vs. LIBS re linking order in various makefiles

Libraries should always be listed last. Should be backported to 1.8.

Signed-off-by: Christian Ruppert <idl0r@qasl.de>
7 years agoBUG/MAJOR: thread: Be sure to request a sync between threads only once at a time
Christopher Faulet [Sat, 2 Dec 2017 08:53:24 +0000 (09:53 +0100)] 
BUG/MAJOR: thread: Be sure to request a sync between threads only once at a time

The first thread requesting a synchronization is responsible to write in the
"sync" pipe to notify all others. But we must write only once in the pipe
between two synchronizations to have exactly one character in the pipe. It is
important because we only read 1 character in return when the last thread exits
from the sync-point.

Here there is a bug. If two threads request a synchronization, only the first
writes in the pipe. But, if the same thread requests several times a
synchronization before entering in the sync-point (because, for instance, it
detects many servers down), it writes as many as characters in the pipe. And
only one of them will be read. Repeating this bug many times will block HAProxy
on the write because the pipe is full.

To fix the bug, we just check if the current thread has already requested a
synchronization before trying to notify all others.

The patch must be backported in 1.8

7 years agoMINOR: threads: Fix pthread_setaffinity_np on FreeBSD.
Olivier Houchard [Fri, 1 Dec 2017 17:19:43 +0000 (18:19 +0100)] 
MINOR: threads: Fix pthread_setaffinity_np on FreeBSD.

As with the call to cpuset_setaffinity(), FreeBSD expects the argument to
pthread_setaffinity_np() to be a cpuset_t, not an unsigned long, so the call
was silently failing.

This should probably be backported to 1.8.

7 years agoBUG/MINOR: mworker: detach from tty when in daemon mode
PiBa-NL [Tue, 28 Nov 2017 22:26:08 +0000 (23:26 +0100)] 
BUG/MINOR: mworker: detach from tty when in daemon mode

This allows a calling script to show the first startup output and
know when to stop reading from stdout so haproxy can daemonize.

To be backpored to 1.8.

7 years agoBUG/MINOR: mworker: fix validity check for the pipe FDs
PiBa-NL [Tue, 28 Nov 2017 22:22:14 +0000 (23:22 +0100)] 
BUG/MINOR: mworker: fix validity check for the pipe FDs

Check if master-worker pipe getenv succeeded, also allow pipe fd 0 as
valid. On FreeBSD in quiet mode the stdin/stdout/stderr are closed
which lets the mworker_pipe to use fd 0 and fd 1. Additionally exit()
upon failure to create or get the master-worker pipe.

This needs to be backported to 1.8.

7 years agoMINOR: config: report when "monitor fail" rules are misplaced
Willy Tarreau [Fri, 1 Dec 2017 17:25:08 +0000 (18:25 +0100)] 
MINOR: config: report when "monitor fail" rules are misplaced

"monitor-uri" may rely on "monitor fail" rules, which are processed
very early, immediately after the HTTP request is parsed and before
any http rulesets. It's not reported by the config parser when this
ruleset is misplaces, causing some configurations not to work like
users would expect. Let's just add the warning for a misplaced rule.

7 years agoBUILD/MINOR: haproxy: compiling config cpu parsing handling when needed
David Carlier [Fri, 1 Dec 2017 09:14:02 +0000 (09:14 +0000)] 
BUILD/MINOR: haproxy: compiling config cpu parsing handling when needed

parse_cpu_set is only relevant where there is cpu affinity,
avoiding in the process compilation warning as well.

7 years agoBUG/MAJOR: thread/peers: fix deadlock on peers sync.
Emeric Brun [Fri, 1 Dec 2017 10:37:36 +0000 (11:37 +0100)] 
BUG/MAJOR: thread/peers: fix deadlock on peers sync.

Table lock was not released on an error path (if there is no
enough room to write table switch message).

[wt: needs to be backported to 1.8]

7 years agoBUG/MEDIUM: peers: fix some track counter rules dont register entries for sync.
Emeric Brun [Wed, 29 Nov 2017 15:15:07 +0000 (16:15 +0100)] 
BUG/MEDIUM: peers: fix some track counter rules dont register entries for sync.

This BUG was introduced with:
'MEDIUM: threads/stick-tables: handle multithreads on stick tables'

The API was reviewed to handle stick table entry updates
asynchronously and the caller must now call a 'stkable_touch_*'
function each time the content of an entry is modified to
register the entry to be synced.

There was missing call to stktable_touch_* resulting in
not propagated entries to remote peers (or local one during reload)

7 years agoBUG/MEDIUM: h2: don't report an error after parsing a 100-continue response
Willy Tarreau [Wed, 29 Nov 2017 14:41:32 +0000 (15:41 +0100)] 
BUG/MEDIUM: h2: don't report an error after parsing a 100-continue response

Yves Lafon reported a breakage with 100-continue. In fact the problem
is caused when an 1xx is the last response in the buffer (which commonly
is the case). We loop back immediately into the parser with what remains
of the input buffer (ie: nothing), while it is not expected to be called
with an empty response, so it fails.

Let's simply get back to the caller to decide whether or not more data
are expected to be sent.

This fix needs to be backported to 1.8.

7 years agoBUG/MEDIUM: threads/peers: decrement, not increment jobs on quitting
Willy Tarreau [Wed, 29 Nov 2017 13:49:30 +0000 (14:49 +0100)] 
BUG/MEDIUM: threads/peers: decrement, not increment jobs on quitting

Commit 8d8aa0d ("MEDIUM: threads/listeners: Make listeners thread-safe")
mistakenly placed HA_ATOMIC_ADD(job, 1) to replace a job--, so it maintains
the job count too high preventing the process from cleanly exiting on
reload.

This needs to be backported to 1.8.

7 years agoBUG/MINOR: ssl: CO_FL_EARLY_DATA removal is managed by stream
Emmanuel Hocdet [Mon, 27 Nov 2017 15:14:40 +0000 (16:14 +0100)] 
BUG/MINOR: ssl: CO_FL_EARLY_DATA removal is managed by stream

Manage BoringSSL early_data as it is with openssl 1.1.1.

7 years agoBUILD/MINOR: Makefile : enabling USE_CPU_AFFINITY
David Carlier [Wed, 29 Nov 2017 11:05:12 +0000 (11:05 +0000)] 
BUILD/MINOR: Makefile : enabling USE_CPU_AFFINITY

FreeBSD can handle cpuset matters just fine, we can hence enable it
by default as linux2628 TARGET.

7 years agoBUILD/MINOR: haproxy : FreeBSD/cpu affinity needs pthread_np header
David Carlier [Wed, 29 Nov 2017 11:02:32 +0000 (11:02 +0000)] 
BUILD/MINOR: haproxy : FreeBSD/cpu affinity needs pthread_np header

for pthread_*_np calls, pthread_np.h is needed under FreeBSD.

7 years agoBUG/MEDIUM: stream: fix session leak on applet-initiated connections
Willy Tarreau [Wed, 29 Nov 2017 13:05:38 +0000 (14:05 +0100)] 
BUG/MEDIUM: stream: fix session leak on applet-initiated connections

Commit 3e13cba ("MEDIUM: session: make use of the connection's destroy
callback") ensured that connections could be autonomous to destroy the
session they initiated, but it didn't take care of doing the same for
applets. Such applets are used for peers, Lua and SPOE outgoing
connections. In this case, once the stream ends, it closes everything
and nothing takes care of releasing the session. The problem is not
immediately obvious since the only visible effect is that older
processes will not quit on reload after having leaked one such session.

For now we check in stream_free() if the session's origin is the applet
we're releasing, and then free the session as well. Something more
uniform should probably be done once we manage to unify applets and
connections a bit more.

This fix needs to be backported to 1.8. Thanks to Emmanuel Hocdet for
reporting the problem.

7 years agoBUILD: checks: don't include server.h
Willy Tarreau [Wed, 29 Nov 2017 09:52:29 +0000 (10:52 +0100)] 
BUILD: checks: don't include server.h

server.h needs checks.h since it references the struct check, but depending
on the include order it will fail if check.h is included first due to this
one including server.h in turn while it doesn't need it.

7 years agoBUG/MEDIUM: cache: bad computation of the remaining size
William Lallemand [Tue, 28 Nov 2017 10:33:02 +0000 (11:33 +0100)] 
BUG/MEDIUM: cache: bad computation of the remaining size

The cache was not setting the hdrs_len to zero when we are called
in the http_forward_data with headers + body.

The consequence is to always try to store a size - the size of headers,
during the calls to http_forward_data even when it has already forwarded
the headers.

Thanks to Cyril Bonté for reporting this bug.

Must be backported to 1.8.

7 years agoBUG/MEDIUM: ssl: don't allocate shctx several time
William Lallemand [Tue, 28 Nov 2017 10:04:43 +0000 (11:04 +0100)] 
BUG/MEDIUM: ssl: don't allocate shctx several time

The shctx_init() function does not check anymore if the pointer is not
NULL, this check must be done is the caller.

The consequence was to allocate one shctx per ssl bind.

Bug introduced by 4f45bb9 ("MEDIUM: shctx: separate ssl and shctx")

Thanks to Maciej Zdeb for reporting this bug.

Must be backported to 1.8.

7 years agoBUG/MEDIUM: tcp-check: Don't lock the server in tcpcheck_main
Christopher Faulet [Tue, 28 Nov 2017 09:06:29 +0000 (10:06 +0100)] 
BUG/MEDIUM: tcp-check: Don't lock the server in tcpcheck_main

There was a deadlock in tcpcheck_main function. The server's lock was already
acquired by the caller (process_chk_conn or wake_srv_chk).

This patch must be backported in 1.8.

7 years agoBUILD/MINOR: deviceatlas: enable thread support
David Carlier [Mon, 27 Nov 2017 11:55:59 +0000 (11:55 +0000)] 
BUILD/MINOR: deviceatlas: enable thread support

DeviceAtlas detection being multi-thread safe, we enable the
new thread feature support.
Needs to be backported to 1.8 branch.

7 years agoDOC: cache: update sections and fix some typos
Cyril Bonté [Sun, 26 Nov 2017 21:24:31 +0000 (22:24 +0100)] 
DOC: cache: update sections and fix some typos

Cache sections were not defined as the others, preventing them to be
correctly parsed by the HTML converter. Also, the "Cache" subsections
where not added to the summary.

This patch should be backported to the 1.8 branch.

7 years agoBUG/MEDIUM: kqueue: Don't bother closing the kqueue after fork.
Olivier Houchard [Sun, 26 Nov 2017 18:53:46 +0000 (19:53 +0100)] 
BUG/MEDIUM: kqueue: Don't bother closing the kqueue after fork.

kqueue fd's are not shared with children after fork(), so the children
don't have to close them, and it may in fact be dangerous, because we may
end up closing a totally unrelated fd.

[wt: to be backported to 1.8 where master-worker broke on this, and
 likely to older versions for completeness]

7 years ago[RELEASE] Released version 1.9-dev0 v1.9-dev0
Willy Tarreau [Sun, 26 Nov 2017 18:50:17 +0000 (19:50 +0100)] 
[RELEASE] Released version 1.9-dev0

Released version 1.9-dev0 with the following main changes :
    - BUG/MEDIUM: stream: don't automatically forward connect nor close
    - BUG/MAJOR: stream: ensure analysers are always called upon close
    - BUG/MINOR: stream-int: don't try to read again when CF_READ_DONTWAIT is set
    - MEDIUM: mworker: Add systemd `Type=notify` support
    - BUG/MEDIUM: cache: free callback to remove from tree
    - CLEANUP: cache: remove unused struct
    - MEDIUM: cache: enable the HTTP analysers
    - CLEANUP: cache: remove wrong comment
    - MINOR: threads/atomic: rename local variables in macros to avoid conflicts
    - MINOR: threads/plock: rename local variables in macros to avoid conflicts
    - MINOR: threads/atomic: implement pl_mb() in asm on x86
    - MINOR: threads/atomic: implement pl_bts() on non-x86
    - MINOR: threads/build: atomic: replace the few inlines with macros
    - BUILD: threads/plock: fix a build issue on Clang without optimization
    - BUILD: ebtree: don't redefine types u32/s32 in scope-aware trees
    - BUILD: compiler: add a new type modifier __maybe_unused
    - BUILD: h2: mark some inlined functions "unused"
    - BUILD: server: check->desc always exists
    - BUG/MEDIUM: h2: properly report connection errors in headers and data handlers
    - MEDIUM: h2: add a function to emit an HTTP/1 request from a headers list
    - MEDIUM: h2: change hpack_decode_headers() to only provide a list of headers
    - BUG/MEDIUM: h2: always reassemble the Cookie request header field
    - BUG/MINOR: systemd: ignore daemon mode
    - CONTRIB: spoa_example: allow to compile outside HAProxy.
    - CONTRIB: spoa_example: remove bref, wordlist, cond_wordlist
    - CONTRIB: spoa_example: remove last dependencies on type "sample"
    - CONTRIB: spoa_example: remove SPOE enums that are useless for clients
    - CLEANUP: cache: reorder includes
    - MEDIUM: shctx: use unsigned int for len and block_count
    - MEDIUM: cache: "show cache" on the cli
    - BUG/MEDIUM: cache: use key=0 as a condition for freeing
    - BUG/MEDIUM: cache: refcount forbids to free the objects
    - BUG/MEDIUM: cache fix cli_kws structure
    - BUG/MEDIUM: deinit: correctly deinitialize the proxy and global listener tasks
    - BUG/MINOR: ssl: Always start the handshake if we can't send early data.
    - MINOR: ssl: Don't disable early data handling if we could not write.
    - MINOR: pools: prepare functions to override malloc/free in pools
    - MINOR: pools: implement DEBUG_UAF to detect use after free
    - BUG/MEDIUM: threads/time: fix time drift correction
    - BUG/MEDIUM: threads/time: maintain a common time reference between all threads
    - MINOR: sample: Add "thread" sample fetch
    - BUG/MINOR: Use crt_base instead of ca_base when crt is parsed on a server line
    - BUG/MINOR: stream: fix tv_request calculation for applets
    - BUG/MAJOR: h2: always remove a stream from the send list before freeing it
    - BUG/MAJOR: threads/task: dequeue expired tasks under the WQ lock
    - MINOR: ssl: Handle reading early data after writing better.
    - MINOR: mux: Make sure every string is woken up after the handshake.
    - MEDIUM: cache: store sha1 for hashing the cache key
    - MINOR: http: implement the "http-request reject" rule
    - MINOR: h2: send RST_STREAM before GOAWAY on reject
    - MEDIUM: h2: don't gracefully close the connection anymore on Connection: close
    - MINOR: h2: make use of client-fin timeout after GOAWAY
    - MEDIUM: config: ensure that tune.bufsize is at least 16384 when using HTTP/2
    - MINOR: ssl: Handle early data with BoringSSL
    - BUG/MEDIUM: stream: always release the stream-interface on abort
    - BUG/MEDIUM: cache: free ressources in chn_end_analyze
    - MINOR: cache: move the refcount decrease in the applet release
    - BUG/MINOR: listener: Allow multiple "process" options on "bind" lines
    - MINOR: config: Support a range to specify processes in "cpu-map" parameter
    - MINOR: config: Slightly change how parse_process_number works
    - MINOR: config: Export parse_process_number and use it wherever it's applicable
    - MINOR: standard: Add my_ffsl function to get the position of the bit set to one
    - MINOR: config: Add auto-increment feature for cpu-map
    - MINOR: config: Support partial ranges in cpu-map directive
    - MINOR:: config: Remove thread-map directive
    - MINOR: config: Add the threads support in cpu-map directive
    - MINOR: config: Add threads support for "process" option on "bind" lines
    - MEDIUM: listener: Bind listeners on a thread subset if specified
    - CLEANUP: debug: Use DPRINTF instead of fprintf into #ifdef DEBUG_FULL/#endif
    - CLEANUP: log: Rename Alert/Warning in ha_alert/ha_warning
    - MINOR/CLEANUP: proxy: rename "proxy" to "proxies_list"
    - CLEANUP: pools: rename all pool functions and pointers to remove this "2"
    - DOC: update the roadmap file with the latest changes merged in 1.8
    - DOC: fix mangled version in peers protocol documentation
    - DOC: add initial peers protovol v2.0 documentation.
    - DOC: mention William as maintainer of the cache and master-worker
    - DOC: add Christopher and Emeric as maintainers of the threads
    - MINOR: cache: replace a fprint() by an abort()
    - MEDIUM: cache: max-age configuration keyword
    - DOC: explain HTTP2 timeout behavior
    - DOC: cache: configuration and management
    - MAJOR: mworker: exits the master on failure
    - BUG/MINOR: threads: don't drop "extern" on the lock in include files
    - MINOR: task: keep a pointer to the currently running task
    - MINOR: task: align the rq and wq locks
    - MINOR: fd: cache-align fdtab and fdcache locks
    - MINOR: buffers: cache-align buffer_wq_lock
    - CLEANUP: server: reorder some fields in struct server to save 40 bytes
    - CLEANUP: proxy: slightly reorder the struct proxy to reduce holes
    - CLEANUP: checks: remove 16 bytes of holes in struct check
    - CLEANUP: cache: more efficiently pack the struct cache
    - CLEANUP: fd: place the lock at the beginning of struct fdtab
    - CLEANUP: pools: align pools on a cache line
    - DOC: config: add a few bits about how to configure HTTP/2
    - BUG/MAJOR: threads/queue: avoid recursive locking in pendconn_get_next_strm()
    - BUILD: Makefile: reorder object files by size

7 years ago[RELEASE] Released version 1.8.0 v1.8.0
Willy Tarreau [Sun, 26 Nov 2017 18:25:23 +0000 (19:25 +0100)] 
[RELEASE] Released version 1.8.0

Released version 1.8.0 with the following main changes :
    - BUG/MEDIUM: stream: don't automatically forward connect nor close
    - BUG/MAJOR: stream: ensure analysers are always called upon close
    - BUG/MINOR: stream-int: don't try to read again when CF_READ_DONTWAIT is set
    - MEDIUM: mworker: Add systemd `Type=notify` support
    - BUG/MEDIUM: cache: free callback to remove from tree
    - CLEANUP: cache: remove unused struct
    - MEDIUM: cache: enable the HTTP analysers
    - CLEANUP: cache: remove wrong comment
    - MINOR: threads/atomic: rename local variables in macros to avoid conflicts
    - MINOR: threads/plock: rename local variables in macros to avoid conflicts
    - MINOR: threads/atomic: implement pl_mb() in asm on x86
    - MINOR: threads/atomic: implement pl_bts() on non-x86
    - MINOR: threads/build: atomic: replace the few inlines with macros
    - BUILD: threads/plock: fix a build issue on Clang without optimization
    - BUILD: ebtree: don't redefine types u32/s32 in scope-aware trees
    - BUILD: compiler: add a new type modifier __maybe_unused
    - BUILD: h2: mark some inlined functions "unused"
    - BUILD: server: check->desc always exists
    - BUG/MEDIUM: h2: properly report connection errors in headers and data handlers
    - MEDIUM: h2: add a function to emit an HTTP/1 request from a headers list
    - MEDIUM: h2: change hpack_decode_headers() to only provide a list of headers
    - BUG/MEDIUM: h2: always reassemble the Cookie request header field
    - BUG/MINOR: systemd: ignore daemon mode
    - CONTRIB: spoa_example: allow to compile outside HAProxy.
    - CONTRIB: spoa_example: remove bref, wordlist, cond_wordlist
    - CONTRIB: spoa_example: remove last dependencies on type "sample"
    - CONTRIB: spoa_example: remove SPOE enums that are useless for clients
    - CLEANUP: cache: reorder includes
    - MEDIUM: shctx: use unsigned int for len and block_count
    - MEDIUM: cache: "show cache" on the cli
    - BUG/MEDIUM: cache: use key=0 as a condition for freeing
    - BUG/MEDIUM: cache: refcount forbids to free the objects
    - BUG/MEDIUM: cache fix cli_kws structure
    - BUG/MEDIUM: deinit: correctly deinitialize the proxy and global listener tasks
    - BUG/MINOR: ssl: Always start the handshake if we can't send early data.
    - MINOR: ssl: Don't disable early data handling if we could not write.
    - MINOR: pools: prepare functions to override malloc/free in pools
    - MINOR: pools: implement DEBUG_UAF to detect use after free
    - BUG/MEDIUM: threads/time: fix time drift correction
    - BUG/MEDIUM: threads/time: maintain a common time reference between all threads
    - MINOR: sample: Add "thread" sample fetch
    - BUG/MINOR: Use crt_base instead of ca_base when crt is parsed on a server line
    - BUG/MINOR: stream: fix tv_request calculation for applets
    - BUG/MAJOR: h2: always remove a stream from the send list before freeing it
    - BUG/MAJOR: threads/task: dequeue expired tasks under the WQ lock
    - MINOR: ssl: Handle reading early data after writing better.
    - MINOR: mux: Make sure every string is woken up after the handshake.
    - MEDIUM: cache: store sha1 for hashing the cache key
    - MINOR: http: implement the "http-request reject" rule
    - MINOR: h2: send RST_STREAM before GOAWAY on reject
    - MEDIUM: h2: don't gracefully close the connection anymore on Connection: close
    - MINOR: h2: make use of client-fin timeout after GOAWAY
    - MEDIUM: config: ensure that tune.bufsize is at least 16384 when using HTTP/2
    - MINOR: ssl: Handle early data with BoringSSL
    - BUG/MEDIUM: stream: always release the stream-interface on abort
    - BUG/MEDIUM: cache: free ressources in chn_end_analyze
    - MINOR: cache: move the refcount decrease in the applet release
    - BUG/MINOR: listener: Allow multiple "process" options on "bind" lines
    - MINOR: config: Support a range to specify processes in "cpu-map" parameter
    - MINOR: config: Slightly change how parse_process_number works
    - MINOR: config: Export parse_process_number and use it wherever it's applicable
    - MINOR: standard: Add my_ffsl function to get the position of the bit set to one
    - MINOR: config: Add auto-increment feature for cpu-map
    - MINOR: config: Support partial ranges in cpu-map directive
    - MINOR:: config: Remove thread-map directive
    - MINOR: config: Add the threads support in cpu-map directive
    - MINOR: config: Add threads support for "process" option on "bind" lines
    - MEDIUM: listener: Bind listeners on a thread subset if specified
    - CLEANUP: debug: Use DPRINTF instead of fprintf into #ifdef DEBUG_FULL/#endif
    - CLEANUP: log: Rename Alert/Warning in ha_alert/ha_warning
    - MINOR/CLEANUP: proxy: rename "proxy" to "proxies_list"
    - CLEANUP: pools: rename all pool functions and pointers to remove this "2"
    - DOC: update the roadmap file with the latest changes merged in 1.8
    - DOC: fix mangled version in peers protocol documentation
    - DOC: add initial peers protovol v2.0 documentation.
    - DOC: mention William as maintainer of the cache and master-worker
    - DOC: add Christopher and Emeric as maintainers of the threads
    - MINOR: cache: replace a fprint() by an abort()
    - MEDIUM: cache: max-age configuration keyword
    - DOC: explain HTTP2 timeout behavior
    - DOC: cache: configuration and management
    - MAJOR: mworker: exits the master on failure
    - BUG/MINOR: threads: don't drop "extern" on the lock in include files
    - MINOR: task: keep a pointer to the currently running task
    - MINOR: task: align the rq and wq locks
    - MINOR: fd: cache-align fdtab and fdcache locks
    - MINOR: buffers: cache-align buffer_wq_lock
    - CLEANUP: server: reorder some fields in struct server to save 40 bytes
    - CLEANUP: proxy: slightly reorder the struct proxy to reduce holes
    - CLEANUP: checks: remove 16 bytes of holes in struct check
    - CLEANUP: cache: more efficiently pack the struct cache
    - CLEANUP: fd: place the lock at the beginning of struct fdtab
    - CLEANUP: pools: align pools on a cache line
    - DOC: config: add a few bits about how to configure HTTP/2
    - BUG/MAJOR: threads/queue: avoid recursive locking in pendconn_get_next_strm()
    - BUILD: Makefile: reorder object files by size

7 years agoBUILD: Makefile: reorder object files by size
Willy Tarreau [Sun, 26 Nov 2017 16:58:17 +0000 (17:58 +0100)] 
BUILD: Makefile: reorder object files by size

We've added many files since last version, it was about time to reorder
the makefile to improve parallel builds by having the slower files built
first. This allows to consistently stay below 4 seconds when using a
20-core build farm.

7 years agoBUG/MAJOR: threads/queue: avoid recursive locking in pendconn_get_next_strm()
Willy Tarreau [Sun, 26 Nov 2017 17:48:14 +0000 (18:48 +0100)] 
BUG/MAJOR: threads/queue: avoid recursive locking in pendconn_get_next_strm()

pendconn_get_next_strm() is called from process_srv_queue() under the
server lock, and calls stream_add_srv_conn() with this lock held, while
the latter tries to take it again. This results in a deadlock when
a server's maxconn is reached and haproxy is built with thread support.

7 years agoDOC: config: add a few bits about how to configure HTTP/2
Willy Tarreau [Sun, 26 Nov 2017 11:18:55 +0000 (12:18 +0100)] 
DOC: config: add a few bits about how to configure HTTP/2

There's hardly anything to say in this file beyond the ALPN
configuration and some precisions about how the HTTP transaction model
applies to HTTP/2.

7 years agoCLEANUP: pools: align pools on a cache line
Willy Tarreau [Sun, 26 Nov 2017 09:50:36 +0000 (10:50 +0100)] 
CLEANUP: pools: align pools on a cache line

There are just a few pools, and they're stressed a lot, so it makes
sense to dedicate them a cache line to avoid contention and to place
the lock at the beginning.

7 years agoCLEANUP: fd: place the lock at the beginning of struct fdtab
Willy Tarreau [Sun, 26 Nov 2017 09:41:47 +0000 (10:41 +0100)] 
CLEANUP: fd: place the lock at the beginning of struct fdtab

The struct is not cache line aligned but at least, every time the lock
will appear in the same cache line as the fd it will benefit from being
accessed first. This improves the performance by about 2% on fd-intensive
workloads with 4 threads.

7 years agoCLEANUP: cache: more efficiently pack the struct cache
Willy Tarreau [Sun, 26 Nov 2017 07:54:31 +0000 (08:54 +0100)] 
CLEANUP: cache: more efficiently pack the struct cache

By having the cache id on 33 bytes as the first member, it was
creating a hole and forcing the "hot" remaining part to be split
across two cache lines. Let's move the id at the end as it's used
only during config parsing.

7 years agoCLEANUP: checks: remove 16 bytes of holes in struct check
Willy Tarreau [Sun, 26 Nov 2017 07:44:34 +0000 (08:44 +0100)] 
CLEANUP: checks: remove 16 bytes of holes in struct check

These ones were easily recovered by swapping two members.

7 years agoCLEANUP: proxy: slightly reorder the struct proxy to reduce holes
Willy Tarreau [Sun, 26 Nov 2017 07:41:31 +0000 (08:41 +0100)] 
CLEANUP: proxy: slightly reorder the struct proxy to reduce holes

16 bytes were recovered from the struct doing minimal reordering.

7 years agoCLEANUP: server: reorder some fields in struct server to save 40 bytes
Willy Tarreau [Sun, 26 Nov 2017 06:26:48 +0000 (07:26 +0100)] 
CLEANUP: server: reorder some fields in struct server to save 40 bytes

In 1.8 many holes were introduced in struct server, so let's slightly
reorder a few fields to plug most of them. This saves 40 bytes in the
struct.

7 years agoMINOR: buffers: cache-align buffer_wq_lock
Willy Tarreau [Sun, 26 Nov 2017 10:08:14 +0000 (11:08 +0100)] 
MINOR: buffers: cache-align buffer_wq_lock

This lock is highly stressed, avoid cache-line sharing to limit stress.

7 years agoMINOR: fd: cache-align fdtab and fdcache locks
Willy Tarreau [Sun, 26 Nov 2017 10:07:34 +0000 (11:07 +0100)] 
MINOR: fd: cache-align fdtab and fdcache locks

These locks are highly contended, let's not make them share cache lines.

7 years agoMINOR: task: align the rq and wq locks
Willy Tarreau [Sun, 26 Nov 2017 09:19:16 +0000 (10:19 +0100)] 
MINOR: task: align the rq and wq locks

We really don't want them to share the same cache line as they are
expected to be used in parallel. Adding a 64-byte alignment here shows
a performance increase of about 4.5% on task-intensive workloads with
2 to 4 threads.

7 years agoMINOR: task: keep a pointer to the currently running task
Willy Tarreau [Sun, 26 Nov 2017 09:08:06 +0000 (10:08 +0100)] 
MINOR: task: keep a pointer to the currently running task

Very often when debugging, the current task's pointer isn't easy to
recover (eg: from a core file). Let's keep a copy of it, it will
likely help, especially with threads.

7 years agoBUG/MINOR: threads: don't drop "extern" on the lock in include files
Willy Tarreau [Sun, 26 Nov 2017 10:00:37 +0000 (11:00 +0100)] 
BUG/MINOR: threads: don't drop "extern" on the lock in include files

Commit 9dcf9b6 ("MINOR: threads: Use __decl_hathreads to declare locks")
accidently lost a few "extern" in certain lock declarations, possibly
causing certain entries to be declared at multiple places. Apparently
it hasn't caused any harm though.

The offending ones were :
  - fdtab_lock
  - fdcache_lock
  - poll_lock
  - buffer_wq_lock

7 years agoMAJOR: mworker: exits the master on failure
William Lallemand [Fri, 24 Nov 2017 21:02:34 +0000 (22:02 +0100)] 
MAJOR: mworker: exits the master on failure

This patch changes the behavior of the master during the exit of a
worker.

When a worker exits with an error code, for example in the case of a
segfault, all workers are now killed and the master leaves.

If you don't want this behavior you can use the option
"master-worker no-exit-on-failure".

7 years agoDOC: cache: configuration and management
William Lallemand [Fri, 24 Nov 2017 20:36:45 +0000 (21:36 +0100)] 
DOC: cache: configuration and management

7 years agoDOC: explain HTTP2 timeout behavior
Lukas Tribus [Fri, 24 Nov 2017 18:05:12 +0000 (19:05 +0100)] 
DOC: explain HTTP2 timeout behavior

Clarifies that in HTTP2 we don't consider "timeout http-keep-alive", but
"timeout client" instead.

7 years agoMEDIUM: cache: max-age configuration keyword
William Lallemand [Fri, 24 Nov 2017 17:53:43 +0000 (18:53 +0100)] 
MEDIUM: cache: max-age configuration keyword

Add a configuration keyword to change the max-age.
The default one is still 60s.

7 years agoMINOR: cache: replace a fprint() by an abort()
William Lallemand [Fri, 24 Nov 2017 17:53:42 +0000 (18:53 +0100)] 
MINOR: cache: replace a fprint() by an abort()

In the applet I/O handler we can never get an object bigger than a
buffer, so we should never reach this case.

7 years agoDOC: add Christopher and Emeric as maintainers of the threads
Willy Tarreau [Fri, 24 Nov 2017 17:50:13 +0000 (18:50 +0100)] 
DOC: add Christopher and Emeric as maintainers of the threads

We'll need to be extremely careful at the beginning regarding changes.

7 years agoDOC: mention William as maintainer of the cache and master-worker
Willy Tarreau [Fri, 24 Nov 2017 17:23:03 +0000 (18:23 +0100)] 
DOC: mention William as maintainer of the cache and master-worker

The latter is very tricky, better not touch anything there without
his approval.

7 years agoDOC: add initial peers protovol v2.0 documentation.
Emeric Brun [Fri, 24 Nov 2017 17:20:57 +0000 (18:20 +0100)] 
DOC: add initial peers protovol v2.0 documentation.

[wt: the new version is 2.1 but it's useful to document the different
 versions since they're found in field. There's some overlap with the
 new one and they complement on certain areas. Most likely they'll
 ultimately be merged.]

7 years agoDOC: fix mangled version in peers protocol documentation
Willy Tarreau [Fri, 24 Nov 2017 17:10:24 +0000 (18:10 +0100)] 
DOC: fix mangled version in peers protocol documentation

Tim Düsterhus noticed that the create-release script had mangled the
version in the peers protocol doc, forcing it to 1.8 due to its syntax
matching the format of an haproxy version. Let's just slightly readjust
the header not to match this by removing the word "version" and placing
it on the same line as the title.

7 years agoDOC: update the roadmap file with the latest changes merged in 1.8
Willy Tarreau [Fri, 24 Nov 2017 17:00:32 +0000 (18:00 +0100)] 
DOC: update the roadmap file with the latest changes merged in 1.8

We're making progress :-)

7 years agoCLEANUP: pools: rename all pool functions and pointers to remove this "2"
Willy Tarreau [Fri, 24 Nov 2017 16:34:44 +0000 (17:34 +0100)] 
CLEANUP: pools: rename all pool functions and pointers to remove this "2"

During the migration to the second version of the pools, the new
functions and pool pointers were all called "pool_something2()" and
"pool2_something". Now there's no more pool v1 code and it's a real
pain to still have to deal with this. Let's clean this up now by
removing the "2" everywhere, and by renaming the pool heads
"pool_head_something".

7 years agoMINOR/CLEANUP: proxy: rename "proxy" to "proxies_list"
Olivier Houchard [Fri, 24 Nov 2017 15:54:05 +0000 (16:54 +0100)] 
MINOR/CLEANUP: proxy: rename "proxy" to "proxies_list"

Rename the global variable "proxy" to "proxies_list".
There's been multiple proxies in haproxy for quite some time, and "proxy"
is a potential source of bugs, a number of functions have a "proxy" argument,
and some code used "proxy" when it really meant "px" or "curproxy". It worked
by pure luck, because it usually happened while parsing the config, and thus
"proxy" pointed to the currently parsed proxy, but we should probably not
rely on this.

[wt: some of these are definitely fixes that are worth backporting]

7 years agoCLEANUP: log: Rename Alert/Warning in ha_alert/ha_warning
Christopher Faulet [Fri, 24 Nov 2017 15:50:31 +0000 (16:50 +0100)] 
CLEANUP: log: Rename Alert/Warning in ha_alert/ha_warning

7 years agoCLEANUP: debug: Use DPRINTF instead of fprintf into #ifdef DEBUG_FULL/#endif
Christopher Faulet [Fri, 24 Nov 2017 15:06:18 +0000 (16:06 +0100)] 
CLEANUP: debug: Use DPRINTF instead of fprintf into #ifdef DEBUG_FULL/#endif

7 years agoMEDIUM: listener: Bind listeners on a thread subset if specified
Christopher Faulet [Fri, 24 Nov 2017 09:08:09 +0000 (10:08 +0100)] 
MEDIUM: listener: Bind listeners on a thread subset if specified

If a "process" option with a thread set is used on the bind line, we use the
corresponding bitmask when the listener's FD is created.

7 years agoMINOR: config: Add threads support for "process" option on "bind" lines
Christopher Faulet [Thu, 23 Nov 2017 21:44:11 +0000 (22:44 +0100)] 
MINOR: config: Add threads support for "process" option on "bind" lines

It is now possible on a "bind" line (or a "stats socket" line) to specify the
thread set allowed to process listener's connections. For instance:

    # HTTPS connections will be processed by all threads but the first and HTTP
    # connection will be processed on the first thread.
    bind *:80 process 1/1
    bind *:443 ssl crt mycert.pem process 1/2-

7 years agoMINOR: config: Add the threads support in cpu-map directive
Christopher Faulet [Wed, 22 Nov 2017 15:50:41 +0000 (16:50 +0100)] 
MINOR: config: Add the threads support in cpu-map directive

Now, it is possible to bind CPU at the thread level instead of the process level
by defining a thread set in "cpu-map" directives. Thus, its format is now:

  cpu-map [auto:]<process-set>[/<thread-set>] <cpu-set>...

where <process-set> and <thread-set> must follow the format:

  all | odd | even | number[-[number]]

Having a process range and a thread range in same time with the "auto:" prefix
is not supported. Only one range is supported, the other one must be a fixed
number. But it is allowed when there is no "auto:" prefix.

Because it is possible to define a mapping for a process and another for a
thread on this process, threads will be bound on the intersection of their
mapping and the one of the process on which they are attached. If the
intersection is null, no specific binding will be set for the threads.

7 years agoMINOR:: config: Remove thread-map directive
Christopher Faulet [Wed, 22 Nov 2017 15:52:28 +0000 (16:52 +0100)] 
MINOR:: config: Remove thread-map directive

It was a temporary directive used for development purpose. Now, CPU mapping for
at the thread level should be done using the cpu-map directive. This feature
will be added in a next commit.

7 years agoMINOR: config: Support partial ranges in cpu-map directive
Christopher Faulet [Wed, 22 Nov 2017 15:38:49 +0000 (16:38 +0100)] 
MINOR: config: Support partial ranges in cpu-map directive

Now, processa and CPU ranges can be partially defined. The higher bound can be
omitted. In such case, it is replaced by the corresponding maximum value, 32 or
64 depending on the machine's word size.

By extension, It is also true for the "bind-process" directive and "process"
parameter on a "bind" or a "stats socket" line.