]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoMEDIUM: stick-table: Stop handling stick-tables as proxies.
Frédéric Lécaille [Thu, 14 Mar 2019 06:07:41 +0000 (07:07 +0100)] 
MEDIUM: stick-table: Stop handling stick-tables as proxies.

This patch adds the support for the "table" line parsing in "peers" sections
to declare stick-table in such sections. This also prevents the user from having
to declare dummy backends sections with a unique stick-table inside.
Even if still supported, this usage will become deprecated.

To do so, the ->table member of proxy struct which is a stktable struct is replaced
by a pointer to a stktable struct allocated at parsing time in src/cfgparse-listen.c
for the dummy stick-table backends and in src/cfgparse.c for "peers" sections.
This has an impact on the code for stick-table sample converters and on the stickiness
rules parsers which first store the name of the dummy before resolving the rules.
This patch replaces proxy_tbl_by_name() calls by stktable_find_by_name() calls
to lookup for stick-tables stored in "stktable_by_name" ebtree at parsing time.
There is only one remaining place where proxy_tbl_by_name() is used: src/hlua.c.

At several places in the code we relied on the fact that ->size member of stick-table
was equal to zero to consider the stick-table was present by not configured,
this do not make sense anymore as ->table member of struct proxyis fow now on a pointer.
These tests are replaced by a test on ->table value itself.

In "peers" section we do not have to temporary store the name of the section the
stick-table are attached to because this name is obviously already known just after
having entered this "peers" section.

About the CLI stick-table I/O handler, the pointer to proxy struct is replaced by
a pointer to a stktable struct.

6 years agoBUILD/MINOR: stick-table: Compilation fix.
Frédéric Lécaille [Fri, 15 Mar 2019 10:24:53 +0000 (11:24 +0100)] 
BUILD/MINOR: stick-table: Compilation fix.

Missing header to dereference struct peers pointer from struct table.

6 years agoMINOR: config: Extract the code of "stick-table" line parsing.
Frédéric Lécaille [Fri, 8 Mar 2019 13:47:00 +0000 (14:47 +0100)] 
MINOR: config: Extract the code of "stick-table" line parsing.

With this patch we move the code responsible of parsing "stick-table"
lines to implement parse_stick_table() function in src/stick-tabble.c
so that to be able to parse "stick-table" elsewhere than in proxy sections.
We have have also added a conf struct to stktable struct to store the filename
and the line in the file the stick-table has been parsed to help in
diagnosing and displaying any configuration issue.

6 years agoMEDIUM: tcp: add the "tfo" option to support TCP fastopen on the server
Willy Tarreau [Mon, 23 Jan 2017 22:36:45 +0000 (23:36 +0100)] 
MEDIUM: tcp: add the "tfo" option to support TCP fastopen on the server

This implements support for the new API which relies on a call to
setsockopt().
On systems that support it (currently, only Linux >= 4.11), this enables
using TCP fast open when connecting to server.
Please note that you should use the retry-on "conn-failure", "empty-response"
and "response-timeout" keywords, or the request won't be able to be retried
on failure.

Co-authored-by: Olivier Houchard <ohouchard@haproxy.com>
6 years agoMEDIUM: proto: Change the prototype of the connect() method.
Olivier Houchard [Mon, 6 May 2019 16:32:29 +0000 (18:32 +0200)] 
MEDIUM: proto: Change the prototype of the connect() method.

The connect() method had 2 arguments, "data", that tells if there's pending
data to be sent, and "delack" that tells if we have to use a delayed ack
inconditionally, or if the backend is configured with tcp-smart-connect.
Turn that into one argument, "flags".
That way it'll be easier to provide more informations to connect() without
adding extra arguments.

6 years agoMINOR: doc: Document the interaction of allow-0rtt and retry-on 0rtt-rejected.
Olivier Houchard [Mon, 6 May 2019 17:01:04 +0000 (19:01 +0200)] 
MINOR: doc: Document the interaction of allow-0rtt and retry-on 0rtt-rejected.

Document that haproxy will try to use early data when connecting to the
server if we have retry-on 0rtt-rejected, as well.

6 years agoMINOR: doc: Document allow-0rtt on the server line.
Olivier Houchard [Mon, 6 May 2019 16:58:48 +0000 (18:58 +0200)] 
MINOR: doc: Document allow-0rtt on the server line.

Briefly document allow-0rtt on the server line, and only the part that apply
to 1.8 and 1.9.

This should be backported to 1.8 and 1.9.

6 years agoBUG/MEDIUM: ssl: Don't attempt to use early data with libressl.
Olivier Houchard [Mon, 6 May 2019 13:18:27 +0000 (15:18 +0200)] 
BUG/MEDIUM: ssl: Don't attempt to use early data with libressl.

Libressl doesn't yet provide early data, so don't put the CO_FL_EARLY_SSL_HS
on the connection if we're building with libressl, or the handshake will
never be done.

6 years agoBUILD: travis: TMPDIR replacement.
Frédéric Lécaille [Fri, 3 May 2019 17:16:02 +0000 (19:16 +0200)] 
BUILD: travis: TMPDIR replacement.

TMPDIR default value may be too long to create UNIX sockets for the stats
used during the reg tests. Indeed vtest builds its temporary working directory
${tmpdir} variable from TMPDIR variable, with /tmp as value if not already set.
This is the case on Linux contrary to OS X which sets TMPDIR with a too much long
value.

With this path we revert the part of 88c63a6 commit which tried to shorten this
TMPDIR value modifying script/run-regtests.sh. Unfortunately this was not
sufficient. Furthermore this patch force TMPDIR to /tmp value for all the OS'es.

Thank you to Tim Düsterhus and Ilya for having helped on this issue.

6 years agoBUILD: temporarily mark LibreSSL builds as allowed to fail
Ilya Shipitsin [Sun, 5 May 2019 19:36:21 +0000 (00:36 +0500)] 
BUILD: temporarily mark LibreSSL builds as allowed to fail

6 years agoBUILD: enable several LibreSSL hacks, including
Ilya Shipitsin [Sun, 5 May 2019 18:27:54 +0000 (23:27 +0500)] 
BUILD: enable several LibreSSL hacks, including

SSL_SESSION_get0_id_context is introduced in LibreSSL-2.7.0
async operations are not supported by LibreSSL
early data is not supported by LibreSSL
packet_length is removed from SSL struct in LibreSSL

6 years agoBUILD: travis-ci: get back to osx without openssl support
Ilya Shipitsin [Sun, 5 May 2019 12:43:37 +0000 (17:43 +0500)] 
BUILD: travis-ci: get back to osx without openssl support

there's some issue with socket path, after it is resolved,
we will enable openssl for osx

6 years agoBUILD: remove "build_libressl" duplicate declaration
Ilya Shipitsin [Sun, 5 May 2019 12:41:12 +0000 (17:41 +0500)] 
BUILD: remove "build_libressl" duplicate declaration

6 years agoDOC: Fix typo in keyword matrix
Tim Duesterhus [Sun, 5 May 2019 23:19:53 +0000 (01:19 +0200)] 
DOC: Fix typo in keyword matrix

