]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
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.

7 years agoMINOR: config: Add auto-increment feature for cpu-map
Christopher Faulet [Wed, 22 Nov 2017 14:01:51 +0000 (15:01 +0100)] 
MINOR: config: Add auto-increment feature for cpu-map

The prefix "auto:" can be added before the process set to let HAProxy
automatically bind a process to a CPU by incrementing process and CPU sets. To
be valid, both sets must have the same size. No matter the declaration order of
the CPU sets, it will be bound from the lower to the higher bound.

  Examples:
      # all these lines bind the process 1 to the cpu 0, the process 2 to cpu 1
      #  and so on.
      cpu-map auto:1-4   0-3
      cpu-map auto:1-4   0-1 2-3
      cpu-map auto:1-4   3 2 1 0

      # bind each process to exaclty one CPU using all/odd/even keyword
      cpu-map auto:all   0-63
      cpu-map auto:even  0-31
      cpu-map auto:odd   32-63

      # invalid cpu-map because process and CPU sets have different sizes.
      cpu-map auto:1-4   0    # invalid
      cpu-map auto:1     0-3  # invalid

7 years agoMINOR: standard: Add my_ffsl function to get the position of the bit set to one
Christopher Faulet [Wed, 22 Nov 2017 14:00:13 +0000 (15:00 +0100)] 
MINOR: standard: Add my_ffsl function to get the position of the bit set to one

7 years agoMINOR: config: Export parse_process_number and use it wherever it's applicable
Christopher Faulet [Wed, 22 Nov 2017 11:06:43 +0000 (12:06 +0100)] 
MINOR: config: Export parse_process_number and use it wherever it's applicable

This function is used when "bind-process" directive is parsed and when "process"
parameter on a "bind" or a "stats socket" line is parsed.

7 years agoMINOR: config: Slightly change how parse_process_number works
Christopher Faulet [Wed, 22 Nov 2017 10:21:58 +0000 (11:21 +0100)] 
MINOR: config: Slightly change how parse_process_number works

Now, this function returns a status code to indicate a success (0) or a failure
(1) and the error message in set in <err> parameter. And the result of the parsing
is set in <proc> parameter.

7 years agoMINOR: config: Support a range to specify processes in "cpu-map" parameter
Christopher Faulet [Wed, 22 Nov 2017 09:24:40 +0000 (10:24 +0100)] 
MINOR: config: Support a range to specify processes in "cpu-map" parameter

Now, you can define processes concerned by a cpu-map line using a range. For
instance, the following line binds the first 32 processes on CPUs 0 to 3:

  cpu-map 1-32 0-3

7 years agoBUG/MINOR: listener: Allow multiple "process" options on "bind" lines
Christopher Faulet [Thu, 23 Nov 2017 21:23:08 +0000 (22:23 +0100)] 
BUG/MINOR: listener: Allow multiple "process" options on "bind" lines

The documentation specifies that you can have several "process" options to
define several ranges on "bind" lines (or "stats socket" lines). It is uncommon,
but it should be possible. So the bind_proc bitmask in bind_conf structure must
not be overwritten at each new "process" option parsed.

This bug also exists in 1.7, 1.6 and 1.5. So it may be backported. But no one
seems to have noticed it, so it was probably never hitted.

7 years agoMINOR: cache: move the refcount decrease in the applet release
William Lallemand [Fri, 24 Nov 2017 13:33:55 +0000 (14:33 +0100)] 
MINOR: cache: move the refcount decrease in the applet release

Move the refcount decrease of the cache in the release callback of the
applet. We don't need to decrease it in the applet code.

7 years agoBUG/MEDIUM: cache: free ressources in chn_end_analyze
William Lallemand [Fri, 24 Nov 2017 13:33:54 +0000 (14:33 +0100)] 
BUG/MEDIUM: cache: free ressources in chn_end_analyze

Upon an aborted HTTP connection, or an error, the filter cache does not
decrement the refcount and does not free the allocated ressources.

7 years agoBUG/MEDIUM: stream: always release the stream-interface on abort
Willy Tarreau [Fri, 24 Nov 2017 14:01:10 +0000 (15:01 +0100)] 
BUG/MEDIUM: stream: always release the stream-interface on abort

The cache exhibited a but in process_stream() where upon abort it is
possible to switch the stream-int's state to SI_ST_CLO without calling
si_release_endpoint(), resulting in a possibly missing ->release() for
the applet.

