Commit Graph

14323 Commits

Author SHA1 Message Date
Willy Tarreau f8d9ec57f0 CONTRIB: move src/da.c and contrib/deviceatlas to addons/deviceatlas
Both the source file and the dummy library are now at the same place.
Maybe the build howto could be moved there as well to make things even
cleaner.

The Makefile, MAINTAINERS, doc, github build matrix, coverity checks
and travis CI's build were updated.
2021-04-02 17:48:42 +02:00
Willy Tarreau 977209d1d8 CONTRIB: move 51Degrees to addons/51degrees
Now it's much cleaner, both 51d.c and the dummy library live together and
are easier to spot and maintain. The build howto probably ought to be moved
there as well. Makefile, docs and MAINTAINERS were updated, as well as
the github CI's build matrix, travis CI's, and coverity checks.
2021-04-02 17:48:42 +02:00
Willy Tarreau 1efe68978e DOC: add a few words about USE_* and the addons directory
Nowhere it was really explained what USE_* was used for. Let's
take this opportunity to introduce addons/ which will also rely
on these.
2021-04-02 17:48:42 +02:00
Willy Tarreau 3dfadc7ae7 CONTRIB: move prometheus-exporter to addons/promex
Let's start to better organize the addons by moving promex there (and
with an easier directory name). The makefile and maintainers files were
updated, as well as the CI's build matrix.
2021-04-02 17:48:42 +02:00
Willy Tarreau 92dc78605a BUILD: makefile: add a "USE_PROMEX" variable to ease building prometheus-exporter
The Prometheus exporter has gained in popularity and deserves to be easier
to build. Let's add a standard "USE_PROMEX" variable to enable it without
having to modify EXTRA_OBJS nor fiddling with the build path. The readme
was updated to reflect this.
2021-04-02 17:48:42 +02:00
Willy Tarreau a9f16c6495 BUILD: makefile: build halog with the correct flags
halog currently emits lots of warnings because it does not benefit from
the default flags. Let's update the main makefile to build it by itself
and remove the other one. The sub-project's makefile was replaced with
A readme indicating how to build it.
2021-04-02 17:48:42 +02:00
Willy Tarreau c4710e14fe ADMIN: halog: automatically enable USE_MEMCHR on the right glibc version
There has been a USE_MEMCHR option for ages that was mostly never enabled
because it was unclear when glibc became faster. A quick look at the code
indicates that this arrived with the SSE implementation of memchr() which
arrived at commit 093ecf92998de2 between 2.14 and 2.15, so let's automatically
turn this on on x86_64 with glibc >= 2.15.

This results in ~6GB of logs read per second (20 million lines) and ~2.5GB/s
(8 million lines) parsed for errors or status codes classification, or 1 GB/s
(3 million lines) for time percentiles.
2021-04-02 17:48:42 +02:00
Willy Tarreau d798889a5d CONTRIB: move halog to admin/
halog is an admin tool, so let's move it to admin/ as well. The makefile
was updated to build from the new directory.
2021-04-02 17:48:42 +02:00
Willy Tarreau 233e868895 CONTRIB: move some admin-related sub-projects to admin/
The following components were moved to admin/ because they're generally
used in field by admins:

  iprange/  netsnmp-perl/  selinux/  systemd/  wireshark-dissectors/
  syntax-highlight/ release-estimator/
2021-04-02 17:48:42 +02:00
Willy Tarreau 6a6dabe668 CONTRIB: merge ip6range with iprange
No need to have two separate sub-projects doing the same thing, let's
merge them.
2021-04-02 17:48:42 +02:00
Willy Tarreau 21ef8b9064 BUILD: makefile: integrate the hpack tools
The few hpack development tools are now integrated into the main
makefile, which allows to remove the original one which was causing
lots of build warnings. A README was added to explain how to build
instead.
2021-04-02 17:48:42 +02:00
Willy Tarreau 339eb0b002 DEV: flags: replace the unneeded makefile with a README
The makefile was not suited anymore as it didn't consider all
required compiler options and was causing way too many build
warnings with modern compilers. Let's just remove it and indicate
that this has to be built from the top of the project.
2021-04-02 17:48:42 +02:00
Willy Tarreau 888bda0ace BUILD: makefile: always build the flags utility
This utility is absolutely required for developers and not having it
built by default is a real pain that tends to encourage keeping an
outdated copy somewhere else. Let's have it built by default then,
since it has no dependency and is ultra-small.
2021-04-02 17:48:42 +02:00
Willy Tarreau 074ebcde29 CONTRIB: move some dev-specific tools to dev/
The following directories were moved from contrib/ to dev/ to make their
use case a bit clearer. In short, only developers are expected to ever
go there. The makefile was updated to build and clean from these ones.

