]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoMEDIUM: pools: implement a thread-local cache for pool entries
Willy Tarreau [Tue, 16 Oct 2018 08:28:54 +0000 (10:28 +0200)] 
MEDIUM: pools: implement a thread-local cache for pool entries

Each thread now keeps the last ~512 kB of freed objects into a local
cache. There are some heuristics involved so that a specific pool cannot
use more than 1/8 of the total cache in number of objects. Tests have
shown that 512 kB is an optimal size on a 24-thread test running on a
dual-socket machine, resulting in an overall 7.5% performance increase
and a cache miss ratio reducing from 19.2 to 17.7%. Anyway it seems
pointless to keep more than an L2 cache, which probably explains why
sizes between 256 and 512 kB are optimal.

Cached objects appear in two lists, one per pool and one LRU to help
with fair eviction. Currently there is no way to check each thread's
cache state nor to flush it. This cache cannot be disabled and is
enabled as soon as the lockless pools are enabled (i.e.: threads are
enabled, no pool debugging is in use and the CPU supports a double word
CAS).

6 years agoMINOR: pools: split pool_free() in the lockfree variant
Willy Tarreau [Tue, 16 Oct 2018 06:55:15 +0000 (08:55 +0200)] 
MINOR: pools: split pool_free() in the lockfree variant

This separates the validity tests from the code committing the object
to the pool, in order to ease insertion of the thread-local cache.

6 years agoMINOR: pools: allocate most memory pools from an array
Willy Tarreau [Tue, 16 Oct 2018 05:58:39 +0000 (07:58 +0200)] 
MINOR: pools: allocate most memory pools from an array

For caching it will be convenient to have indexes associated with pools,
without having to dereference the pool itself. One solution could consist
in replacing all pool pointers with integers but this would limit the
number of allocatable pools. Instead here we allocate the 32 first pools
from a pre-allocated array whose base address is known so that it's trivial
to convert a pool to an index in this array. Pools that cannot fit there
will be allocated normally.

6 years agoDOC: Fix a few typos
Bertrand Jacquin [Sat, 13 Oct 2018 15:06:18 +0000 (16:06 +0100)] 
DOC: Fix a few typos

these are mostly spelling mistakes, some of them might be candidate for
backporting as well.

6 years agoOPTIM: tasks: group all tree roots per cache line
Willy Tarreau [Mon, 15 Oct 2018 14:12:48 +0000 (16:12 +0200)] 
OPTIM: tasks: group all tree roots per cache line

Currently we have per-thread arrays of trees and counts, but these
ones unfortunately share cache lines and are accessed very often. This
patch moves the task-specific stuff into a structure taking a multiple
of a cache line, and has one such per thread. Just doing this has
reduced the cache miss ratio from 19.2% to 18.7% and increased the
12-thread test performance by 3%.

It starts to become visible that we really need a process-wide per-thread
storage area that would cover more than just these parts of the tasks.
The code was arranged so that it's easy to move the pieces elsewhere if
needed.

6 years agoMAJOR: tasks: create per-thread wait queues
Willy Tarreau [Mon, 15 Oct 2018 12:52:21 +0000 (14:52 +0200)] 
MAJOR: tasks: create per-thread wait queues

Now we still have a main contention point with the timers in the main
wait queue, but the vast majority of the tasks are pinned to a single
thread. This patch creates a per-thread wait queue and queues a task
to the local wait queue without any locking if the task is bound to a
single thread (the current one) otherwise to the shared queue using
locking. This significantly reduces contention on the wait queue. A
test with 12 threads showed 11 ms spent in the WQ lock compared to
4.7 seconds in the same test without this change. The cache miss ratio
decreased from 19.7% to 19.2% on the 12-thread test, and its performance
increased by 1.5%.

Another indirect benefit is that the average queue size is divided
by the number of threads, which roughly removes log(nbthreads) levels
in the tree and further speeds up lookups.

6 years agoMEDIUM: fd/threads: only grab the fd's lock if the FD has more than one thread
Willy Tarreau [Mon, 15 Oct 2018 07:44:46 +0000 (09:44 +0200)] 
MEDIUM: fd/threads: only grab the fd's lock if the FD has more than one thread

The vast majority of FDs are only seen by one thread. Currently the lock
on FDs costs a lot because it's touched often, though there should be very
little contention. This patch ensures that the lock is only grabbed if the
FD is shared by more than one thread, since otherwise the situation is safe.
Doing so resulted in a 15% performance boost on a 12-threads test.

6 years agoMINOR: config: use atleast2() instead of my_popcountl() where relevant
Willy Tarreau [Mon, 15 Oct 2018 07:37:03 +0000 (09:37 +0200)] 
MINOR: config: use atleast2() instead of my_popcountl() where relevant

Quite often we used my_popcountl() just to check for > 1 bit set. Now
we have an easier solution, let's use it.

6 years agoMINOR: tools: add a new function atleast2() to test masks for more than 1 bit
Willy Tarreau [Mon, 15 Oct 2018 07:33:41 +0000 (09:33 +0200)] 
MINOR: tools: add a new function atleast2() to test masks for more than 1 bit

For threads it's common to have to check if a mask contains more than
one bit set. Let's have this "atleast2()" function report this.

6 years agoBUILD: peers: check allocation error during peers_init_sync()
Willy Tarreau [Mon, 15 Oct 2018 09:18:03 +0000 (11:18 +0200)] 
BUILD: peers: check allocation error during peers_init_sync()

peers_init_sync() doesn't check task_new()'s return value and doesn't
return any result to indicate success or failure. Let's make it return
an int and check it from the caller.

This can be backported as far as 1.6.

6 years agoBUILD: stick-table: make sure not to fail on task_new() during initialization
Willy Tarreau [Mon, 15 Oct 2018 09:12:15 +0000 (11:12 +0200)] 
BUILD: stick-table: make sure not to fail on task_new() during initialization

Gcc reports a potential null-deref error in the stick-table init code.
While not critical there, it's trivial to fix. This check has been
missing since 1.4 so this fix can be backported to all supported versions.

6 years agoBUILD: ssl: fix another null-deref warning in ssl_sock_switchctx_cbk()
Willy Tarreau [Mon, 15 Oct 2018 11:20:07 +0000 (13:20 +0200)] 
BUILD: ssl: fix another null-deref warning in ssl_sock_switchctx_cbk()

This null-deref cannot happen either as there necesarily is a listener
where this function is called. Let's use __objt_listener() to address
this.

This may be backported to 1.8.

6 years agoBUILD: ssl: fix null-deref warning in ssl_fc_cipherlist_str sample fetch
Willy Tarreau [Mon, 15 Oct 2018 09:01:59 +0000 (11:01 +0200)] 
BUILD: ssl: fix null-deref warning in ssl_fc_cipherlist_str sample fetch