It should affect all other applets as well (eg: lua, spoe, peers) and
should carefully be backported to stable branches after some observation
period.

7 years agoMINOR: ssl: Handle early data with BoringSSL
Emmanuel Hocdet [Thu, 23 Nov 2017 11:40:07 +0000 (12:40 +0100)] 
MINOR: ssl: Handle early data with BoringSSL

BoringSSL early data differ from OpenSSL 1.1.1 implementation. When early
handshake is done, SSL_in_early_data report if SSL_read will be done on early
data. CO_FL_EARLY_SSL_HS and CO_FL_EARLY_DATA can be adjust accordingly.

7 years agoMEDIUM: config: ensure that tune.bufsize is at least 16384 when using HTTP/2
Willy Tarreau [Fri, 24 Nov 2017 10:28:00 +0000 (11:28 +0100)] 
MEDIUM: config: ensure that tune.bufsize is at least 16384 when using HTTP/2

HTTP/2 mandates the support of 16384 bytes frames by default, so we need
a large enough buffer to process them. Till now if tune.bufsize was too
small, H2 connections were simply rejected during their establishment,
making it quite hard to troubleshoot the issue.

Now we detect when HTTP/2 is enabled on an HTTP frontend and emit an
error if tune.bufsize is not large enough, with the appropriate
recommendation.

7 years agoMINOR: h2: make use of client-fin timeout after GOAWAY
Willy Tarreau [Fri, 24 Nov 2017 09:16:00 +0000 (10:16 +0100)] 
MINOR: h2: make use of client-fin timeout after GOAWAY

At the moment, the "client" timeout is used on an HTTP/2 connection once
it's idle with no active stream. With this patch, this timeout is replaced
by client-fin once a GOAWAY frame is sent. This closely matches what is
done on HTTP/1 since the principle is the same, as it indicates a willing
ness to quickly close a connection on which we don't expect to see anything
anymore.

7 years agoMEDIUM: h2: don't gracefully close the connection anymore on Connection: close
Willy Tarreau [Fri, 24 Nov 2017 07:17:28 +0000 (08:17 +0100)] 
MEDIUM: h2: don't gracefully close the connection anymore on Connection: close

As reported by Lukas, it causes more harm than good, for example on
prompt for authentication. Now we have an "http-request reject" rule
to use instead of "http-request deny" if we absolutely want to close
the connection.

7 years agoMINOR: h2: send RST_STREAM before GOAWAY on reject
Willy Tarreau [Fri, 24 Nov 2017 07:00:30 +0000 (08:00 +0100)] 
MINOR: h2: send RST_STREAM before GOAWAY on reject

Apparently the h2c client has trouble reading the RST_STREAM frame after
a GOAWAY was sent, so it's likely that other clients may face the same
difficulty. Curl and Firefox don't care about this ordering, so let's
send it first.

7 years agoMINOR: http: implement the "http-request reject" rule
Willy Tarreau [Fri, 24 Nov 2017 06:52:01 +0000 (07:52 +0100)] 
MINOR: http: implement the "http-request reject" rule

This one acts similarly to its tcp-request counterpart. It immediately
closes the request without emitting any response. It can be suitable in
certain DoS conditions, as well as to close an HTTP/2 connection.

7 years agoMEDIUM: cache: store sha1 for hashing the cache key
William Lallemand [Thu, 23 Nov 2017 18:43:17 +0000 (19:43 +0100)] 
MEDIUM: cache: store sha1 for hashing the cache key

The cache was relying on the txn->uri for creating its key, which was a
big problem when there was no log activated.

This patch does a sha1 of the host + uri, and stores it in the txn.
When a object is stored, the eb32node uses the first 32 bits of the hash
as a key, and the whole hash is stored in the cache entry.

During a lookup, the truncated hash is used, and when it matches an
entry we check the real sha1.

7 years agoMINOR: mux: Make sure every string is woken up after the handshake.
Olivier Houchard [Thu, 23 Nov 2017 17:25:47 +0000 (18:25 +0100)] 
MINOR: mux: Make sure every string is woken up after the handshake.

In case any stream was waiting for the handshake after receiving early data,
we have to wake all of them. Do so by making the mux responsible for
removing the CO_FL_EARLY_DATA flag after all of them are woken up, instead
of doing it in si_cs_wake_cb(), which would then only work for the first one.
This makes wait_for_handshake work with HTTP/2.