base64/  flags/  hpack/  plug_qdisc/  poll/  tcploop/  trace/
2021-04-02 17:48:42 +02:00
Willy Tarreau 34b4369709 CONTRIB: debug: split poll from flags
Now poll is its own project and doesn't share the "flags" Makefile
any more. One of the issues was that it was making references to the
haproxy include path which is not needed here.
2021-04-02 17:48:42 +02:00
Willy Tarreau 6a54d74662 CONTRIB: debug: add the show-fd-to-flags script
This script reads the output of a "show fd" command and for each line
showing a connection, will decode its flags by calling "flags".
2021-04-02 17:48:42 +02:00
Willy Tarreau c3890e5a2d CONTRIB: tcploop: add a shutr command
Usually this has limited effect except for listening sockets, but
at least it helps compare behaviors with and without.
2021-04-02 17:48:42 +02:00
Willy Tarreau b00c00e82c CONTRIB: halog: fix issue with array of type char
I just noticed this in the windows build after moving the file to dev/:

   In file included from include/import/ist.h:32,
                   from include/haproxy/connection-t.h:32,
                   from dev/flags/flags.c:5:
  dev/flags/flags.c: In function `main':
  dev/flags/flags.c:442:20: error: array subscript has type `char' [-Werror=char-subscripts]
    442 |           (isalnum(*err) && toupper(*err) != 'U' && toupper(*err) != 'L'))
        |                    ^~~~
    LD      haproxy
  cc1: all warnings being treated as errors
  make: *** [Makefile:932: dev/flags/flags.o] Error 1
  make: *** Waiting for unfinished jobs....
  Error: Process completed with exit code 2.

Let's just cast it to uchar as is done everywhere else.
2021-04-02 17:47:21 +02:00
William Lallemand a1e832b867 REGTESTS: ssl: mark set_ssl_cert_bundle.vtc as broken
set_ssl_cert_bundle.vtc requires at least OpenSSL 1.1.0 and we don't
have any way to check this when launching the reg-tests suite.

Mark the reg-test as broken since it will fails on old versions of
openSSL and libreSSL.
2021-04-02 17:13:55 +02:00
William Lallemand 35201833aa REGTESTS: ssl: "set ssl cert" and multi-certificates bundle
This test loads a configuration which uses multi-certificates bundle and
tries to change them over the CLI.