Gcc 6.4 detects a potential null-deref warning in smp_fetch_ssl_fc_cl_str().
This one is not real since already addressed a few lines above. Let's use
__objt_conn() instead of objt_conn() to avoid the extra test that confuses
it.

This could be backported to 1.8.

6 years agoBUILD: lua: silence some compiler warnings about potential null derefs
Willy Tarreau [Mon, 15 Oct 2018 09:55:18 +0000 (11:55 +0200)] 
BUILD: lua: silence some compiler warnings about potential null derefs

These ones are on error paths that are properly handled by luaL_error()
which does a longjmp() but the compiler cannot know it. By adding an
__unreachable() statement in WILL_LJMP(), there is no ambiguity anymore.

This may be backported to 1.8 but the previous patch (BUILD: compiler:
add a new statement "__unreachable()") is needed for this.

6 years agoBUILD: compiler: add a new statement "__unreachable()"
Willy Tarreau [Mon, 15 Oct 2018 09:53:34 +0000 (11:53 +0200)] 
BUILD: compiler: add a new statement "__unreachable()"

This statement is used as a hint for the compiler so that it knows that
the location where it's placed cannot be reached. It will mostly be used
after longjmp() or equivalent statements that deal with error processing
and that the compiler doesn't know will not return on certain conditions,
so that it doesn't complain about null dereferences on error paths.

6 years agoBUG/MEDIUM: stream: don't crash on out-of-memory
Willy Tarreau [Mon, 15 Oct 2018 09:08:55 +0000 (11:08 +0200)] 
BUG/MEDIUM: stream: don't crash on out-of-memory

In case pool_alloc() fails in stream_new(), we try to detach the stream
from the list before it has been added, dereferencing a NULL. In order
to fix it, simply move the LIST_DEL call upwards.

This must be backported to 1.8.

6 years agoBUG/MEDIUM: mworker: don't poll on LI_O_INHERITED listeners
William Lallemand [Fri, 12 Oct 2018 08:39:54 +0000 (10:39 +0200)] 
BUG/MEDIUM: mworker: don't poll on LI_O_INHERITED listeners

The listeners with the LI_O_INHERITED flag were deleted but not unbound
which is a problem since we have a polling in the master.

This patch unbind every listeners which are not require for the master,
but does not close the FD of those that have a LI_O_INHERITED flag.

6 years agoMINOR: h2: add a new flag to quickly distinguish front vs back connection
Willy Tarreau [Wed, 3 Oct 2018 11:56:38 +0000 (13:56 +0200)] 
MINOR: h2: add a new flag to quickly distinguish front vs back connection

We will need to know if a mux was created for a front or a back
connection and once it's established it's much harder, so let's
introduce H2_CF_IS_BACK for this.

6 years agoMINOR: h2: split h2c_stream_new() into h2s_new() + h2c_frt_stream_new()
Willy Tarreau [Wed, 3 Oct 2018 16:53:55 +0000 (18:53 +0200)] 
MINOR: h2: split h2c_stream_new() into h2s_new() + h2c_frt_stream_new()

For backend connections we'll have to initialize streams but not allocate
conn_streams since they'll already be there. Thus this patch splits the
h2c_stream_new() function into one dedicated to allocation of a new stream
and another one supposed to attach this stream to an existing frontend
connection.

6 years agoMINOR: h2: retrieve the front proxy from the caller instead of the session
Willy Tarreau [Wed, 3 Oct 2018 08:33:02 +0000 (10:33 +0200)] 
MINOR: h2: retrieve the front proxy from the caller instead of the session

Till now in order to figure the timeouts, we used to retrieve the proxy
from the session's owner, but the new API provides it so it's better to
simply take it from the caller at init time. We take this opportunity to
store the pointer to the proxy into the h2 connection so that we can
reuse it later when needed.

6 years agoMINOR: h2: unify the mux init function
Willy Tarreau [Wed, 3 Oct 2018 11:52:41 +0000 (13:52 +0200)] 
MINOR: h2: unify the mux init function

The init function was split into the mux init and the front init, but it
appears that most of the code will be common between the two sides when
implementing the backend init. Thus let's simply make this a unique
h2_init() function.

6 years agoMINOR: h2: don't try to send data before preface
Willy Tarreau [Mon, 8 Oct 2018 07:43:03 +0000 (09:43 +0200)] 
MINOR: h2: don't try to send data before preface

h2_snd_buf() must not accept to send data if the preface was not yet
received nor sent. At the moment it doesn't happen but it can with
server-side H2.

6 years agoCLEANUP: h2: rename h2c_snd_settings() to h2c_send_settings()
Willy Tarreau [Mon, 8 Oct 2018 05:13:08 +0000 (07:13 +0200)] 
CLEANUP: h2: rename h2c_snd_settings() to h2c_send_settings()

It's the only function not called h2c_send_<something>() and it took me
a while to find it.

6 years agoMEDIUM: h2: stop relying on H2_SS_IDLE / H2_SS_CLOSED
Willy Tarreau [Fri, 5 Oct 2018 08:16:37 +0000 (10:16 +0200)] 
MEDIUM: h2: stop relying on H2_SS_IDLE / H2_SS_CLOSED

At a few places we check these states to detect if a stream has valid
data/errcode or is one of the two dummy streams (idle or closed). It
will become problematic for outgoing streams as it will not be possible
to report errors for example since the stream will switch from IDLE
state only after sending a HEADERS frame.

There is a safer solution consisting in checking the stream ID, which
may only be zero in the dummy streams. This patch changes the test to
only rely on the stream ID.

6 years agoMINOR: chunk: add chunk_cpy() and chunk_cat()
Willy Tarreau [Mon, 8 Oct 2018 05:34:25 +0000 (07:34 +0200)] 
MINOR: chunk: add chunk_cpy() and chunk_cat()

Sometimes we need to concatenate constant chunks to existing ones, but
no function currently exists to do this easily, hence these two new ones.

6 years agoMINOR: log: make sess_log() support sess=NULL
Willy Tarreau [Fri, 5 Oct 2018 08:22:27 +0000 (10:22 +0200)] 
MINOR: log: make sess_log() support sess=NULL

At many places in muxes we'll have to add tests to check if the
connection is front or back before deciding to log. Instead let's
centralize this test in sess_log() to simply do nothing when sess=NULL.

6 years agoMINOR: h1: Add the flag H1_MF_NO_PHDR to not add pseudo-headers during parsing
Christopher Faulet [Mon, 8 Oct 2018 13:50:15 +0000 (15:50 +0200)] 
MINOR: h1: Add the flag H1_MF_NO_PHDR to not add pseudo-headers during parsing

Some pseudo-headers are added during the headers parsing, mainly for the mux
H2. With this flag, it is possible to not add them. This avoid some boring
filtering in the mux H1.