It should read 'deprecated' instead of 'deprectated'.

6 years agoCLEANUP: Remove appsession documentation
Tim Duesterhus [Sun, 5 May 2019 23:19:52 +0000 (01:19 +0200)] 
CLEANUP: Remove appsession documentation

I was about to partly revert 294d0f08b3d100fcae0e71c26d4f9f93d26e3569,
because there were no 'X' for 'appsession' in the keyword matrix until
I checked the blame, realizing that the feature does not exist any more.

Clearly the documentation is confusing here, the removal note is only
listed *below* the old documentation and the supported sections still
show 'backend' and 'listen'.

It's been 3.5 years and 4 releases (1.6, 1.7, 1.8 and 1.9), I guess
this can be removed from the documentation of future versions.

6 years agoBUILD: extend travis-ci matrix
Ilya Shipitsin [Fri, 3 May 2019 09:31:20 +0000 (14:31 +0500)] 
BUILD: extend travis-ci matrix

added openssl-1.0.2, 1.1.0, 1.1.1, libressl-2.7.5, 2.8.3, 2.9.1
added linux-ppc64le image

6 years agoBUG/MINOR: logs/threads: properly split the log area upon startup
Willy Tarreau [Sun, 5 May 2019 08:11:39 +0000 (10:11 +0200)] 
BUG/MINOR: logs/threads: properly split the log area upon startup

If logs were emitted before creating the threads, then the dataptr pointer
keeps a copy of the end of the log header. Then after the threads are
created, the headers are reallocated for each thread. However the end
pointer was not reset until the end of the first second, which may result
in logs emitted by multiple threads during the first second to be mangled,
or possibly in some cases to use a memory area that was reused for something
else. The fix simply consists in reinitializing the end pointers immediately
when the threads are created.

This fix must be backported to 1.9 and 1.8.

6 years agoBUG/MEDIUM: checks: make sure the warmup task takes the server lock
Willy Tarreau [Sun, 5 May 2019 04:54:22 +0000 (06:54 +0200)] 
BUG/MEDIUM: checks: make sure the warmup task takes the server lock

The server warmup task is used when a server uses the "slowstart"
parameter. This task affects the server's weight and maxconn, and may
dequeue pending connections from the queue. This must be done under
the server's lock, which was not the case.

This must be backported to 1.9 and 1.8.

6 years agoBUG/MINOR: stream: also increment the retry stats counter on L7 retries
Willy Tarreau [Sat, 4 May 2019 08:38:31 +0000 (10:38 +0200)] 
BUG/MINOR: stream: also increment the retry stats counter on L7 retries

It happens that the retries stats use their own counter and are not
derived from the stream interface, so we need to update it as well
when performing an L7 retry.

No backport is needed.

6 years agoMEDIUM: streams: Add a new keyword for retry-on, "junk-response"
Olivier Houchard [Fri, 3 May 2019 21:01:47 +0000 (23:01 +0200)] 
MEDIUM: streams: Add a new keyword for retry-on, "junk-response"

Add a way to retry requests if we got a junk response from the server, ie
an incomplete response, or something that is not valid HTTP.
To do so, one can use the new "junk-response" keyword for retry-on.

6 years agoMEDIUM: streams: Add a way to replay failed 0rtt requests.
Olivier Houchard [Fri, 3 May 2019 20:46:27 +0000 (22:46 +0200)] 
MEDIUM: streams: Add a way to replay failed 0rtt requests.

Add a new keyword for retry-on, 0rtt-rejected. If set, we will try to
replay requests for which we sent early data that got rejected by the
server.
If that option is set, we will attempt to use 0rtt if "allow-0rtt" is set
on the server line even if the client didn't send early data.

6 years agoMEDIUM: streams: Add the ability to retry a request on L7 failure.
Olivier Houchard [Fri, 5 Apr 2019 13:30:12 +0000 (15:30 +0200)] 
MEDIUM: streams: Add the ability to retry a request on L7 failure.

When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.

To do so, add a new backend keyword, "retry-on".

It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".

The default is "conn-failure".

6 years agoBUG/MEDIUM: streams: Don't add CF_WRITE_ERROR if early data were rejected.
Olivier Houchard [Fri, 3 May 2019 20:21:24 +0000 (22:21 +0200)] 
BUG/MEDIUM: streams: Don't add CF_WRITE_ERROR if early data were rejected.

In sess_update_st_con_tcp(), if we have an error on the stream_interface
because we tried to send early_data but failed, don't flag the request
channel as CF_WRITE_ERROR, or we will never reach the analyser that sends
back the 425 response.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: ssl: Use the early_data API the right way.
Olivier Houchard [Fri, 3 May 2019 18:56:19 +0000 (20:56 +0200)] 
BUG/MEDIUM: ssl: Use the early_data API the right way.

We can only read early data if we're a server, and write if we're a client,
so don't attempt to mix both.

This should be backported to 1.8 and 1.9.

6 years agoMINOR: init/threads: make the threads array global
Willy Tarreau [Fri, 3 May 2019 07:22:44 +0000 (09:22 +0200)] 
MINOR: init/threads: make the threads array global

Currently the thread array is a local variable inside a function block
and there is no access to it from outside, which often complicates
debugging. Let's make it global and export it. Also the allocation
return is now checked.

6 years agoMINOR: init/threads: remove the useless tids[] array
Willy Tarreau [Fri, 3 May 2019 07:27:30 +0000 (09:27 +0200)] 
MINOR: init/threads: remove the useless tids[] array

It's still obscure how we managed to initialize an array of integers
with values always equal to the index, just to retrieve the value
from an opaque pointer to the index instead of directly using it! I
suspect it's a leftover from the very early threading experiments.

This commit gets rid of this and simply passes the thread ID as the
argument to run_thread_poll_loop(), thus significantly simplifying the
few call places and removing the need to allocate then free an array
of identity.

6 years agoMINOR: threads: flatten the per-thread cpu-map
Willy Tarreau [Fri, 3 May 2019 07:41:23 +0000 (09:41 +0200)] 
MINOR: threads: flatten the per-thread cpu-map

When we initially experimented with threads and processes support, we
needed to implement arrays of threads per process for cpu-map, but this
is not needed anymore since we support either threads or processes.
Let's simply make the thread-based cpu-map per thread and not per
thread and per process since that's not used anymore. Doing so reduces
the global struct from 33kB to 1.5kB.

6 years agoBUG/MEDIUM: connections: Make sure we remove CO_FL_SESS_IDLE on disown.
Olivier Houchard [Thu, 2 May 2019 10:04:15 +0000 (12:04 +0200)] 
BUG/MEDIUM: connections: Make sure we remove CO_FL_SESS_IDLE on disown.

When for some reason the session is not the owner of the connection anymore,
make sure we remove CO_FL_SESS_IDLE, even if we're about to call
conn->mux->destroy(), as the destroy may not destroy the connection
immediately if it's still in use.
This should be backported to 1.9.
u