Could be backported as far as 2.2, however the 2.2 version must be
adapted to commit the bundle and not each certificate individually.
2021-04-02 15:47:17 +02:00
Willy Tarreau d4359fd98b TESTS: move tests/*.cfg to tests/config
These are a collection of test files for a variety of features (old or
more recent). 2 or 3 files were found lying there non-committed and
were moved at the same time. A few deprecated or obsolete keywords were
updated to their recent equivalent. Many of these configurations are
made to trigger different parsing errors so it is normal that plenty
of them fail.

Now the tests directory is cleaner and easier to navigate through.
2021-04-02 10:59:29 +02:00
Willy Tarreau 38ceb554fd TESTS: slightly reorganize the code in the tests/ directory
The code that is there to run some unit tests on some internal features
was moved to tests/unit. Ideally it should be buildable from the main
makefile though this is not yet the case.

The code that is kept for experimentation purposes (hashes, syscall
optimization etc) as well as some captures of the results was moved
to tests/exp.

A few totally obsolete files which couldn't build anymore and were
not relevant to current versions were removed.
2021-04-02 10:51:12 +02:00
Amaury Denoyelle 728be0f437 MINOR: config: diag if global section after non-global
Detect if a global section is present after another section and reports
a diagnostic about it.
2021-04-01 18:03:37 +02:00
Amaury Denoyelle de2fab55aa MINOR: diag: diag if servers use the same cookie value
Add a diagnostic to check that two servers of the same backend does not
use the same cookie value. Ignore backup servers as it is quite common
for them to share a cookie value with a primary one.
2021-04-01 18:03:37 +02:00
Amaury Denoyelle 5a6926dcf0 MINOR: diag: create cfgdiag module
This module is intended to serve as a placeholder for various
diagnostics executed after the configuration file has been fully loaded.
2021-04-01 18:03:37 +02:00
Amaury Denoyelle da0e7f61e0 MINOR: server: diag for 0 weight server
Output a diagnostic report if a server has been configured with a null
weight.
2021-04-01 18:03:37 +02:00
Amaury Denoyelle c4d47d609a MINOR: cfgparse: diag for multiple nbthread statements
Output a diagnostic report if the nbthread statement is defined on
several places in the configuration.
2021-04-01 18:03:37 +02:00
Amaury Denoyelle 7b01a8dbdd MINOR: global: define diagnostic mode of execution
Define MODE_DIAG which is used to run haproxy in diagnostic mode. This
mode is used to output extra warnings about possible configuration
blunder or sub-optimal usage. It can be activated with argument '-dD'.

A new output function ha_diag_warning is implemented reserved for
diagnostic output. It serves to standardize the format of diagnostic
messages.

A macro HA_DIAG_WARN_COND is also available to automatically check if
diagnostic mode is on before executing the diagnostic check.
2021-04-01 18:03:37 +02:00
Willy Tarreau 374edc70ba CLEANUP: vars: always pre-initialize smp in vars_parse_cli_get_var()
In issue #1200 Coverity believes we may use an uninitialized field
smp.sess here while it's not possible because the returned variable
necessarily matches SCOPE_PROC hence smp.sess is not used. But it
cannot see this and it could be confusing if the code later evolved
into something more complex. That's not a critical path so let's
first reset the sample.
2021-04-01 17:04:17 +02:00
Christopher Faulet 09f88364b7 BUG/MINOR: http-fetch: Fix test on message state to capture the version
A bug was introduced when the legacy HTTP mode was removed. To capture the
HTTP version of the request or the response, we rely on the message state to
be sure the status line was received. However, the test is inverted. The
version can be captured if message headers were received, not the opposite.

This patch must be backported as far as 2.2.
2021-04-01 16:45:40 +02:00
Christopher Faulet d57d9fe3d8 REGTESTS: Add script to tests the wait-for-body HTTP action
This script tests the wait-for-body HTTP action, on the request side and the
response side.
2021-04-01 16:45:34 +02:00
Christopher Faulet 021a8e4d7b MEDIUM: http-rules: Add wait-for-body action on request and response side
Historically, an option was added to wait for the request payload (option
http-buffer-request). This option has 2 drawbacks. First, it is an ON/OFF
option for the whole proxy. It cannot be enabled on demand depending on the
message. Then, as its name suggests, it only works on the request side. The
only option to wait for the response payload was to write a dedicated
filter. While it is an acceptable solution for complex applications, it is a
bit overkill to simply match strings in the body.

To make everyone happy, this patch adds a dedicated HTTP action to wait for
the message payload, for the request or the response depending it is used in
an http-request or an http-response ruleset. The time to wait is
configurable and, optionally, the minimum payload size to have before stop
to wait.

Both the http action and the old http analyzer rely on the same internal
function.
2021-04-01 16:27:40 +02:00
Christopher Faulet 581db2b829 MINOR: payload/config: Warn if a L6 sample fetch is used from an HTTP proxy
L6 sample fetches are now ignored when called from an HTTP proxy. Thus, a
warning is emitted during the startup if such usage is detected. It is true
for most ACLs and for log-format strings. Unfortunately, it is a bit painful
to do so for sample expressions.

This patch relies on the commit "MINOR: action: Use a generic function to
check validity of an action rule list".
2021-04-01 15:34:22 +02:00
Christopher Faulet 42c6cf9501 MINOR: action: Use a generic function to check validity of an action rule list
The check_action_rules() function is now used to check the validity of an
action rule list. It is used from check_config_validity() function to check
L5/6/7 rulesets.
2021-04-01 15:34:22 +02:00
Christopher Faulet 2e96194d00 MINOR: htx: Make internal.strm.is_htx an internal sample fetch
It is not really a context-less sample fetch, but it is internal. And it
only fails if no stream is attached to the sample. This way, it is still
possible to use it on an HTTP proxy (L6 sample fetches are ignored now for
HTTP proxies).

If the commit "BUG/MINOR: payload/htx: Ingore L6 sample fetches for HTX
streams/checks" is backported, it may be a good idea to backport this one
too. But only as far as 2.2.
2021-04-01 15:34:22 +02:00
Christopher Faulet a434a00864 BUG/MINOR: payload/htx: Ingore L6 sample fetches for HTX streams/checks
Use a L6 sample fetch on an HTX streams or a HTX health-check is meaningless
because data are not raw but structured. So now, these sample fetches fail
when called from an HTTP proxy. In addition, a warning has been added in the
configuration manual, at the begining of the L6 sample fetches section.

Note that req.len and res.len samples return the HTX data size instead of
failing. It is not accurate because it does not reflect the buffer size nor
the raw data length. But we keep it for backward compatibility purpose.
However it remains a bit strange to use it on an HTTP proxy.

This patch may be backported to all versions supporting the HTX, i.e as far
as 2.0. But the part about the health-checks is only valid for the 2.2 and
upper.
2021-04-01 15:31:55 +02:00
Christopher Faulet e1b9e1bb1e REGTESTS: Add script to tests TCP to HTTP upgrades
This script tests various TCP>HTTP upgrade scenarios and also performs some
checks for invalid/forbidden upgrades.
2021-04-01 13:51:22 +02:00
Christopher Faulet 4d37e53dfc DOC: config: Add documentation about TCP to HTTP upgrades
This patch adds explanation about chaining a TCP frontend to an HTTP
backend. It also explain how the HTTP upgrades work in this context. A note
has also been added in "Fetching HTTP samples" section to warning about HTTP
content processing in TCP.
2021-04-01 13:24:40 +02:00
Christopher Faulet 5eef0189c7 MINOR: config/proxy: Warn if a TCP proxy without backend is upgradable to HTTP
If a 'switch-mode http' tcp action is configured on a listener with no
backend, a warning is displayed to remember HTTP connections cannot be
routed to TCP servers. Indeed, backend connection is still established using
the proxy mode.
2021-04-01 13:24:34 +02:00
Christopher Faulet 3b6446f4d9 MINOR: config/proxy: Don't warn for HTTP rules in TCP if 'switch-mode http' set
Warnings about ignored HTTP directives in a TCP proxy are inhibited if at
least one switch-mode tcp action is configured to perform HTTP upgraded.
2021-04-01 13:22:42 +02:00
Christopher Faulet ae863c62e3 MEDIUM: Add tcp-request switch-mode action to perform HTTP upgrade
It is now possible to perform HTTP upgrades on a TCP stream from the
frontend side. To do so, a tcp-request content rule must be defined with the
switch-mode action, specifying the mode (for now, only http is supported)
and optionnaly the proto (h1 or h2).

This way it could be possible to set HTTP directives on a TCP frontend which
will only be evaluated if an upgrade is performed. This new way to perform
HTTP upgrades should replace progressively the old way, consisting to route
the request to an HTTP backend. And it should be also a good start to remove
all HTTP processing from tcp-request content rules.

This action is terminal, it stops the ruleset evaluation. It is only
available on proxy with the frontend capability.

The configuration manual has been updated accordingly.
2021-04-01 13:17:19 +02:00
Christopher Faulet 6c1fd987f6 MINOR: stream: Handle stream HTTP upgrade in a dedicated function
The code responsible to perform an HTTP upgrade from a TCP stream is moved
in a dedicated function, stream_set_http_mode().

The stream_set_backend() function is slightly updated, especially to
correctly set the request analysers.
2021-04-01 11:06:48 +02:00
Christopher Faulet 75f619ad92 MINOR: http-ana: Simplify creation/destruction of HTTP transactions
Now allocation and initialization of HTTP transactions are performed in a
unique function. Historically, there were two functions because the same TXN
was reset for K/A connections in the legacy HTTP mode. Now, in HTX, K/A
connections are handled at the mux level. A new stream, and thus a new TXN,
is created for each request. In addition, the function responsible to end
the TXN is now also reponsible to release it.

So, now, http_create_txn() and http_destroy_txn() must be used to create and
destroy an HTTP transaction.
2021-04-01 11:06:48 +02:00
Christopher Faulet c2ac5e4f27 MINOR: filters/http-ana: Decide to filter HTTP headers in HTTP analysers
It is just a small cleanup. AN_REQ_FLT_HTTP_HDRS and AN_RES_FLT_HTTP_HDRS
analysers are now set in HTTP analysers at the same place
AN_REQ_HTTP_XFER_BODY and AN_RES_HTTP_XFER_BODY are set.
2021-04-01 11:06:48 +02:00
Christopher Faulet 1bb6afa35d MINOR: stream: Use stream type instead of proxy mode when appropriate
We now use the stream instead of the proxy to know if we are processing HTTP
data or not. If the stream is an HTX stream, it means we are dealing with
HTTP data. It is more accurate than the proxy mode because when an HTTP
upgrade is performed, the proxy is not changed and only the stream may be
used.

Note that it was not a problem to rely on the proxy because HTTP upgrades
may only happen when an HTTP backend was set. But, we will add the support
of HTTP upgrades on the frontend side, after te tcp-request rules
evaluation.  In this context, we cannot rely on the proxy mode.
2021-04-01 11:06:48 +02:00
Christopher Faulet 982e17dcf5 DOC: config: Improve documentation about proto/check-proto keywords
This patch adds a description about information provided by "haproxy -vv"
command regarding the available protocols. The description is adapted
depending the context (bind line, server line or health-check).
2021-04-01 11:06:48 +02:00
Christopher Faulet bb69d781c8 MINOR: muxes: Show muxes flags when the mux list is displayed
When the mux list is displayed on "haproxy -vv" output, the mux flags are
now diplayed. The flags meaning may be found in the configuration manual.
2021-04-01 11:06:48 +02:00
Christopher Faulet 28da3f5131 MEDIUM: mux-pt: Expose passthrough in the list of supported mux protocols
Add "none" in the list of supported mux protocols. It relies on the
passthrough multiplexer and use almost the same mux_ops structure. Only the
flags differ because this "new" mux does not support the upgrades. "none"
was chosen to explicitly stated there is not processing at the mux level.

Thus it is now possible to set "proto none" or "check-proto none" on
bind/server lines, depending on the context. However, when set, no upgrade
to HTTP is performed. It may be a way to disable HTTP upgrades per bind
line.
2021-04-01 11:06:48 +02:00
Christopher Faulet 3f612f7e4d MEDIUM: mux-h1: Expose h1 in the list of supported mux protocols
Add "h1" in the list of supported mux protocols. It relies on the H1
multiplexer and use the almost the same mux_ops structure. Only the flags
differ because this "new" mux does not support the upgrades.

Thus it is now possible to set "proto h1" or "check-proto h1" on bind/server
lines, depending on the context. However, when set, no upgrade to HTTP/2 is
performed. It may be a way to disable implicit HTTP/2 upgrades per bind
line.
2021-04-01 11:06:47 +02:00
Christopher Faulet 7a9e362b90 MINOR: mux-pt: Don't perform implicit HTTP upgrade if not supported by mux
For now this tests is useless, but if the PT muliplexer is flagged to
explicitly not support the upgrades to HTTP, an error is returned.
2021-04-01 11:06:47 +02:00