6 years agoMINOR: h1: Change the union h1_sl to use indirect strings to store infos
Christopher Faulet [Mon, 8 Oct 2018 13:34:02 +0000 (15:34 +0200)] 
MINOR: h1: Change the union h1_sl to use indirect strings to store infos

Instead of using offsets relating to the parsed buffer to store start line
infos, we now use indirect strings. So now, these infos remain valid only if the
origin buffer remains untouched. But it's not a real problem because this union
is used during the parsing and never stored to a later use.

6 years agoMINOR: conn-stream: Add CL_FL_NOT_FIRST flag
Christopher Faulet [Mon, 1 Oct 2018 10:10:13 +0000 (12:10 +0200)] 
MINOR: conn-stream: Add CL_FL_NOT_FIRST flag

This flags will be used by multiplexers to warn a conn-stream (and, by
transitivity, a stream) it is not the first one created by the mux. It will help
mux H1 to handle keep-alive connections.

6 years agoMINOR: h1: Add EOH marker during headers parsing
Christopher Faulet [Tue, 25 Sep 2018 11:59:46 +0000 (13:59 +0200)] 
MINOR: h1: Add EOH marker during headers parsing

When headers parsing ends, a pseudo header with an empty name and an empty value
is added to the array of parsed headers to mark its end. It is convenient to
loop on this array, but not really useful if we want remove the last header or
add a new one, because we don't really know where is the last CRLF (the empty
line ending the headers block). So now, instead the name of this pseudo header
points on this last CRLF. Its length is still 0 and its value is still empty, so
loops on the array remains unchanged.

6 years agoMINOR: http: Use same flag for httpclose and forceclose options
Christopher Faulet [Fri, 21 Sep 2018 14:26:19 +0000 (16:26 +0200)] 
MINOR: http: Use same flag for httpclose and forceclose options

Since keep-alive mode is the default mode, the passive close has disappeared,
and in the code, httpclose and forceclose options are handled the same way:
connections with the client and the server are closed as soon as the request and
the response are received and missing "Connection: close" header is added in
each direction.

So to make things clearer, forceclose is now an alias for httpclose. And
httpclose is explicitly an active close. So the old passive close does not exist
anymore. Internally, the flag PR_O_HTTP_PCL has been removed and PR_O_HTTP_FCL
has been replaced by PR_O_HTTP_CLO. In HTTP analyzers, the checks done to find
the right mode to use, depending on proxies options and "Connection: " header
value, have been simplified.

This should only be a cleanup and no changes are expected.

6 years agoMEDIUM: http: Ignore http-tunnel option on backend
Christopher Faulet [Fri, 21 Sep 2018 08:42:19 +0000 (10:42 +0200)] 
MEDIUM: http: Ignore http-tunnel option on backend

This option is frontends specific, so there is no reason to support it on
backends. So now, it is ignored if it is set on a backend and a warning is
emitted during the startup. The change is quite trivial, but the commit is
tagged as MEDIUM because it is a small breakage with previous versions and
configurations using this options could emit a warning now.

6 years agoMEDIUM: http: Ignore http-pretend-keepalive option on frontend
Christopher Faulet [Fri, 21 Sep 2018 08:25:19 +0000 (10:25 +0200)] 
MEDIUM: http: Ignore http-pretend-keepalive option on frontend

This option is backends specific, so there is no reason to support it on
frontends. So now, it is ignored if it is set on a frontend and a warning is
emitted during the startup. The change is quite trivial, but the commit is
tagged as MEDIUM because it is a small breakage with previous versions and
configurations using this options could emit a warning now.

6 years agoMINOR: http: Export some functions and do cleanup to prepare HTTP refactoring
Christopher Faulet [Wed, 3 Oct 2018 13:17:28 +0000 (15:17 +0200)] 
MINOR: http: Export some functions and do cleanup to prepare HTTP refactoring

To ease the refactoring, the function "http_header_add_tail" have been
remove. Now, "http_header_add_tail2" is always used. And the function
"capture_headers" have been renamed into "http_capture_headers". Finally, some
functions have been exported.

6 years agoMINOR: stats: Add missing include
Christopher Faulet [Wed, 3 Oct 2018 14:11:20 +0000 (16:11 +0200)] 
MINOR: stats: Add missing include

"proto/stats.h" must include "types/stats.h".

6 years agoMINOR: http: Move comment about some HTTP macros in the right header file
Christopher Faulet [Wed, 3 Oct 2018 12:15:28 +0000 (14:15 +0200)] 
MINOR: http: Move comment about some HTTP macros in the right header file

HTTP_FLG_* and HTTP_IS_* were moved from "proto/proto_http.h" to "common/http.h"
but the associated comment was forgotten during the move.

This is 1.9-specific and should not be backported.

6 years agoBUG/MEDIUM: stream: Make sure to unsubscribe before si_release_endpoint.
Olivier Houchard [Thu, 11 Oct 2018 15:09:14 +0000 (17:09 +0200)] 
BUG/MEDIUM: stream: Make sure to unsubscribe before si_release_endpoint.

Make sure we unsubscribe from events before si_release_endpoint destroys
the conn_stream, or it will be never called. To do so, move the call to
unsubscribe to si_release_endpoint() directly.

This is 1.9-specific and shouldn't be backported.

6 years agoBUG/MEDIUM: mworker: segfault receiving SIGUSR1 followed by SIGTERM.
Emeric Brun [Thu, 11 Oct 2018 13:27:07 +0000 (15:27 +0200)] 
BUG/MEDIUM: mworker: segfault receiving SIGUSR1 followed by SIGTERM.

This bug appeared only if nbthread > 1. Handling the pipe with the
master, multiple threads of the same worker could process the deinit().

In addition, deinit() was called while some other threads were still
performing some tasks.

This patch assign the handler of the pipe with master to only the first
thread and removes the call to deinit() before exiting with an error.

This patch should be backported in v1.8.

6 years agoBUG/MEDIUM: h2: Make sure we're not in the send list on flow control.
Olivier Houchard [Wed, 10 Oct 2018 16:51:00 +0000 (18:51 +0200)] 
BUG/MEDIUM: h2: Make sure we're not in the send list on flow control.

If we can't send data for a stream because of its flow control, make sure
not to put it in the send_list, until the flow control lets it send again.

This is specific to 1.9, and should not be backported.

6 years agoMEDIUM: connections: Change struct wait_list to wait_event.
Olivier Houchard [Wed, 10 Oct 2018 16:25:41 +0000 (18:25 +0200)] 
MEDIUM: connections: Change struct wait_list to wait_event.

When subscribing, we don't need to provide a list element, only the h2 mux
needs it. So instead, Add a list element to struct h2s, and use it when a
list is needed.
This forces us to use the unsubscribe method, since we can't just unsubscribe
by using LIST_DEL anymore.
This patch is larger than it should be because it includes some renaming.