6 years agoBUG/MEDIUM: channels: Don't forget to reset output in channel_erase().
Olivier Houchard [Wed, 1 May 2019 22:58:53 +0000 (00:58 +0200)] 
BUG/MEDIUM: channels: Don't forget to reset output in channel_erase().

In channel_erase(), don't forget to set output to 0, otherwise the
channel won't seem empty, when it really is, and that could lead to
stream never closing properly.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: pattern: fix memory leak in regex pattern functions
Dragan Dosen [Mon, 29 Apr 2019 23:03:26 +0000 (01:03 +0200)] 
BUG/MEDIUM: pattern: fix memory leak in regex pattern functions

The allocated regex is not freed properly and can cause a memory leak,
eg. when patterns are updated via CLI socket.

This patch should be backported to all supported versions.

6 years agoBUG/MINOR: checks: free memory allocated for tasklets
Dragan Dosen [Mon, 29 Apr 2019 22:56:20 +0000 (00:56 +0200)] 
BUG/MINOR: checks: free memory allocated for tasklets

The check->wait_list.task and agent->wait_list.task were not
freed properly on deinit().

This patch should be backported to 1.9.

6 years agoBUG/MINOR: log: properly free memory on logformat parse error and deinit()
Dragan Dosen [Mon, 29 Apr 2019 22:40:02 +0000 (00:40 +0200)] 
BUG/MINOR: log: properly free memory on logformat parse error and deinit()

This patch may be backported to all supported versions.

6 years agoBUG/MINOR: haproxy: fix rule->file memory leak
Dragan Dosen [Mon, 29 Apr 2019 22:38:36 +0000 (00:38 +0200)] 
BUG/MINOR: haproxy: fix rule->file memory leak

