]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMINOR: ssl: Define a default https log format
Remi Tricot-Le Breton [Thu, 29 Jul 2021 07:45:52 +0000 (09:45 +0200)] 
MINOR: ssl: Define a default https log format

This patch adds a new httpslog option and a new HTTP over SSL log-format
that expands the default HTTP format and adds SSL specific information.

3 years agoMINOR: ssl: Add new ssl_fc_hsk_err sample fetch
Remi Tricot-Le Breton [Thu, 29 Jul 2021 07:45:51 +0000 (09:45 +0200)] 
MINOR: ssl: Add new ssl_fc_hsk_err sample fetch

This new sample fetch along the ssl_fc_hsk_err_str fetch contain the
last SSL error of the error stack that occurred during the SSL
handshake (from the frontend's perspective). The errors happening during
the client's certificate verification will still be given by the
ssl_c_err and ssl_c_ca_err fetches. This new fetch will only hold errors
retrieved by the OpenSSL ERR_get_error function.

3 years agoMINOR: ssl: Enable error fetches in case of handshake error
Remi Tricot-Le Breton [Thu, 29 Jul 2021 07:45:50 +0000 (09:45 +0200)] 
MINOR: ssl: Enable error fetches in case of handshake error

The ssl_c_err, ssl_c_ca_err and ssl_c_ca_err_depth sample fetches values
were not recoverable when the connection failed because of the test
"conn->flags & CO_FL_WAIT_XPRT" (which required the connection to be
established). They could then not be used in a log-format since whenever
they would have sent a non-null value, the value fetching was disabled.
This patch ensures that all these values can be fetched in case of
connection failure.

3 years agoMINOR: connection: Add a connection error code sample fetch
Remi Tricot-Le Breton [Thu, 29 Jul 2021 07:45:49 +0000 (09:45 +0200)] 
MINOR: connection: Add a connection error code sample fetch

The fc_conn_err and fc_conn_err_str sample fetches give information
about the problem that made the connection fail. This information would
previously only have been given by the error log messages meaning that
thanks to these fetches, the error log can now be included in a custom
log format. The log strings were all found in the conn_err_code_str
function.

3 years agoBUG/MINOR: connection: Add missing error labels to conn_err_code_str
Remi Tricot-Le Breton [Thu, 29 Jul 2021 07:45:48 +0000 (09:45 +0200)] 
BUG/MINOR: connection: Add missing error labels to conn_err_code_str

The CO_ER_SSL_EARLY_FAILED and CO_ER_CIP_TIMEOUT connection error codes
were missing in the conn_err_code_str switch which converts the error
codes into string.

This patch can be backported on all stable branches.

3 years agoCLEANUP: mworker: PR_CAP already initialized with alloc_new_proxy()
William Lallemand [Thu, 29 Jul 2021 13:35:48 +0000 (15:35 +0200)] 
CLEANUP: mworker: PR_CAP already initialized with alloc_new_proxy()

Remove the PR_CAP initialization in mworker_cli_proxy_create() which is
already done in alloc_new_proxy().

3 years agoCLEANUP: mworker: use the proxy helper functions in mworker_cli_proxy_create()
William Lallemand [Thu, 29 Jul 2021 13:13:22 +0000 (15:13 +0200)] 
CLEANUP: mworker: use the proxy helper functions in mworker_cli_proxy_create()

Cleanup the mworker_cli_proxy_create() function by removing the
allocation and init of the proxy which is done manually, and replace it
by alloc_new_proxy(). Do the same with the free_proxy() function.

This patch also move the insertion at the end of the function.

3 years agoMINOR: stats: don't output internal proxies (PR_CAP_INT)
William Lallemand [Wed, 28 Jul 2021 15:45:18 +0000 (17:45 +0200)] 
MINOR: stats: don't output internal proxies (PR_CAP_INT)

Disable the output of the statistics of internal proxies (PR_CAP_INT),
wo we don't rely only on the px->uuid > 0. This will allow to hide more
cleanly the internal proxies in the stats.

3 years agoMINOR: mworker: the mworker CLI proxy is internal
William Lallemand [Wed, 28 Jul 2021 15:40:56 +0000 (17:40 +0200)] 
MINOR: mworker: the mworker CLI proxy is internal

Sets the mworker CLI proxy as a internal one (PR_CAP_INT) so we could
exlude it from stats and other tests.

3 years agoMINOR: proxy: rename PR_CAP_LUA to PR_CAP_INT
William Lallemand [Wed, 28 Jul 2021 13:48:16 +0000 (15:48 +0200)] 
MINOR: proxy: rename PR_CAP_LUA to PR_CAP_INT

This patch renames the proxy capability "LUA" to "INT" so it could be
used for any internal proxy.

Every proxy that are not user defined should use this flag.

3 years agoBUG/MEDIUM: mux-h2: Handle remaining read0 cases on partial frames
Christopher Faulet [Mon, 26 Jul 2021 10:06:53 +0000 (12:06 +0200)] 
BUG/MEDIUM: mux-h2: Handle remaining read0 cases on partial frames

This part was fixed several times since commit aade4edc1 ("BUG/MEDIUM:
mux-h2: Don't handle pending read0 too early on streams") and there are
still some cases where a read0 event may be ignored because a partial frame
inhibits the event.

Here, we must take care to set H2_CF_END_REACHED flag if a read0 was
received while a partial frame header is received or if the padding length
is missing.

To ease partial frame detection, H2_CF_DEM_SHORT_READ flag is introduced. It
is systematically removed when some data are received and is set when a
partial frame is found or when dbuf buffer is empty. At the end of the
demux, if the connection must be closed ASAP or if data are missing to move
forward, we may acknowledge the pending read0 event, if any. For now,
H2_CF_DEM_SHORT_READ is not part of H2_CF_DEM_BLOCK_ANY mask.

This patch should fix the issue #1328. It must be backported as far as 2.0.

3 years agoBUG/MINOR: mux-h1: Be sure to swap H1C to splice mode when rcv_pipe() is called
Christopher Faulet [Mon, 26 Jul 2021 08:49:39 +0000 (10:49 +0200)] 
BUG/MINOR: mux-h1: Be sure to swap H1C to splice mode when rcv_pipe() is called

The splicing does not work anymore because the H1 connection is not swap to
splice mode when rcv_pipe() callback function is called. It is important to
set H1C_F_WANT_SPLICE flag to inhibit data receipt via the buffer
API. Otherwise, because there are always data in the buffer, it is not
possible to use the kernel splicing.

This bug was introduced by the commit 2b861bf72 ("MINOR: mux-h1: clean up
conditions to enabled and disabled splicing").

The patch must be backported to 2.4.

3 years agoBUG/MINOR: mux-h2: Obey dontlognull option during the preface
Christopher Faulet [Mon, 26 Jul 2021 08:18:35 +0000 (10:18 +0200)] 
BUG/MINOR: mux-h2: Obey dontlognull option during the preface

If a connection is closed during the preface while no data are received, if
the dontlognull option is set, no log message must be emitted. However, this
will still be handled as a protocol error. Only the log is omitted.

This patch should fix the issue #1336 for H2 sessions. It must be backported
to 2.4 and 2.3 at least, and probably as far as 2.0.

3 years agoBUG/MINOR: mux-h1: Obey dontlognull option for empty requests
Christopher Faulet [Mon, 26 Jul 2021 07:42:49 +0000 (09:42 +0200)] 
BUG/MINOR: mux-h1: Obey dontlognull option for empty requests

If a H1 connection is closed while no data are received, if the dontlognull
option is set, no log message must be emitted. Because the H1 multiplexer
handles early errors, it must take care to obey this option. It is true for
400-Bad-Request, 408-Request-Time-out and 501-Not-Implemented
responses. 500-Internal-Server-Error responses are still logged.

This patch should fix the issue #1336 for H1 sessions. It must be backported
to 2.4.

3 years agoBUG/MINOR: systemd: must check the configuration using -Ws
William Lallemand [Mon, 26 Jul 2021 09:03:54 +0000 (11:03 +0200)] 
BUG/MINOR: systemd: must check the configuration using -Ws

When doing a reload with a configuration which requires the
master-worker mode, the configuration check will fail because the check
is not done with -W/-Ws.

Example:
wla@kikyo:~/haproxy$ ./haproxy -Ws -c -f haproxy.cfg
Configuration file is valid
wla@kikyo:~/haproxy$ ./haproxy -c -f haproxy.cfg
[NOTICE]   (13153) : haproxy version is 2.5-dev2-4567b3-16
[NOTICE]   (13153) : path to executable is ./haproxy
[ALERT]    (13153) : config : Can't use a 'program' section without master worker mode.
[ALERT]    (13153) : config : Fatal errors found in configuration.

This patch fixes the issue by adding -Ws on the check command line.

Must be backported in all stable branches. (The file was previously in
contrib/systemd/haproxy.service.in).

3 years agoMINOR: ssl: use __objt_* variant when retrieving counters
Amaury Denoyelle [Mon, 26 Jul 2021 07:59:06 +0000 (09:59 +0200)] 
MINOR: ssl: use __objt_* variant when retrieving counters

Use non-checked function to retrieve listener/server via obj_type. This
is done as a previous obj_type function ensure that the type is well
known and the instance is not NULL.

Incidentally, this should prevent the coverity report from the #1335
github issue which warns about a possible NULL dereference.

3 years agoBUG/MINOR: resolvers: Use a null-terminated string to lookup in servers tree
Christopher Faulet [Thu, 22 Jul 2021 12:29:26 +0000 (14:29 +0200)] 
BUG/MINOR: resolvers: Use a null-terminated string to lookup in servers tree

When we evaluate a DNS response item, it may be necessary to look for a
server with a hostname matching the item target into the named servers
tree. To do so, the item target is transformed to a lowercase string. It
must be a null-terminated string. Thus we must explicitly set the trailing
'\0' character.

For a specific resolution, the named servers tree contains all servers using
this resolution with a hostname loaded from a state file. Because of this
bug, same entry may be duplicated because we are unable to find the right
server, assigning this way the item to a free server slot.

This patch should fix the issue #1333. It must be backported as far as 2.2.

3 years agoBUILD: threads: fix pthread_mutex_unlock when !USE_THREAD
Willy Tarreau [Thu, 22 Jul 2021 12:42:32 +0000 (14:42 +0200)] 
BUILD: threads: fix pthread_mutex_unlock when !USE_THREAD

Commit 048368ef6 ("MINOR: deinit: always deinit the init_mutex on
failed initialization") added the missing unlock but forgot to
condition it on USE_THREAD, resulting in a build failure. No
backport is needed.

This addresses oss-fuzz issue 36426.

3 years agoBUG/MINOR: check: fix the condition to validate a port-less server
Willy Tarreau [Thu, 22 Jul 2021 09:06:41 +0000 (11:06 +0200)] 
BUG/MINOR: check: fix the condition to validate a port-less server

A config like the below fails to validate because of a bogus test:

  backend b1
      tcp-check connect port 1234
      option tcp-check
      server s1 1.2.3.4 check

[ALERT] (18887) : config : config: proxy 'b1': server 's1' has neither
                  service port nor check port, and a tcp_check rule
                  'connect' with no port information.

A || instead of a && only validates the connect rule when both the
address *and* the port are set. A work around is to set the rule like
this:

      tcp-check connect addr 0:1234 port 1234

This needs to be backported as far as 2.2 (2.0 is OK).

3 years agoBUG/MINOR: stats: Add missing agent stats on servers
Christopher Faulet [Thu, 22 Jul 2021 06:04:38 +0000 (08:04 +0200)] 
BUG/MINOR: stats: Add missing agent stats on servers

Agent stats were lost during the stats refactoring performed in the 2.4 to
simplify the Prometheus exporter. stats_fill_sv_stats() function must fill
ST_F_AGENT_* and ST_F_LAST_AGT stats.

This patch should fix the issue #1331. It must be backported to 2.4.

3 years agoBUG/MEDIUM: ssl_sample: fix segfault for srv samples on invalid request
Amaury Denoyelle [Wed, 21 Jul 2021 09:50:12 +0000 (11:50 +0200)] 
BUG/MEDIUM: ssl_sample: fix segfault for srv samples on invalid request

Some ssl samples cause a segfault when the stream is not instantiated,
for example during an invalid HTTP request. A new check is added to
prevent the stream dereferencing if NULL.

This is the list of the affected samples :
- ssl_s_chain_der
- ssl_s_der
- ssl_s_i_dn
- ssl_s_key_alg
- ssl_s_notafter
- ssl_s_notbefore
- ssl_s_s_dn
- ssl_s_serial
- ssl_s_sha1
- ssl_s_sig_alg
- ssl_s_version

This bug can be reproduced easily by using one of these samples in a
log-format string. Emit an invalid HTTP request with an HTTP client to
trigger the crash.

This bug has been reported in redmine issue 3913.

This must be backported up to 2.2.

3 years agoBUILD/MINOR: memprof fix macOs build.
David CARLIER [Tue, 20 Jul 2021 19:37:45 +0000 (20:37 +0100)] 
BUILD/MINOR: memprof fix macOs build.

this platform has a similar malloc_usable_size too.

3 years agoBUG/MINOR: mworker: do not export HAPROXY_MWORKER_REEXEC across programs
Willy Tarreau [Wed, 21 Jul 2021 08:17:02 +0000 (10:17 +0200)] 
BUG/MINOR: mworker: do not export HAPROXY_MWORKER_REEXEC across programs

This undocumented variable is only for internal use, and its sole
presence affects the process' behavior, as shown in bug #1324. It must
not be exported to workers, external checks, nor programs. Let's unset
it before forking programs and workers.

This should be backported as far as 1.8. The worker code might differ
a bit before 2.5 due to the recent removal of multi-process support.

3 years agoBUG/MEDIUM: mworker: do not register an exit handler if exit is expected
Willy Tarreau [Wed, 21 Jul 2021 08:01:36 +0000 (10:01 +0200)] 
BUG/MEDIUM: mworker: do not register an exit handler if exit is expected

The master-worker code registers an exit handler to deal with configuration
issues during reload, leading to a restart of the master process in wait
mode. But it shouldn't do that when it's expected that the program stops
during config parsing or condition checks, as the reload operation is
unexpectedly called and results in abnormal behavior and even crashes:

  $ HAPROXY_MWORKER_REEXEC=1  ./haproxy -W -c -f /dev/null
  Configuration file is valid
  [NOTICE]   (18418) : haproxy version is 2.5-dev2-ee2420-6
  [NOTICE]   (18418) : path to executable is ./haproxy
  [WARNING]  (18418) : config : Reexecuting Master process in waitpid mode
  Segmentation fault

  $ HAPROXY_MWORKER_REEXEC=1 ./haproxy -W -cc 1
  [NOTICE]   (18412) : haproxy version is 2.5-dev2-ee2420-6
  [NOTICE]   (18412) : path to executable is ./haproxy
  [WARNING]  (18412) : config : Reexecuting Master process in waitpid mode
  [WARNING]  (18412) : config : Reexecuting Master process

Note that the presence of this variable happens by accident when haproxy
is called from within its own programs (see issue #1324), but this should
be the object of a separate fix.

This patch fixes this by preventing the atexit registration in such
situations. This should be backported as far as 1.8. MODE_CHECK_CONDITION
has to be dropped for versions prior to 2.5.

3 years agoBUG/MEDIUM: cfgcond: limit recursion level in the condition expression parser
Willy Tarreau [Tue, 20 Jul 2021 15:58:34 +0000 (17:58 +0200)] 
BUG/MEDIUM: cfgcond: limit recursion level in the condition expression parser

Oss-fuzz reports in issue 36328 that we can recurse too far by passing
extremely deep expressions to the ".if" parser. I thought we were still
limited to the 1024 chars per line, that would be highly sufficient, but
we don't have any limit now :-/

Let's just pass a maximum recursion counter to the recursive parsers.
It's decremented for each call and the expression fails if it reaches
zero. On the most complex paths it can add 3 levels per parenthesis,
so with a limit of 1024, that's roughly 343 nested sub-expressions that
are supported in the worst case. That's more than sufficient, for just
a few kB of RAM.

No backport is needed.

3 years agoMINOR: deinit: always deinit the init_mutex on failed initialization
jenny-cheung [Sun, 18 Jul 2021 08:40:57 +0000 (16:40 +0800)] 
MINOR: deinit: always deinit the init_mutex on failed initialization

The init_mutex was not unlocked in case an error is encountered during
a thread initialization, and the polling loop was aborted during startup.
In practise it does not have any observable effect since an explicit
exit() is placed there, but it could confuse some debugging tools or
some static analysers, so let's release it as expected.

This addresses issue #1326.

3 years agoCLEANUP: http_ana: Remove now unused label from http_process_request()
Christopher Faulet [Mon, 19 Jul 2021 08:32:16 +0000 (10:32 +0200)] 
CLEANUP: http_ana: Remove now unused label from http_process_request()

Since last change on HTTP analysers (252412316 "MEDIUM: proxy: remove
long-broken 'option http_proxy'"), http_process_request() may only return
internal errors on failures. Thus the label used to handle bad requests may
be removed.

This patch should fix the issue #1330.

3 years agoMEDIUM: proxy: remove long-broken 'option http_proxy'
Willy Tarreau [Sun, 18 Jul 2021 17:18:56 +0000 (19:18 +0200)] 
MEDIUM: proxy: remove long-broken 'option http_proxy'

This option had always been broken in HTX, which means that the first
breakage appeared in 1.9, that it was broken by default in 2.0 and that
no workaround existed starting with 2.1. The way this option works is
praticularly unfit to the rest of the configuration and to the internal
architecture. It had some uses when it was introduced 14 years ago but
nowadays it's possible to do much better and more reliable using a
set of "http-request set-dst" and "http-request set-uri" rules, which
additionally are compatible with DNS resolution (via do-resolve) and
are not exclusive to normal load balancing. The "option-http_proxy"
example config file was updated to reflect this.

The option is still parsed so that an error message gives hints about
what to look for.

3 years agoBUG/MINOR: cfgcond: revisit the condition freeing mechanism to avoid a leak
Willy Tarreau [Sat, 17 Jul 2021 16:46:30 +0000 (18:46 +0200)] 
BUG/MINOR: cfgcond: revisit the condition freeing mechanism to avoid a leak

The cfg_free_cond_{term,and,expr}() functions used to take a pointer to
the pointer to be freed in order to replace it with a NULL once done.
But this doesn't cope well with freeing lists as it would require
recursion which the current code tried to avoid.

Let's just change the API to free the area and let the caller set the NULL.

This leak was reported by oss-fuzz (issue 36265).

3 years agoBUG/MINOR: arg: free all args on make_arg_list()'s error path
Willy Tarreau [Sat, 17 Jul 2021 16:36:43 +0000 (18:36 +0200)] 
BUG/MINOR: arg: free all args on make_arg_list()'s error path

While we do free the array containing the arguments, we do not free
allocated ones. Most of them are unresolved, but strings are allocated
and have to be freed as well. Note that for the sake of not breaking
the args resolution list that might have been set, we still refrain
from doing this if a resolution was already programmed, but for most
common cases (including the ones that can be found in config conditions
and at run time) we're safe.

This may be backported to stable branches, but it relies on the new
free_args() function that was introduced by commit ab213a5b6 ("MINOR:
arg: add a free_args() function to free an args array"), and which is
likely safe to backport as well.

This leak was reported by oss-fuzz (issue 36265).

3 years ago[RELEASE] Released version 2.5-dev2 v2.5-dev2
Willy Tarreau [Sat, 17 Jul 2021 10:35:11 +0000 (12:35 +0200)] 
[RELEASE] Released version 2.5-dev2

Released version 2.5-dev2 with the following main changes :
    - BUILD/MEDIUM: tcp: set-mark support for OpenBSD
    - DOC: config: use CREATE USER for mysql-check
    - BUG/MINOR: stick-table: fix several printf sign errors dumping tables
    - BUG/MINOR: peers: fix data_type bit computation more than 32 data_types
    - MINOR: stick-table: make skttable_data_cast to use only std types
    - MEDIUM: stick-table: handle arrays of standard types into stick-tables
    - MEDIUM: peers: handle arrays of std types in peers protocol
    - DOC: stick-table: add missing documentation about gpt0 stored type
    - MEDIUM: stick-table: add the new array of gpt data_type
    - MEDIUM: stick-table: make the use of 'gpt' excluding the use of 'gpt0'
    - MEDIUM: stick-table: add the new arrays of gpc and gpc_rate
    - MEDIUM: stick-table: make the use of 'gpc' excluding the use of 'gpc0/1''
    - BUG/MEDIUM: sock: make sure to never miss early connection failures
    - BUG/MINOR: cli: fix server name output in "show fd"
    - Revert "MINOR: tcp-act: Add set-src/set-src-port for "tcp-request content" rules"
    - MEDIUM: stats: include disabled proxies that hold active sessions to stats
    - BUILD: stick-table: shut up invalid "uninitialized" warning in gcc 8.3
    - MINOR: http: implement http_get_scheme
    - MEDIUM: http: implement scheme-based normalization
    - MEDIUM: h1-htx: apply scheme-based normalization on h1 requests
    - MEDIUM: h2: apply scheme-based normalization on h2 requests
    - REGTESTS: add http scheme-based normalization test
    - BUILD: http_htx: fix ci compilation error with isdigit for Windows
    - MINOR: http: implement http uri parser
    - MINOR: http: use http uri parser for scheme
    - MINOR: http: use http uri parser for authority
    - REORG: http_ana: split conditions for monitor-uri in wait for request
    - MINOR: http: use http uri parser for path
    - BUG/MEDIUM: http_ana: fix crash for http_proxy mode during uri rewrite
    - MINOR: mux_h2: define config to disable h2 websocket support
    - CLEANUP: applet: remove unused thread_mask
    - BUG/MINOR: ssl: Default-server configuration ignored by server
    - BUILD: add detection of missing important CFLAGS
    - BUILD: lua: silence a build warning with TCC
    - MINOR: srv: extract tracking server config function
    - MINOR: srv: do not allow to track a dynamic server
    - MEDIUM: server: support track keyword for dynamic servers
    - REGTESTS: test track support for dynamic servers
    - MINOR: init: verify that there is a single word on "-cc"
    - MINOR: init: make -cc support environment variables expansion
    - MINOR: arg: add a free_args() function to free an args array
    - CLEANUP: config: use free_args() to release args array in cfg_eval_condition()
    - CLEANUP: hlua: use free_args() to release args arrays
    - REORG: config: move the condition preprocessing code to its own file
    - MINOR: cfgcond: start to split the condition parser to introduce terms
    - MEDIUM: cfgcond: report invalid trailing chars after expressions
    - MINOR: cfgcond: remerge all arguments into a single line
    - MINOR: cfgcond: support negating conditional expressions
    - MINOR: cfgcond: make the conditional term parser automatically allocate nodes
    - MINOR: cfgcond: insert an expression between the condition and the term
    - MINOR: cfgcond: support terms made of parenthesis around expressions
    - REGTEST: make check_condition.vtc fail as soon as possible
    - REGTESTS: add more complex check conditions to check_conditions.vtc
    - BUG/MEDIUM: init: restore behavior of command-line "-m" for memory limitation

3 years agoBUG/MEDIUM: init: restore behavior of command-line "-m" for memory limitation
Willy Tarreau [Sat, 17 Jul 2021 10:31:08 +0000 (12:31 +0200)] 
BUG/MEDIUM: init: restore behavior of command-line "-m" for memory limitation

The removal for the shared inter-process cache in commit 6fd0450b4
("CLEANUP: shctx: remove the different inter-process locking techniques")
accidentally removed the enforcement of rlimit_memmax_all which
corresponds to what is passed to the command-line "-m" argument.
Let's restore it.

Thanks to @nafets227 for spotting this. This fixes github issue #1319.

3 years agoREGTESTS: add more complex check conditions to check_conditions.vtc
Willy Tarreau [Sat, 17 Jul 2021 08:43:33 +0000 (10:43 +0200)] 
REGTESTS: add more complex check conditions to check_conditions.vtc

Now that we support logic expressions, variables and parenthesis, let's
add a few more tests to check_conditions.vtc. The tests are conditionned
by the version being at least 2.5-dev2 so that it will not cause failures
during a possible later bisect session or if backported.

The test verifies that exported variables are seen, that operators precedence
works as expected, that parenthesis work at least through two levels, that an
empty condition is false while a negative number is true, and that extraneous
chars in an expression, or unfinished strings are properly caught.

3 years agoREGTEST: make check_condition.vtc fail as soon as possible
Willy Tarreau [Sat, 17 Jul 2021 08:54:46 +0000 (10:54 +0200)] 
REGTEST: make check_condition.vtc fail as soon as possible

The test consists in a sequence of shell commands, but the shell is not
necessarily started with strict errors enabled, so only the last command
provides the verdict. Let's add "set -e" to make it fail on the first
test that fails.

3 years agoMINOR: cfgcond: support terms made of parenthesis around expressions
Willy Tarreau [Fri, 16 Jul 2021 12:56:59 +0000 (14:56 +0200)] 
MINOR: cfgcond: support terms made of parenthesis around expressions

Now it's possible to form a term using parenthesis around an expression.
This will soon allow to build more complex expressions. For now they're
still pretty limited but parenthesis do work.

3 years agoMINOR: cfgcond: insert an expression between the condition and the term
Willy Tarreau [Fri, 16 Jul 2021 12:46:09 +0000 (14:46 +0200)] 
MINOR: cfgcond: insert an expression between the condition and the term

Now evaluating a condition will rely on an expression (or an empty string),
and this expression will support ORing a sub-expression with another
optional expression. The sub-expressions ANDs a term with another optional
sub-expression. With this alone precedence between && and || is respected,
and the following expression:

     A && B && C || D || E && F || G

will naturally evaluate as:

     (A && B && C) || D || (E && F) || G

3 years agoMINOR: cfgcond: make the conditional term parser automatically allocate nodes
Willy Tarreau [Fri, 16 Jul 2021 12:27:20 +0000 (14:27 +0200)] 
MINOR: cfgcond: make the conditional term parser automatically allocate nodes

It's not convenient to let the caller be responsible for node allocation,
better have the leaf function do that and implement the accompanying free
call. Now only a pointer is needed instead of a struct, and the leaf
function makes sure to leave the situation in a consistent way.

3 years agoMINOR: cfgcond: support negating conditional expressions
Willy Tarreau [Fri, 16 Jul 2021 11:56:54 +0000 (13:56 +0200)] 
MINOR: cfgcond: support negating conditional expressions

Now preceeding a config condition term with "!" will simply negate it.
Example:

   .if !feature(OPENSSL)
       .alert "SSL support is mandatory"
   .endif

3 years agoMINOR: cfgcond: remerge all arguments into a single line
Willy Tarreau [Fri, 16 Jul 2021 14:38:58 +0000 (16:38 +0200)] 
MINOR: cfgcond: remerge all arguments into a single line

Till now we were dealing with single-word expressions but in order to
extend the configuration condition language a bit more, we'll need to
support slightly more complex expressions involving operators, and we
must absolutely support spaces around them to keep them readable.

As all arguments are pointers to the same line with spaces replaced by
zeroes, we can trivially rebuild the whole line before calling the
condition evaluator, and remove the test for extraneous argument. This
is what this patch does.

3 years agoMEDIUM: cfgcond: report invalid trailing chars after expressions
Willy Tarreau [Fri, 16 Jul 2021 14:18:03 +0000 (16:18 +0200)] 
MEDIUM: cfgcond: report invalid trailing chars after expressions

Random characters placed after a configuration predicate currently do
not report an error. This is a problem because extra parenthesis,
commas or even other random left-over chars may accidently appear there.
Let's now report an error when this happens.

This is marked MEDIUM because it may break otherwise working configs
which are faulty.

3 years agoMINOR: cfgcond: start to split the condition parser to introduce terms
Willy Tarreau [Fri, 16 Jul 2021 10:12:00 +0000 (12:12 +0200)] 
MINOR: cfgcond: start to split the condition parser to introduce terms

The purpose is to build a descendent parser that will split conditions
into expressions made of terms. There are two phases, a parsing phase
and an evaluation phase. Strictly speaking it's not required to cut
that in two right now, but it's likely that in the future we won't want
certain predicates to be evaluated during the parsing (e.g. file system
checks or execution of some external commands).

The cfg_eval_condition() function is now much simpler, it just tries to
parse a single term, and if OK evaluates it, then returns the result.
Errors are unchanged and may still be reported during parsing or
evaluation.

It's worth noting that some invalid expressions such as streq(a,b)zzz
continue to parse correctly for now (what remains after the parenthesis
is simply ignored as not necessary).

3 years agoREORG: config: move the condition preprocessing code to its own file
Willy Tarreau [Fri, 16 Jul 2021 13:39:28 +0000 (15:39 +0200)] 
REORG: config: move the condition preprocessing code to its own file

The .if/.else/.endif and condition evaluation code is quite dirty and
was dumped into cfgparse.c because it was easy. But it should be tidied
quite a bit as it will need to evolve.

Let's move all that to cfgcond.{c,h}.

3 years agoCLEANUP: hlua: use free_args() to release args arrays
Willy Tarreau [Fri, 16 Jul 2021 08:26:56 +0000 (10:26 +0200)] 
CLEANUP: hlua: use free_args() to release args arrays

Argument arrays used in hlua_lua2arg_check() as well as in the functions
used to call sample fetches and converters were manually released, let's
use the cleaner and more reliable free_args() instead. The prototype of
hlua_lua2arg_check() was amended to mention that the function relies on
the final ARGT_STOP, which is already the case, and the pointless test
for this was removed.

3 years agoCLEANUP: config: use free_args() to release args array in cfg_eval_condition()
Willy Tarreau [Fri, 16 Jul 2021 08:26:09 +0000 (10:26 +0200)] 
CLEANUP: config: use free_args() to release args array in cfg_eval_condition()

Doing so is cleaner than open-coding it and will support future extensions.

3 years agoMINOR: arg: add a free_args() function to free an args array
Willy Tarreau [Fri, 16 Jul 2021 08:13:00 +0000 (10:13 +0200)] 
MINOR: arg: add a free_args() function to free an args array

make_arg_list() can create an array of arguments, some of which remain
to be resolved, but all users had to deal with their own roll back on
error. Let's add a free_args() function to release all the array's
elements and let the caller deal with the array itself (sometimes it's
allocated in the stack).

3 years agoMINOR: init: make -cc support environment variables expansion
Willy Tarreau [Fri, 16 Jul 2021 17:14:54 +0000 (19:14 +0200)] 
MINOR: init: make -cc support environment variables expansion

I found myself a few times testing some conditoin examples from the doc
against command line's "-cc" to see that they didn't work with environment
variables expansion. Not being documented as being on purpose it looks like
a miss, so let's add PARSE_OPT_ENV and PARSE_OPT_WORD_EXPAND to be able to
test for example -cc "streq(${WITH_SSL},yes)" to help debug expressions.

3 years agoMINOR: init: verify that there is a single word on "-cc"
Willy Tarreau [Fri, 16 Jul 2021 14:36:05 +0000 (16:36 +0200)] 
MINOR: init: verify that there is a single word on "-cc"

This adds the exact same restriction as commit 5546c8bdc ("MINOR:
cfgparse: Fail when encountering extra arguments in macro") but for
the "-cc" command line argument, for the sake of consistency.

3 years agoREGTESTS: test track support for dynamic servers
Amaury Denoyelle [Thu, 15 Jul 2021 09:23:17 +0000 (11:23 +0200)] 
REGTESTS: test track support for dynamic servers

Create a regtest for the 'track' keyword support by dynamic servers.

First checks are executed to ensure that tracking cannot be activated on
non-check server or dynamic servers.

Then, 3 scenarii are written to ensure that the deletion of a dynamic
server with track is properly handled and other servers in the track
chain are properly maintained.

3 years agoMEDIUM: server: support track keyword for dynamic servers
Amaury Denoyelle [Tue, 13 Jul 2021 08:36:03 +0000 (10:36 +0200)] 
MEDIUM: server: support track keyword for dynamic servers

Allow the usage of the 'track' keyword for dynamic servers. On server
deletion, the server is properly removed from the tracking chain to
prevents NULL pointer dereferencing.

3 years agoMINOR: srv: do not allow to track a dynamic server
Amaury Denoyelle [Tue, 13 Jul 2021 08:35:50 +0000 (10:35 +0200)] 
MINOR: srv: do not allow to track a dynamic server

Prevents the use of the "track" keyword for a dynamic server. This
simplifies the deletion of a dynamic server, without having to worry
about servers which might tracked it.

A BUG_ON is present in the dynamic server delete function to validate
this assertion.

3 years agoMINOR: srv: extract tracking server config function
Amaury Denoyelle [Tue, 13 Jul 2021 08:35:23 +0000 (10:35 +0200)] 
MINOR: srv: extract tracking server config function

Extract the post-config tracking setup in a dedicated function
srv_apply_track. This will be useful to implement track support for
dynamic servers.

3 years agoBUILD: lua: silence a build warning with TCC
Willy Tarreau [Wed, 14 Jul 2021 17:41:25 +0000 (19:41 +0200)] 
BUILD: lua: silence a build warning with TCC

TCC doesn't have the equivalent of __builtin_unreachable() and complains
that hlua_panic_ljmp() may return no value. Let's add a return 0 there.
All compilers that know that longjmp() doesn't return will see no change
and tcc will be happy.

3 years agoBUILD: add detection of missing important CFLAGS
Willy Tarreau [Wed, 14 Jul 2021 15:54:01 +0000 (17:54 +0200)] 
BUILD: add detection of missing important CFLAGS

Modern compilers love to break existing code, and some options detected
at build time (such as -fwrapv) are absolutely critical otherwise some
bad code can be generated.

Given that some users rely on packages that force CFLAGS without being
aware of this and can be hit by runtime bugs, we have to help packagers
figure that they need to be careful about their build options.

The test here consists in detecting correct wrapping of signed integers.
Some of the old code relies on it, and modern compilers recently decided
to break it. It's normally addressed using -fwrapv which users will
rarely enforce in their own flags. Thus it is a good indicator of missing
critical CFLAGS, and it happens to be very easy to detect at run time.
Note that the test uses argc in order to have a variable. While gcc
ignores wrapping even for constants, clang only ignores it for variables.
The way the code is constructed doesn't result in code being emitted for
optimized builds thanks to value range propagation.

This should address GitHub issue #1315, and should be backported to all
stable versions. It may result in instantly breaking binaries that seemed
to work fine (typically the ones suddenly showing a busy loop after a few
weeks of uptime), and require packagers to fix their flags. The vast
majority of distro packages are fine and will not be affected though.

4 years agoBUG/MINOR: ssl: Default-server configuration ignored by server
Remi Tricot-Le Breton [Tue, 13 Jul 2021 16:28:22 +0000 (18:28 +0200)] 
BUG/MINOR: ssl: Default-server configuration ignored by server

When a default-server line specified a client certificate to use, the
frontend would not take it into account and create an empty SSL context,
which would raise an error on the backend side ("peer did not return a
certificate").

This bug was introduced by d817dc733eacfd7cf5bb0bbc6128f44644db078e in
which the SSL contexts are created earlier than before (during the
default-server line parsing) without setting it in the corresponding
server structures. It then made the server create an empty SSL context
in ssl_sock_prepare_srv_ctx because it thought it needed one.

It was raised on redmine, in Bug #3906.

It can be backported to 2.4.

4 years agoCLEANUP: applet: remove unused thread_mask
Willy Tarreau [Tue, 13 Jul 2021 16:01:46 +0000 (18:01 +0200)] 
CLEANUP: applet: remove unused thread_mask

Since 1.9 with commit 673867c35 ("MAJOR: applets: Use tasks, instead
of rolling our own scheduler.") the thread_mask field of the appctx
became unused, but the code hadn't been cleaned for this. The appctx
has its own task and the task's thread_mask is the one to be displayed.

It's worth noting that all calls to appctx_new() pass tid_bit as the
thread_mask. This makes sense, and it could be convenient to decide
that this becomes the norm and to simplify the API.

4 years agoMINOR: mux_h2: define config to disable h2 websocket support
Amaury Denoyelle [Fri, 9 Jul 2021 15:14:30 +0000 (17:14 +0200)] 
MINOR: mux_h2: define config to disable h2 websocket support

Define a new global config statement named
"h2-workaround-bogus-websocket-clients".

This statement will disable the automatic announce of h2 websocket
support as specified in the RFC8441. This can be use to overcome clients
which fail to implement the relatively fresh RFC8441. Clients will in
his case automatically downgrade to http/1.1 for the websocket tunnel
if the haproxy configuration allows it.

This feature is relatively simple and can be backported up to 2.4, which
saw the introduction of h2 websocket support.

4 years agoBUG/MEDIUM: http_ana: fix crash for http_proxy mode during uri rewrite
Amaury Denoyelle [Thu, 8 Jul 2021 15:27:01 +0000 (17:27 +0200)] 
BUG/MEDIUM: http_ana: fix crash for http_proxy mode during uri rewrite

Fix the wrong usage of http_uri_parser which is defined with an
uninitialized uri. This causes a crash which happens when forwarding a
request to a backend configured in plain proxy ('option http_proxy').

This has been reported through a clang warning on the CI.

This bug has been introduced by the refactoring of URI parser API.
  c453f9547e14c563f7bdf03d68979a5083c0372b
  MINOR: http: use http uri parser for path
This does not need to be backported.

WARNING: although this patch fix the crash, the 'option http_proxy'
seems to be non buggy, possibly since quite a few stable versions.
Indeed, the URI rewriting is not functional : the path is written on the
beginning of the URI but the rest of the URI is not and this garbage is
passed to the server which does not understand the request.

4 years agoMINOR: http: use http uri parser for path
Amaury Denoyelle [Tue, 6 Jul 2021 09:40:12 +0000 (11:40 +0200)] 
MINOR: http: use http uri parser for path

Replace http_get_path by the http_uri_parser API. The new functions is
renamed http_parse_path. Replace duplicated code for scheme and
authority parsing by invocations to http_parse_scheme/authority.

If no scheme is found for an URI detected as an absolute-uri/authority,
consider it to be an authority format : no path will be found. For an
absolute-uri or absolute-path, use the remaining of the string as the
path. A new http_uri_parser state is declared to mark the path parsing
as done.

4 years agoREORG: http_ana: split conditions for monitor-uri in wait for request
Amaury Denoyelle [Tue, 6 Jul 2021 09:23:10 +0000 (11:23 +0200)] 
REORG: http_ana: split conditions for monitor-uri in wait for request

Split in two the condition which check if the monitor-uri is set for the
current request. This will allow to easily use the http_uri_parser type
for http_get_path.

4 years agoMINOR: http: use http uri parser for authority
Amaury Denoyelle [Tue, 6 Jul 2021 09:02:22 +0000 (11:02 +0200)] 
MINOR: http: use http uri parser for authority

Replace http_get_authority by the http_uri_parser API.

The new function is renamed http_parse_authority. Replace duplicated
scheme parsing code by http_parse_scheme invocation. A new
http_uri_parser state is declared to mark the authority parsing as done.

4 years agoMINOR: http: use http uri parser for scheme
Amaury Denoyelle [Tue, 6 Jul 2021 08:52:58 +0000 (10:52 +0200)] 
MINOR: http: use http uri parser for scheme

Replace http_get_scheme by the http_uri_parser API. The new function is
renamed http_parse_scheme. A new http_uri_parser state is declared to
mark the scheme parsing as completed.

4 years agoMINOR: http: implement http uri parser
Amaury Denoyelle [Tue, 6 Jul 2021 08:48:44 +0000 (10:48 +0200)] 
MINOR: http: implement http uri parser

Implement a http uri parser type. This type will be used as a context to
parse the various elements of an uri.

The goal of this serie of patches is to factorize duplicated code
between the http_get_scheme/authority/path functions. A simple parsing
API is designed to be able to extract once each element of an HTTP URI
in order. The functions will be renamed in the following patches to
reflect the API change with the prefix http_parse_*.

For the parser API, the http_uri_parser type must first be
initialized before usage. It will register the URI to parse and detect
its format according to the rfc 7230.

4 years agoBUILD: http_htx: fix ci compilation error with isdigit for Windows
Amaury Denoyelle [Wed, 7 Jul 2021 15:17:39 +0000 (17:17 +0200)] 
BUILD: http_htx: fix ci compilation error with isdigit for Windows

The warning is encountered on platforms for which char type is signed by
default.

cf the following links
https://stackoverflow.com/questions/10186219/array-subscript-has-type-char

This must be backported up to 2.4.

4 years agoREGTESTS: add http scheme-based normalization test
Amaury Denoyelle [Wed, 7 Jul 2021 08:49:29 +0000 (10:49 +0200)] 
REGTESTS: add http scheme-based normalization test

This test ensure that http scheme-based normalization is properly
applied on target URL and host header. It uses h2 clients as it is not
possible to specify an absolute url for h1 vtc clients.

4 years agoMEDIUM: h2: apply scheme-based normalization on h2 requests
Amaury Denoyelle [Wed, 7 Jul 2021 08:49:28 +0000 (10:49 +0200)] 
MEDIUM: h2: apply scheme-based normalization on h2 requests

Apply the rfc 3986 scheme-based normalization on h2 requests. This
process will be executed for most of requests because scheme and
authority are present on every h2 requests, except CONNECT. However, the
normalization will only be applied on requests with defaults http port
(http/80 or https/443) explicitly specified which most http clients
avoid.

This change is notably useful for http2 websockets with Firefox which
explicitly specify the 443 default port on Extended CONNECT. In this
case, users can be trapped if they are using host routing without
removing the port. With the scheme-based normalization, the default port
will be removed.

To backport this change, it is required to backport first the following
commits:
* MINOR: http: implement http_get_scheme
* MEDIUM: http: implement scheme-based normalization

4 years agoMEDIUM: h1-htx: apply scheme-based normalization on h1 requests
Amaury Denoyelle [Wed, 7 Jul 2021 08:49:27 +0000 (10:49 +0200)] 
MEDIUM: h1-htx: apply scheme-based normalization on h1 requests

Apply the rfc 3986 scheme-based normalization on h1 requests. It is
executed only for requests which uses absolute-form target URI, which is
not the standard case.

4 years agoMEDIUM: http: implement scheme-based normalization
Amaury Denoyelle [Wed, 7 Jul 2021 08:49:26 +0000 (10:49 +0200)] 
MEDIUM: http: implement scheme-based normalization

Implement the scheme-based uri normalization as described in rfc3986
6.3.2. Its purpose is to remove the port of an uri if the default one is
used according to the uri scheme : 80/http and 443/https. All other
ports are not touched.

This method uses an htx message as an input. It requires that the target
URI is in absolute-form with a http/https scheme. This represents most
of h2 requests except CONNECT. On the contrary, most of h1 requests
won't be elligible as origin-form is the standard case.

The normalization is first applied on the target URL of the start line.
Then, it is conducted on every Host headers present, assuming that they
are equivalent to the target URL.

This change will be notably useful to not confuse users who are
accustomed to use the host for routing without specifying default ports.
This problem was recently encountered with Firefox which specify the 443
default port for http2 websocket Extended CONNECT.

4 years agoMINOR: http: implement http_get_scheme
Amaury Denoyelle [Wed, 7 Jul 2021 08:49:25 +0000 (10:49 +0200)] 
MINOR: http: implement http_get_scheme

This method can be used to retrieve the scheme part of an uri, with the
suffix '://'. It will be useful to implement scheme-based normalization.

4 years agoBUILD: stick-table: shut up invalid "uninitialized" warning in gcc 8.3
Willy Tarreau [Tue, 6 Jul 2021 16:51:12 +0000 (18:51 +0200)] 
BUILD: stick-table: shut up invalid "uninitialized" warning in gcc 8.3

gcc 8.3.0 spews a bunch of:

  src/stick_table.c: In function 'action_inc_gpc0':
  include/haproxy/freq_ctr.h:66:12: warning: 'period' may be used uninitialized in this function [-Wmaybe-uninitialized]
    curr_tick += period;
            ^~
  src/stick_table.c:2241:15: note: 'period' was declared here
    unsigned int period;
               ^~~~~~
but they're incorrect because all accesses are guarded by the exact same
condition (ptr1 not being null), it's just the compiler being overzealous
about the uninitialized detection that seems to be stronger than its
ability to follow its own optimizations. This code path is not critical,
let's just pre-initialize the period to zero.

No backport is needed.

4 years agoMEDIUM: stats: include disabled proxies that hold active sessions to stats
Marno Krahmer [Thu, 24 Jun 2021 14:51:08 +0000 (16:51 +0200)] 
MEDIUM: stats: include disabled proxies that hold active sessions to stats

After reloading HAProxy, the old process may still hold active sessions.
Currently there is no way to gather information, how many sessions such
a process still holds. This patch will not exclude disabled proxies from
stats output when they hold at least one active session. This will allow
sending `!@<PID> show stat` through a master socket to the disabled
process and have it returning its stats data.

4 years agoRevert "MINOR: tcp-act: Add set-src/set-src-port for "tcp-request content" rules"
Christopher Faulet [Tue, 6 Jul 2021 09:25:36 +0000 (11:25 +0200)] 
Revert "MINOR: tcp-act: Add set-src/set-src-port for "tcp-request content" rules"

This reverts commit 19bbbe05629ea947dd60d5b96d96f0066b047b97.

For now, set-src/set-src-port actions are directly performed on the client
connection. Using these actions at the stream level is really a problem with
HTTP connection (See #90) because all requests are affected by this change
and not only the current request. And it is worse with the H2, because
several requests can set their source address into the same connection at
the same time.

It is already an issue when these actions are called from "http-request"
rules. It is safer to wait a bit before adding the support to "tcp-request
content" rules. The solution is to be able to set src/dst address on the
stream and not on the connection when the action if performed from the L7
level..

Reverting the above commit means the issue #1303 is no longer fixed.

This patch must be backported in all branches containing the above commit
(as far as 2.0 for now).

4 years agoBUG/MINOR: cli: fix server name output in "show fd"
Willy Tarreau [Tue, 6 Jul 2021 09:41:10 +0000 (11:41 +0200)] 
BUG/MINOR: cli: fix server name output in "show fd"

A server name was displayed as <srv>/<proxy> instead of the reverse.
It only confuses diagnostics. This was introduced by commit 7a4a0ac71
("MINOR: cli: add a new "show fd" command") so this fix can be backport
down to 1.8.

4 years agoBUG/MEDIUM: sock: make sure to never miss early connection failures
Willy Tarreau [Tue, 6 Jul 2021 06:29:20 +0000 (08:29 +0200)] 
BUG/MEDIUM: sock: make sure to never miss early connection failures

As shown in issue #1251, it is possible for a connect() to report an
error directly via the poller without ever reporting send readiness,
but currentlt sock_conn_check() manages to ignore that situation,
leading to high CPU usage as poll() wakes up on these FDs.

The bug was apparently introduced in 1.5-dev22 with commit fd803bb4d
("MEDIUM: connection: add check for readiness in I/O handlers"), but
was likely only woken up by recent changes to conn_fd_handler() that
made use of wakeups instead of direct calls between 1.8 and 1.9,
voiding any chance to catch such errors in the early recv() callback.

The exact sequence that leads to this situation remains obscure though
because the poller does not report send readiness nor does it report an
error. Only HUP and IN are reported on the FD. It is also possible that
some recent kernel updates made this condition appear while it never
used to previously.

This needs to be backported to all stable branches, at least as far
as 2.0. Before 2.2 the code was in tcp_connect_probe() in proto_tcp.c.

4 years agoMEDIUM: stick-table: make the use of 'gpc' excluding the use of 'gpc0/1''
Emeric Brun [Wed, 30 Jun 2021 17:06:43 +0000 (19:06 +0200)] 
MEDIUM: stick-table: make the use of 'gpc' excluding the use of 'gpc0/1''

This patch makes the use of 'gpc' excluding the use of the legacy
types 'gpc0' and 'gpc1" on the same table.

It also makes the use of 'gpc_rate' excluding the use of the legacy
types 'gpc0_rate' and 'gpc1_rate" on the same table.

The 'gpc0' and 'gpc1' related fetches and actions will apply
to the first two elements of the 'gpc' array if stored in table.

The 'gpc0_rate' and 'gpc1_rate' related fetches and actions will apply
to the first two elements of the 'gpc_rate' array if stored in table.

4 years agoMEDIUM: stick-table: add the new arrays of gpc and gpc_rate
Emeric Brun [Wed, 30 Jun 2021 17:04:16 +0000 (19:04 +0200)] 
MEDIUM: stick-table: add the new arrays of gpc and gpc_rate

This patch adds the definition of two new array data_types:
'gpc': This is an array of 32bits General Purpose Counters.
'gpc_rate': This is an array on increment rates of General Purpose Counters.

Like for all arrays, they are limited to 100 elements.

This patch also adds actions and fetches to handle
elements of those arrays.

Note: As documented, those new actions and fetches won't
apply to the legacy 'gpc0', 'gpc1', 'gpc0_rate' nor 'gpc1_rate'.

4 years agoMEDIUM: stick-table: make the use of 'gpt' excluding the use of 'gpt0'
Emeric Brun [Wed, 30 Jun 2021 16:58:22 +0000 (18:58 +0200)] 
MEDIUM: stick-table: make the use of 'gpt' excluding the use of 'gpt0'

This patch makes the use of 'gpt' excluding the use of the legacy
type 'gpt0' on the same table.

It also makes the 'gpt0' related fetches and actions applying
to the first element of the 'gpt' array if stored in table.

4 years agoMEDIUM: stick-table: add the new array of gpt data_type
Emeric Brun [Wed, 30 Jun 2021 16:57:49 +0000 (18:57 +0200)] 
MEDIUM: stick-table: add the new array of gpt data_type

This patch adds the definition of a new array data_type
'gpt'. This is an array of 32bits General Purpose Tags.

Like for all arrays, it is limited to 100 elements.

This patch also adds actions and fetches to handle
elements of this array.

Note: As documented, those new actions and fetches won't
apply to the legacy 'gpt0' data type.

4 years agoDOC: stick-table: add missing documentation about gpt0 stored type
Emeric Brun [Thu, 1 Jul 2021 16:34:48 +0000 (18:34 +0200)] 
DOC: stick-table: add missing documentation about gpt0 stored type

The store type 'gpt0' was present in code but was not documented.

The patch fix this and should be backported since 'gpt0' is supported.
[wt: ~1.6-dev4 hence all stable]

4 years agoMEDIUM: peers: handle arrays of std types in peers protocol
Emeric Brun [Tue, 22 Jun 2021 14:09:55 +0000 (16:09 +0200)] 
MEDIUM: peers: handle arrays of std types in peers protocol

This patch adds support of array data_types on the peer protocol.

The table definition message will provide an additionnal parameter
for array data-types: the number of elements of the array.

In case of array of frqp it also provides a second parameter:
the period used to compute freq counter.

The array elements are std_type values linearly encoded in
the update message.

Note: if a remote peer announces an array data_type without
parameters into the table definition message, all updates
on this table will be ignored because we can not
parse update messages consistently.

4 years agoMEDIUM: stick-table: handle arrays of standard types into stick-tables
Emeric Brun [Wed, 30 Jun 2021 16:01:02 +0000 (18:01 +0200)] 
MEDIUM: stick-table: handle arrays of standard types into stick-tables

This patch provides the code to handle arrays of some
standard types (SINT, UINT, ULL and FRQP) in stick table.

This way we could define new "array" data types.

Note: the number of elements of an array was limited
to 100 to put a limit and to ensure that an encoded
update message will continue to fit into a buffer
when the peer protocol will handle such data types.

4 years agoMINOR: stick-table: make skttable_data_cast to use only std types
Emeric Brun [Wed, 30 Jun 2021 15:18:28 +0000 (17:18 +0200)] 
MINOR: stick-table: make skttable_data_cast to use only std types

This patch replaces all advanced data type aliases on
stktable_data_cast calls by standard types.

This way we could call the same stktable_data_cast
regardless of the used advanced data type as long they
are using the same std type.

It also removes all the advanced data type aliases.

4 years agoBUG/MINOR: peers: fix data_type bit computation more than 32 data_types
Emeric Brun [Thu, 1 Jul 2021 16:54:05 +0000 (18:54 +0200)] 
BUG/MINOR: peers: fix data_type bit computation more than 32 data_types

This patch fixes the computation of the bit of the current data_type
in some part of code of peer protocol where the computation is limited
to 32bits whereas the bitfield of data_types can support 64bits.

Without this patch it could result in bugs when we will define more
than 32 data_types.

Backport is useless because there is currently less than 32 data_types

4 years agoBUG/MINOR: stick-table: fix several printf sign errors dumping tables
Emeric Brun [Wed, 30 Jun 2021 14:24:04 +0000 (16:24 +0200)] 
BUG/MINOR: stick-table: fix several printf sign errors dumping tables

This patch fixes several errors printing integers
of stick table entry values and args during dump on cli.

This patch should be backported since the dump of entries
is supported.  [wt: roughly 1.5-dev1 hence all stable branches]

4 years agoDOC: config: use CREATE USER for mysql-check
Daniel Black [Thu, 1 Jul 2021 02:09:32 +0000 (12:09 +1000)] 
DOC: config: use CREATE USER for mysql-check

CREATE USER has been the standard way of creating users since
MySQL-5.0 (2005).

The current syntax of INSERT INTO mysql.user won't actually work
on MariaDB-10.4+.

Because haproxy doesn't use any resources the MySQL executable comment
syntax provides resource contraints to make it more palatable
to risk adverse users.

/*!50701 is a syntax recognised by MySQL and MariaDB 5.7.1+ when
resource contraints where added.

/*M!100201 is a MariaDB executable comment syntax recognised for MariaDB
for the 10.2.1 where the MAX_STATEMENT_TIME was added.

This patch may be backported as far as 2.0.

4 years agoBUILD/MEDIUM: tcp: set-mark support for OpenBSD
David Carlier [Sat, 3 Jul 2021 09:15:15 +0000 (10:15 +0100)] 
BUILD/MEDIUM: tcp: set-mark support for OpenBSD

set-mark support for this platform, for routing table purpose.
Follow-up from f7f53afcf9d367d19, this time for OpenBSD.

4 years ago[RELEASE] Released version 2.5-dev1 v2.5-dev1
Willy Tarreau [Wed, 30 Jun 2021 14:16:14 +0000 (16:16 +0200)] 
[RELEASE] Released version 2.5-dev1

Released version 2.5-dev1 with the following main changes :
    - CLEANUP: ssl: Move ssl_store related code to ssl_ckch.c
    - MINOR: ssl: Allow duplicated entries in the cafile_tree
    - MEDIUM: ssl: Chain ckch instances in ca-file entries
    - MINOR: ssl: Add reference to default ckch instance in bind_conf
    - MINOR: ssl: Add helper functions to create/delete cafile entries
    - MEDIUM: ssl: Add a way to load a ca-file content from memory
    - MINOR: ssl: Add helper function to add cafile entries
    - MINOR: ssl: Ckch instance rebuild and cleanup factorization in CLI handler
    - MEDIUM: ssl: Add "set+commit ssl ca-file" CLI commands
    - REGTESTS: ssl: Add new ca-file update tests
    - MINOR: ssl: Add "abort ssl ca-file" CLI command
    - MINOR: ssl: Add a cafile_entry type field
    - MINOR: ssl: Refactorize the "show certificate details" code
    - MEDIUM: ssl: Add "show ssl ca-file" CLI command
    - MEDIUM: ssl: Add "new ssl ca-file" CLI command
    - MINOR: ssl: Add "del ssl ca-file" CLI command
    - REGTESTS: ssl: Add "new/del ssl ca-file" tests
    - DOC: ssl: Add documentation about CA file hot update commands
    - DOC: internals: update the SSL architecture schema
    - MINOR: ssl: Chain instances in ca-file entries
    - MEDIUM: ssl: Add "set+commit ssl crl-file" CLI commands
    - MEDIUM: ssl: Add "new+del crl-file" CLI commands
    - MINOR: ssl: Add "abort ssl crl-file" CLI command
    - MEDIUM: ssl: Add "show ssl crl-file" CLI command
    - REGTESTS: ssl: Add "new/del ssl crl-file" tests
    - REGTESTS: ssl: Add "set/commit ssl crl-file" test
    - DOC: ssl: Add documentation about CRL file hot update commands
    - BUILD/MINOR: ssl: Fix compilation with SSL enabled
    - BUILD/MINOR: ssl: Fix compilation with OpenSSL 1.0.2
    - CI: introduce scripts/build-vtest.sh for installing VTest
    - CLEANUP: ssl: Fix coverity issues found in CA file hot update code
    - CI: github actions: add OpenTracing builds
    - BUG/MEDIUM: ebtree: Invalid read when looking for dup entry
    - BUG/MAJOR: server: prevent deadlock when using 'set maxconn server'
    - BUILD/MINOR: opentracing: fixed build when using clang
    - BUG/MEDIUM: filters: Exec pre/post analysers only one time per filter
    - BUG/MINOR: http-comp: Preserve HTTP_MSGF_COMPRESSIONG flag on the response
    - MINOR: map/acl: print the count of all the map/acl entries in "show map/acl"
    - CLEANUP: pattern: remove export of non-existent function pattern_delete()
    - MINOR: h1-htx: Update h1 parsing functions to return result as a size_t
    - MEDIUM: h1-htx: Adapt H1 data parsing to copy wrapping data in one call
    - MINOR: mux-h1/mux-fcgi: Don't needlessly loop on data parsing
    - MINOR: h1-htx: Move HTTP chunks parsing into a dedicated function
    - MEDIUM: h1-htx: Split function to parse a chunk and the loop on the buffer
    - MEDIUM: h1-htx: Add a function to parse contiguous small chunks
    - MINOR: h1-htx: Use a correlation table to speed-up small chunks parsing
    - MINOR: buf: Add function to realign a buffer with a specific head position
    - MINOR: muxes/h1-htx: Realign input buffer using b_slow_realign_ofs()
    - CLEANUP: mux-h1: Rename functions parsing input buf and filling output buf
    - Revert "MEDIUM: http-ana: Deal with L7 retries in HTTP analysers"
    - BUG/MINOR: http-ana: Send the right error if max retries is reached on L7 retry
    - BUG/MINOR: http-ana: Handle L7 retries on refused early data before K/A aborts
    - MINOR: http-ana: Perform L7 retries because of status codes in response analyser
    - MINOR: cfgparse: Fail when encountering extra arguments in macro
    - DOC: intro: Fix typo in starter guide
    - BUG/MINOR: server: Missing calloc return value check in srv_parse_source
    - BUG/MINOR: peers: Missing calloc return value check in peers_register_table
    - BUG/MINOR: ssl: Missing calloc return value check in ssl_init_single_engine
    - BUG/MINOR: http: Missing calloc return value check in parse_http_req_capture
    - BUG/MINOR: proxy: Missing calloc return value check in proxy_parse_declare
    - BUG/MINOR: proxy: Missing calloc return value check in proxy_defproxy_cpy
    - BUG/MINOR: http: Missing calloc return value check while parsing tcp-request/tcp-response
    - BUG/MINOR: http: Missing calloc return value check while parsing tcp-request rule
    - BUG/MINOR: compression: Missing calloc return value check in comp_append_type/algo
    - BUG/MINOR: worker: Missing calloc return value check in mworker_env_to_proc_list
    - BUG/MINOR: http: Missing calloc return value check while parsing redirect rule
    - BUG/MINOR: http: Missing calloc return value check in make_arg_list
    - BUG/MINOR: proxy: Missing calloc return value check in chash_init_server_tree
    - CLEANUP: http-ana: Remove useless if statement about L7 retries
    - BUG/MAJOR: stream-int: Release SI endpoint on server side ASAP on retry
    - MINOR: backend: Don't release SI endpoint anymore in connect_server()
    - BUG/MINOR: vars: Be sure to have a session to get checks variables
    - DOC/MINOR: move uuid in the configuration to the right alphabetical order
    - CLEANUP: mux-fcgi: Don't needlessly store result of data/trailers parsing
    - BUILD: fix compilation for OpenSSL-3.0.0-alpha17
    - MINOR: http-ana: Use -1 status for client aborts during queuing and connect
    - REGTESTS: Fix http_abortonclose.vtc to support -1 status for some client aborts
    - CLEANUP: backend: fix incorrect comments on locking conditions for lb functions
    - CLEANUP: reg-tests: Remove obsolete no-htx parameter for reg-tests
    - CI: github actions: add OpenSSL-3.0.0 builds
    - CI: github actions: -Wno-deprecated-declarations with OpenSSL 3.0.0
    - MINOR: errors: allow empty va_args for diag variadic macro
    - REORG: errors: split errors reporting function from log.c
    - CLEANUP: server: fix cosmetic of error message on sni parsing
    - MEDIUM: errors: implement user messages buffer
    - MINOR: log: do not discard stderr when starting is over
    - MEDIUM: errors: implement parsing context type
    - MINOR: errors: use user messages context in print_message
    - MINOR: log: display exec path on first warning
    - MINOR: errors: specify prefix "config" for parsing output
    - MINOR: log: define server user message format
    - REORG: server: use parsing ctx for server parsing
    - REORG: config: use parsing ctx for server config check
    - MINOR: server: use parsing ctx for server init addr
    - MINOR: server: use ha_alert in server parsing functions
    - DOC: use the req.ssl_sni in examples
    - CLEANUP: cfgparse: Remove duplication of `MAX_LINE_ARGS + 1`
    - CLEANUP: tools: Make errptr const in `parse_line()`
    - MINOR: haproxy: Add `-cc` argument
    - BUG: errors: remove printf positional args for user messages context
    - CI: Make matrix.py executable and add shebang
    - BUILD: make tune.ssl.keylog available again
    - BUG/MINOR: ssl: OCSP stapling does not work if expire too far in the future
    - Revert "BUG/MINOR: opentracing: initialization after establishing daemon mode"
    - BUG/MEDIUM: opentracing: initialization before establishing daemon and/or chroot mode
    - SCRIPTS: opentracing: enable parallel builds in build-ot.sh
    - BUG/MEDIUM: compression: Fix loop skipping unused blocks to get the next block
    - BUG/MEDIUM: compression: Properly get the next block to iterate on payload
    - BUG/MEDIUM: compression: Add a flag to know the filter is still processing data
    - MINOR: ssl: Keep the actual key length in the certificate_ocsp structure
    - MINOR: ssl: Add new "show ssl ocsp-response" CLI command
    - MINOR: ssl: Add the OCSP entry key when displaying the details of a certificate
    - MINOR: ssl: Add the "show ssl cert foo.pem.ocsp" CLI command
    - REGTESTS: ssl: Add "show ssl ocsp-response" test
    - BUG/MINOR: server: explicitly set "none" init-addr for dynamic servers
    - BUG/MINOR: pools: fix a possible memory leak in the lockless pool_flush()
    - BUG/MINOR: pools: make DEBUG_UAF always write to the to-be-freed location
    - MINOR: pools: do not maintain the lock during pool_flush()
    - MINOR: pools: call malloc_trim() under thread isolation
    - MEDIUM: pools: use a single pool_gc() function for locked and lockless
    - BUG/MAJOR: pools: fix possible race with free() in the lockless variant
    - CLEANUP: pools: remove now unused seq and pool_free_list
    - MEDIUM: pools: remove the locked pools implementation
    - BUILD: ssl: Fix compilation with BoringSSL
    - BUG/MEDIUM: errors: include missing obj_type file
    - REGTESTS: ssl: show_ssl_ocspresponce.vtc is broken with BoringSSL
    - BUG/MAJOR: htx: Fix htx_defrag() when an HTX block is expanded
    - BUG/MINOR: mux-fcgi: Expose SERVER_SOFTWARE parameter by default
    - BUG/MINOR: h1-htx: Fix a signess bug with char data type when parsing chunk size
    - CLEANUP: l7-retries: do not test the buffer before calling b_alloc()
    - BUG/MINOR: resolvers: answser item list was randomly purged or errors
    - MEDIUM: resolvers: add a ref on server to the used A/AAAA answer item
    - MEDIUM: resolvers: add a ref between servers and srv request or used SRV record
    - BUG/MINOR: server-state: load SRV resolution only if params match the config
    - MINOR: config: remove support for deprecated option "tune.chksize"
    - MINOR: config: completely remove support for "no option http-use-htx"
    - MINOR: log: remove the long-deprecated early log-format tags
    - MINOR: http: remove the long deprecated "set-cookie()" sample fetch function
    - MINOR: config: reject long-deprecated "option forceclose"
    - MINOR: config: remove deprecated option "http-tunnel"
    - MEDIUM: proxy: remove the deprecated "grace" keyword
    - MAJOR: config: remove parsing of the global "nbproc" directive
    - BUILD: init: remove initialization of multi-process thread mappings
    - BUILD: log: remove unused fmt_directive()
    - REGTESTS: Remove REQUIRE_VERSION=1.6 from all tests
    - REGTESTS: Remove REQUIRE_VERSION=1.7 from all tests
    - CI: github actions: enable alpine/musl builds
    - BUG/MAJOR: resolvers: segfault using server template without SRV RECORDs
    - DOC: lua: Add a warning about buffers modification in HTTP
    - MINOR: ssl: Use OpenSSL's ASN1_TIME convertor when available
    - BUG/MINOR: stick-table: insert srv in used_name tree even with fixed id
    - BUG/MEDIUM: server: extend thread-isolate over much of CLI 'add server'
    - BUG/MEDIUM: server: clear dynamic srv on delete from proxy id/name trees
    - BUG/MEDIUM: server: do not forget to generate the dynamic servers ids
    - BUG/MINOR: server: do not keep an invalid dynamic server in px ids tree
    - BUG/MEDIUM: server: do not auto insert a dynamic server in px addr_node
    - BUG/MEDIUM: shctx: use at least thread-based locking on USE_PRIVATE_CACHE
    - BUG/MINOR: ssl: use atomic ops to update global shctx stats
    - BUG/MINOR: mworker: fix typo in chroot error message
    - CLEANUP: global: remove unused definition of stopping_task[]
    - MEDIUM: init: remove the loop over processes during init
    - MINOR: mworker: remove the initialization loop over processes
    - CLEANUP: global: remove the nbproc field from the global structure
    - CLEANUP: global: remove pid_bit and all_proc_mask
    - MEDIUM: global: remove dead code from nbproc/bind_proc removal
    - MEDIUM: config: simplify cpu-map handling
    - MEDIUM: cpu-set: make the proc a single bit field and not an array
    - CLEANUP: global: remove unused definition of MAX_PROCS
    - MEDIUM: global: remove the relative_pid from global and mworker
    - DOC: update references to process numbers in cpu-map and bind-process
    - MEDIUM: config: warn about "bind-process" deprecation
    - CLEANUP: shctx: remove the different inter-process locking techniques
    - BUG/MAJOR: queue: set SF_ASSIGNED when setting strm->target on dequeue
    - MINOR: backend: only skip LB when there are actual connections
    - BUG/MINOR: mux-h1: do not skip the error response on bad requests
    - MINOR: connection: add helper conn_append_debug_info()
    - MINOR: mux-h2/trace: report a few connection-level info during h2_init()
    - CLEANUP: mux-h2/traces: better align user messages
    - BUG/MINOR: stats: make "show stat typed desc" work again
    - MINOR: mux-h2: obey http-ignore-probes during the preface
    - BUG/MINOR: mux-h2/traces: bring back the lost "rcvd H2 REQ" trace
    - BUG/MINOR: mux-h2/traces: bring back the lost "sent H2 REQ/RES" traces
    - CLEANUP: assorted typo fixes in the code and comments
    - CI: Replace the requirement for 'sudo' with a call to 'ulimit -n'
    - REGTESTS: Replace REQUIRE_VERSION=2.5 with 'haproxy -cc'
    - REGTESTS: Replace REQUIRE_OPTIONS with 'haproxy -cc' for 2.5+ tests
    - REGTESTS: Replace REQUIRE_BINARIES with 'command -v'
    - REGTESTS: Remove support for REQUIRE_BINARIES
    - CI: ssl: enable parallel builds for OpenSSL on Linux
    - CI: ssl: do not needlessly build the OpenSSL docs
    - CI: ssl: keep the old method for ancient OpenSSL versions
    - CLEANUP: server: a separate function for initializing the per_thr field
    - BUG/MINOR: server: Forbid to set fqdn on the CLI if SRV resolution is enabled
    - BUG/MEDIUM: server/cli: Fix ABBA deadlock when fqdn is set from the CLI
    - MINOR: resolvers: Clean server in a dedicated function when removing a SRV item
    - MINOR: resolvers: Remove server from named_servers tree when removing a SRV item
    - BUG/MEDIUM: resolvers: Add a task on servers to check SRV resolution status
    - BUG/MINOR: backend: restore the SF_SRV_REUSED flag original purpose
    - BUG/MINOR: backend: do not set sni on connection reuse
    - BUG/MINOR: resolvers: Use resolver's lock in resolv_srvrq_expire_task()
    - BUG/MINOR: server/cli: Fix locking in function processing "set server" command
    - BUG/MINOR: cache: Correctly handle existing-but-empty 'accept-encoding' header
    - MINOR: ssl: fix typo in usage for 'new ssl ca-file'
    - MINOR: ssl: always initialize random generator
    - MINOR: ssl: check allocation in ssl_sock_init_srv
    - MINOR: ssl: check allocation in parse ciphers/ciphersuites/verifyhost
    - MINOR: ssl: check allocation in parse npn/sni
    - MINOR: server: disable CLI 'set server ssl' for dynamic servers
    - MINOR: ssl: render file-access optional on server crt loading
    - MINOR: ssl: split parse functions for alpn/check-alpn
    - MINOR: ssl: support ca-file arg for dynamic servers
    - MINOR: ssl: support crt arg for dynamic servers
    - MINOR: ssl: support crl arg for dynamic servers
    - MINOR: ssl: enable a series of ssl keywords for dynamic servers
    - MINOR: ssl: support ssl keyword for dynamic servers
    - REGTESTS: server: test ssl support for dynamic servers
    - MINOR: queue: update the stream's pend_pos before queuing it
    - CLEANUP: Prevent channel-t.h from being detected as C++ by GitHub
    - BUG/MAJOR: server: fix deadlock when changing maxconn via agent-check
    - REGTESTS: fix maxconn update with agent-check
    - MEDIUM: queue: make pendconn_process_next_strm() only return the pendconn
    - MINOR: queue: update proxy->served once out of the loop
    - MEDIUM: queue: refine the locking in process_srv_queue()
    - MINOR: lb/api: remove the locked argument from take_conn/drop_conn
    - MINOR: queue: create a new structure type "queue"
    - MINOR: proxy: replace the pendconns-related stuff with a struct queue
    - MINOR: server: replace the pendconns-related stuff with a struct queue
    - MEDIUM: queue: use a dedicated lock for the queues
    - MEDIUM: queue: simplify again the process_srv_queue() API
    - MINOR: queue: factor out the proxy/server queuing code
    - MINOR: queue: use atomic-ops to update the queue's index
    - MEDIUM: queue: determine in process_srv_queue() if the proxy is usable
    - MEDIUM: queue: move the queue lock manipulation to pendconn_process_next_strm()
    - MEDIUM: queue: unlock as soon as possible
    - MINOR: queue: make pendconn_first() take the lock by itself
    - CLEANUP: backend: remove impossible case of round-robin + consistent hash
    - MINOR: tcp-act: Add set-src/set-src-port for "tcp-request content" rules
    - DOC: config: Add missing actions in "tcp-request session" documentation
    - CLEANUP: dns: Remove a forgotten debug message
    - DOC: Replace issue templates by issue forms
    - Revert "MINOR: queue: make pendconn_first() take the lock by itself"
    - Revert "MEDIUM: queue: unlock as soon as possible"
    - Revert "MEDIUM: queue: move the queue lock manipulation to pendconn_process_next_strm()"
    - Revert "MEDIUM: queue: determine in process_srv_queue() if the proxy is usable"
    - Revert "MINOR: queue: use atomic-ops to update the queue's index"
    - Revert "MINOR: queue: factor out the proxy/server queuing code"
    - Revert "MEDIUM: queue: simplify again the process_srv_queue() API"
    - Revert "MEDIUM: queue: use a dedicated lock for the queues"
    - Revert "MEDIUM: queue: refine the locking in process_srv_queue()"
    - Revert "MINOR: queue: update proxy->served once out of the loop"
    - Revert "MEDIUM: queue: make pendconn_process_next_strm() only return the pendconn"
    - MEDIUM: queue: update px->served and lb's take_conn once per loop
    - MEDIUM: queue: use a dedicated lock for the queues (v2)
    - MEDIUM: queue: simplify again the process_srv_queue() API (v2)
    - MEDIUM: queue: determine in process_srv_queue() if the proxy is usable (v2)
    - MINOR: queue: factor out the proxy/server queuing code (v2)
    - MINOR: queue: use atomic-ops to update the queue's index (v2)
    - MEDIUM: queue: take the proxy lock only during the px queue accesses
    - MEDIUM: queue: use a trylock on the server's queue
    - MINOR: queue: add queue_init() to initialize a queue
    - MINOR: queue: add a pointer to the server and the proxy in the queue
    - MINOR: queue: store a pointer to the queue into the pendconn
    - MINOR: queue: remove the px/srv fields from pendconn
    - MINOR: queue: simplify pendconn_unlink() regarding srv vs px
    - BUG: backend: stop looking for queued connections once there's no more
    - BUG/MINOR: queue/debug: use the correct lock labels on the queue lock
    - BUG/MINOR: resolvers: Always attach server on matching record on resolution
    - BUG/MINOR: resolvers: Reset server IP when no ip is found in the response
    - MINOR: resolvers: Reset server IP on error in resolv_get_ip_from_response()
    - BUG/MINOR: checks: return correct error code for srv_parse_agent_check
    - BUILD: Makefile: fix linkage for Haiku.
    - BUG/MINOR: tcpcheck: Fix numbering of implicit HTTP send/expect rules
    - MINOR: http-act/tcp-act: Add "set-log-level" for tcp content rules
    - MINOR: http-act/tcp-act: Add "set-nice" for tcp content rules
    - MINOR: http-act/tcp-act: Add "set-mark" and "set-tos" for tcp content rules
    - CLEANUP: tcp-act: Sort action lists
    - BUILD/MEDIUM: tcp: set-mark setting support for FreeBSD.
    - BUILD: tcp-act: avoid warning when set-mark / set-tos are not supported
    - BUG/MINOR: mqtt: Fix parser for string with more than 127 characters
    - BUG/MINOR: mqtt: Support empty client ID in CONNECT message
    - BUG/MEDIUM: resolvers: Make 1st server of a template take part to SRV resolution
    - CLEANUP: peers: re-write intdecode function comment.

4 years agoCLEANUP: peers: re-write intdecode function comment.
Emeric Brun [Wed, 30 Jun 2021 11:21:58 +0000 (13:21 +0200)] 
CLEANUP: peers: re-write intdecode function comment.

The varint decoding function comment was not clear enough and
didn't reflect the current usage.

This patch re-writes this.

4 years agoBUG/MEDIUM: resolvers: Make 1st server of a template take part to SRV resolution
Christopher Faulet [Tue, 29 Jun 2021 18:52:35 +0000 (20:52 +0200)] 
BUG/MEDIUM: resolvers: Make 1st server of a template take part to SRV resolution

The commit 3406766d5 ("MEDIUM: resolvers: add a ref between servers and srv
request or used SRV record") introduced a regression. The first server of a
template based on SRV record is no longer resolved. The same bug exists for
a normal server based on a SRV record.

In fact, the server used during parsing (used as reference when a
server-template line is parsed) is never attached to the corresponding srvrq
object. Thus with following lines, no resolution is performed because
"srvrq->attached_servers" is empty:

  server-template test 1 _http.domain.tld resolvers dns ...
  server test1 _http.domain.tld resolvers dns ...

This patch should fix the issue #1295 (but not confirmed yet it is the same
bug). It must be backported everywhere the above commit is.

4 years agoBUG/MINOR: mqtt: Support empty client ID in CONNECT message
Christopher Faulet [Mon, 28 Jun 2021 13:37:59 +0000 (15:37 +0200)] 
BUG/MINOR: mqtt: Support empty client ID in CONNECT message

As specified by the MQTT specification (MQTT-3.1.3-6), the client ID may be
empty. That means the length of the client ID string may be 0. However, The
MQTT parser does not support empty strings.

So, to fix the bug, the mqtt_read_string() function may now parse empty
string. 2 bytes must be found to decode the string length, but the length
may be 0 now. It is the caller responsibility to test the string emptiness
if necessary. In addition, in mqtt_parse_connect(), the client ID may be
empty now.

This patch should partely fix the issue #1310. It must be backported to 2.4.

4 years agoBUG/MINOR: mqtt: Fix parser for string with more than 127 characters
Christopher Faulet [Mon, 28 Jun 2021 13:26:00 +0000 (15:26 +0200)] 
BUG/MINOR: mqtt: Fix parser for string with more than 127 characters

Parsing of too long strings (> 127 characters) was buggy because of a wrong
cast on the length bytes. To fix the bug, we rely on mqtt_read_2byte_int()
function. This way, the string length is properly decoded.

This patch should partely fix the issue #1310. It must be backported to 2.4.

4 years agoBUILD: tcp-act: avoid warning when set-mark / set-tos are not supported
Willy Tarreau [Mon, 28 Jun 2021 05:12:22 +0000 (07:12 +0200)] 
BUILD: tcp-act: avoid warning when set-mark / set-tos are not supported

Since recent commit 469c06c30 ("MINOR: http-act/tcp-act: Add "set-mark"
and "set-tos" for tcp content rules") there's a build warning (or error)
on Windows due to static function tcp_action_set_mark() not being used
because the set-mark functionality is not supported there. It's caused
by the fact that only the parsing function uses it so if the code is
ifdefed out the function remains unused.

Let's surround it with ifdefs as well, and do the same for
tcp_action_set_tos() which could suffer the same fate on operating systems
not defining IP_TOS.

This may need to be backported if the patch above is backported. Also
be careful, the condition was adjusted to cover FreeBSD after commit
f7f53afcf ("BUILD/MEDIUM: tcp: set-mark setting support for FreeBSD.").

4 years agoBUILD/MEDIUM: tcp: set-mark setting support for FreeBSD.
David Carlier [Sat, 26 Jun 2021 11:04:36 +0000 (12:04 +0100)] 
BUILD/MEDIUM: tcp: set-mark setting support for FreeBSD.

This platform has a similar socket option from Linux's SO_MARK,
marking a socket with an id for packet filter purpose, DTrace
monitoring and so on.

4 years agoCLEANUP: tcp-act: Sort action lists
Christopher Faulet [Fri, 25 Jun 2021 13:18:33 +0000 (15:18 +0200)] 
CLEANUP: tcp-act: Sort action lists

Sort the lists used to register tcp actions.

4 years agoMINOR: http-act/tcp-act: Add "set-mark" and "set-tos" for tcp content rules
Christopher Faulet [Fri, 25 Jun 2021 13:11:35 +0000 (15:11 +0200)] 
MINOR: http-act/tcp-act: Add "set-mark" and "set-tos" for tcp content rules

It is now possible to set the Netfilter MARK and the TOS field value in all
packets sent to the client from any tcp-request rulesets or the "tcp-response
content" one. To do so, the parsing of "set-mark" and "set-tos" actions are
moved in tcp_act.c and the actions evaluation is handled in dedicated functions.

This patch may be backported as far as 2.2 if necessary.

4 years agoMINOR: http-act/tcp-act: Add "set-nice" for tcp content rules
Christopher Faulet [Fri, 25 Jun 2021 12:46:02 +0000 (14:46 +0200)] 
MINOR: http-act/tcp-act: Add "set-nice" for tcp content rules

It is now possible to set the "nice" factor of the current stream from a
"tcp-request content" or "tcp-response content" ruleset. To do so, the
action parsing is moved in stream.c and the action evaluation is handled in
a dedicated function.

This patch may be backported as far as 2.2 if necessary.

4 years agoMINOR: http-act/tcp-act: Add "set-log-level" for tcp content rules
Christopher Faulet [Fri, 25 Jun 2021 12:35:29 +0000 (14:35 +0200)] 
MINOR: http-act/tcp-act: Add "set-log-level" for tcp content rules

It is now possible to set the stream log level from a "tcp-request content"
or "tcp-response content" ruleset. To do so, the action parsing is moved in
stream.c and the action evaluation is handled in a dedicated function.

This patch should fix issue #1306. It may be backported as far as 2.2 if
necessary.

4 years agoBUG/MINOR: tcpcheck: Fix numbering of implicit HTTP send/expect rules
Christopher Faulet [Fri, 25 Jun 2021 09:37:45 +0000 (11:37 +0200)] 
BUG/MINOR: tcpcheck: Fix numbering of implicit HTTP send/expect rules

The index of the failing rule is reported in the health-check log message. The
rules index is also used in the check traces. But for implicit HTTP send/expect
rules, the index is wrong. It must be incremented by one compared to the
preceding rule.

This patch may be backported as far as 2.2.

4 years agoBUILD: Makefile: fix linkage for Haiku.
David Carlier [Sat, 19 Jun 2021 14:42:43 +0000 (14:42 +0000)] 
BUILD: Makefile: fix linkage for Haiku.

At runtime, the haiku's loader displays `could not resolve symbol: __start_i_STG_ALLOC`
thus using linker setting fallback.

4 years agoBUG/MINOR: checks: return correct error code for srv_parse_agent_check
Dirkjan Bussink [Fri, 18 Jun 2021 19:57:49 +0000 (19:57 +0000)] 
BUG/MINOR: checks: return correct error code for srv_parse_agent_check

In srv_parse_agent_check the error code is not returned in case
something goes wrong. The value 0 is always return.

Additionally, there's a small cleanup of unreachable returns that in
most checks are not present either and removed in two places they were
present. This makes the code consistent across the different checks.

4 years agoMINOR: resolvers: Reset server IP on error in resolv_get_ip_from_response()
Christopher Faulet [Thu, 24 Jun 2021 13:33:52 +0000 (15:33 +0200)] 
MINOR: resolvers: Reset server IP on error in resolv_get_ip_from_response()

If resolv_get_ip_from_response() returns an error (or an unexpected return
value), the server is set to RMAINT status. However, its address must also
be reset. Otherwise, it is still reported by the cli on "show servers state"
commands. This may be confusing. Note that it is a theorical patch because
this code path does not exist. Thus it is not tagged as a BUG.

This patch may be backported as far as 2.0.