6 years agoMINOR: connections: Introduce an unsubscribe method.
Olivier Houchard [Fri, 28 Sep 2018 15:57:58 +0000 (17:57 +0200)] 
MINOR: connections: Introduce an unsubscribe method.

As we don't know how subscriptions are handled, we can't just assume we can
use LIST_DEL() to unsubscribe, so introduce a new method to mux and connections
to do so.

6 years agoBUG/MINOR: checks: queues null-deref
mildis [Tue, 2 Oct 2018 14:46:34 +0000 (16:46 +0200)] 
BUG/MINOR: checks: queues null-deref

queues can be null if calloc() failed.
Bypass free* calls when calloc did fail.

6 years agoBUG/MINOR: h2: null-deref
mildis [Tue, 2 Oct 2018 14:44:18 +0000 (16:44 +0200)] 
BUG/MINOR: h2: null-deref

h2c can be null if pool_alloc() failed.
Bypass tasklet_free and pool_free if pool_alloc did fail.

6 years agoOPTIM: tools: optimize my_ffsl() for x86_64
Willy Tarreau [Wed, 10 Oct 2018 17:05:56 +0000 (19:05 +0200)] 
OPTIM: tools: optimize my_ffsl() for x86_64

This call is now used quite a bit in the fd cache, to decide which cache
to add/remove the fd to/from, when waking up a task for a single thread
in __task_wakeup(), in fd_cant_recv() and in fd_process_cached_events(),
and we can replace it with a single instruction, removing ~30 instructions
and ~80 bytes from the inner loop of some of these functions.

In addition the test for zero value was replaced with a comment saying
that it is illegal and leads to an undefined behaviour. The code does
not make use of this useless case today.

6 years agoBUG/MINOR: threads: move declaration of capabilities to config.h
Willy Tarreau [Wed, 10 Oct 2018 16:29:23 +0000 (18:29 +0200)] 
BUG/MINOR: threads: move declaration of capabilities to config.h

