]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
5 years agoMINOR: mworker: replace ha_alert by ha_warning when exiting successfuly
William Lallemand [Wed, 6 May 2020 15:27:03 +0000 (17:27 +0200)] 
MINOR: mworker: replace ha_alert by ha_warning when exiting successfuly

Since commit bb86986 ("MINOR: init: report the haproxy version and
executable path once on errors") the master-worker displays its version
and path upon a successful exits of a current worker. Which is kind of
confusing upon a clean exits.

This is due to the fact that that commit displays this upon a ha_alert()
which was used during the exit of the process.

Replace the ha_alert() by an ha_warning() if the process exit correctly
and was supposed to.

It still displays the message upon a SIGINT since the workers are
catching the signal.

5 years agoREGTEST: checks: Adapt SSL error message reported when connection is rejected
Christopher Faulet [Wed, 6 May 2020 09:10:51 +0000 (11:10 +0200)] 
REGTEST: checks: Adapt SSL error message reported when connection is rejected

Depending on the SSL library version, the reported error may differ when the
connection is rejected during the handshake. An empty handshke may be detected
or just an generic handshake error. So tcp-check-ssl.vtc has been adapted to
support both error messages.

5 years agoMINOR: checks/sample: Remove unnecessary tests on the sample session
Christopher Faulet [Wed, 6 May 2020 07:42:04 +0000 (09:42 +0200)] 
MINOR: checks/sample: Remove unnecessary tests on the sample session

A sample must always have a session defined. Otherwise, it is a bug. So it is
unnecessary to test if it is defined when called from a health checks context.

This patch fixes the issue #616.

5 years agoMINOR: checks: Simplify matching on HTTP headers in HTTP expect rules
Christopher Faulet [Tue, 5 May 2020 18:23:13 +0000 (20:23 +0200)] 
MINOR: checks: Simplify matching on HTTP headers in HTTP expect rules

Extra parameters on http-check expect rules, for the header matching method, to
use log-format string or to match full header line have been removed. There is
now separate matching methods to match a full header line or to match each
comma-separated values. "http-check expect fhdr" must be used in the first case,
and "http-check expect hdr" in the second one. In addition, to match log-format
header name or value, "-lf" suffix must be added to "name" or "value"
keyword. For intance:

   http-check expect hdr name "set-cookie" value-lf -m beg "sessid=%[var(check.cookie)]"

Thanks to this changes, each parameter may only be interpreted in one way.

5 years agoMINOR: checks: Use dedicated actions to send log-format strings in send rules
Christopher Faulet [Tue, 5 May 2020 16:43:43 +0000 (18:43 +0200)] 
MINOR: checks: Use dedicated actions to send log-format strings in send rules

Following actions have been added to send log-format strings from a tcp-check
ruleset instead the log-format parameter:

  * tcp-check send-lf <fmt>
  * tcp-check send-binary-lf <fmt>

It is easier for tools generating configurations. Each action may only be
interpreted in one way.

5 years agoCLEANUP: checks: sort and rename tcpcheck_expect_type types
Christopher Faulet [Tue, 5 May 2020 16:10:01 +0000 (18:10 +0200)] 
CLEANUP: checks: sort and rename tcpcheck_expect_type types

The same naming format is used for all expect rules. And names are sorted to be
grouped by type.

5 years agoMEDIUM: checks: Remove dedicated sample fetches and use response ones instead
Christopher Faulet [Tue, 5 May 2020 15:46:34 +0000 (17:46 +0200)] 
MEDIUM: checks: Remove dedicated sample fetches and use response ones instead

All sample fetches in the scope "check." have been removed. Response sample
fetches must be used instead. It avoids keyword duplication. So, for instance,
res.hdr() must be now used instead of check.hdr().

To do so, following sample fetches have been added on the response :

  * res.body, res.body_len and res.body_size
  * res.hdrs and res.hdrs_bin

Sample feches dealing with the response's body are only useful in the health
checks context. When called from a stream context, there is no warranty on the
body presence. There is no option to wait the response's body.

5 years agoDOC: Fix req.body and co documentation to be accurate
Christopher Faulet [Tue, 5 May 2020 15:33:25 +0000 (17:33 +0200)] 
DOC: Fix req.body and co documentation to be accurate

Because the HTX is the only mode to represent HTTP data, "option
http-request-buffer" is no longer mandatory to have body data. Without this
option, there is no warranty on the body presence. So it is recommanded to use
it. But it is not a requirement. In addition, the note about chunked body is
removed because outdated.

5 years agoMEDIUM: checks: Add matching on log-format string for expect rules
Christopher Faulet [Tue, 5 May 2020 13:54:22 +0000 (15:54 +0200)] 
MEDIUM: checks: Add matching on log-format string for expect rules

It is now possible to use log-format string (or hexadecimal string for the
binary version) to match a content in tcp-check based expect rules. For
hexadecimal log-format string, the conversion in binary is performed after the
string evaluation, during health check execution. The pattern keywords to use
are "string-lf" for the log-format string and "binary-lf" for the hexadecimal
log-format string.

5 years agoMINOR: checks: Improve report of unexpected errors for expect rules
Christopher Faulet [Tue, 5 May 2020 13:50:37 +0000 (15:50 +0200)] 
MINOR: checks: Improve report of unexpected errors for expect rules

TCP and HTTP expect rules may fail because of unexpected and internal
error. Mainly during log-format strings eval. The error report is improved by
this patch.

5 years ago[RELEASE] Released version 2.2-dev7 v2.2-dev7
Willy Tarreau [Tue, 5 May 2020 19:49:10 +0000 (21:49 +0200)] 
[RELEASE] Released version 2.2-dev7

Released version 2.2-dev7 with the following main changes :
    - MINOR: version: Show uname output in display_version()
    - CI: run weekly OpenSSL "no-deprecated" builds
    - CLEANUP: log: fix comment of parse_logformat_string()
    - DOC: Improve documentation on http-request set-src
    - MINOR: ssl/cli: disallow SSL options for directory in 'add ssl crt-list'
    - MINOR: ssl/cli: restrain certificate path when inserting into a directory
    - MINOR: ssl: add ssl-skip-self-issued-ca global option
    - BUG/MINOR: ssl: default settings for ssl server options are not used
    - MINOR: config: add a global directive to set default SSL curves
    - BUG/MEDIUM: http-ana: Handle NTLM messages correctly.
    - DOC: internals: update the SSL architecture schema
    - BUG/MINOR: tools: fix the i386 version of the div64_32 function
    - BUG/MINOR: mux-fcgi/trace: fix wrong set of trace flags in fcgi_strm_add_eom()
    - BUG/MINOR: http: make url_decode() optionally convert '+' to SP
    - DOC: option logasap does not depend on mode
    - MEDIUM: memory: make pool_gc() run under thread isolation
    - MINOR: contrib: make the peers wireshark dissector a plugin
    - BUG/MINOR: http-ana: Throw a 500 error if after-response ruleset fails on errors
    - BUG/MINOR: check: Update server address and port to execute an external check
    - MINOR: mini-clist: Add functions to iterate backward on a list
    - MINOR: checks: Add a way to send custom headers and payload during http chekcs
    - MINOR: server: respect warning and alert semantic
    - BUG/MINOR: checks: Respect the no-check-ssl option
    - BUG/MEDIUM: server/checks: Init server check during config validity check
    - CLEANUP: checks: Don't export anymore init_check and srv_check_healthcheck_port
    - BUG/MINOR: checks: chained expect will not properly wait for enough data
    - BUG/MINOR: checks: Forbid tcp-check lines in default section as documented
    - MINOR: checks: Use an enum to describe the tcp-check rule type
    - MINOR: checks: Simplify connection flag parsing in tcp-check connect
    - MEDIUM: checks: rewind to the first inverse expect rule of a chain on new data
    - MINOR: checks: simplify tcp expect config parser
    - MINOR: checks: add min-recv tcp-check expect option
    - MINOR: checks: add linger option to tcp connect
    - MINOR: checks: define a tcp expect type
    - MEDIUM: checks: rewrite tcp-check expect block
    - MINOR: checks: Stop xform buffers to null-terminated string for tcp-check rules
    - MINOR: checks: add rbinary expect match type
    - MINOR: checks: Simplify functions to get step id and comment
    - MEDIUM: checks: capture groups in expect regexes
    - MINOR: checks: Don't use a static tcp rule list head
    - MEDIUM: checks: Use a non-comment rule iterator to get next rule
    - MEDIUM: proxy/checks: Register a keyword to parse tcp-check rules
    - MINOR: checks: Set the tcp-check rule index during parsing
    - MINOR: checks: define tcp-check send type
    - MINOR: checks: define a tcp-check connect type
    - MEDIUM: checks: Add implicit tcp-check connect rule
    - MAJOR: checks: Refactor and simplify the tcp-check loop
    - MEDIUM: checks: Associate a session to each tcp-check healthcheck
    - MINOR: checks/vars: Add a check scope for variables
    - MEDIUM: checks: Parse custom action rules in tcp-checks
    - MINOR: checks: Add support to set-var and unset-var rules in tcp-checks
    - MINOR: checks: Add the sni option for tcp-check connect rules
    - MINOR: checks: Add the via-socks4 option for tcp-check connect rules
    - MINOR: checks: Add the alpn option for tcp-check connect rules
    - MINOR: ssl: Export a generic function to parse an alpn string
    - MINOR: checks: Add the default option for tcp-check connect rules
    - MINOR: checks: Add the addr option for tcp-check connect rule
    - MEDIUM: checks: Support expression to set the port
    - MEDIUM: checks: Support log-format strings for tcp-check send rules
    - MINOR: log: Don't depends on a stream to process samples in log-format string
    - MINOR: log: Don't systematically set LW_REQ when a sample expr is added
    - MEDIUM: checks: Add a shared list of tcp-check rules
    - MINOR: sample: add htonl converter
    - MINOR: sample: add cut_crlf converter
    - MINOR: sample: add ltrim converter
    - MINOR: sample: add rtrim converter
    - MINOR: checks: Use a name for the healthcheck status enum
    - MINOR: checks: Add option to tcp-check expect rules to customize error status
    - MINOR: checks: Merge tcp-check comment rules with the others at config parsing
    - MINOR: checks: Add a sample fetch to extract a block from the input check buffer
    - MEDIUM: checks: Add on-error/on-success option on tcp-check expect rules
    - MEDIUM: checks: Add status-code sample expression on tcp-check expect rules
    - MINOR: checks: Relax the default option for tcp-check connect rules
    - MEDIUM: checks: Add a list of vars to set before executing a tpc-check ruleset
    - MINOR: checks: Export the tcpcheck_eval_ret enum
    - MINOR: checks: Use dedicated function to handle onsuccess/onerror messages
    - MINOR: checks: Support custom functions to eval a tcp-check expect rules
    - MEDIUM: checks: Implement redis check using tcp-check rules
    - MEDIUM: checks: Implement ssl-hello check using tcp-check rules
    - MEDIUM: checks: Implement smtp check using tcp-check rules
    - MEDIUM: checks: Implement postgres check using tcp-check rules
    - MEDIUM: checks: Implement MySQL check using tcp-check rules
    - MEDIUM: checks: Implement LDAP check using tcp-check rules
    - MEDIUM: checks: Implement SPOP check using tcp-check rules
    - MINOR: server/checks: Move parsing of agent keywords in checks.c
    - MINOR: server/checks: Move parsing of server check keywords in checks.c
    - MEDIUM: checks: Implement agent check using tcp-check rules
    - REGTEST: Adapt regtests about checks to recent changes
    - MINOR: Produce tcp-check info message for pure tcp-check rules only
    - MINOR: checks: Add an option to set success status of tcp-check expect rules
    - MINOR: checks: Improve log message of tcp-checks on success
    - MINOR: proxy/checks: Move parsing of httpchk option in checks.c
    - MINOR: proxy/checks: Move parsing of tcp-check option in checks.c
    - MINOR: proxy/checks: Register a keyword to parse http-check rules
    - MINOR: proxy/checks: Move parsing of external-check option in checks.c
    - MINOR: proxy/checks: Register a keyword to parse external-check rules
    - MEDIUM: checks: Use a shared ruleset to store tcp-check rules
    - MINOR: checks: Use an indirect string to represent the expect matching string
    - MINOR: checks: Introduce flags to configure in tcp-check expect rules
    - MINOR: standard: Add my_memspn and my_memcspn
    - MINOR: checks: Add a reverse non-comment rule iterator to get last rule
    - MAJOR: checks: Implement HTTP check using tcp-check rules
    - MINOR: checks: Make resume conditions more explicit in tcpcheck_main()
    - MINOR: connection: Add macros to know if a conn or a cs uses an HTX mux
    - MEDIUM: checks: Refactor how data are received in tcpcheck_main()
    - MINOR: checks/obj_type: Add a new object type for checks
    - BUG/MINOR: obj_type: Handle stream object in obj_base_ptr() function
    - MINOR: checks: Use the check as origin when a session is created
    - MINOR: checks: Add a mux proto to health-check and tcp-check connect rule
    - MINOR: connection: Add a function to install a mux for a health-check
    - MAJOR: checks: Use the best mux depending on the protocol for health checks
    - MEDIUM: checks: Implement default TCP check using tcp-check rules
    - MINOR: checks: Remove unused code about pure TCP checks
    - CLEANUP: checks: Reorg checks.c file to be more readable
    - REGTEST: Fix reg-tests about health-checks to adapt them to recent changes
    - MINOR: ist: Add a function to retrieve the ist pointer
    - MINOR: checks: Use ist API as far as possible
    - BUG/MEDIUM: checks: Be sure to subscribe for sends if outgoing data remains
    - MINOR: checks: Use a tree instead of a list to store tcp-check rulesets
    - BUG/MINOR: checks: Send the right amount of outgoing data for HTTP checks
    - REGTEST: Add scripts to test based tcp-check health-checks
    - Revert "MEDIUM: checks: capture groups in expect regexes"
    - DOC: Add documentation about comments for tcp-check and http-check directives
    - DOC: Fix the tcp-check and http-check directives layout
    - BUG/MEDIUM: checks: Use the mux protocol specified on the server line
    - MINOR: checks: Support mux protocol definition for tcp and http health checks
    - BUG/MINOR: mux-fcgi: Be sure to have a connection as session's origin to use it
    - MINOR: checks: Support list of status codes on http-check expect rules
    - BUG/MEDIUM: checks: Unsubscribe to mux events when a conn-stream is destroyed
    - REGTEST: Add a script to validate agent checks
    - BUG/MINOR: server: Fix server_finalize_init() to avoid unused variable
    - BUG/MEDIUM: checks: unsubscribe for events on the old conn-stream on connect
    - BUG/MINOR: checks: Only use ssl_sock_is_ssl() if compiled with SSL support
    - BUG/MINOR: checks/server: use_ssl member must be signed
    - BUG/MEDIUM: sessions: Always pass the mux context as argument to destroy a mux
    - BUG/MEDIUM: checks: Destroy the conn-stream before the session
    - BUG/MINOR: checks: Fix PostgreSQL regex on the authentication packet
    - CI: cirrus-ci: remove reg-tests/checks/tcp-check-ssl.vtc on CentOS 6
    - MINOR: checks: Support HTTP/2 version (without '.0') for http-check send rules
    - MINOR: checks: Use ver keyword to specify the HTTP version for http checks
    - BUG/MINOR: checks: Remove wrong variable redeclaration
    - BUG/MINOR: checks: Properly handle truncated mysql server messages
    - CLEANUP: checks: Remove unused code when ldap server message is parsed
    - MINOR: checks: Make the use of the check's server more explicit on connect
    - BUG/MINOR: checks: Avoid incompatible cast when a binary string is parsed
    - BUG/MINOR: checks: Remove bad call to free() when an expect rule is parsed
    - BUG/MINOR: checks: Don't lose warning on proxy capability
    - MINOR: log: Add "Tu" timer
    - BUG/MINOR: checks: Set the output buffer length before calling parse_binary()
    - BUG/MEDIUM: mux-h1: make sure we always have a timeout on front connections
    - REGTEST: ssl: test the client certificate authentication
    - DOC: give a more accurate description of what check does
    - BUG/MEDIUM: capture: capture-req/capture-res converters crash without a stream
    - BUG/MEDIUM: capture: capture.{req,res}.* crash without a stream
    - BUG/MEDIUM: http: the "http_first_req" sample fetch could crash without a steeam
    - BUG/MEDIUM: http: the "unique-id" sample fetch could crash without a steeam
    - CLEANUP: http: add a few comments on certain functions' assumptions about streams
    - BUG/MEDIUM: sample: make the CPU and latency sample fetches check for a stream
    - MINOR: http-htx: Export functions to update message authority and host
    - MINOR: checks: Don't support multiple host header for http-check send rule
    - MINOR: checks: Skip some headers for http-check send rules
    - MINOR: checks: Keep the Host header and the request uri synchronized
    - CLEANUP: checks: Fix checks includes
    - DOC: Fix send rules in the http-check connect example
    - DOC: Add more info about request formatting in http-check send description
    - REGTEST: http-rules: Require PCRE or PCRE2 option to run map_redirect script
    - REGTEST: ssl: remove curl from the "add ssl crt-list" test
    - REGTEST: ssl: improve the "set ssl cert" test
    - CLEANUP: ssl: silence a build warning when threads are disabled
    - BUG/MEDIUM: listener: mark the thread as not stuck inside the loop
    - MINOR: threads: export the POSIX thread ID in panic dumps
    - BUG/MINOR: debug: properly use long long instead of long for the thread ID
    - BUG/MEDIUM: shctx: really check the lock's value while waiting
    - BUG/MEDIUM: shctx: bound the number of loops that can happen around the lock
    - MINOR: stream: report the list of active filters on stream crashes
    - BUG/MEDIUM: mux-fcgi: Return from detach if server don't keep the connection
    - BUG/MEDIUM: mux_fcgi: Free the FCGI connection at the end of fcgi_release()
    - BUG/MEDIUM: mux-fcgi: Fix wrong test on FCGI_CF_KEEP_CONN in fcgi_detach()
    - BUG/MEDIUM: connections: force connections cleanup on server changes
    - BUG/MEDIUM: h1: Don't compare host and authority if only h1 headers are parsed
    - BUG/MEDIUM: ssl: fix the id length check within smp_fetch_ssl_fc_session_id()
    - CLEANUP: connections: align function declaration
    - BUG/MINOR: sample: Set the correct type when a binary is converted to a string
    - MEDIUM: checks/http-fetch: Support htx prefetch from a check for HTTP samples
    - DOC: Document the log-format parameter for tcp-check send/send-binary rules
    - MINOR: checks: Add support of payload-based sample fetches
    - MINOR: checks: Add support of be_id, be_name, srv_id and srv_name sample fetches
    - MINOR: checks: Add support of server side ssl sample fetches
    - MINOR: checks: Add support of HTTP response sample fetches
    - MINOR: http-htx: Support different methods to look for header names
    - MINOR: checks: Set by default expect rule status to UNKNOWN during parsing
    - BUG/MINOR: checks: Support multiple HTTP expect rules
    - REGTEST: checks: Fix sync condition for agent-check
    - MEDIUM: checks: Support matching on headers for http-check expect rules
    - MINOR: lua: allow changing port with set_addr
    - BUG/MINOR: da: Fix HTX message prefetch
    - BUG/MINOR: wurfl: Fix HTX message prefetch
    - BUG/MINOR: 51d: Fix HTX message prefetch
    - MINOR: ist: add istadv() function
    - MINOR: ist: add istissame() function
    - MINOR: istbuf: add ist2buf() function
    - BUG/MINOR: threads: fix multiple use of argument inside HA_ATOMIC_CAS()
    - BUG/MINOR: threads: fix multiple use of argument inside HA_ATOMIC_UPDATE_{MIN,MAX}()
    - DOC: update intro.txt for 2.2
    - DOC: intro: add a contacts section

5 years agoDOC: intro: add a contacts section
Willy Tarreau [Tue, 5 May 2020 16:08:07 +0000 (18:08 +0200)] 
DOC: intro: add a contacts section

This indicates where to find help and where to report bugs.

5 years agoDOC: update intro.txt for 2.2
Willy Tarreau [Tue, 5 May 2020 15:39:16 +0000 (17:39 +0200)] 
DOC: update intro.txt for 2.2

A number of things have changed since last update, for example caching
and fastcgi were not mentioned.

5 years agoBUG/MINOR: threads: fix multiple use of argument inside HA_ATOMIC_UPDATE_{MIN,MAX}()
Willy Tarreau [Tue, 5 May 2020 14:13:36 +0000 (16:13 +0200)] 
BUG/MINOR: threads: fix multiple use of argument inside HA_ATOMIC_UPDATE_{MIN,MAX}()

Just like in previous patch, it happens that HA_ATOMIC_UPDATE_MIN() and
HA_ATOMIC_UPDATE_MAX() would evaluate the (val) argument up to 3 times.
However this time it affects both thread and non-thread versions. It's
strange because the copy was properly performed for the (new) argument
in order to avoid this. Anyway it was done for the "val" one as well.

A quick code inspection showed that this currently has no effect as
these macros are fairly limited in usage.

It would be best to backport this for long-term stability (till 1.8)
but it will not fix an existing bug.

5 years agoBUG/MINOR: threads: fix multiple use of argument inside HA_ATOMIC_CAS()
Willy Tarreau [Tue, 5 May 2020 13:58:00 +0000 (15:58 +0200)] 
BUG/MINOR: threads: fix multiple use of argument inside HA_ATOMIC_CAS()

When threads are disabled, HA_ATOMIC_CAS() becomes a simple compound
expression. However this expression presents a problem, which is that
its arguments are evaluated multiple times, once for the comparison
and once again for the assignement. This presents a risk of performing
some side-effect operations twice in the non-threaded case (e.g. in
case of auto-increment or function return).

The macro was rewritten using local copies for arguments like the
other macros do.

Fortunately a complete inspection of the code indicates that this case
currently never happens. It was however responsible for the strict-aliasing
warning emitted when building fd.c without threads but with 64-bit CAS.

This may be backported as far as 1.8 though it will not fix any existing
bug and is more of a long-term safety measure in case a future fix would
depend on this behavior.

5 years agoMINOR: istbuf: add ist2buf() function
Baptiste Assmann [Sat, 18 Apr 2020 12:50:11 +0000 (14:50 +0200)] 
MINOR: istbuf: add ist2buf() function

Purpose of this function is to build a <struct buffer> from a <struct
ist>.

5 years agoMINOR: ist: add istissame() function
Baptiste Assmann [Sun, 29 Mar 2020 07:10:27 +0000 (09:10 +0200)] 
MINOR: ist: add istissame() function

The istissame() function takes 2 ist and compare their <.ptr> and <.len>
values respectively. It returns non-zero if they are the same.

5 years agoMINOR: ist: add istadv() function
Baptiste Assmann [Sun, 29 Mar 2020 06:10:16 +0000 (08:10 +0200)] 
MINOR: ist: add istadv() function

The purpose of istadv() function is to move forward <.ptr> by <nb>
characters. It is very useful when parsing a payload.

5 years agoBUG/MINOR: 51d: Fix HTX message prefetch
Christopher Faulet [Tue, 5 May 2020 09:53:43 +0000 (11:53 +0200)] 
BUG/MINOR: 51d: Fix HTX message prefetch

An additional argument has been added to smp_prefetch_htx() function in the
commit 778f5ed47 ("MEDIUM: checks/http-fetch: Support htx prefetch from a check
for HTTP samples"). But forgot to update call in 51d module.

No need to backport.

5 years agoBUG/MINOR: wurfl: Fix HTX message prefetch
Christopher Faulet [Tue, 5 May 2020 09:52:13 +0000 (11:52 +0200)] 
BUG/MINOR: wurfl: Fix HTX message prefetch

An additional argument has been added to smp_prefetch_htx() function in the
commit 778f5ed47 ("MEDIUM: checks/http-fetch: Support htx prefetch from a check
for HTTP samples"). But forgot to update call in wurfl module.

No need to backport.

5 years agoBUG/MINOR: da: Fix HTX message prefetch
Christopher Faulet [Tue, 5 May 2020 09:49:57 +0000 (11:49 +0200)] 
BUG/MINOR: da: Fix HTX message prefetch

An additional argument has been added to smp_prefetch_htx() function in the
commit 778f5ed47 ("MEDIUM: checks/http-fetch: Support htx prefetch from a check
for HTTP samples"). But forgot to update call in da module.

No need to backport.

5 years agoMINOR: lua: allow changing port with set_addr
Joseph C. Sible [Tue, 5 May 2020 02:20:32 +0000 (22:20 -0400)] 
MINOR: lua: allow changing port with set_addr

Add an optional port parameter, which can be either a number or a
string (to support '+' and '-' for port mapping).

This fixes issue #586.

5 years agoMEDIUM: checks: Support matching on headers for http-check expect rules
Christopher Faulet [Tue, 5 May 2020 08:47:36 +0000 (10:47 +0200)] 
MEDIUM: checks: Support matching on headers for http-check expect rules

It is now possible to add http-check expect rules matching HTTP header names and
values. Here is the format of these rules:

  http-check expect header name [ -m <meth> ] <name> [log-format] \
                           [ value [ -m <meth> ] <value> [log-format] [full] ]

the name pattern (name ...) is mandatory but the value pattern (value ...) is
optionnal. If not specified, only the header presence is verified. <meth> is the
matching method, applied on the header name or the header value. Supported
matching methods are:

  * "str" (exact match)
  * "beg" (prefix match)
  * "end" (suffix match)
  * "sub" (substring match)
  * "reg" (regex match)

If not specified, exact matching method is used. If the "log-format" option is
used, the pattern (<name> or <value>) is evaluated as a log-format string. This
option cannot be used with the regex matching method. Finally, by default, the
header value is considered as comma-separated list. Each part may be tested. The
"full" option may be used to test the full header line. Note that matchings are
case insensitive on the header names.

5 years agoREGTEST: checks: Fix sync condition for agent-check
Christopher Faulet [Tue, 5 May 2020 06:10:36 +0000 (08:10 +0200)] 
REGTEST: checks: Fix sync condition for agent-check

agent-check.vtc script fails time to time because the 2nd cli command is sent to
early. Waiting for the connection close in the s1 server should be enough to be
sure the server state is updated.

5 years agoBUG/MINOR: checks: Support multiple HTTP expect rules
Christopher Faulet [Tue, 5 May 2020 05:59:23 +0000 (07:59 +0200)] 
BUG/MINOR: checks: Support multiple HTTP expect rules

For an http-check ruleset, it should be allowed to set a chain of expect
rules. But an error is triggered during the post-parsing because of a wrong
test, inherited from the evaluation mode before the refactoring.

No need to backport.

5 years agoMINOR: checks: Set by default expect rule status to UNKNOWN during parsing
Christopher Faulet [Tue, 5 May 2020 05:55:50 +0000 (07:55 +0200)] 
MINOR: checks: Set by default expect rule status to UNKNOWN during parsing

The status (ok, error and timeout) of an TCP or HTTP expect rule are set to
HCHK_STATUS_UNKNOWN by default, when not specified, during the configuration
parsing. This does not change the default status used for a terminal expect rule
(ok=L7OK, err=L7RSP and tout=L7TOUT). But this way, it is possible to know if a
specific status was forced by config or not.

5 years agoMINOR: http-htx: Support different methods to look for header names
Christopher Faulet [Tue, 5 May 2020 05:42:42 +0000 (07:42 +0200)] 
MINOR: http-htx: Support different methods to look for header names

It is now possible to use different matching methods to look for header names in
an HTTP message:

 * The exact match. It is the default method. http_find_header() uses this
   method. http_find_str_header() is an alias.

 * The prefix match. It evals the header names starting by a prefix.
   http_find_pfx_header() must be called to use this method.

 * The suffix match. It evals the header names ending by a suffix.
   http_find_sfx_header() must be called to use this method.

 * The substring match. It evals the header names containing a string.
   http_find_sub_header() must be called to use this method.

 * The regex match. It evals the header names matching a regular expression.
   http_match_header() must be called to use this method.

5 years agoMINOR: checks: Add support of HTTP response sample fetches
Christopher Faulet [Thu, 30 Apr 2020 09:30:00 +0000 (11:30 +0200)] 
MINOR: checks: Add support of HTTP response sample fetches

HTPP sample fetches acting on the response can now be called from any sample
expression or log-format string in a tcp-check based ruleset. To avoid any
ambiguities, all these sample fetches are in the check scope, for instance
check.hdr() or check.cook().

5 years agoMINOR: checks: Add support of server side ssl sample fetches
Christopher Faulet [Thu, 30 Apr 2020 08:03:55 +0000 (10:03 +0200)] 
MINOR: checks: Add support of server side ssl sample fetches

SSL sample fetches acting on the server connection can now be called from any
sample expression or log-format string in a tcp-check based ruleset. ssl_bc and
ssl_bc_* sample fetches are concerned.

5 years agoMINOR: checks: Add support of be_id, be_name, srv_id and srv_name sample fetches
Christopher Faulet [Thu, 30 Apr 2020 07:51:15 +0000 (09:51 +0200)] 
MINOR: checks: Add support of be_id, be_name, srv_id and srv_name sample fetches

It is now possible to call be_id, be_name, srv_id and srv_name sample fetches
from any sample expression or log-format string in a tcp-check based ruleset.

5 years agoMINOR: checks: Add support of payload-based sample fetches
Christopher Faulet [Thu, 30 Apr 2020 07:38:08 +0000 (09:38 +0200)] 
MINOR: checks: Add support of payload-based sample fetches

It is now possible to call check.payload(), check.payload_lv() and check.len()
sample fetches from any sample expression or log-format string in a tcp-check
based ruleset. In fact, check.payload() was already added. But instead of having
a specific function to handle this sample fetch, we use the same than
req.payload().

These sample fetches act on the check input buffer, containing data received for
the server. So it should be part of or after an expect rule, but before any send
rule. Because the input buffer is cleared at this stage.

5 years agoDOC: Document the log-format parameter for tcp-check send/send-binary rules
Christopher Faulet [Thu, 30 Apr 2020 05:50:54 +0000 (07:50 +0200)] 
DOC: Document the log-format parameter for tcp-check send/send-binary rules

The documentation was not updated when the parameter was added.

5 years agoMEDIUM: checks/http-fetch: Support htx prefetch from a check for HTTP samples
Christopher Faulet [Wed, 29 Apr 2020 13:51:55 +0000 (15:51 +0200)] 
MEDIUM: checks/http-fetch: Support htx prefetch from a check for HTTP samples

Some HTTP sample fetches will be accessible from the context of a http-check
health check. Thus, the prefetch function responsible to return the HTX message
has been update to handle a check, in addition to a channel. Both cannot be used
at the same time. So there is no ambiguity.

5 years agoBUG/MINOR: sample: Set the correct type when a binary is converted to a string
Christopher Faulet [Thu, 30 Apr 2020 07:57:40 +0000 (09:57 +0200)] 
BUG/MINOR: sample: Set the correct type when a binary is converted to a string

A binary sample data can be converted, implicitly or not, to a string by cutting
the buffer on the first null byte.

I guess this patch should be backported to all stable versions.

5 years agoCLEANUP: connections: align function declaration
William Dauchy [Mon, 4 May 2020 11:52:40 +0000 (13:52 +0200)] 
CLEANUP: connections: align function declaration

srv_cleanup_connections() is supposed to be static, so mark it as so.
This patch should be backported where commit 6318d33ce625
("BUG/MEDIUM: connections: force connections cleanup on server changes")
will be backported, that is to say v1.9 to v2.1.

Fixes: 6318d33ce625 ("BUG/MEDIUM: connections: force connections cleanup
on server changes")
Signed-off-by: William Dauchy <w.dauchy@criteo.com>
5 years agoBUG/MEDIUM: ssl: fix the id length check within smp_fetch_ssl_fc_session_id()
Dragan Dosen [Mon, 4 May 2020 07:07:28 +0000 (09:07 +0200)] 
BUG/MEDIUM: ssl: fix the id length check within smp_fetch_ssl_fc_session_id()

After we call SSL_SESSION_get_id(), the length of the id in bytes is
stored in "len", which was never checked. This could cause unexpected
behavior when using the "ssl_fc_session_id" or "ssl_bc_session_id"
fetchers (eg. the result can be an empty value).

The issue was introduced with commit 105599c ("BUG/MEDIUM: ssl: fix
several bad pointer aliases in a few sample fetch functions").

This patch must be backported to 2.1, 2.0, and 1.9.

5 years agoBUG/MEDIUM: h1: Don't compare host and authority if only h1 headers are parsed
Christopher Faulet [Mon, 4 May 2020 07:01:45 +0000 (09:01 +0200)] 
BUG/MEDIUM: h1: Don't compare host and authority if only h1 headers are parsed

When only request headers are parsed, the host header should not be compared to
the request authority because no start-line was parsed. Thus there is no
authority.

Till now this bug was hidden because this parsing mode was only used for the
response in the FCGI multiplexer. Since the HTTP checks refactoring, the request
headers may now also be parsed without the start-line.

This patch fixes the issue #610. It must be backported to 2.1.

5 years agoBUG/MEDIUM: connections: force connections cleanup on server changes
William Dauchy [Sat, 2 May 2020 19:52:36 +0000 (21:52 +0200)] 
BUG/MEDIUM: connections: force connections cleanup on server changes

I've been trying to understand a change of behaviour between v2.2dev5 and
v2.2dev6. Indeed our probe is regularly testing to add and remove
servers on a given backend such as:

 # echo "show servers state be_foo" | sudo socat stdio /var/lib/haproxy/stats
 113 be_foo 1 srv0 10.236.139.34 2 0 1 1 263 15 3 4 6 0 0 0 - 31255 -
 113 be_foo 2 srv1 0.0.0.0 0 1 256 256 0 15 3 0 14 0 0 0 - 0 -

 -> curl on the corresponding frontend: reply from server:31255

 # echo "set server be_foo/srv1 addr 10.236.139.34 port 31257" | sudo socat stdio /var/lib/haproxy/stats
 IP changed from '0.0.0.0' to '10.236.139.34', port changed from '0' to '31257' by 'stats socket command'
 # echo "set server be_foo/srv1 weight 256" | sudo socat stdio /var/lib/haproxy/stats
 # echo "set server be_foo/srv1 check-port 8500" | sudo socat stdio /var/lib/haproxy/stats
 health check port updated.
 # echo "set server be_foo/srv1 state ready" | sudo socat stdio /var/lib/haproxy/stats
 # echo "show servers state be_foo" | sudo socat stdio /var/lib/haproxy/stats
 113 be_foo 1 srv0 10.236.139.34 2 0 1 1 105 15 3 4 6 0 0 0 - 31255 -
 113 be_foo 2 srv1 10.236.139.34 2 0 256 256 2319 15 3 2 6 0 0 0 - 31257 -

 -> curl on the corresponding frontend: reply for server:31257
 (notice the difference of weight)

 # echo "set server be_foo/srv1 state maint" | sudo socat stdio /var/lib/haproxy/stats
 # echo "set server be_foo/srv1 addr 0.0.0.0 port 0" | sudo socat stdio /var/lib/haproxy/stats
 IP changed from '10.236.139.34' to '0.0.0.0', port changed from '31257' to '0' by 'stats socket command'
 # echo "show servers state be_foo" | sudo socat stdio /var/lib/haproxy/stats
 113 be_foo 1 srv0 10.236.139.34 2 0 1 1 263 15 3 4 6 0 0 0 - 31255 -
 113 be_foo 2 srv1 0.0.0.0 0 1 256 256 0 15 3 0 14 0 0 0 - 0 -

 -> curl on the corresponding frontend: reply from server:31255

 # echo "set server be_foo/srv1 addr 10.236.139.34 port 31256" | sudo socat stdio /var/lib/haproxy/stats
 IP changed from '0.0.0.0' to '10.236.139.34', port changed from '0' to '31256' by 'stats socket command'
 # echo "set server be_foo/srv1 weight 256" | sudo socat stdio /var/lib/haproxy/stats
 # echo "set server be_foo/srv1 check-port 8500" | sudo socat stdio /var/lib/haproxy/stats
 health check port updated.
 # echo "set server be_foo/srv1 state ready" | sudo socat stdio /var/lib/haproxy/stats
 # echo "show servers state be_foo" | sudo socat stdio /var/lib/haproxy/stats
 113 be_foo 1 srv0 10.236.139.34 2 0 1 1 105 15 3 4 6 0 0 0 - 31255 -
 113 be_foo 2 srv1 10.236.139.34 2 0 256 256 2319 15 3 2 6 0 0 0 - 31256 -

 -> curl on the corresponding frontend: reply from server:31257 (!)

Here we indeed would expect to get an anver from server:31256. The issue
is highly linked to the usage of `pool-purge-delay`, with a value which
is higher than the duration of the test, 10s in our case.

a git bisect between dev5 and dev6 seems to show commit
079cb9af22da6 ("MEDIUM: connections: Revamp the way idle connections are killed")
being the origin of this new behaviour.

So if I understand the later correctly, it seems that it was more a
matter of chance that we did not saw the issue earlier.

My patch proposes to force clean idle connections in the two following
cases:
- we set a (still running) server to maintenance
- we change the ip/port of a server

This commit should be backported to 2.1, 2.0, and 1.9.

Signed-off-by: William Dauchy <w.dauchy@criteo.com>
5 years agoBUG/MEDIUM: mux-fcgi: Fix wrong test on FCGI_CF_KEEP_CONN in fcgi_detach()
Christopher Faulet [Sat, 2 May 2020 07:21:24 +0000 (09:21 +0200)] 
BUG/MEDIUM: mux-fcgi: Fix wrong test on FCGI_CF_KEEP_CONN in fcgi_detach()

When a stream is detached from its connection, we try to move the connection in
an idle list to keep it opened, the session one or the server one. But it must
only be done if there is no connection error and if we want to keep it
open. This last statement is true if FCGI_CF_KEEP_CONN flag is set. But the test
is inverted at the stage.

This patch must be backported to 2.1.

5 years agoBUG/MEDIUM: mux_fcgi: Free the FCGI connection at the end of fcgi_release()
Christopher Faulet [Sat, 2 May 2020 07:17:52 +0000 (09:17 +0200)] 
BUG/MEDIUM: mux_fcgi: Free the FCGI connection at the end of fcgi_release()

fcgi_release() function is responsible to release a FCGI connection. But the
release of the connection itself is missing.

This patch must be backported to 2.1.

5 years agoBUG/MEDIUM: mux-fcgi: Return from detach if server don't keep the connection
Christopher Faulet [Sat, 2 May 2020 07:08:54 +0000 (09:08 +0200)] 
BUG/MEDIUM: mux-fcgi: Return from detach if server don't keep the connection

When the last stream is detached from a FCGI connection, if the server don't add
the connection in its idle list, the connection is destroyed. Thus it is
important to exist immediately from the detach function. A return statement is
missing here.

This bug was introduced in the commit 2444aa5b6 ("MEDIUM: sessions: Don't be
responsible for connections anymore.").

It is a 2.2-dev bug. No need to backport.

5 years agoMINOR: stream: report the list of active filters on stream crashes
Willy Tarreau [Fri, 1 May 2020 14:57:02 +0000 (16:57 +0200)] 
MINOR: stream: report the list of active filters on stream crashes

Now we very rarely catch spinning streams, and whenever we catch one it
seems a filter is involved, but we currently report no info about them.
Let's print the list of enabled filters on the stream with such a crash
to help with the reports. A typical output will now look like this:

  [ALERT] 121/165908 (1110) : A bogus STREAM [0x7fcaf4016a60] is spinning at 2 calls per second and refuses to die, aborting now! Please report this error to developers [strm=0x7fcaf4016a60 src=127.0.0.1 fe=l1 be=l1 dst=<CACHE> rqf=6dc42000 rqa=48000 rpf=a0040223 rpa=24000000 sif=EST,10008 sib=DIS,80110 af=(nil),0 csf=0x7fcaf4023c00,10c000 ab=0x7fcaf40235f0,4 csb=(nil),0 cof=0x7fcaf4016610,1300:H1(0x7fcaf4016840)/RAW((nil))/tcpv4(29) cob=(nil),0:NONE((nil))/NONE((nil))/NONE(0) filters={0x7fcaf4016fb0="cache store filter", 0x7fcaf4017080="compression filter"}]

This may be backported to 2.0.

5 years agoBUG/MEDIUM: shctx: bound the number of loops that can happen around the lock
Willy Tarreau [Fri, 1 May 2020 11:15:32 +0000 (13:15 +0200)] 
BUG/MEDIUM: shctx: bound the number of loops that can happen around the lock

Given that a "count" value of 32M was seen in _shctx_wait4lock(), it
is very important to prevent this from happening again. It's absolutely
essential to prevent the value from growing unbounded because with an
increase of the number of threads, the number of successive failed
attempts will necessarily grow.

Instead now we're scanning all 2^p-1 values from 3 to 255 and are
bounding to count to 255 so that in the worst case each thread tries an
xchg every 255 failed read attempts. That's one every 4 on average per
thread when there are 64 threads, which corresponds to the initial count
of 4 for the first attempt so it seems like a reasonable value to keep a
low latency.

The bug was introduced with the shctx entries in 1.5 so the fix must
be backported to all versions. Before 1.8 the function was called
_shared_context_wait4lock() and was in shctx.c.

5 years agoBUG/MEDIUM: shctx: really check the lock's value while waiting
Willy Tarreau [Fri, 1 May 2020 11:05:29 +0000 (13:05 +0200)] 
BUG/MEDIUM: shctx: really check the lock's value while waiting

Jérôme reported an amazing crash in the spinlock version of
_shctx_wait4lock() with an extremely high <count> value of 32M! The
root cause is that the function cannot deal with contention on the lock
at all because it forgets to check if the lock's value has changed! As
such, every time it's called due to a contention, it waits twice as
long before trying again and lets the caller check for the contention
by itself.

The correct thing to do is to compare the value again at each loop.
This way it makes sure to mostly perform read accesses on the shared
cache line without writing too often, and to be ready fast enough to
try to grab the lock. And we must not increase the count on success
either!

Unfortunately I'd have expected to see a performance boost on the cache
with this but there was absolutely no change, so it's very likely that
these issues only happen once in a while and are sufficient to derail
the process when they strike, but not to have a permanent performance
impact.

The bug was introduced with the shctx entries in 1.5 so the fix must
be backported to all versions. Before 1.8 the function was called
_shared_context_wait4lock() and was in shctx.c.

5 years agoBUG/MINOR: debug: properly use long long instead of long for the thread ID
Willy Tarreau [Fri, 1 May 2020 10:26:03 +0000 (12:26 +0200)] 
BUG/MINOR: debug: properly use long long instead of long for the thread ID

I changed my mind twice on this one and pushed after the last test with
threads disabled, without re-enabling long long, causing this rightful
build warning.

This needs to be backported if the previous commit ff64d3b027 ("MINOR:
threads: export the POSIX thread ID in panic dumps") is backported as
well.

5 years agoMINOR: threads: export the POSIX thread ID in panic dumps
Willy Tarreau [Fri, 1 May 2020 09:28:49 +0000 (11:28 +0200)] 
MINOR: threads: export the POSIX thread ID in panic dumps

It is very difficult to map a panic dump against a gdb thread dump
because the thread numbers do not match. However gdb provides the
pthread ID but this one is supposed to be opaque and not to be cast
to a scalar.

This patch provides a fnuction, ha_get_pthread_id() which retrieves
the pthread ID of the indicated thread and casts it to an unsigned
long long so as to lose the least possible amount of information from
it. This is done cleanly using a union to maintain alignment so as
long as these IDs are stored on 1..8 bytes they will be properly
reported. This ID is now presented in the panic dumps so it now
becomes possible to map these threads. When threads are disabled,
zero is returned. For example, this is a panic dump:

  Thread 1 is about to kill the process.
  *>Thread 1 : id=0x7fe92b825180 act=0 glob=0 wq=1 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=1 prof=0 harmless=0 wantrdv=0
               cpu_ns: poll=5119122 now=2009446995 diff=2004327873
               curr_task=0xc99bf0 (task) calls=4 last=0
                 fct=0x592440(task_run_applet) ctx=0xca9c50(<CLI>)
               strm=0xc996a0 src=unix fe=GLOBAL be=GLOBAL dst=<CLI>
               rqf=848202 rqa=0 rpf=80048202 rpa=0 sif=EST,200008 sib=EST,204018
               af=(nil),0 csf=0xc9ba40,8200
               ab=0xca9c50,4 csb=(nil),0
               cof=0xbf0e50,1300:PASS(0xc9cee0)/RAW((nil))/unix_stream(20)
               cob=(nil),0:NONE((nil))/NONE((nil))/NONE(0)
               call trace(20):
               |       0x59e4cf [48 83 c4 10 5b 5d 41 5c]: wdt_handler+0xff/0x10c
               | 0x7fe92c170690 [48 c7 c0 0f 00 00 00 0f]: libpthread:+0x13690
               | 0x7ffce29519d9 [48 c1 e2 20 48 09 d0 48]: linux-vdso:+0x9d9
               | 0x7ffce2951d54 [eb d9 f3 90 e9 1c ff ff]: linux-vdso:__vdso_gettimeofday+0x104/0x133
               |       0x57b484 [48 89 e6 48 8d 7c 24 10]: main+0x157114
               |       0x50ee6a [85 c0 75 76 48 8b 55 38]: main+0xeaafa
               |       0x50f69c [48 63 54 24 20 85 c0 0f]: main+0xeb32c
               |       0x59252c [48 c7 c6 d8 ff ff ff 44]: task_run_applet+0xec/0x88c
    Thread 2 : id=0x7fe92b6e6700 act=0 glob=0 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=0 prof=0 harmless=1 wantrdv=0
               cpu_ns: poll=786738 now=1086955 diff=300217
               curr_task=0
    Thread 3 : id=0x7fe92aee5700 act=0 glob=0 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=0 prof=0 harmless=1 wantrdv=0
               cpu_ns: poll=828056 now=1129738 diff=301682
               curr_task=0
    Thread 4 : id=0x7fe92a6e4700 act=0 glob=0 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
               stuck=0 prof=0 harmless=1 wantrdv=0
               cpu_ns: poll=818900 now=1153551 diff=334651
               curr_task=0

And this is the gdb output:

  (gdb) info thr
    Id   Target Id                         Frame
  * 1    Thread 0x7fe92b825180 (LWP 15234) 0x00007fe92ba81d6b in raise () from /lib64/libc.so.6
    2    Thread 0x7fe92b6e6700 (LWP 15235) 0x00007fe92bb56a56 in epoll_wait () from /lib64/libc.so.6
    3    Thread 0x7fe92a6e4700 (LWP 15237) 0x00007fe92bb56a56 in epoll_wait () from /lib64/libc.so.6
    4    Thread 0x7fe92aee5700 (LWP 15236) 0x00007fe92bb56a56 in epoll_wait () from /lib64/libc.so.6

We can clearly see that while threads 1 and 2 are the same, gdb's
threads 3 and 4 respectively are haproxy's threads 4 and 3.

This may be backported to 2.0 as it removes some confusion in github issues.

5 years agoBUG/MEDIUM: listener: mark the thread as not stuck inside the loop
Willy Tarreau [Fri, 1 May 2020 07:51:11 +0000 (09:51 +0200)] 
BUG/MEDIUM: listener: mark the thread as not stuck inside the loop

We tried hard to make sure we report threads as not stuck at various
crucial places, but one of them is special, it's the listener_accept()
function. The reason it is special is because it will loop a certain
number of times (default: 64) accepting incoming connections, allocating
resources, dispatching them to other threads or running L4 rules on them,
and while all of this is supposed to be extremely fast, when the machine
slows down or runs low on memory, the expectedly small delays in malloc()
caused by contention with other threads can quickly accumulate and suddenly
become critical to the point of triggering the watchdog. Furthermore, it
is technically possible to trigger this by pure configuration by setting
a huge tune.maxaccept value, which should not be possible.

Given that each operation isn't related to the same task but to a different
one each time, it is appropriate to mark the thread as not stuck each time
it accepts new work that possibly gets dispatched to other threads which
execute it.

This looks like this could be a good reason for the issue reported in
issue #388.

This fix must be backported to 2.0.

5 years agoCLEANUP: ssl: silence a build warning when threads are disabled
Willy Tarreau [Fri, 1 May 2020 09:38:39 +0000 (11:38 +0200)] 
CLEANUP: ssl: silence a build warning when threads are disabled

Building without threads now shows this warning:

src/ssl_sock.c: In function 'cli_io_handler_commit_cert':
src/ssl_sock.c:12121:24: warning: unused variable 'bind_conf' [-Wunused-variable]
      struct bind_conf *bind_conf = ckchi->bind_conf;
                        ^~~~~~~~~

This is because the variable is needed only to unlock the structure, and
the unlock operation does nothing in this case. Let's mark the variable
__maybe_unused for this, but it would be convenient in the long term if
we could make the thread macros pretend they consume the argument so that
this remains less visible outside.

No backport is needed.

5 years agoREGTEST: ssl: improve the "set ssl cert" test
William Lallemand [Thu, 30 Apr 2020 08:19:40 +0000 (10:19 +0200)] 
REGTEST: ssl: improve the "set ssl cert" test

Improve the test by removing the curl command and using the same proxy
chaining technique as in commit 3ed722f ("REGTEST: ssl: remove curl from
the "add ssl crt-list" test").

A 3rd request was added which must fail, to ensure that the SNI was
effectively removed from HAProxy.

This patch also adds timeouts in the default section, logs on stderr and
fix some indentation issues.

5 years agoREGTEST: ssl: remove curl from the "add ssl crt-list" test
William Lallemand [Thu, 30 Apr 2020 07:47:08 +0000 (09:47 +0200)] 
REGTEST: ssl: remove curl from the "add ssl crt-list" test

Using curl for SSL tests can be a problem if it wasn't compiled with the
right SSL library and if it didn't share any cipher with HAProxy. To
have more robust tests we now use HAProxy as an SSL client, so we are
sure that the client and the server share the same SSL requirements.

This patch also adds timeouts in the default section, logs on stderr and
fix some indentation issues.

5 years agoREGTEST: http-rules: Require PCRE or PCRE2 option to run map_redirect script
Christopher Faulet [Wed, 29 Apr 2020 12:32:26 +0000 (14:32 +0200)] 
REGTEST: http-rules: Require PCRE or PCRE2 option to run map_redirect script

Only PCRE was specified as required option to execute this script. But PCRE2 is
an valid alternative.

5 years agoDOC: Add more info about request formatting in http-check send description
Christopher Faulet [Wed, 29 Apr 2020 12:20:47 +0000 (14:20 +0200)] 
DOC: Add more info about request formatting in http-check send description

Only one Host header can be defined and some headers are automatically skipped
(Connection, Content-Length and Transfer-Encoding). In addition, a note about
the synchronisation of the Host header value and the request uri has been added.

5 years agoDOC: Fix send rules in the http-check connect example
Christopher Faulet [Wed, 29 Apr 2020 12:19:13 +0000 (14:19 +0200)] 
DOC: Fix send rules in the http-check connect example

Method, uri and version arguments must be explicitly named.

5 years agoCLEANUP: checks: Fix checks includes
Christopher Faulet [Wed, 29 Apr 2020 11:32:21 +0000 (13:32 +0200)] 
CLEANUP: checks: Fix checks includes

5 years agoMINOR: checks: Keep the Host header and the request uri synchronized
Christopher Faulet [Wed, 29 Apr 2020 11:21:37 +0000 (13:21 +0200)] 
MINOR: checks: Keep the Host header and the request uri synchronized

Because in HTTP, the host header and the request authority, if any, must be
identical, we keep both synchornized. It means the right flags are set on the
HTX statrt-line calling http_update_host(). There is no header when it happens,
but it is not an issue. Then, if a Host header is inserted,
http_update_authority() is called.

Note that for now, the host header is not automatically added when required.

5 years agoMINOR: checks: Skip some headers for http-check send rules
Christopher Faulet [Wed, 29 Apr 2020 09:50:01 +0000 (11:50 +0200)] 
MINOR: checks: Skip some headers for http-check send rules

Connection, content-length and transfer-encoding headers are ignored for
http-check send rules. For now, the keep-alive is not supported and the
"connection: close" header is always added to the request. And the
content-length header is automatically added.

5 years agoMINOR: checks: Don't support multiple host header for http-check send rule
Christopher Faulet [Wed, 29 Apr 2020 09:45:44 +0000 (11:45 +0200)] 
MINOR: checks: Don't support multiple host header for http-check send rule

Only one host header definition is supported. There is no reason to define it
several times.

5 years agoMINOR: http-htx: Export functions to update message authority and host
Christopher Faulet [Tue, 28 Apr 2020 17:57:29 +0000 (19:57 +0200)] 
MINOR: http-htx: Export functions to update message authority and host

These functions will be used by HTTP health checks when a request is formatted
before sending it.

5 years agoBUG/MEDIUM: sample: make the CPU and latency sample fetches check for a stream
Willy Tarreau [Wed, 29 Apr 2020 09:59:02 +0000 (11:59 +0200)] 
BUG/MEDIUM: sample: make the CPU and latency sample fetches check for a stream

cpu_calls, cpu_ns_avg, cpu_ns_tot, lat_ns_avg and lat_ns_tot depend on the
stream to find the current task and must check for it or they may cause a
crash if misused or used in a log-format string after commit 5f940703b3
("MINOR: log: Don't depends on a stream to process samples in log-format
string").

This must be backported as far as 1.9.

5 years agoCLEANUP: http: add a few comments on certain functions' assumptions about streams
Willy Tarreau [Wed, 29 Apr 2020 09:52:51 +0000 (11:52 +0200)] 
CLEANUP: http: add a few comments on certain functions' assumptions about streams

get_http_auth() expects a valid stream but this is not mentioned, though
fortunately it's always called from places which already check this.

smp_prefetch_htx() performs all the required checks and is the key to the
stability of almost all sample fetch functions, so let's make this clearer.

5 years agoBUG/MEDIUM: http: the "unique-id" sample fetch could crash without a steeam
Willy Tarreau [Wed, 29 Apr 2020 09:50:38 +0000 (11:50 +0200)] 
BUG/MEDIUM: http: the "unique-id" sample fetch could crash without a steeam

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The unique-id sample fetch function, if called without a stream, will result
in a crash.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.7.

5 years agoBUG/MEDIUM: http: the "http_first_req" sample fetch could crash without a steeam
Willy Tarreau [Wed, 29 Apr 2020 09:52:13 +0000 (11:52 +0200)] 
BUG/MEDIUM: http: the "http_first_req" sample fetch could crash without a steeam

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The http_first_req sample fetch function, if called without a stream, will
result in a crash.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.

5 years agoBUG/MEDIUM: capture: capture.{req,res}.* crash without a stream
Willy Tarreau [Wed, 29 Apr 2020 09:44:54 +0000 (11:44 +0200)] 
BUG/MEDIUM: capture: capture.{req,res}.* crash without a stream

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The capture.req.hdr, capture.res.hdr, capture.req.method, capture.req.uri,
capture.req.ver and capture.res.ver sample fetches used to assume the
presence of a stream, which is not necessarily the case (especially after
the commit above) and would crash haproxy if incorrectly used. Let's make
sure they check for this stream.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.

5 years agoBUG/MEDIUM: capture: capture-req/capture-res converters crash without a stream
Willy Tarreau [Wed, 29 Apr 2020 09:22:08 +0000 (11:22 +0200)] 
BUG/MEDIUM: capture: capture-req/capture-res converters crash without a stream

Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The capture-req and capture-res converters were in this case and could
crash the process if misused.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.

5 years agoDOC: give a more accurate description of what check does
Jerome Magnin [Sun, 26 Apr 2020 12:23:04 +0000 (14:23 +0200)] 
DOC: give a more accurate description of what check does

The documentation for check implies that without an application
level check configured, it only enables simple tcp checks. What it
actually does is verify that the configured transport layer is available,
and that optional application level checks succeed.

5 years agoREGTEST: ssl: test the client certificate authentication
William Lallemand [Tue, 28 Apr 2020 19:52:38 +0000 (21:52 +0200)] 
REGTEST: ssl: test the client certificate authentication

This reg-test tests the client auth feature of HAProxy for both the
backend and frontend section with a CRL list.

This reg-test uses 2 chained listeners because vtest does not handle the
SSL. Test the frontend client auth and the backend side at the same
time.

It sends 3 requests: one with a correct certificate, one with an expired
one and one which was revoked. The client then checks if we received the
right one with the right error.

Certificates, CA and CRL are expiring in 2050 so it should be fine for
the CI.

This test could be backported as far as HAProxy 1.6

5 years agoBUG/MEDIUM: mux-h1: make sure we always have a timeout on front connections
Willy Tarreau [Tue, 28 Apr 2020 17:48:41 +0000 (19:48 +0200)] 
BUG/MEDIUM: mux-h1: make sure we always have a timeout on front connections

Mux-h1 currently heavily relies on the presence of an upper stream, even
when waiting for a new request after one is being finished, and it's that
upper stream that's in charge of request and keep-alive timeouts for now.
But since recent commit 493d9dc6ba ("MEDIUM: mux-h1: do not blindly wake
up the tasklet at end of request anymore") that assumption was broken as
the purpose of this change was to avoid initiating processing of a request
when there's no data in the buffer. The side effect is that there's no more
timeout to handle the front connection, resulting in dead front connections
stacking up as clients get kicked off the net.

This fix makes sure we always enable the timeout when there's no stream
attached to the connection. It doesn't do this for back connections since
they may purposely be left idle.

No backport is needed as this bug was introduced in 2.2-dev4.

5 years agoBUG/MINOR: checks: Set the output buffer length before calling parse_binary()
Christopher Faulet [Tue, 28 Apr 2020 14:40:41 +0000 (16:40 +0200)] 
BUG/MINOR: checks: Set the output buffer length before calling parse_binary()

A bug was introduced in the commit 2edcd4cbd ("BUG/MINOR: checks: Avoid
incompatible cast when a binary string is parsed"). The length of the
destination buffer must be set before call the parse_binary() function.

No backport needed.

5 years agoMINOR: log: Add "Tu" timer
Damien Claisse [Tue, 28 Apr 2020 12:09:19 +0000 (12:09 +0000)] 
MINOR: log: Add "Tu" timer

It can be sometimes useful to measure total time of a request as seen
from an end user, including TCP/TLS negotiation, server response time
and transfer time. "Tt" currently provides something close to that, but
it also takes client idle time into account, which is problematic for
keep-alive requests as idle time can be very long. "Ta" is also not
sufficient as it hides TCP/TLS negotiationtime. To improve that, introduce
a "Tu" timer, without idle time and everything else. It roughly estimates
time spent time spent from user point of view (without DNS resolution
time), assuming network latency is the same in both directions.

5 years agoBUG/MINOR: checks: Don't lose warning on proxy capability
Christopher Faulet [Tue, 28 Apr 2020 08:47:28 +0000 (10:47 +0200)] 
BUG/MINOR: checks: Don't lose warning on proxy capability

When a tcp-check line is parsed, a warning may be reported if the keyword is
used for a frontend. The return value must be used to report it. But this info
is lost before the end of the function.

Partly fixes issue #600. No backport needed.

5 years agoBUG/MINOR: checks: Remove bad call to free() when an expect rule is parsed
Christopher Faulet [Tue, 28 Apr 2020 08:42:42 +0000 (10:42 +0200)] 
BUG/MINOR: checks: Remove bad call to free() when an expect rule is parsed

When an error is found during the parsing of an expect rule (tcp or http),
everything is released at the same place, at the end of the function.

Partly fixes issue #600. No backport needed.

5 years agoBUG/MINOR: checks: Avoid incompatible cast when a binary string is parsed
Christopher Faulet [Tue, 28 Apr 2020 08:39:50 +0000 (10:39 +0200)] 
BUG/MINOR: checks: Avoid incompatible cast when a binary string is parsed

parse_binary() function must be called with a pointer on an integer. So don't
pass a pointer on a size_t element, casting it to a pointer on a integer.

Partly fixes issue #600. No backport needed.

5 years agoMINOR: checks: Make the use of the check's server more explicit on connect
Christopher Faulet [Tue, 28 Apr 2020 08:31:53 +0000 (10:31 +0200)] 
MINOR: checks: Make the use of the check's server more explicit on connect

The variable s, pointing on the check server, may be null when a connection is
openned. It happens for email alerts. To avoid ambiguities, its use is now more
explicit. Comments have been added at some places and tests on the variable have
been added elsewhere (useless but explicit).

Partly fixes issue #600.

5 years agoCLEANUP: checks: Remove unused code when ldap server message is parsed
Christopher Faulet [Tue, 28 Apr 2020 08:29:04 +0000 (10:29 +0200)] 
CLEANUP: checks: Remove unused code when ldap server message is parsed

In tcpcheck_ldap_expect_bindrsp(), wait_more_data label cannot be reached.

Partly fixes issue #600.

5 years agoBUG/MINOR: checks: Properly handle truncated mysql server messages
Christopher Faulet [Tue, 28 Apr 2020 08:24:23 +0000 (10:24 +0200)] 
BUG/MINOR: checks: Properly handle truncated mysql server messages

If a message is not fully received from a mysql server, depending on last_read
value, an error must be reported or we must wait for more data. The first if
statement must not check last_read.

Partly fixes issue #600. No backport needed.

5 years agoBUG/MINOR: checks: Remove wrong variable redeclaration
Christopher Faulet [Tue, 28 Apr 2020 07:46:20 +0000 (09:46 +0200)] 
BUG/MINOR: checks: Remove wrong variable redeclaration

When mysql-check option is parsed, the user variable is redeclared without any
reason. thus the redeclared variable is removed.

No backport needed.

5 years agoMINOR: checks: Use ver keyword to specify the HTTP version for http checks
Christopher Faulet [Tue, 28 Apr 2020 07:37:00 +0000 (09:37 +0200)] 
MINOR: checks: Use ver keyword to specify the HTTP version for http checks

'ver' keyword is already used by sample fetches while 'vsn' is not used anywhere
else. So better to use 'ver' too for http-check send rules.

5 years agoMINOR: checks: Support HTTP/2 version (without '.0') for http-check send rules
Christopher Faulet [Tue, 28 Apr 2020 07:10:19 +0000 (09:10 +0200)] 
MINOR: checks: Support HTTP/2 version (without '.0') for http-check send rules

The version is partially parsed to set the flag HTX_SL_F_VER_11 on the HTX
message. But exactly 8 chars is expected. So if "HTTP/2" is specified, the flag
is not set. Thus, the version parsing has been updated to handle "HTTP/2" and
"HTTP/2.0" the same way.

5 years agoCI: cirrus-ci: remove reg-tests/checks/tcp-check-ssl.vtc on CentOS 6
Ilya Shipitsin [Mon, 27 Apr 2020 18:35:13 +0000 (23:35 +0500)] 
CI: cirrus-ci: remove reg-tests/checks/tcp-check-ssl.vtc on CentOS 6

reg-tests/checks/tcp-check-ssl.vtc requires ALPN which is not
available on CentOS 6

5 years agoBUG/MINOR: checks: Fix PostgreSQL regex on the authentication packet
Christopher Faulet [Mon, 27 Apr 2020 16:29:49 +0000 (18:29 +0200)] 
BUG/MINOR: checks: Fix PostgreSQL regex on the authentication packet

For PostgreSQL health check, there is a regex on the backend authentication
packet. It must match to succeed. But it exists 6 types of authentication
packets and the regex only matches the first one (AuthenticationOK). This patch
fixes the regex to match all authentication packets.

No backport needed.

5 years agoBUG/MEDIUM: checks: Destroy the conn-stream before the session
Christopher Faulet [Mon, 27 Apr 2020 13:59:22 +0000 (15:59 +0200)] 
BUG/MEDIUM: checks: Destroy the conn-stream before the session

At the end of a tcp-check based health check, if there is still a connection
attached to the check, it must be closed. But it must be done before releasing
the session, because the session may still be referenced by the mux. For
instance, an h2 stream may still have a reference on the session.

No need to backport.

5 years agoBUG/MEDIUM: sessions: Always pass the mux context as argument to destroy a mux
Christopher Faulet [Mon, 27 Apr 2020 13:53:41 +0000 (15:53 +0200)] 
BUG/MEDIUM: sessions: Always pass the mux context as argument to destroy a mux

This bug was introduced by the commit 2444aa5b ("MEDIUM: sessions: Don't be
responsible for connections anymore."). In session_check_idle_conn(), when the
mux is destroyed, its context must be passed as argument instead of the
connection.

It is de 2.2-dev bug. No need to backport.

5 years agoBUG/MINOR: checks/server: use_ssl member must be signed
Christopher Faulet [Mon, 27 Apr 2020 10:13:06 +0000 (12:13 +0200)] 
BUG/MINOR: checks/server: use_ssl member must be signed

5 years agoBUG/MINOR: checks: Only use ssl_sock_is_ssl() if compiled with SSL support
Christopher Faulet [Mon, 27 Apr 2020 10:06:55 +0000 (12:06 +0200)] 
BUG/MINOR: checks: Only use ssl_sock_is_ssl() if compiled with SSL support

ssl_sock_is_ssl() only exists if HAProxy is complied with SSL support.

No backport needed.

5 years agoBUG/MEDIUM: checks: unsubscribe for events on the old conn-stream on connect
Christopher Faulet [Mon, 27 Apr 2020 09:22:56 +0000 (11:22 +0200)] 
BUG/MEDIUM: checks: unsubscribe for events on the old conn-stream on connect

When a new connection is established, if an old connection is still attached to
the current check, it must be detroyed. When it happens, the old conn-stream
must be used to unsubscribe for events, not the new one.

No backport is needed.

5 years agoBUG/MINOR: server: Fix server_finalize_init() to avoid unused variable
Christopher Faulet [Mon, 27 Apr 2020 09:17:10 +0000 (11:17 +0200)] 
BUG/MINOR: server: Fix server_finalize_init() to avoid unused variable

The variable 'ret' must only be declared When HAProxy is compiled with the SSL
support (more precisely SSL_CTRL_SET_TLSEXT_HOSTNAME must be defined).

No backport needed.

5 years agoREGTEST: Add a script to validate agent checks
Christopher Faulet [Fri, 24 Apr 2020 14:25:28 +0000 (16:25 +0200)] 
REGTEST: Add a script to validate agent checks

5 years agoBUG/MEDIUM: checks: Unsubscribe to mux events when a conn-stream is destroyed
Christopher Faulet [Fri, 24 Apr 2020 14:20:49 +0000 (16:20 +0200)] 
BUG/MEDIUM: checks: Unsubscribe to mux events when a conn-stream is destroyed

Since the tcp-check based heath checks uses the best multuplexer for a
connection, the mux-pt is no longer the only possible choice. So events
subscriptions and unsubscriptions must be done with the mux.

No backport needed.

5 years agoMINOR: checks: Support list of status codes on http-check expect rules
Christopher Faulet [Fri, 24 Apr 2020 11:53:12 +0000 (13:53 +0200)] 
MINOR: checks: Support list of status codes on http-check expect rules

It is now possible to match on a comma-separated list of status codes or range
of codes. In addtion, instead of a string comparison to match the response's
status code, a integer comparison is performed. Here is an example:

  http-check expect status 200,201,300-310

5 years agoBUG/MINOR: mux-fcgi: Be sure to have a connection as session's origin to use it
Christopher Faulet [Fri, 24 Apr 2020 05:19:04 +0000 (07:19 +0200)] 
BUG/MINOR: mux-fcgi: Be sure to have a connection as session's origin to use it

When default parameters are set in a request message, we get the client
connection using the session's origin. But it is not necessarily a
conncection. For instance, for health checks, thanks to recent changes, it may
be a check object. At this step, the client connection may be NULL. Thus, we
must be sure to have a client connection before using it.

This patch must be backported to 2.1.

5 years agoMINOR: checks: Support mux protocol definition for tcp and http health checks
Christopher Faulet [Thu, 23 Apr 2020 14:27:59 +0000 (16:27 +0200)] 
MINOR: checks: Support mux protocol definition for tcp and http health checks

It is now possible to force the mux protocol for a tcp-check based health check
using the server keyword "check-proto". If set, this parameter overwrites the
server one.

In the same way, a "proto" parameter has been added for tcp-check and http-check
connect rules. If set, this mux protocol overwrites all others for the current
connection.

5 years agoBUG/MEDIUM: checks: Use the mux protocol specified on the server line
Christopher Faulet [Thu, 23 Apr 2020 13:50:18 +0000 (15:50 +0200)] 
BUG/MEDIUM: checks: Use the mux protocol specified on the server line

First, when a server health check is initialized, it inherits the mux protocol
from the server if it is not already specified. Because there is no option to
specify the mux protocol for the checks, it is always inherited from the server
for now.

Then, if the connect rule is configured to use the server options, the mux
protocol of the check is used, if defined. Of course, if a mux protocol is
already defined for the connect rule, it is used in priority. But for now, it is
not possible.

Thus, if a server is configured to use, for instance, the h2 protocol, it is
possible to do the same for the health-checks.

No backport needed.

5 years agoDOC: Fix the tcp-check and http-check directives layout
Christopher Faulet [Thu, 23 Apr 2020 13:43:35 +0000 (15:43 +0200)] 
DOC: Fix the tcp-check and http-check directives layout

5 years agoDOC: Add documentation about comments for tcp-check and http-check directives
Christopher Faulet [Thu, 23 Apr 2020 13:22:33 +0000 (15:22 +0200)] 
DOC: Add documentation about comments for tcp-check and http-check directives

The documentation about the comment argument for some tcp-check and http-check
directives was missing. As well as the description of "tcp-check comment" and
"http-check comment" directives.

5 years agoRevert "MEDIUM: checks: capture groups in expect regexes"
Christopher Faulet [Wed, 22 Apr 2020 13:32:11 +0000 (15:32 +0200)] 
Revert "MEDIUM: checks: capture groups in expect regexes"

This reverts commit 1979943c30ef285ed04f07ecf829514de971d9b2.

Captures in comment was only used when a tcp-check expect based on a negative
regex matching failed to eventually report what was captured while it was not
expected. It is a bit far-fetched to be useable IMHO. on-error and on-success
log-format strings are far more usable. For now there is few check sample
fetches (in fact only one...). But it could be really powerful to report info in
logs.

5 years agoREGTEST: Add scripts to test based tcp-check health-checks
Christopher Faulet [Wed, 22 Apr 2020 13:16:58 +0000 (15:16 +0200)] 
REGTEST: Add scripts to test based tcp-check health-checks

These scripts have been added to validate the health-checks based on tcp-check
rules (http, redis, MySQL...).

5 years agoBUG/MINOR: checks: Send the right amount of outgoing data for HTTP checks
Christopher Faulet [Wed, 22 Apr 2020 09:09:25 +0000 (11:09 +0200)] 
BUG/MINOR: checks: Send the right amount of outgoing data for HTTP checks

HTTP health-checks now use HTX multiplexers. So it is important to really send
the amount of outgoing data for such checks because the HTX buffers appears
always full.

No backport needed.

5 years agoMINOR: checks: Use a tree instead of a list to store tcp-check rulesets
Christopher Faulet [Tue, 21 Apr 2020 11:45:00 +0000 (13:45 +0200)] 
MINOR: checks: Use a tree instead of a list to store tcp-check rulesets

Since all tcp-check rulesets are globally stored, it is a problem to use
list. For configuration with many backends, the lookups in list may be costly
and slow downs HAProxy startup. To solve this problem, tcp-check rulesets are
now stored in a tree.

5 years agoBUG/MEDIUM: checks: Be sure to subscribe for sends if outgoing data remains
Christopher Faulet [Tue, 21 Apr 2020 11:02:14 +0000 (13:02 +0200)] 
BUG/MEDIUM: checks: Be sure to subscribe for sends if outgoing data remains

When some data are scheduled to be sent, we must be sure to subscribe for sends
if nothing was sent. Because of a bug, when nothing was sent, connection errors
are checks. If no error is found, we exit, waiting for more data, without any
subcription on send events.

No need to backport.

5 years agoMINOR: checks: Use ist API as far as possible
Christopher Faulet [Tue, 21 Apr 2020 08:57:42 +0000 (10:57 +0200)] 
MINOR: checks: Use ist API as far as possible

Instead of accessing directly to the ist fields, the ist API is used instead. To
get its length or its pointer, to release it or to duplicate it. It is more
readable this way.