When using the "use_backend" configuration directive, the configuration
file name stored as rule->file was not freed in some situations. This
was introduced in commit 4ed1c95 ("MINOR: http/conf: store the
use_backend configuration file and line for logs").

This patch should be backported to 1.9, 1.8 and 1.7.

6 years agoBUG/MEDIUM: ssl: Don't pretend we can retry a recv/send if we got a shutr/w.
Olivier Houchard [Wed, 1 May 2019 15:24:36 +0000 (17:24 +0200)] 
BUG/MEDIUM: ssl: Don't pretend we can retry a recv/send if we got a shutr/w.

In ha_ssl_write() and ha_ssl_read(), don't pretend we can retry a read/write
if we got a shutr/shutw, or we will never properly shutdown the connection.

6 years agoBUG/MEDIUM: servers: fix typo "src" instead of "srv"
Ilya Shipitsin [Tue, 30 Apr 2019 16:21:28 +0000 (21:21 +0500)] 
BUG/MEDIUM: servers: fix typo "src" instead of "srv"

When copying the settings for all servers when using server templates,
fix a typo, or we would never copy the length of the ALPN to be used for
checks.

This should be backported to 1.9.

6 years agoCLEANUP: config: Don't alter listener->maxaccept when nbproc is set to 1
Christopher Faulet [Tue, 30 Apr 2019 12:08:41 +0000 (14:08 +0200)] 
CLEANUP: config: Don't alter listener->maxaccept when nbproc is set to 1

This patch only removes a useless calculation on listener->maxaccept when nbproc
is set to 1. Indeed, the following formula has no effet in such case:

  listener->maxaccept = (listener->maxaccept + nbproc - 1) / nbproc;

This patch may be backported as far as 1.5.

6 years agoMINOR: config: Test validity of tune.maxaccept during the config parsing
Christopher Faulet [Tue, 30 Apr 2019 12:03:56 +0000 (14:03 +0200)] 
MINOR: config: Test validity of tune.maxaccept during the config parsing

Only -1 and positive integers from 0 to INT_MAX are accepted. An error is
triggered during the config parsing for any other values.

This patch may be backported to all supported versions.

6 years agoBUG/MEDIUM: listener: Fix how unlimited number of consecutive accepts is handled
Christopher Faulet [Tue, 30 Apr 2019 10:17:13 +0000 (12:17 +0200)] 
BUG/MEDIUM: listener: Fix how unlimited number of consecutive accepts is handled

There is a bug when global.tune.maxaccept is set to -1 (no limit). It is pretty
visible with one process (nbproc sets to 1). The functions listener_accept() and
accept_queue_process() don't expect to handle negative maxaccept values. So
instead of accepting incoming connections without any limit, none are never
accepted and HAProxy loop infinitly in the scheduler.

When there are 2 or more processes, the bug is a bit more subtile. The limit for
a listener is set to 1. So only one connection is accepted at a time by a given
listener. This happens because the listener's maxaccept value is an unsigned
integer. In check_config_validity(), it is first set to UINT_MAX (-1 casted in
an unsigned integer), and then some calculations on it leads to an integer
overflow.

To fix the bug, the listener's maxaccept value is now a signed integer. So, if a
negative value is set for global.tune.maxaccept, we keep it untouched for the
listener and no calculation is made on it. Then, in the listener code, this
signed value is casted to a unsigned one. It simplifies all tests instead of
dealing with negative values. So, it limits the number of connections accepted
at a time to UINT_MAX at most. But, honestly, it not an issue.

This patch must be backported to 1.9 and 1.8.

6 years agoBUG/MEDIUM: port_range: Make the ring buffer lock-free.
Olivier Houchard [Mon, 29 Apr 2019 16:52:06 +0000 (18:52 +0200)] 
BUG/MEDIUM: port_range: Make the ring buffer lock-free.

Port range uses a ring buffer, and unfortunately, when making haproxy
multithreaded, it's been overlooked, and the ring buffer is not thread-safe.
When specifying a source range, 2 or more threads could pick the same
port, and of course only one of them could use the port, the others would
always fail the connection.
To fix this, make it a lock-free ring buffer. This is easier than usual
because we know the ring buffer can never be full.

This should be backported to 1.8 and 1.9.

6 years agoMINOR: threads: Implement HA_ATOMIC_LOAD().
Olivier Houchard [Tue, 30 Apr 2019 11:38:02 +0000 (13:38 +0200)] 
MINOR: threads: Implement HA_ATOMIC_LOAD().

The same way we have HA_ATOMIC_STORE(), implement HA_ATOMIC_LOAD().

This should be backported to 1.8 and 1.9, as we need it for a bug fix
in port ranges.

6 years agoMINOR: activity: report context switch counts instead of rates
Willy Tarreau [Tue, 30 Apr 2019 12:55:18 +0000 (14:55 +0200)] 
MINOR: activity: report context switch counts instead of rates

It's not logical to report context switch rates per thread in show activity
because everything else is a counter and it's not even possible to compare
values. Let's only report counts. Further, this simplifies the scheduler's
code.

6 years agoCLEANUP: task: move the task_per_thread definition to task.h
Willy Tarreau [Tue, 30 Apr 2019 12:36:47 +0000 (14:36 +0200)] 
CLEANUP: task: move the task_per_thread definition to task.h

It's the second time I look for it and can't find it because it's not
in the right file.

6 years agoREGTEST: Make this reg test be Linux specific.
Frédéric Lécaille [Mon, 29 Apr 2019 14:10:12 +0000 (16:10 +0200)] 
REGTEST: Make this reg test be Linux specific.

This patch reverts 9ffb88 commit (REGTEST: Be less Linux specific with a syslog
regex.) and makes this script be Linux specific.

6 years agoBUG/MAJOR: map/acl: real fix segfault during show map/acl on CLI
Willy Tarreau [Tue, 30 Apr 2019 09:43:43 +0000 (11:43 +0200)] 
BUG/MAJOR: map/acl: real fix segfault during show map/acl on CLI

A previous commit 8d85aa44d ("BUG/MAJOR: map: fix segfault during
'show map/acl' on cli.") was provided to address a concurrency issue
between "show acl" and "clear acl" on the CLI. Sadly the code placed
there was copy-pasted without changing the element type (which was
struct stream in the original code) and not tested since the crash
is still present.

The reproducer is simple : load a large ACL file (e.g. geolocation
addresses), issue "show acl #0" in loops in one window and issue a
"clear acl #0" in the other one, haproxy crashes.

This fix was also tested with threads enabled and looks good since
the locking seems to work correctly in these areas though. It will
have to be backported as far as 1.6 since the commit above went
that far as well...

6 years agoREGTEST: Add a new reg test for log load-balancing feature.
Frédéric Lécaille [Thu, 25 Apr 2019 18:14:43 +0000 (20:14 +0200)] 
REGTEST: Add a new reg test for log load-balancing feature.

This is a reg test for the log load-balancing feature implemented by
these commits:
  MINOR: log: Add "sample" new keyword to "log" lines
  MINOR: log: Enable the log sampling and load-balancing feature

The size of the logging buffer for vtest has been doubled to support this script.

6 years agoDOC: log: Document the sampling and load-balancing logging feature.
Frédéric Lécaille [Thu, 25 Apr 2019 08:52:17 +0000 (10:52 +0200)] 
DOC: log: Document the sampling and load-balancing logging feature.

This document should come with these commits:
  'MINOR: log: Enable the log sampling and load-balancing feature'
  'MINOR: log: Add "sample" new keyword to "log" lines.'

6 years agoMINOR: log: Enable the log sampling and load-balancing feature.
Frédéric Lécaille [Thu, 25 Apr 2019 05:42:09 +0000 (07:42 +0200)] 
MINOR: log: Enable the log sampling and load-balancing feature.

This patch implements the sampling and load-balancing of log servers configured
with "sample" new keyword implemented by this commit:
    'MINOR: log: Add "sample" new keyword to "log" lines'.
As the list of ranges used to sample the log to balance is ordered, we only
have to maintain ->curr_idx member of smp_info struct which is the index of
the sample and check if it belongs or not to the current range to decide if we
must send it to the log server or not.

6 years agoMINOR: log: Add "sample" new keyword to "log" lines.
Frédéric Lécaille [Wed, 24 Apr 2019 14:14:33 +0000 (16:14 +0200)] 
MINOR: log: Add "sample" new keyword to "log" lines.

This patch implements the parsing of "sample" new optional keyword for "log" lines
to be able to sample and balance the load of log messages between serveral log
destinations declared by "log" lines. This keyword must be followed by a list of
comma seperated ranges of indexes numbered from 1 to define the samples to be used
to balance the load of logs to send. This "sample" keyword must be used on "log" lines
obviously before the remaining optional ones without keyword. The list of ranges
must be followed by a colon character to separate it from the log sampling size.

With such following configuration declarations:

   log stderr local0
   log 127.0.0.1:10001 sample 2-3,8-11:11 local0
   log 127.0.0.2:10002 sample 5:5 local0

in addition to being sent to stderr, about the second "log" line, every 11 logs
the logs #2 up to #3 would be sent to 127.0.0.1:10001, then #8 up tp #11 four
logs would be sent to the same log server and so on periodically. Logs would be
sent to 127.0.0.2:100002 every 5 logs.

It is also possible to define the size of the sample with a value different of
the maximum of the high limits of the ranges, for instance as follows:

   log 127.0.0.1:10001 sample 2-3,8-11:15 local0

as before the two logs #2 and #3 would be sent to 127.0.0.1:10001, then #8
up tp #11 logs, but in this case here, this would be done periodically every 15
messages.

Also note that the ranges must not overlap each others. This is to ease the
way the logs are periodically sent.

6 years agoBUG/MEDIUM: contrib/modsecurity: If host header is NULL, don't try to strdup it
Yann Cézard [Thu, 25 Apr 2019 12:30:23 +0000 (14:30 +0200)] 
BUG/MEDIUM: contrib/modsecurity: If host header is NULL, don't try to strdup it

I discovered this bug when running OWASP regression tests against HAProxy +
modsecurity-spoa (it's a POC to evaluate how it is working).  I found out that
modsecurity spoa will crash when the request doesn't have any Host header.

See the pull request #86 on github for details.

This patch must be backported to 1.9 and 1.8.

6 years agoDOC: contrib/modsecurity: Typos and fix the reject example
Yann Cézard [Thu, 25 Apr 2019 12:48:38 +0000 (14:48 +0200)] 
DOC: contrib/modsecurity: Typos and fix the reject example

Thanks to https://www.mail-archive.com/haproxy@formilux.org/msg30056.html

This patch may be backported to 1.9 and 1.8.

6 years agoMINOR: spoe: Use the sample context to pass frag_ctx info during encoding
Christopher Faulet [Fri, 26 Apr 2019 12:30:15 +0000 (14:30 +0200)] 
MINOR: spoe: Use the sample context to pass frag_ctx info during encoding

This simplifies the API and hide the details in the sample. This way, only
string and binary are aware of these info, because other types cannot be
partially encoded.

This patch may be backported to 1.9 and 1.8.

6 years agoBUG/MEDIUM: spoe: arg len encoded in previous frag frame but len changed
Kevin Zhu [Fri, 26 Apr 2019 06:00:01 +0000 (14:00 +0800)] 
BUG/MEDIUM: spoe: arg len encoded in previous frag frame but len changed

Fragmented arg will do fetch at every encode time, each fetch may get
different result if SMP_F_MAY_CHANGE, for example res.payload, but
the length already encoded in first fragment of the frame, that will
cause SPOA decode failed and waste resources.

This patch must be backported to 1.9 and 1.8.

6 years agoBUG/MINOR: http: Call stream_inc_be_http_req_ctr() only one time per request
Christopher Faulet [Mon, 29 Apr 2019 11:12:02 +0000 (13:12 +0200)] 
BUG/MINOR: http: Call stream_inc_be_http_req_ctr() only one time per request

The function stream_inc_be_http_req_ctr() is called at the beginning of the
analysers AN_REQ_HTTP_PROCESS_FE/BE. It as an effect only on the backend. But we
must be careful to call it only once. If the processing of HTTP rules is
interrupted in the middle, when the analyser is resumed, we must not call it
again. Otherwise, the tracked counters of the backend are incremented several
times.

This bug was reported in github. See issue #74.

This fix should be backported as far as 1.6.

6 years agoBUG/MEDIUM: mux-h2: properly deal with too large headers frames
Willy Tarreau [Mon, 29 Apr 2019 08:20:21 +0000 (10:20 +0200)] 
BUG/MEDIUM: mux-h2: properly deal with too large headers frames

In h2c_decode_headers(), now that we support CONTINUATION frames, we
try to defragment all pending frames at once before processing them.
However if the first is exactly full and the second cannot be parsed,
we don't detect the problem and we wait for the next part forever due
to an incorrect check on exit; we must abort the processing as soon as
the current frame remains full after defragmentation as in this case
there is no way to make forward progress.

Thanks to Yves Lafon for providing traces exhibiting the problem.

This must be backported to 1.9.

6 years agoMEDIUM: da: HTX mode support.
David CARLIER [Wed, 24 Apr 2019 19:41:53 +0000 (20:41 +0100)] 
MEDIUM: da: HTX mode support.

The DeviceAtlas module now can support both the legacy
mode and the new HTX's with the known set of support headers
for the latter.

6 years agoBUILD/MEDIUM: contrib: Dummy DeviceAtlas API.
David Carlier [Fri, 26 Apr 2019 12:02:28 +0000 (12:02 +0000)] 
BUILD/MEDIUM: contrib: Dummy DeviceAtlas API.

Creating a "mocked" version mainly for testing purposes.

6 years agoMEDIUM: streams: measure processing time and abort when detecting bugs
Willy Tarreau [Thu, 25 Apr 2019 17:48:10 +0000 (19:48 +0200)] 
MEDIUM: streams: measure processing time and abort when detecting bugs

On some occasions we've had loops happening when processing actions
(e.g. a yield not being well understood) resulting in analysers being
called in loops until the analysis timeout without incrementing the
stream's call count, thus this type of bug cannot be caught by the
current protection system.

What this patch proposes is to start to measure the time spent in analysers
when profiling is enabled on the thread, in order to detect if a stream is
really misbehaving. In this case we measured the consumed CPU time, not the
wall clock time, so as not to be affected by possible noisy neighbours
sharing the same CPU. When more than 100ms are spent in an analyser, we
trigger the stream_dump_and_crash() function to report the anomaly.

The choice of 100ms comes from the fact that regular calls only take around
1 microsecond and it seems reasonable to accept a degradation factor of
100000, which covers very slow machines such as home gateways running on
sub-ghz processors, with extremely heavy configurations. Some complete
tests show that even this common bogus map_regm() entry supposedly designed
to extract a port from an IP:port entry does not trigger the timeout (25 ms
evaluation time for a 4kB header, exercise left to the reader to spot the
mistake) :

   ([0-9]{0,3}).([0-9]{0,3}).([0-9]{0,3}).([0-9]{0,3}):([0-9]{0,5}) \5

However this one purposely designed to kill haproxy definitely dies as it
manages to completely freeze the whole process for more than one second
on a 4 GHz CPU for only 120 bytes in :

   (.{0,20})(.{0,20})(.{0,20})(.{0,20})(.{0,20})b \1

This protection will definitely help during the code stabilization period
and may possibly be left enabled later depending on reported issues or not.

If you've noticed that your workload is affected by this patch, please
report it as you have very likely found a bug. And in the mean time you
can turn profiling off to disable it.

6 years agoMEDIUM: stream/debug: force a crash if a stream spins over itself forever
Willy Tarreau [Thu, 25 Apr 2019 17:15:20 +0000 (19:15 +0200)] 
MEDIUM: stream/debug: force a crash if a stream spins over itself forever

If a stream is caught spinning over itself at more than 100000 loops per
second and for more than one second, the process will be aborted and the
offender reported on the console and logs. Typical figures usually are just
a few tens to hundreds per second over a very short time so there is a huge
margin here. Using even higher values could also work but there is the risk
of not being able to catch offenders if multiple ones start to bug at the
same time and share the load. This code should ideally be disabled for
stable releases, though in theory nothing should ever trigger it.

6 years agoMEDIUM: appctx/debug: force a crash if an appctx spins over itself forever
Willy Tarreau [Thu, 25 Apr 2019 17:12:26 +0000 (19:12 +0200)] 
MEDIUM: appctx/debug: force a crash if an appctx spins over itself forever

If an appctx is caught spinning over itself at more than 100000 loops per
second and for more than one second, the process will be aborted and the
offender reported on the console and logs. Typical figures usually are just
a few tens to hundreds per second over a very short time so there is a huge
margin here. Using even higher values could also work but there is the risk
of not being able to catch offenders if multiple ones start to bug at the
same time and share the load. This code should ideally be disabled for
stable releases, though in theory nothing should ever trigger it.

6 years agoMINOR: stream/debug: make a stream dump and crash function
Willy Tarreau [Thu, 25 Apr 2019 17:08:48 +0000 (19:08 +0200)] 
MINOR: stream/debug: make a stream dump and crash function

During 1.9 development (and even a bit after) we've started to face a
significant number of situations where streams were abusively spinning
due to an uncaught error flag or complex conditions that couldn't be
correctly identified. Sometimes streams wake appctx up and conversely
as well. More importantly when this happens the only fix is to restart.

This patch adds a new function to report a serious error, some relevant
info and to crash the process using abort() so that a core dump is
available. The purpose will be for this function to be called in various
situations where the process is unfixable. It will help detect these
issues much earlier during development and may even help fixing test
platforms which are able to automatically restart when such a condition
happens, though this is not the primary purpose.

This patch only provides the function and doesn't use it yet.

6 years agoMINOR: connection: make the debugging helper functions safer
Willy Tarreau [Thu, 25 Apr 2019 16:35:49 +0000 (18:35 +0200)] 
MINOR: connection: make the debugging helper functions safer

We have various functions like conn_get_ctrl_name() to retrieve
some information reported in "show sess" for debugging, which
assume that the connection is valid. This is really not convenient
in code aimed at debugging and is error-prone. Let's add a validity
test first.

6 years agoBUG/MINOR: proto_http: properly reset the stream's call rate on keep-alive
Willy Tarreau [Thu, 25 Apr 2019 16:33:37 +0000 (18:33 +0200)] 
BUG/MINOR: proto_http: properly reset the stream's call rate on keep-alive

The stream's call rate measurement was added by commit 2e9c1d296 ("MINOR:
stream: measure and report a stream's call rate in "show sess"") but it
forgot to reset it in case of HTTP keep-alive (legacy mode), resulting
in incorrect measurements.

No backport is needed, unless the patch above is backported.

6 years agoCLEANUP: standard: use proper const to addr_to_str() and port_to_str()
Willy Tarreau [Thu, 25 Apr 2019 15:48:16 +0000 (17:48 +0200)] 
CLEANUP: standard: use proper const to addr_to_str() and port_to_str()

The input parameter was not marked const, making it painful for some calls.

6 years agoMINOR: activity: enable automatic profiling turn on/off
Willy Tarreau [Thu, 25 Apr 2019 15:09:07 +0000 (17:09 +0200)] 
MINOR: activity: enable automatic profiling turn on/off

Instead of having to manually turn task profiling on/off in the
configuration, by default it will work in "auto" mode, which
automatically turns on on any thread experiencing sustained loop
latencies over one millisecond averaged over the last 1024 samples.

This may happen with configs using lots of regex (thing map_reg for
example, which is the lazy way to convert Apache's rewrite rules but
must not be abused), and such high latencies affect all the process
and the problem is most often intermittent (e.g. hitting a map which
is only used for certain host names).

Thus now by default, with profiling set to "auto", it remains off all
the time until something bad happens. This also helps better focus on
the issues when looking at the logs as well as in "show sess" output.
It automatically turns off when the average loop latency over the last
1024 calls goes below 990 microseconds (which typically takes a while
when in idle).

This patch could be backported to stable versions after a bit more
exposure, as it definitely improves observability and the ability to
quickly spot the culprit. In this case, previous patch ("MINOR:
activity: make the profiling status per thread and not global") must
also be taken.

6 years agoMINOR: activity: make the profiling status per thread and not global
Willy Tarreau [Thu, 25 Apr 2019 06:57:41 +0000 (08:57 +0200)] 
MINOR: activity: make the profiling status per thread and not global

In order to later support automatic profiling turn on/off, we need to
have it per-thread. We're keeping the global option to know whether to
turn it or on off, but the profiling status is now set per thread. We're
updating the status in activity_count_runtime() which is called before
entering poll(). The reason is that we'll extend this with run time
measurement when deciding to automatically turn it on or off.

6 years agoBUG/MINOR: activity: always initialize the profiling variable
Willy Tarreau [Thu, 25 Apr 2019 06:55:47 +0000 (08:55 +0200)] 
BUG/MINOR: activity: always initialize the profiling variable

It happens it was only set if present in the configuration. It's
harmless anyway but can still cause doubts when comparing logs and
configurations so better correctly initialize it.

This should be backported to 1.9.

6 years agoBUILD: travis: remove the "allow_failures" entry
Willy Tarreau [Thu, 25 Apr 2019 06:58:02 +0000 (08:58 +0200)] 
BUILD: travis: remove the "allow_failures" entry

Now that OSX passes all regtests as well, remove this temporary entry.

6 years agoREGTEST: exclude OSX and generic targets from abns_socket.vtc
Willy Tarreau [Thu, 25 Apr 2019 06:50:25 +0000 (08:50 +0200)] 
REGTEST: exclude OSX and generic targets from abns_socket.vtc

This one relies on Linux's abstract namespace sockets which are not
available there. FreeBSD used to already be excluded.

6 years agoREGTEST: relax the IPv6 address format checks in converters_ipmask_concat_strcmp_fiel...
Willy Tarreau [Thu, 25 Apr 2019 06:47:15 +0000 (08:47 +0200)] 
REGTEST: relax the IPv6 address format checks in converters_ipmask_concat_strcmp_field_word

In Travis build https://travis-ci.com/haproxy/haproxy/jobs/195477767 we
can see that OSX tends to pad zeroes at a different position than Linux
in compact IPv6 addresses, resulting in a failure in the checks which
were developped on Linux. This patch uses [0:]* in holes and [0:]+ at the
end of addresses to allow the different variants. It will unfortunately
also accept impossible addresses but there is no reason that we have to
care about for such crap to be emitted.

6 years agoREGTEST: exclude osx and generic targets for 40be_2srv_odd_health_checks
Willy Tarreau [Thu, 25 Apr 2019 06:39:48 +0000 (08:39 +0200)] 
REGTEST: exclude osx and generic targets for 40be_2srv_odd_health_checks

As explained in the commit below, this test relies on TCP_DEFER_ACCEPT
which is not available everywhere, and as such fails on OSX as well :
15685c791 ("REGTEST: Exclude freebsd target for some reg tests.")

6 years agoBUILD: extend Travis CI config to support more platforms
Tim Duesterhus [Wed, 24 Apr 2019 14:11:09 +0000 (19:11 +0500)] 
BUILD: extend Travis CI config to support more platforms

This commit extends the Travis CI configuration to build HAProxy
with gcc on Linux, clang on Mac and cleans up the build flag
configuration to be easier extendable.

Note: At the moment HAProxy fails on Travis for configurations
on OS X

6 years agoMINOR: applet: measure and report an appctx's call rate in "show sess"
Willy Tarreau [Wed, 24 Apr 2019 06:41:29 +0000 (08:41 +0200)] 
MINOR: applet: measure and report an appctx's call rate in "show sess"

Very similarly to previous commit doing the same for streams, we now
measure and report an appctx's call rate. This will help catch applets
which do not consume all their data and/or which do not properly report
that they're waiting for something else. Some of them like peers might
theorically be able to exhibit some occasional peeks when teaching a
full table to a nearby peer (e.g. the new replacement process), but
nothing close to what a bogus service can do so there is no risk of
confusion.

6 years agoMINOR: stream: measure and report a stream's call rate in "show sess"
Willy Tarreau [Wed, 24 Apr 2019 06:28:31 +0000 (08:28 +0200)] 
MINOR: stream: measure and report a stream's call rate in "show sess"

Quite a few times some bugs have made a stream task incorrectly
handle a complex combination of events, which was often reported as
"100% CPU", and was usually caused by the event not being properly
identified and flushed, and the stream's handler called in loops.

This patch adds a call rate counter to the stream struct. It's not
huge, it's really inexpensive (especially compared to the rest of the
processing function) and will easily help spot such tasks in "show sess"
output, possibly even allowing to kill them.

A future patch should probably consist in alerting when they're above a
certain threshold, possibly sending a dump and killing them. Some options
could also consist in aborting in order to get an analyzable core dump
and let a service manager restart a fresh new process.

6 years agoMINOR: tasks/activity: report the context switch and task wakeup rates
Willy Tarreau [Wed, 24 Apr 2019 06:10:57 +0000 (08:10 +0200)] 
MINOR: tasks/activity: report the context switch and task wakeup rates

It's particularly useful to spot runaway tasks to see this. The context
switch rate covers all tasklet calls (tasks and I/O handlers) while the
task wakeups only covers tasks picked from the run queue to be executed.
High values there will indicate either an intense traffic or a bug that
mades a task go wild.

6 years agoCLEANUP: task: report calls as unsigned in show sess
Willy Tarreau [Wed, 24 Apr 2019 06:21:41 +0000 (08:21 +0200)] 
CLEANUP: task: report calls as unsigned in show sess

The "show sess" output used signed ints to report the number of calls,
which is confusing for runaway tasks where the call count can turn
negative.

6 years agoBUG/MINOR: htx: Exclude TCP proxies when the HTX mode is handled during startup
Christopher Faulet [Wed, 24 Apr 2019 13:25:00 +0000 (15:25 +0200)] 
BUG/MINOR: htx: Exclude TCP proxies when the HTX mode is handled during startup

When tests are performed on the HTX mode during HAProxy startup, only HTTP
proxies are considered. It is important because, since the commit 1d2b586cd
("MAJOR: htx: Enable the HTX mode by default for all proxies"), the HTX is
enabled on all proxies by default. But for TCP proxies, it is "deactivated".

This patch must be backported to 1.9.

6 years agoBUG/MAJOR: muxes: Use the HTX mode to find the best mux for HTTP proxies only
Christopher Faulet [Wed, 24 Apr 2019 13:01:22 +0000 (15:01 +0200)] 
BUG/MAJOR: muxes: Use the HTX mode to find the best mux for HTTP proxies only

Since the commit 1d2b586cd ("MAJOR: htx: Enable the HTX mode by default for all
proxies"), the HTX is enabled by default for all proxies, HTTP and TCP, but also
CLI and HEALTH proxies. But when the best mux is retrieved, only HTTP and TCP
modes are checked. If the TCP mode is not explicitly set, it is considered as an
HTTP proxy. It is an hidden bug introduced when the option "http-use-htx" was
added. It has no effect until the commit 1d2b586cd. But now, when a stats socket
is created for the master process, the mux h1 is installed on all incoming
connections to the CLI proxy, leading to segfaults because HTX operations are
performed on raw buffers.

So to fix the buf, when a mux is installed, all proxies are considered as TCP
proxies, except HTTP ones. This way, CLI and HEALTH proxies will be handled as
TCP proxies.

This patch must be backported to 1.9 although it has no effect. It is safer to
not keep hidden bugs.

6 years agoBUG/MAJOR: lb/threads: fix AB/BA locking issue in round-robin LB
Willy Tarreau [Wed, 24 Apr 2019 08:48:00 +0000 (10:48 +0200)] 
BUG/MAJOR: lb/threads: fix AB/BA locking issue in round-robin LB

An occasional divide by zero in the round-robin scheduler was addressed
in commit 9df86f997 ("BUG/MAJOR: lb/threads: fix insufficient locking on
round-robin LB") by grabing the server's lock in fwrr_get_server_from_group().

But it happens that this is not the correct approach as it introduces a
case of AB/BA deadlock reported by Maksim Kupriianov. This happens when
a server weight changes from/to zero while another thread extracts this
server from the tree. The reason is that the functions used to manipulate
the state work under the server's lock and grab the LB lock while the ones
used in LB work under the LB lock and grab the server's lock when needed.

This commit mostly reverts the changes above and instead further completes
the locking analysis performed on this code to identify areas that really
need to be protected by the server's lock, since this is the only algorithm
which happens to have this requirement. This audit showed that in fact all
locations which require the server's lock are already protected by the LB
lock. This was not noticed the first time due to the server's lock being
taken instead and due to some functions misleadingly using atomic ops to
modify server fields which are under the LB lock protection (these ones
were now removed).

The change consists in not taking the server's lock anymore here, and
instead making sure that the aforementioned function which used to
suffer from the server's weight becoming zero only uses a copy of the
weight which was preliminary verified to be non-null (when the weight
is null, the server will be removed from the tree anyway so there is
no need to recalculate its position).

With this change, the code survived an injection at 200k req/s split
on two servers with weights changing 50 times a second.

This commit must be backported to 1.9 only.

6 years agoBUG/MEDIUM: ssl: Return -1 on recv/send if we got EAGAIN.
Olivier Houchard [Wed, 24 Apr 2019 10:04:36 +0000 (12:04 +0200)] 
BUG/MEDIUM: ssl: Return -1 on recv/send if we got EAGAIN.

In ha_ssl_read()/ha_ssl_write(), if we couldn't send/receive data because
we got EAGAIN, return -1 and not 0, as older SSL versions expect that.
This should fix the problems with OpenSSL < 1.1.0.

6 years agoBUG/MINOR: spoe: Don't systematically wakeup SPOE stream in the applet handler
Christopher Faulet [Tue, 23 Apr 2019 13:39:32 +0000 (15:39 +0200)] 
BUG/MINOR: spoe: Don't systematically wakeup SPOE stream in the applet handler

This can lead to wakeups in loop between the SPOE stream and the SPOE applets
waiting to receive agent messages (mainly AGENT-HELLO and AGENT-DISCONNECT).

This patch must be backported to 1.9 and 1.8.

6 years agoBUG/MEDIUM: stream: Fix the way early aborts on the client side are handled
Christopher Faulet [Tue, 23 Apr 2019 15:34:22 +0000 (17:34 +0200)] 
BUG/MEDIUM: stream: Fix the way early aborts on the client side are handled

A regression was introduced with the commit c9aecc8ff ("BUG/MEDIUM: stream:
Don't request a server connection if a shutw was scheduled"). Among other this,
it breaks the CLI when the shutr on the client side is handled with the client
data. To depend on the flag CF_SHUTW_NOW to not establish the server connection
when an error on the client side is detected is the right way to fix the bug,
because this flag may be set without any error on the client side.

So instead, we abort the request where the error is handled and only when the
backend stream-interface is in the state SI_ST_INI. This way, there is no
ambiguity on the reason why the abort accurred. The stream-interface is also
switched to the state SI_ST_CLO.

This patch must be backported to 1.9. If the commit c9aecc8ff is backported to
previous versions, this one MUST also be backported. Otherwise, it MAY be
backported to older versions that 1.9 with caution.

6 years agoBUG/MAJOR: stream: Missing DNS context initializations.
Frédéric Lécaille [Tue, 23 Apr 2019 15:26:33 +0000 (17:26 +0200)] 
BUG/MAJOR: stream: Missing DNS context initializations.

Fix some missing initializations wich came with 333939c commit (MINOR: action:
new '(http-request|tcp-request content) do-resolve' action). The DNS contexts of
streams which were allocated were not initialized by stream_new(). This leaded to
accesses to non-allocated memory when freeing these contexts with stream_free().

6 years agoREGTEST: make the "run-regtests" script search for tests in reg-tests by default
Willy Tarreau [Tue, 23 Apr 2019 14:09:50 +0000 (16:09 +0200)] 
REGTEST: make the "run-regtests" script search for tests in reg-tests by default

It happens almost daily to me that make regtests fails because the script
found a temporary, old, or broken VTC file that was lying in my work dir,
leaving me no place to hide it. This is a real pain as some tests take ages
to fail, so let's make this script only look up for tests where they are
expected to be stored, under reg-tests only. It remains possible to force
the location on the command line though.

6 years agoREGTEST: adapt some reg tests after renaming.
Frédéric Lécaille [Fri, 29 Mar 2019 15:13:48 +0000 (16:13 +0100)] 
REGTEST: adapt some reg tests after renaming.

Some reg tests and their dependencies have been renamed. They may be
referenced by the .vtc files. So, this patch modifies also the references
to these dependencies.

6 years agoREGTEST: rename the reg test files.
Frédéric Lécaille [Fri, 29 Mar 2019 14:37:07 +0000 (15:37 +0100)] 
REGTEST: rename the reg test files.

We rename all the VTC files to avoid name collisions when importing/backporting.

6 years agoREGTEST: replace LEVEL option by a more human readable one.
Frédéric Lécaille [Fri, 29 Mar 2019 14:07:24 +0000 (15:07 +0100)] 
REGTEST: replace LEVEL option by a more human readable one.

This patch replaces LEVEL variable by REGTESTS_TYPES variable which is more
mnemonic and human readable. It is uses as a filter to run the reg tests scripts
where a commented #REGTEST_TYPE may be defined to designate their types.
Running the following command:

    $ REGTESTS_TYPES=slow,default

will start all the reg tests where REGTEST_TYPE is defines as 'slow' or 'default'.
Note that 'default' is also the default value of REGTEST_TYPE when not specified
dedicated to run all the current h*.vtc files. When REGTESTS_TYPES is not specified
there is no filter at all. All the tests are run.

This patches also defines REGTEST_TYPE with 'slow' value for all the s*.vtc files,
'bug' value for al the b*.vtc files, 'broken' value for all the k*.vtc files.

6 years agoMINOR: log: Extract some code to send syslog messages.
Frédéric Lécaille [Wed, 10 Apr 2019 06:22:17 +0000 (08:22 +0200)] 
MINOR: log: Extract some code to send syslog messages.

This patch extracts the code of __send_log() responsible of sending a syslog
message to a syslog destination represented as a logsrv struct to define
__do_send_log() function. __send_log() calls __do_send_log() for each syslog
destination of a proxy after having prepared some of its parameters.

6 years agoMINOR: action: new '(http-request|tcp-request content) do-resolve' action
Baptiste Assmann [Mon, 21 Jan 2019 07:34:50 +0000 (08:34 +0100)] 
MINOR: action: new '(http-request|tcp-request content) do-resolve' action

The 'do-resolve' action is an http-request or tcp-request content action
which allows to run DNS resolution at run time in HAProxy.
The name to be resolved can be picked up in the request sent by the
client and the result of the resolution is stored in a variable.
The time the resolution is being performed, the request is on pause.
If the resolution can't provide a suitable result, then the variable
will be empty. It's up to the admin to take decisions based on this
statement (return 503 to prevent loops).

Read carefully the documentation concerning this feature, to ensure your
setup is secure and safe to be used in production.

This patch creates a global counter to track various errors reported by
the action 'do-resolve'.

6 years agoMINOR: obj_type: new object type for struct stream
Baptiste Assmann [Tue, 30 Jan 2018 07:10:20 +0000 (08:10 +0100)] 
MINOR: obj_type: new object type for struct stream

This patch creates a new obj_type for the struct stream in HAProxy.

6 years agoMINOR: dns: move callback affection in dns_link_resolution()
Baptiste Assmann [Tue, 30 Jan 2018 07:08:04 +0000 (08:08 +0100)] 
MINOR: dns: move callback affection in dns_link_resolution()

In dns.c, dns_link_resolution(), each type of dns requester is managed
separately, that said, the callback function is affected globaly (and
points to server type callbacks only).
This design prevents the addition of new dns requester type and this
patch aims at fixing this limitation: now, the callback setting is done
directly into the portion of code dedicated to each requester type.

6 years agoMINOR: dns: dns_requester structures are now in a memory pool
Baptiste Assmann [Mon, 21 Jan 2019 07:18:09 +0000 (08:18 +0100)] 
MINOR: dns: dns_requester structures are now in a memory pool

dns_requester structure can be allocated at run time when servers get
associated to DNS resolution (this happens when SRV records are used in
conjunction with service discovery).
Well, this memory allocation is safer if managed in an HAProxy pool,
furthermore with upcoming HTTP action which can perform DNS resolution
at runtime.

This patch moves the memory management of the dns_requester structure
into its own pool.

6 years agoMINOR: contrib: dummy wurfl library
paulborile [Thu, 18 Apr 2019 10:31:25 +0000 (12:31 +0200)] 
MINOR: contrib: dummy wurfl library

This is dummy version of the Scientiamobile WURFL C API that can be used
to successfully build/run haproxy compiled with USE_WURFL=1.
It is marked as version 1.11.2.100 to distinguish it from any real version
of the lib. It has no external dependencies so it should work out of the
box by building it like this :

   $ make -C contrib/wurfl

In order to use it, simply reference this directory as the WURFL include
and library paths :

   $ make TARGET=<target> USE_WURFL=1 WURFL_INC=$PWD/contrib/wurfl WURFL_LIB=$PWD/contrib/wurfl

6 years agoMINOR: wurfl: enabled multithreading mode
paulborile [Thu, 18 Apr 2019 10:18:54 +0000 (12:18 +0200)] 
MINOR: wurfl: enabled multithreading mode

Initially excluded multithreaded mode is completely supported (libwurfl is fully MT safe).
Internal tests now are run also with multithreading enabled.

6 years agoDOC: wurfl: added point of contact in MAINTAINERS file
paulborile [Thu, 18 Apr 2019 10:17:47 +0000 (12:17 +0200)] 
DOC: wurfl: added point of contact in MAINTAINERS file

6 years agoCLEANUP: wurfl: removed deprecated methods
paulborile [Thu, 18 Apr 2019 09:57:04 +0000 (11:57 +0200)] 
CLEANUP: wurfl: removed deprecated methods

last 2 major releases of libwurfl included a complete review of engine options with
the result of deprecating many features. The patch removes unecessary code and fixes
the documentation.
Can be backported on any version of haproxy.

[wt: must not be backported since it removes config keywords and would
 thus break existing configurations]
Signed-off-by: Willy Tarreau <w@1wt.eu>
6 years agoBUILD: wurfl: build fix for 1.9/2.0 code base
paulborile [Wed, 17 Apr 2019 10:20:42 +0000 (12:20 +0200)] 
BUILD: wurfl: build fix for 1.9/2.0 code base

This applies the required changes for the new buffer API that came in 1.9.
This patch must be backported to 1.9.

6 years agoMINOR: wurfl: indicate in haproxy -vv the wurfl version in use
Willy Tarreau [Fri, 19 Apr 2019 14:28:53 +0000 (16:28 +0200)] 
MINOR: wurfl: indicate in haproxy -vv the wurfl version in use

It also explicitly mentions that the library is the dummy one when it
is detected.

We have this output now :

$ ./haproxy  -vv |grep -i wurfl
Built with WURFL support (dummy library version 1.11.2.100)

6 years agoBUILD: add USE_WURFL to the list of known build options
Willy Tarreau [Tue, 23 Apr 2019 08:57:09 +0000 (10:57 +0200)] 
BUILD: add USE_WURFL to the list of known build options

Since the removal of WURFL we've improved the build system to report
known build options, let's reference this option there as well.

6 years agoRevert "CLEANUP: wurfl: remove dead, broken and unmaintained code"
Willy Tarreau [Fri, 19 Apr 2019 14:03:32 +0000 (16:03 +0200)] 
Revert "CLEANUP: wurfl: remove dead, broken and unmaintained code"

This reverts commit 8e5e1e7bf000f2603a085c76be118214d22c55b4.

The following patches will fix this code and may be backported.

6 years agoMINOR: ssl/cli: async fd io-handlers printable on show fd
Emeric Brun [Fri, 19 Apr 2019 15:15:28 +0000 (17:15 +0200)] 
MINOR: ssl/cli: async fd io-handlers printable on show fd

This patch exports the async fd iohandlers and make them printable
doing a 'show fd' on cli.