In commit f161d0f51 ("BUG/MINOR: pools/threads: don't ignore DEBUG_UAF
on double-word CAS capable archs") I moved some defines and accidently
messed up with lockfree pools. The problem is that the HA_HAVE_CAS_DW
macro is not defined anymore where the CONFIG_HAP_LOCKLESS_POOLS macro
is set, so this fix implicitly disabled lockfree pools.

This patch fixes this by moving the capabilities definition to config.h
(probably that we'd benefit from having an "arch.h" file to declare the
capabilities offered by the architecture). In a test on a 12-core machine,
we used to measure 19s spent in the pool lock for 1M requests without
this patch, and 0 with it so that's definitely a net saving.

No backport is required, this is only for 1.9.

6 years agoBUG/MEDIUM: Cur/CumSslConns counters not threadsafe.
Emeric Brun [Wed, 10 Oct 2018 12:51:02 +0000 (14:51 +0200)] 
BUG/MEDIUM: Cur/CumSslConns counters not threadsafe.

CurSslConns inc/dec operations are not threadsafe. The unsigned CurSslConns
counter can wrap to a negative value. So we could notice connection rejects
because of MaxSslConns limit artificially exceeded.

CumSslConns inc operation are also not threadsafe so we could miss
some connections and show inconsistenties values compared to CumConns.

This fix should be backported to v1.8.

6 years agoMEDIUM: task: perform a single tree lookup per run queue batch
Willy Tarreau [Wed, 10 Oct 2018 14:39:22 +0000 (16:39 +0200)] 
MEDIUM: task: perform a single tree lookup per run queue batch

The run queue is designed to perform a single tree lookup and to
use multiple passes to eb32sc_next(). The scheduler rework took a
conservative approach first but this is not needed anymore and it
increases the processing cost of process_runnable_tasks() and even
the time during which the RQ lock is held if the global queue is
heavily loaded. Let's simply move the initial lookup to the entry
of the loop like the previous scheduler used to do. This has reduced
by a factor of 5.5 the number of calls to eb32sc_lookup_get() there.

6 years agoCLEANUP: stick-tables: Remove unneeded double (()) around conditional clause
Dirkjan Bussink [Fri, 14 Sep 2018 12:31:22 +0000 (14:31 +0200)] 
CLEANUP: stick-tables: Remove unneeded double (()) around conditional clause

In the past this conditional had multiple conditionals which is why the
additional parentheses were needed. The conditional was simplified but
the duplicate parentheses were not cleaned up.

6 years agoCLEANUP: h1: Fix debug warnings for h1 headers
Dirkjan Bussink [Fri, 14 Sep 2018 12:30:25 +0000 (14:30 +0200)] 
CLEANUP: h1: Fix debug warnings for h1 headers

The wrong method was used to debug the h1m state here. This fixes both
the signature of the h1m method and also fixes the invocation to be
correct.

6 years agoCLEANUP: haproxy: Remove unused variable
Dirkjan Bussink [Fri, 14 Sep 2018 12:29:16 +0000 (14:29 +0200)] 
CLEANUP: haproxy: Remove unused variable

Looking at the code, this variable is no longer used and referenced
nowhere. That means it can be safely removed.

6 years agoMEDIUM: ssl: add support for ciphersuites option for TLSv1.3
Dirkjan Bussink [Fri, 14 Sep 2018 09:14:21 +0000 (11:14 +0200)] 
MEDIUM: ssl: add support for ciphersuites option for TLSv1.3

OpenSSL released support for TLSv1.3. It also added a separate function
SSL_CTX_set_ciphersuites that is used to set the ciphers used in the
TLS 1.3 handshake. This change adds support for that new configuration
option by adding a ciphersuites configuration variable that works
essentially the same as the existing ciphers setting.

Note that it should likely be backported to 1.8 in order to ease usage
of the now released openssl-1.1.1.

6 years agoBUG/MEDIUM: buffers: Make sure we don't wrap in ci_insert_line2/b_rep_blk.
Olivier Houchard [Wed, 26 Sep 2018 13:09:58 +0000 (15:09 +0200)] 
BUG/MEDIUM: buffers: Make sure we don't wrap in ci_insert_line2/b_rep_blk.

In ci_insert_line2() and b_rep_blk(), we can't afford to wrap, so don't use
b_tail() to check if we do, use __b_tail() instead.

This should be backported to previous versions.

6 years agoMINOR: ssl: generate-certificates for BoringSSL
Emmanuel Hocdet [Mon, 1 Oct 2018 16:45:19 +0000 (18:45 +0200)] 
MINOR: ssl: generate-certificates for BoringSSL

6 years agoMINOR: ssl: cleanup old openssl API call
Emmanuel Hocdet [Mon, 1 Oct 2018 16:41:36 +0000 (18:41 +0200)] 
MINOR: ssl: cleanup old openssl API call

For generate-certificates, X509V3_EXT_conf is used but it's an old API
call: X509V3_EXT_nconf must be preferred. Openssl compatibility is ok
because it's inside #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME, introduce 5
years after X509V3_EXT_nconf.

6 years agoREGTEST/MINOR: compatibility: use unix@ instead of abns@ sockets
PiBa-NL [Wed, 3 Oct 2018 21:54:49 +0000 (23:54 +0200)] 
REGTEST/MINOR: compatibility: use unix@ instead of abns@ sockets

Changes the /reg-tests/connection/b00000.vtc test to use unix@ instead of abns@ sockets.
This to allow the test to complete on other operating systems like FreeBSD that do not have 'namespaces'.

6 years agoBUG/MEDIUM: h2: make h2_stream_new() return an error on memory allocation failure
Willy Tarreau [Wed, 3 Oct 2018 16:27:52 +0000 (18:27 +0200)] 
BUG/MEDIUM: h2: make h2_stream_new() return an error on memory allocation failure

Commit 8ae735da0 ("MEDIUM: mux_h2: Revamp the send path when blocking.")
added a tasklet allocation in h2_stream_new(), however the error exit path
fails to reset h2s in case the tasklet cannot be allocated, resulting in
the h2s pointer to be returned as valid to the caller. Let's readjust the
exit path to always return NULL on error and to always log as well (since
there is no reason for not logging on such important errors).

No backport is needed, this is strictly 1.9-dev.

6 years agoBUG/MEDIUM: h2: check that the connection is still valid at the end of init()
Willy Tarreau [Wed, 3 Oct 2018 12:22:21 +0000 (14:22 +0200)] 
BUG/MEDIUM: h2: check that the connection is still valid at the end of init()

Since commit 7505f94f9 ("MEDIUM: h2: Don't use a wake() method anymore."),
the H2 mux's init() calls h2_process(). But this last one may detect an
early error and call h2_release(), destroying the connection, and return
-1. At this point we're screwed because the caller will still dereference
the connection for various things ranging from the configuration of the
proxy protocol header to the retries. We could simply return -1 here upon
failure but that's not enough since the stream layer really needs to keep
its connection structure allocated (to clean it up in session_kill_embryonic
or for example because it holds the destination address to reconnect to
when the connection goes to the backend). Thus the correct solution here is
to only schedule a wakeup of the I/O callback so that the init succeeds,
and that the connection is only handled later.

No backport is needed, this is 1.9-specific.

6 years agoBUG/MINOR: backend: check that the mux installed properly
Willy Tarreau [Wed, 3 Oct 2018 08:20:19 +0000 (10:20 +0200)] 
BUG/MINOR: backend: check that the mux installed properly

The return value from conn_install_mux() was not checked, so if an
inconsistency happens in the code, or a memory allocation fails while
initializing the mux, we can crash while using an uninitialized mux.
In practice the code inconsistency does not really happen since we
cannot configure such a situation, except during development, but
the out of memory condition could definitely happen.

This should be backported to 1.8 (the code is a bit different there,
there are two calls to conn_install_mux()).

6 years agoBUILD: Makefile: speed up compiler options detection
Willy Tarreau [Wed, 3 Oct 2018 07:52:51 +0000 (09:52 +0200)] 
BUILD: Makefile: speed up compiler options detection

Commits b78016649 and d3a7f4035 brought the ability to detect the build
options and warnings that the compiler supports. However, they're detected
using "$(CC) -c", which is 50% slower than "$(CC) -E" for the same result,
just because it starts the assembler at the end. Given that we're starting
to check for a number of warnings, this detection alone starts to become
visible, taking a bit more than 300 ms on the build time. Let's switch to
-E instead to shrink this incompressible time by roughly 100 ms.

6 years agoBUILD: Makefile: add a "make opts" target to simply show the build options
Willy Tarreau [Wed, 3 Oct 2018 07:40:22 +0000 (09:40 +0200)] 
BUILD: Makefile: add a "make opts" target to simply show the build options

We're often missing an easy way to map input variables to output ones.
The "opts" build target will simply show the input variables and the ones
passed to the compiler and linker. This way it's easier to quickly see
what a given build script or package will use, or the detected warnings
supported by the compiler.

6 years agoCLEANUP: http: remove some leftovers from recent cleanups
Willy Tarreau [Tue, 2 Oct 2018 16:37:27 +0000 (18:37 +0200)] 
CLEANUP: http: remove some leftovers from recent cleanups

The prototypes of functions find_hdr_value_end(), extract_cookie_value()
and http_header_match2() were still in proto_http.h while some of them
don't exist anymore and the others were just moved. Let's remove them.
In addition, da.c was updated to use http_extract_cookie_value() which
is the correct one.

6 years agoREORG: http: move HTTP rules parsing to http_rules.c
Willy Tarreau [Tue, 2 Oct 2018 14:43:32 +0000 (16:43 +0200)] 
REORG: http: move HTTP rules parsing to http_rules.c

These ones are mostly called from cfgparse.c for the parsing and do
not depend on the HTTP representation. The functions's prototypes
were moved to proto/http_rules.h, making this file work exactly like
tcp_rules. Ideally we should stop calling these functions directly
from cfgparse and register keywords, but there are a few cases where
that wouldn't work (stats http-request) so it's probably not worth
trying to go this far.

6 years agoREORG: http: move the code to different files
Willy Tarreau [Tue, 2 Oct 2018 14:01:16 +0000 (16:01 +0200)] 
REORG: http: move the code to different files

The current proto_http.c file is huge and contains different processing
domains making it very difficult to work on an alternative representation.
This commit moves some parts to other files :

  - ACL registration code => http_acl.c
    This code only creates some ACL mappings and doesn't know anything
    about HTTP nor about the representation. This code could even have
    moved to acl.c but it was not worth polluting it again.

  - HTTP sample conversion => http_conv.c
    This code doesn't depend on the internal representation but definitely
    manipulates some HTTP elements, such as dates. It also has access to
    captures.

  - HTTP sample fetching => http_fetch.c
    This code does depend entirely on the internal representation but is
    totally independent on the analysers. Placing it into a different
    file will ease the transition to the new representation and the
    creation of a wrapper if required. An include file was created due
    to CHECK_HTTP_MESSAGE_FIRST() being used at various places.

  - HTTP action registration => http_act.c
    This code doesn't directly interact with the messages nor the
    transaction but it does so via some exported http functions like
    http_replace_req_line() or http_set_status() so it will be easier
    to change only this after the conversion.

  - a few very generic parts were found and moved to http.{c,h} as
    relevant.

It is worth noting that the functions moved to these new files are not
referenced anywhere outside of the files and are only called as registered
callbacks, so these files do not even require associated include files.

6 years agoBUG/MINOR: connection: avoid null pointer dereference in send-proxy-v2
Ilya Shipitsin [Fri, 14 Sep 2018 19:50:05 +0000 (00:50 +0500)] 
BUG/MINOR: connection: avoid null pointer dereference in send-proxy-v2

found by coverity.

[wt: this bug was introduced by commit 404d978 ("MINOR: add ALPN
 information to send-proxy-v2"). It might be triggered by a health
 check on a server using ppv2 or by an applet making use of such a
 server, if at all configurable].

This needs to be backported to 1.8.

6 years agoDOC: clarify force-private-cache is an option
Lukas Tribus [Mon, 1 Oct 2018 00:00:16 +0000 (02:00 +0200)] 
DOC: clarify force-private-cache is an option

"boolean" may confuse users into thinking they need to provide
additional arguments, like false or true. This is a simple option
like many others, so lets not confuse the users with internals.

Also fixes an additional typo.

Should be backported to 1.8 and 1.7.

6 years agoBUILD: Allow configuration of pcre-config path
Fabrice Fontaine [Fri, 28 Sep 2018 17:21:26 +0000 (19:21 +0200)] 
BUILD: Allow configuration of pcre-config path

Add PCRE_CONFIG and PCRE2_CONFIG variables to allow the user to
configure path of pcre-config or pcre2-config instead of using the one
in his path.
This is particulary useful when cross-compiling.

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
6 years ago[RELEASE] Released version 1.9-dev3 v1.9-dev3
Willy Tarreau [Sat, 29 Sep 2018 18:17:33 +0000 (20:17 +0200)] 
[RELEASE] Released version 1.9-dev3

Released version 1.9-dev3 with the following main changes :
    - BUG/MINOR: h1: don't consider the status for each header
    - MINOR: h1: report in the h1m struct if the HTTP version is 1.1 or above
    - MINOR: h1: parse the Connection header field
    - DOC: Fix typos in lua documentation
    - MINOR: h1: Add H1_MF_XFER_LEN flag
    - MINOR: http: add http_hdr_del() to remove a header from a list
    - MINOR: h1: add headers to the list after controls, not before
    - MEDIUM: h1: better handle transfer-encoding vs content-length
    - MEDIUM: h1: deduplicate the content-length header
    - BUG/MEDIUM: patterns: fix possible double free when reloading a pattern list
    - BUG/MEDIUM: h1: Really skip all updates when incomplete messages are parsed
    - CLEANUP/CONTRIB: hpack: remove some h1 build warnings
    - BUG/MINOR: tools: fix set_net_port() / set_host_port() on IPv4
    - BUG/MINOR: cli: make sure the "getsock" command is only called on connections
    - MINOR: stktable: provide an unchecked version of stktable_data_ptr()
    - MINOR: stream-int: make si_appctx() never fail
    - BUILD: ssl_sock: remove build warnings on potential null-derefs
    - BUILD: stats: remove build warnings on potential null-derefs
    - BUILD: stream: address null-deref build warnings at -Wextra
    - BUILD: http: address a couple of null-deref warnings at -Wextra
    - BUILD: log: silent build warnings due to unchecked __objt_{server,applet}
    - BUILD: dns: fix null-deref build warning at -Wextra
    - BUILD: checks: silence a null-deref build warning at -Wextra
    - BUILD: connection: silence a couple of null-deref build warnings at -Wextra
    - BUILD: backend: fix 3 build warnings related to null-deref at -Wextra
    - BUILD: sockpair: silence a build warning at -Wextra
    - BUILD: build with -Wextra and sort out certain warnings
    - BUG/CRITICAL: hpack: fix improper sign check on the header index value
    - BUG/MEDIUM: http: Don't parse chunked body if there is no input data
    - DOC: Update configuration doc about the maximum number of stick counters.
    - BUG/MEDIUM: process_stream: Don't use si_cs_io_cb() in process_stream().
    - MINOR: h2/stream_interface: Reintroduce te wake() method.
    - BUG/MEDIUM: h2: Wake the task instead of calling h2_recv()/h2_process().
    - BUG/MEDIUM: process_stream(): Don't wake the task if no new data was received.
    - MEDIUM: lua: Add stick table support for Lua.

6 years agoMEDIUM: lua: Add stick table support for Lua.
Adis Nezirovic [Fri, 13 Jul 2018 10:18:33 +0000 (12:18 +0200)] 
MEDIUM: lua: Add stick table support for Lua.

This ads support for accessing stick tables from Lua. The supported
operations are reading general table info, lookup by string/IP key, and
dumping the table.

Similar to "show table", a data filter is available during dump, and as
an improvement over "show table" it's possible to use up to 4 filter
expressions instead of just one (with implicit AND clause binding the
expressions). Dumping with/without filters can take a long time for
large tables, and should be used sparingly.

6 years agoBUG/MEDIUM: process_stream(): Don't wake the task if no new data was received.
Olivier Houchard [Fri, 28 Sep 2018 12:38:51 +0000 (14:38 +0200)] 
BUG/MEDIUM: process_stream(): Don't wake the task if no new data was received.

At the eand of process_stream(), we wake the task if there's something in
the input buffer, after attempting a recv. However this is wrong, and we should
only do so if we received new data. Just check the CF_READ_PARTIAL flag.

This is 1.9-specific and should not be backported.

6 years agoBUG/MEDIUM: h2: Wake the task instead of calling h2_recv()/h2_process().
Olivier Houchard [Mon, 24 Sep 2018 16:02:03 +0000 (18:02 +0200)] 
BUG/MEDIUM: h2: Wake the task instead of calling h2_recv()/h2_process().

In a number of cases, we may end up recursively calling h2_recv() via
h2_process(), so just wake the tasklet up instead.

6 years agoMINOR: h2/stream_interface: Reintroduce te wake() method.
Olivier Houchard [Fri, 14 Sep 2018 21:21:44 +0000 (23:21 +0200)] 
MINOR: h2/stream_interface: Reintroduce te wake() method.

For the time being, reintroduce the wake methods, it may be revisited later.h

6 years agoBUG/MEDIUM: process_stream: Don't use si_cs_io_cb() in process_stream().
Olivier Houchard [Fri, 14 Sep 2018 17:41:13 +0000 (19:41 +0200)] 
BUG/MEDIUM: process_stream: Don't use si_cs_io_cb() in process_stream().

Instead of using si_cs_io_cb() in process_stream()  use si_cs_send/si_cs_recv
instead, as si_cs_io_cb() may lead to process_stream being woken up when it
shouldn't be, and thus timeout would never get triggered.

6 years agoDOC: Update configuration doc about the maximum number of stick counters.
Moemen MHEDHBI [Tue, 25 Sep 2018 15:50:53 +0000 (17:50 +0200)] 
DOC: Update configuration doc about the maximum number of stick counters.

Previous patches added support to tracking up to MAX_SESS_STKCTR stick
counters in the same connection, but without updating the DOC, it is done
here.

6 years agoBUG/MEDIUM: http: Don't parse chunked body if there is no input data
Christopher Faulet [Thu, 20 Sep 2018 09:31:01 +0000 (11:31 +0200)] 
BUG/MEDIUM: http: Don't parse chunked body if there is no input data

With recent modifications on the buffers API, when a buffer is released (calling
b_free), we replace it by BUF_NULL where the area pointer is NULL. So many
operations, like b_peek, must be avoided on a released or not allocated
buffer. These changes were mainly made in the commit c9fa048 ("MAJOR: buffer:
finalize buffer detachment").

Since this commit, HAProxy can crash during the body parsing of chunked HTTP
messages because there is no check on the channel's buffer in HTTP analyzers
(http_request_forward_body and http_response_forward_body) nor in H1 functions
reponsible to parse chunked content (h1_skip_chunk_crlf & co). If a stream is
woken up after all input data were forwarded, its input channel's buffer is
released (so set to BUF_NULL). In this case, if we resume the parsing of a
chunk, HAProxy crashes.

To fix this issue, we just skip the parsing of chunks if there is no input data
for the corresponding channel. This is only done if the message state is
strickly lower to HTTP_MSG_ENDING.

6 years agoBUG/CRITICAL: hpack: fix improper sign check on the header index value
Willy Tarreau [Mon, 17 Sep 2018 12:07:33 +0000 (14:07 +0200)] 
BUG/CRITICAL: hpack: fix improper sign check on the header index value

Tim Düsterhus found using afl-fuzz that some parts of the HPACK decoder
use incorrect bounds checking which do not catch negative values after
a type cast. The first culprit is hpack_valid_idx() which takes a signed
int and is fed with an unsigned one, but a few others are affected as
well due to being designed to work with an uint16_t as in the table
header, thus not being able to detect the high offset bits, though they
are not exposed if hpack_valid_idx() is fixed.

The impact is that the HPACK decoder can be crashed by an out-of-bounds
read. The only work-around without this patch is to disable H2 in the
configuration.

CVE-2018-14645 was assigned to this bug.

This patch addresses all of these issues at once. It must be backported
to 1.8.

6 years agoBUILD: build with -Wextra and sort out certain warnings
Willy Tarreau [Thu, 20 Sep 2018 08:38:08 +0000 (10:38 +0200)] 
BUILD: build with -Wextra and sort out certain warnings

We're not far from being able to build with -Wextra -Werror. The
following warnings had to be disabled to enable a clean build at
-Wextra on x86_64 using gcc 4.7, 5.5, 6.4 and 7.3 :

   sign-compare, unused-parameter, old-style-declaration,
   ignored-qualifiers, clobbered, missing-field-initializers,
   implicit-fallthrough

The following extra warnings could be added without side effects :

   type-limits, shift-negative-value, shift-overflow=2 duplicated-cond,
   null-dereference

As a result, -Wextra was enabled by default, hoping it will help catch
issues over the long term. If new undesired warnings pop up, it's easy
to disable them using the nowarn call.

6 years agoBUILD: sockpair: silence a build warning at -Wextra
Willy Tarreau [Thu, 20 Sep 2018 09:39:39 +0000 (11:39 +0200)] 
BUILD: sockpair: silence a build warning at -Wextra

An invalid null-deref warning is emitted because cmsg is not checked,
though it definitely is valid given the test performed 10 lines above,
but the compiler cannot necessarily guess this. Adding a null test to
the problematic condition is enough to get rid of it and cheap enough.

6 years agoBUILD: backend: fix 3 build warnings related to null-deref at -Wextra
Willy Tarreau [Thu, 20 Sep 2018 09:29:28 +0000 (11:29 +0200)] 
BUILD: backend: fix 3 build warnings related to null-deref at -Wextra

These ones are not valid either since the checks are performed a few
lines above the call. Let's switch to __objt_server() instead.

6 years agoBUILD: connection: silence a couple of null-deref build warnings at -Wextra
Willy Tarreau [Thu, 20 Sep 2018 09:26:52 +0000 (11:26 +0200)] 
BUILD: connection: silence a couple of null-deref build warnings at -Wextra

These ones don't need to be checked either.

6 years agoBUILD: checks: silence a null-deref build warning at -Wextra
Willy Tarreau [Thu, 20 Sep 2018 09:25:12 +0000 (11:25 +0200)] 
BUILD: checks: silence a null-deref build warning at -Wextra

Simply don't use cs_conn() on a valid CS.

6 years agoBUILD: dns: fix null-deref build warning at -Wextra
Willy Tarreau [Thu, 20 Sep 2018 09:15:27 +0000 (11:15 +0200)] 
BUILD: dns: fix null-deref build warning at -Wextra

Like for the other checks, the type is being tested just before calling
objt_{server,dns_srvrq}() so let's use the unguarded version instead to
silence the warning.

6 years agoBUILD: log: silent build warnings due to unchecked __objt_{server,applet}
Willy Tarreau [Thu, 20 Sep 2018 09:13:58 +0000 (11:13 +0200)] 
BUILD: log: silent build warnings due to unchecked __objt_{server,applet}

These ones are safe to use there since the same check is performed in
the switch/case they're used it. Let's use the unguarded versions
instead.

6 years agoBUILD: http: address a couple of null-deref warnings at -Wextra
Willy Tarreau [Thu, 20 Sep 2018 09:12:58 +0000 (11:12 +0200)] 
BUILD: http: address a couple of null-deref warnings at -Wextra

These two warnings are caused by the use of objt_server() without
checking its result. These are turned to __objt_server() which is
safe there.

6 years agoBUILD: stream: address null-deref build warnings at -Wextra
Willy Tarreau [Thu, 20 Sep 2018 09:11:15 +0000 (11:11 +0200)] 
BUILD: stream: address null-deref build warnings at -Wextra

These warnings are caused by the improper use of stktable_data_ptr()
whose result is not checked instead of using __stktable_data_ptr().

6 years agoBUILD: stats: remove build warnings on potential null-derefs
Willy Tarreau [Thu, 20 Sep 2018 09:01:01 +0000 (11:01 +0200)] 
BUILD: stats: remove build warnings on potential null-derefs

A couple of objt_appctx() could be replaced with their unchecked
equivalent since the pointer is guaranteed and not checked there.

6 years agoBUILD: ssl_sock: remove build warnings on potential null-derefs
Willy Tarreau [Thu, 20 Sep 2018 08:57:52 +0000 (10:57 +0200)] 
BUILD: ssl_sock: remove build warnings on potential null-derefs

When building with -Wnull-dereferences, gcc sees some cases where a
pointer is dereferenced after a check may set it to null. While all of
these are already guarded by either a preliminary test or the code's
construction (eg: listeners code being called only on listeners), it
cannot be blamed for not "seeing" this, so better use the unguarded
calls everywhere this happens, particularly after checks. This is a
step towards building with -Wextra.

6 years agoMINOR: stream-int: make si_appctx() never fail
Willy Tarreau [Thu, 20 Sep 2018 09:08:47 +0000 (11:08 +0200)] 
MINOR: stream-int: make si_appctx() never fail

Callers of si_appctx() always use the result without checking it because
they know by construction that it's valid. This results in unchecked null
pointer warnings at -Wextra, so let's remove this test and make it clear
that it's up to the caller to check validity first.

6 years agoMINOR: stktable: provide an unchecked version of stktable_data_ptr()
Willy Tarreau [Thu, 20 Sep 2018 09:06:33 +0000 (11:06 +0200)] 
MINOR: stktable: provide an unchecked version of stktable_data_ptr()

stktable_data_ptr() currently performs null pointer checks but most
callers don't check the result since they know by construction that
it cannot be null. This causes valid warnings when building with
-Wextra which are worth addressing since it will result in better
code. Let's provide an unguarded version of this function for use
where the check is known to be useless and untested.

6 years agoBUG/MINOR: cli: make sure the "getsock" command is only called on connections
Willy Tarreau [Thu, 20 Sep 2018 09:22:29 +0000 (11:22 +0200)] 
BUG/MINOR: cli: make sure the "getsock" command is only called on connections

Theorically nothing would prevent a front applet form connecting to a stats
socket, and if a "getsock" command was issued, it would cause a crash. Right
now nothing in the code does this so in its current form there is no impact.

It may or may not be backported to 1.8.

6 years agoBUG/MINOR: tools: fix set_net_port() / set_host_port() on IPv4
Willy Tarreau [Thu, 20 Sep 2018 08:48:35 +0000 (10:48 +0200)] 
BUG/MINOR: tools: fix set_net_port() / set_host_port() on IPv4

These two functions were apparently written on the same model as their
parents when added by commit 11bcb6c4f ("[MEDIUM] IPv6 support for syslog")
except that they perform an assignment instead of a return, and as a
result fall through the next case where the assigned value may possibly
be partially overwritten. At least under Linux the port offset is the
same in both sockaddr_in and sockaddr_in6 so the value is written twice
without side effects.

This needs to be backported as far as 1.5.

6 years agoCLEANUP/CONTRIB: hpack: remove some h1 build warnings
Willy Tarreau [Mon, 17 Sep 2018 09:44:09 +0000 (11:44 +0200)] 
CLEANUP/CONTRIB: hpack: remove some h1 build warnings

These are inherited by recent reorganization to the H1 code.

6 years agoBUG/MEDIUM: h1: Really skip all updates when incomplete messages are parsed
Christopher Faulet [Wed, 19 Sep 2018 12:01:04 +0000 (14:01 +0200)] 
BUG/MEDIUM: h1: Really skip all updates when incomplete messages are parsed

In h1_headers_to_hdr_list, when an incomplete message is parsed, all updates
must be skipped until the end of the message is found. Then the parsing is
restarted from the beginning. But not all updates were skipped, leading to
invalid rewritting or segfault.

No backport is needed.

6 years agoBUG/MEDIUM: patterns: fix possible double free when reloading a pattern list
Dragan Dosen [Tue, 18 Sep 2018 18:18:09 +0000 (20:18 +0200)] 
BUG/MEDIUM: patterns: fix possible double free when reloading a pattern list

A null pointer assignment was missing after free() in function
pat_ref_reload() which can lead to segfault.

This bug was introduced in commit b5997f7 ("MAJOR: threads/map: Make
acls/maps thread safe").

Must be backported to 1.8.

6 years agoMEDIUM: h1: deduplicate the content-length header
Willy Tarreau [Fri, 14 Sep 2018 15:11:33 +0000 (17:11 +0200)] 
MEDIUM: h1: deduplicate the content-length header

Just like we used to do in proto_http, we now check that each and every
occurrence of the content-length header field and each of its values are
exactly identical, and we normalize the header to return the last value
of the first header with spaces trimmed.

6 years agoMEDIUM: h1: better handle transfer-encoding vs content-length
Willy Tarreau [Fri, 14 Sep 2018 14:34:47 +0000 (16:34 +0200)] 
MEDIUM: h1: better handle transfer-encoding vs content-length

The transfer-encoding header processing was a bit lenient in this part
because it was made to read messages already validated by haproxy. We
absolutely need to reinstate the strict processing defined in RFC7230
as is currently being done in proto_http.c. That is, transfer-encoding
presence alone is enough to cancel content-length, and must be
terminated by the "chunked" token, except in the response where we
can fall back to the close mode if it's not last.

For this we now use a specific parsing function which updates the
flags and we introduce a new flag H1_MF_XFER_ENC indicating that the
transfer-encoding header is present.

Last, if such a header is found, we delete all content-length header
fields found in the message.

6 years agoMINOR: h1: add headers to the list after controls, not before
Willy Tarreau [Fri, 14 Sep 2018 14:28:15 +0000 (16:28 +0200)] 
MINOR: h1: add headers to the list after controls, not before

This will ease removal/skipping of duplicates such as content-length.

6 years agoMINOR: http: add http_hdr_del() to remove a header from a list
Willy Tarreau [Fri, 14 Sep 2018 15:32:05 +0000 (17:32 +0200)] 
MINOR: http: add http_hdr_del() to remove a header from a list

This one removes all occurrences of the specified header field name from
a complete list and returns the new count.

6 years agoMINOR: h1: Add H1_MF_XFER_LEN flag
Christopher Faulet [Fri, 14 Sep 2018 09:15:52 +0000 (11:15 +0200)] 
MINOR: h1: Add H1_MF_XFER_LEN flag

This flag is usefull to handle cases where there is no body, regardless of CL or
TE headers (for instance, responses to HEAD requests). It will not be set by the
parser itself.

6 years agoDOC: Fix typos in lua documentation
Bertrand Jacquin [Mon, 10 Sep 2018 20:26:07 +0000 (21:26 +0100)] 
DOC: Fix typos in lua documentation

6 years agoMINOR: h1: parse the Connection header field
Willy Tarreau [Thu, 13 Sep 2018 12:15:58 +0000 (14:15 +0200)] 
MINOR: h1: parse the Connection header field

The new function h1_parse_connection_header() is called when facing a
connection header in the generic parser, and it will set up to 3 bits
in h1m->flags indicating if at least one "close", "keep-alive" or "upgrade"
tokens was seen.