]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoCI: Github Actions: enable USE_QUIC=1 for BoringSSL builds
Ilya Shipitsin [Sun, 9 May 2021 16:27:28 +0000 (21:27 +0500)] 
CI: Github Actions: enable USE_QUIC=1 for BoringSSL builds

if haproxy is built against BoringSSL, let us add USE_QUIC=1 dynamically

4 years agoBUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD
Willy Tarreau [Sun, 9 May 2021 21:46:45 +0000 (23:46 +0200)] 
BUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD

This include is needed for malloc_usable_size(). It's also important to
think about disabling global pools.

4 years agoBUILD: memprof: make the old caller pointer a const in get_prof_bin()
Willy Tarreau [Sun, 9 May 2021 21:18:50 +0000 (23:18 +0200)] 
BUILD: memprof: make the old caller pointer a const in get_prof_bin()

It's a const void* in the target, we can't use a void* in the caller,
this causes a build warning with clang.

4 years agoCLEANUP: cli/mworker: properly align the help messages
Willy Tarreau [Sun, 9 May 2021 20:49:44 +0000 (22:49 +0200)] 
CLEANUP: cli/mworker: properly align the help messages

CLI help commands were re-aligned by commit b205bfdab but the
master-worker ones were not done, let's do it now.

4 years agoMINOR: cli: sort the output of the "help" keywords
Willy Tarreau [Sun, 9 May 2021 19:45:29 +0000 (21:45 +0200)] 
MINOR: cli: sort the output of the "help" keywords

It's still very difficult to find all commands starting with a given
keyword like "set", "show" etc. Let's sort the lines by usage message,
this is much more convenient.

4 years agoMINOR: cli: make "help" support a command in argument
Willy Tarreau [Sun, 9 May 2021 18:59:23 +0000 (20:59 +0200)] 
MINOR: cli: make "help" support a command in argument

With ~100 commands on the CLI, it's particularly difficult to find a
specific one in the "help" output. The function used to display the
help already supports filtering on certain commands, so in the end it's
just needed to pass the argument of the help command to enable the
automatic filtering. That's what this patch does so that "help clear"
only lists commands starting with "clear" and that "help map" lists
commands containing "map" in them.

4 years agoREGTESTS: disable inter-thread idle connection sharing on sensitive tests
Willy Tarreau [Sun, 9 May 2021 12:41:41 +0000 (14:41 +0200)] 
REGTESTS: disable inter-thread idle connection sharing on sensitive tests

Some regtests involve multiple requests from multiple clients, which can
be dispatched as multiple requests to a server. It turns out that the
idle connection sharing works so well that very quickly few connections
are used, and regularly some of the remaining idle server connections
time out at the moment they were going to be reused, causing those random
"HTTP header incomplete" traces in the logs that make them fail often. In
the end this is only an artefact of the test environment.

And indeed, some tests like normalize-uri which perform a lot of reuse
fail very often, about 20-30% of the times in the CI, and 100% of the
time in local when running 1000 tests in a row. Others like ubase64,
sample_fetches or vary_* fail less often but still a lot in tests.

This patch addresses this by adding "tune.idle-pool.shared off" to all
tests which have at least twice as many requests as clients. It proves
very effective as no single error happens on normalize-uri anymore after
10000 tests. Also 100 full runs of all tests yield no error anymore.

One test is tricky, http_abortonclose, it used to fail ~10 times per
1000 runs and with this workaround still fails once every 1000 runs.
But the test is complex and there's a warning in it mentioning a
possible issue when run in parallel due to a port reuse.

4 years agoBUILD: errors: include stdarg in errors.h
Willy Tarreau [Sun, 9 May 2021 10:04:09 +0000 (12:04 +0200)] 
BUILD: errors: include stdarg in errors.h

It's needed for va_list as defined in ha_vdiag_warning().

4 years agoBUILD: ssl: define HAVE_CRYPTO_memcmp() based on the library version
Willy Tarreau [Sun, 9 May 2021 09:59:49 +0000 (11:59 +0200)] 
BUILD: ssl: define HAVE_CRYPTO_memcmp() based on the library version

The build fails on versions older than 1.0.1d which is the first one
introducing CRYPTO_memcmp(), so let's have a define for this instead
of enabling it whenever USE_OPENSSL is set. One could also wonder why
we're relying on openssl for such a trivial thing, and a simple local
implementation could also allow to restore lexicographic ordering.

4 years agoBUILD: http_fetch: address a few aliasing warnings with older compilers
Willy Tarreau [Sun, 9 May 2021 08:32:54 +0000 (10:32 +0200)] 
BUILD: http_fetch: address a few aliasing warnings with older compilers

gcc-4.4 complains about aliasing in smp_fetch_url_port() and
smp_fetch_url_ip() because the local addr variable is casted to sturct
sockaddr_in before being checked. The family should be checked on the
sockaddr_storage and we have a function to retrieve the port.
The compiler still sees some warnings but these ones are OK now.

4 years agoMINOR: tools/rnd: compute the result outside of the CAS loop
Willy Tarreau [Sun, 9 May 2021 08:26:14 +0000 (10:26 +0200)] 
MINOR: tools/rnd: compute the result outside of the CAS loop

ha_random64() uses a DWCAS loop to produce the random, but it computes
the resulting value inside the loop while it doesn't change upon success,
so this is a needless overhead inside the critcal path that participates
to making threads fail the race and try again. Let's take the value out
of the loop.

4 years agoDOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments
Willy Tarreau [Sun, 9 May 2021 04:47:26 +0000 (06:47 +0200)] 
DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments

Some of the Lua doc and a few places still used "Haproxy" or "HAproxy".
There was even one "HA proxy". A few of them were in an example of VTest
output, indicating that VTest ought to be fixed as well. No big deal but
better address all the remaining ones so that these inconsistencies stop
spreading around.

4 years agoMEDIUM: mailers: use "HAProxy" nor "HAproxy" in the subject of messages
Willy Tarreau [Sun, 9 May 2021 04:45:16 +0000 (06:45 +0200)] 
MEDIUM: mailers: use "HAProxy" nor "HAproxy" in the subject of messages

It seems to be the last visible casing inconsistency, but better address
it for completeness otherwise we'll always have to deal with some
exceptions.

4 years agoADMIN: netsnmp: report "HAProxy" and not "Haproxy" in output descriptions
Willy Tarreau [Sun, 9 May 2021 04:41:37 +0000 (06:41 +0200)] 
ADMIN: netsnmp: report "HAProxy" and not "Haproxy" in output descriptions

In the SNMP fields descriptions, "Haproxy" was mentioned, let's make it
consistent with the rest.

4 years agoDOC: peers: fix the protocol tag name in the doc
Willy Tarreau [Sun, 9 May 2021 04:38:07 +0000 (06:38 +0200)] 
DOC: peers: fix the protocol tag name in the doc

The peers protocol has been using "HAProxyS" as a binary tag sent on the
wire since day one in 1.5-dev3 with commit 2b920a1af ("[MAJOR] Add new
files src/peer.c, include/proto/peers.h and include/types/peers.h for
sync stick table management"), regardless, the doc says the protocol
identifier is "HaproxyS". It is likely this got fixed in the code before
merging and not in the doc.

This should be backported to any release as the doc is wrong.

4 years agoDOC: remove last occurrences of "HA-Proxy" syntax
Willy Tarreau [Sun, 9 May 2021 04:25:16 +0000 (06:25 +0200)] 
DOC: remove last occurrences of "HA-Proxy" syntax

There were only a few more used as output examples and comments in a few
docs, it was the right moment to get rid of them. The file intro.txt
which explains how to parse the version also got a hint about the possible
presence of a hyphen in the name in older versions.

4 years agoMINOR: version: report "HAProxy" not "HA-Proxy" in the version output
Willy Tarreau [Sun, 9 May 2021 04:14:25 +0000 (06:14 +0200)] 
MINOR: version: report "HAProxy" not "HA-Proxy" in the version output

When running "haproxy -v", we still get "HA-Proxy" which is the last
place where this confusing oddity happens. Being so used to it I didn't
even notice it until it was reported to me just after 2.2 but it never
got fixed, despite the PRODUCT_NAME macro that is used to report the
name in the stats page and in "show info" being already set to "HAProxy"
15 years ago in 1.2.14 with commit e03312613. It's about time to
uniformize everything.

4 years agoREGTESTS: run-regtests: match both "HAProxy" and "HA-Proxy" in the version
Willy Tarreau [Sun, 9 May 2021 04:12:41 +0000 (06:12 +0200)] 
REGTESTS: run-regtests: match both "HAProxy" and "HA-Proxy" in the version

The script checks the HAProxy version and was looking for "HA-Proxy" which
is hard-coded in haproxy.c, let's relax the test to also accept "HAProxy".

4 years agoDOC: Fix a few grammar/spelling issues and casing of HAProxy
Daniel Corbett [Sat, 8 May 2021 14:50:37 +0000 (10:50 -0400)] 
DOC: Fix a few grammar/spelling issues and casing of HAProxy

This patch fixes a few grammar and spelling issues in configuration.txt.
It was also noted that there was a wide range of case usage
(i.e. haproxy, HAproxy, HAProxy, etc... ). This patch updates them
all to be consistently "HAProxy" except where a binary is mentioned.

4 years agoBUILD: makefile: reorder object files by build time
Willy Tarreau [Sat, 8 May 2021 21:33:25 +0000 (23:33 +0200)] 
BUILD: makefile: reorder object files by build time

This is the per-release reordering to improve build parallelism.
It didn't change much, mostly dns+resolvers inflated this time.
Nowadays build times are mostly dominated by the long dependencies
of include files, no less than 170MB of preprocessed code has to be
built, and half of this is SSL support is disabled. Includes should
likely be reworked to be smaller with less dependencies each,
possibly splitting what's the core of each of them and what is used
to interface with other ones. Each split of a .C file in two adds
0.3s of build time just because of this.

4 years agoBUILD: config: do not include proxy.h nor errors.h anymore in cfgparse.h
Willy Tarreau [Sat, 8 May 2021 18:25:57 +0000 (20:25 +0200)] 
BUILD: config: do not include proxy.h nor errors.h anymore in cfgparse.h

These ones induce a long dependency chain and are not needed anymore.

4 years agoBUILD: fd: include log.h from fd.c
Willy Tarreau [Sat, 8 May 2021 18:35:03 +0000 (20:35 +0200)] 
BUILD: fd: include log.h from fd.c

It's needed for ha_alert() and the header was missing.

4 years agoBUILD: comp: include proxy.h from flt_http_comp.c
Willy Tarreau [Sat, 8 May 2021 18:34:16 +0000 (20:34 +0200)] 
BUILD: comp: include proxy.h from flt_http_comp.c

It's used for proxy_type_str() but the header was missing.

4 years agoBUILD: thread: include log.h from thread.c
Willy Tarreau [Sat, 8 May 2021 18:33:02 +0000 (20:33 +0200)] 
BUILD: thread: include log.h from thread.c

It's needed for ha_alert(). Probably that a separate file for error
reporting at boot would be useful.

4 years agoBUILD: http-rules: include proxy.h from http_rules.c
Willy Tarreau [Sat, 8 May 2021 18:30:37 +0000 (20:30 +0200)] 
BUILD: http-rules: include proxy.h from http_rules.c

Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.

4 years agoBUILD: listener: include proxy.h from listener.c
Willy Tarreau [Sat, 8 May 2021 18:30:37 +0000 (20:30 +0200)] 
BUILD: listener: include proxy.h from listener.c

Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.

4 years agoBUILD: mux-fcgi: include proxy.h from mux-fcgi.c
Willy Tarreau [Sat, 8 May 2021 18:28:54 +0000 (20:28 +0200)] 
BUILD: mux-fcgi: include proxy.h from mux-fcgi.c

proxy_capture_error() was called there without the include, which was
inherited via cfgparse.h.

4 years agoBUILD: mux-h1: include proxy.h from mux-h1.c
Willy Tarreau [Sat, 8 May 2021 18:28:54 +0000 (20:28 +0200)] 
BUILD: mux-h1: include proxy.h from mux-h1.c

proxy_capture_error() was called there without the include, which was
inherited via cfgparse.h.

4 years agoBUILD: hlua: include proxy.h from hlua.c
Willy Tarreau [Sat, 8 May 2021 18:28:07 +0000 (20:28 +0200)] 
BUILD: hlua: include proxy.h from hlua.c

Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.

4 years agoBUILD: connection: stop including listener-t.h
Willy Tarreau [Sat, 8 May 2021 18:14:39 +0000 (20:14 +0200)] 
BUILD: connection: stop including listener-t.h

listener-t comes with openssl just due to the SSL_CTX type that is
declred as a typedef in openssl hence cannot be abstracted at this
level. However connection-t.h doen't need all that just to know that
bind_conf is a struct. Let's declare it with other external types
instead..

4 years agoMINOR: task: stop including stream.h from task.c
Willy Tarreau [Sat, 8 May 2021 18:10:13 +0000 (20:10 +0200)] 
MINOR: task: stop including stream.h from task.c

This one comes with a very deep dependency hell, only to know that
process_stream() is a function. Dropping it reduces the preprocessed
output from 1.5MB to 640kB.

4 years agoBUILD: task: remove unused includes from task.c
Willy Tarreau [Sat, 8 May 2021 18:08:58 +0000 (20:08 +0200)] 
BUILD: task: remove unused includes from task.c

freq_ctr.h and time.h are not used, let's drop them.

4 years agoREORG: config: uninline warnifnotcap() and failifnotcap()
Willy Tarreau [Sat, 8 May 2021 17:58:37 +0000 (19:58 +0200)] 
REORG: config: uninline warnifnotcap() and failifnotcap()

These ones are used by virtually every config parser. Not only they
provide no benefit in being inlined, but they imply a very deep
dependency starting at proxy.h, which results for example in task.c
including openssl.

Let's move these two functions to cfgparse.c.

4 years agoREORG: stick-table: move composite address functions to stick_table.h
Willy Tarreau [Sat, 8 May 2021 12:12:47 +0000 (14:12 +0200)] 
REORG: stick-table: move composite address functions to stick_table.h

These caddr_* functions were once placed into tools.h in the hope they
would be useful but nobody knows they exist. They could deserve being
moved to their own file with other pointer manipulation functions maybe,
but for now they're the only reason left for stick_table.h to include
tools.h, so let's move them directly there since it's its only user.
This allows to remove tools.h from stick_table.h and slightly reduce
the overall build time.

4 years agoREORG: stick-table: uninline stktable_alloc_data_type()
Willy Tarreau [Sat, 8 May 2021 12:10:42 +0000 (14:10 +0200)] 
REORG: stick-table: uninline stktable_alloc_data_type()

This function has no business being inlined in stick_table.h since it's
only used at boot time by the config parser. In addition it causes an
undesired dependency on tools.h because it uses parse_time_err(). Let's
move it to stick_table.c.

4 years agoBUILD: connection: move list_mux_proto() to connection.c
Willy Tarreau [Sat, 8 May 2021 12:06:09 +0000 (14:06 +0200)] 
BUILD: connection: move list_mux_proto() to connection.c

No idea why this was put inlined into connection.h, it's used only once
for haproxy -vv, and requires tools.h, causing an undesired dependency
from connection.h. Let's move it to connection.c instead where it ought
to have been.

4 years agoBUILD: fcgi-app: include proxy.h in fcgi-app.c
Willy Tarreau [Sat, 8 May 2021 18:23:18 +0000 (20:23 +0200)] 
BUILD: fcgi-app: include proxy.h in fcgi-app.c

It's needed for proxies_list and used to be inherited via cfgparse.h.

4 years agoBUILD: filters: include proxy.h in filters.c
Willy Tarreau [Sat, 8 May 2021 18:22:17 +0000 (20:22 +0200)] 
BUILD: filters: include proxy.h in filters.c

It's needed for proxies_list and used to be inherited via cfgparse.h.

4 years agoBUILD: mworker: include proxy.h in mworker.c
Willy Tarreau [Sat, 8 May 2021 18:21:31 +0000 (20:21 +0200)] 
BUILD: mworker: include proxy.h in mworker.c

It's needed for proxies_list and used to be inherited via cfgparse.h.

4 years agoBUILD: sink: include proxy.h in sink.c
Willy Tarreau [Sat, 8 May 2021 18:20:21 +0000 (20:20 +0200)] 
BUILD: sink: include proxy.h in sink.c

It's needed for proxies_list but was missing.

4 years agoBUILD: server: include missing proxy.h in server.c
Willy Tarreau [Sat, 8 May 2021 18:18:59 +0000 (20:18 +0200)] 
BUILD: server: include missing proxy.h in server.c

It's needed for a number of functions and definitions but was missing.

4 years agoBUILD: server: include tools.h from server.c
Willy Tarreau [Sat, 8 May 2021 12:09:40 +0000 (14:09 +0200)] 
BUILD: server: include tools.h from server.c

A lot of functions from tools.h are used there but the file was only
inherited via other ones.

4 years agoBUILD: stick-table: include freq_ctr.h from stick_table.h
Willy Tarreau [Sat, 8 May 2021 12:08:38 +0000 (14:08 +0200)] 
BUILD: stick-table: include freq_ctr.h from stick_table.h

It's needed for update_freq_ctr_period() which is used there.

4 years agoBUILD: udp: include tools.h from proto_udp.c
Willy Tarreau [Sat, 8 May 2021 11:59:56 +0000 (13:59 +0200)] 
BUILD: udp: include tools.h from proto_udp.c

A few functions are used from there for address conversion but the
file wasn't included.

4 years agoBUILD: queue: include tools.h from queue.c
Willy Tarreau [Sat, 8 May 2021 11:59:05 +0000 (13:59 +0200)] 
BUILD: queue: include tools.h from queue.c

It uses memprintf() without including the file because it inherited
it from other ones.

4 years agoBUILD: mworker: include tools.h from mworker.c
Willy Tarreau [Sat, 8 May 2021 11:58:19 +0000 (13:58 +0200)] 
BUILD: mworker: include tools.h from mworker.c

It needs it for memprintf() but didn't include the file.

4 years agoBUILD: compression: include tools.h in compression.c
Willy Tarreau [Sat, 8 May 2021 11:57:19 +0000 (13:57 +0200)] 
BUILD: compression: include tools.h in compression.c

It needs it for memprintf() but it wasn't included.

4 years agoBUILD: vars: include tools.h in vars.c
Willy Tarreau [Sat, 8 May 2021 11:56:31 +0000 (13:56 +0200)] 
BUILD: vars: include tools.h in vars.c

A number of functions from tools.h are used there but the file was not
included.

4 years agoBUILD: payload: include tools.h in payload.c
Willy Tarreau [Sat, 8 May 2021 11:55:40 +0000 (13:55 +0200)] 
BUILD: payload: include tools.h in payload.c

It needs it for memprintf() but used to inherit it via other include files.

4 years agoBUILD: dns: include tools.h in dns.c
Willy Tarreau [Sat, 8 May 2021 11:09:46 +0000 (13:09 +0200)] 
BUILD: dns: include tools.h in dns.c

It is used for get_addr_len() without being included. It could be worth
splitting address manipulation functions to a different set of files.

4 years agoBUILD: server-state: include tools.h from server_state.c
Willy Tarreau [Sat, 8 May 2021 11:08:34 +0000 (13:08 +0200)] 
BUILD: server-state: include tools.h from server_state.c

Many functions from tools.h are called there without the file being
included.

4 years agoBUILD: connection: include tools.h in connection.c
Willy Tarreau [Sat, 8 May 2021 11:07:31 +0000 (13:07 +0200)] 
BUILD: connection: include tools.h in connection.c

Several functions from tools.h are called there without the file being
included.

4 years agoBUILD: sink: include tools.h in sink.c
Willy Tarreau [Sat, 8 May 2021 11:05:30 +0000 (13:05 +0200)] 
BUILD: sink: include tools.h in sink.c

Several functions from tools.h are used in sink.c without tools.h being
included.

4 years agoBUILD: cache: include tools.h in cache.c
Willy Tarreau [Sat, 8 May 2021 11:03:55 +0000 (13:03 +0200)] 
BUILD: cache: include tools.h in cache.c

cache.c uses a lot of functions from tools.h without including it.

4 years agoBUILD: session: include tools.h in session.c
Willy Tarreau [Sat, 8 May 2021 11:03:04 +0000 (13:03 +0200)] 
BUILD: session: include tools.h in session.c

The file session.c calls plenty of functions from tools.h but did not
include it.

4 years agoBUILD: proxy: include tools.h in proxy.c
Willy Tarreau [Sat, 8 May 2021 11:02:07 +0000 (13:02 +0200)] 
BUILD: proxy: include tools.h in proxy.c

Many functions are used from tools.h but the file wasn't included and
was inherited through others.

4 years agoBUILD: htx: include tools.h in http_htx.c
Willy Tarreau [Sat, 8 May 2021 11:01:23 +0000 (13:01 +0200)] 
BUILD: htx: include tools.h in http_htx.c

Several functions from tools.h are called there and it used to be
inherited through others.

4 years agoBUILD: config: include tools.h in cfgparse-listen.c
Willy Tarreau [Sat, 8 May 2021 11:00:23 +0000 (13:00 +0200)] 
BUILD: config: include tools.h in cfgparse-listen.c

Many functions defined in tools.h were called there but the file used
to be inherited via others.

4 years agoBUILD: resolvers: include tools.h
Willy Tarreau [Sat, 8 May 2021 10:59:47 +0000 (12:59 +0200)] 
BUILD: resolvers: include tools.h

Many functions from tools.h are called there but it was inherited via others.

4 years agoBUILD: promex: service-prometheus.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:58:12 +0000 (12:58 +0200)] 
BUILD: promex: service-prometheus.c needs tools.h

It calls url_decode() and memprintf() but used to inherit them through
others.

4 years agoBUILD: spoe: flt_spoe.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:57:17 +0000 (12:57 +0200)] 
BUILD: spoe: flt_spoe.c needs tools.h

It uses many functions declared there but used to inherit it through others.

4 years agoBUILD: wurfl: wurfl.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:56:20 +0000 (12:56 +0200)] 
BUILD: wurfl: wurfl.c needs tools.h

It calls memprintf() which is defined there but used to inherit it
through others.

4 years agoBUILD: config: cfgparse-ssl.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:54:42 +0000 (12:54 +0200)] 
BUILD: config: cfgparse-ssl.c needs tools.h

It calls parse_time_err() which is defined there but used to inherit it
through others.

4 years agoBUILD: ssl: ssl_utils requires chunk.h
Willy Tarreau [Sat, 8 May 2021 10:52:56 +0000 (12:52 +0200)] 
BUILD: ssl: ssl_utils requires chunk.h

It uses chunk_printf() so it needs it. Currently it gets it through
others.

4 years agoREORG: mworker: move proc_self from global to mworker
Willy Tarreau [Sat, 8 May 2021 10:30:50 +0000 (12:30 +0200)] 
REORG: mworker: move proc_self from global to mworker

Only mworker uses proc_self, and it was declared in global.h, forcing
users of global.h to include mworker and its dependencies.

Moving it to mworker reduces the preprocessed size of version.c from
170 to 125kB by shrinking the number of local includes from 30 to 16
and the number of system includes from 147 to 132.

4 years agoBUILD: auth: include missing list.h
Willy Tarreau [Sat, 8 May 2021 10:29:51 +0000 (12:29 +0200)] 
BUILD: auth: include missing list.h

list_for_each_entry() requires list.h but used to inherit it by accident
through global.h and mworker-t.h. Let's explicitly add it.

4 years agoBUILD: wdt: include signal-t.h
Willy Tarreau [Sat, 8 May 2021 10:27:42 +0000 (12:27 +0200)] 
BUILD: wdt: include signal-t.h

WDT_SIG is used there, thus signal-t.h is required. Currently it's
retrieved by accident through global.h.

4 years agoREORG: threads: move all_thread_mask() to thread.h
Willy Tarreau [Sat, 8 May 2021 10:26:10 +0000 (12:26 +0200)] 
REORG: threads: move all_thread_mask() to thread.h

It was declared in global.h, forcing plenty of source files to include
it only for this while it's only based on definitions from thread.h.

4 years agoREORG: vars: move the "proc" scope variables out of the global struct
Willy Tarreau [Sat, 8 May 2021 09:41:28 +0000 (11:41 +0200)] 
REORG: vars: move the "proc" scope variables out of the global struct

The presence of this field causes a long dependency chain because almost
everyone includes global-t.h, and vars include sample_data which include
some system includes as well as HTTP parts.

There is absolutely no reason for having the process-wide variables in
the global struct, let's just move them into vars.c and vars.h. This
reduces from ~190k to ~170k the preprocessed output of version.c.

4 years agoMINOR: config: mark tune.fd.edge-triggered as experimental
Willy Tarreau [Sat, 8 May 2021 09:06:32 +0000 (11:06 +0200)] 
MINOR: config: mark tune.fd.edge-triggered as experimental

This one is stated as experimental in the doc but could still be used
by accidental copy-paste. Let's mark it with KWF_EXPERIMENTAL so that
users have to opt-in to use it.

4 years agoMINOR: stats: make "show info" able to report rates as floats when asked
Willy Tarreau [Sat, 8 May 2021 06:14:04 +0000 (08:14 +0200)] 
MINOR: stats: make "show info" able to report rates as floats when asked

Now "show info float" will also report SSL rates, connection rates and
key reuse ratios as floats. This can be convenient at very low rates.

Note that the SSL reuse ratio which used to commonly oscillate between
0 and 1 under load is now more often above zero with small values. It
indicates that for better stability we shouldn't be comparing a key rate
with a connection rate but instead we should measure the reuse rate at
its source.

4 years agoMINOR: stats: report uptime and start time as floats with subsecond resolution
Willy Tarreau [Sat, 8 May 2021 05:56:56 +0000 (07:56 +0200)] 
MINOR: stats: report uptime and start time as floats with subsecond resolution

When "show info float" is used, the uptime and start time will be reported
with subsecond resolution (microsecond actually since timeval is used).

4 years agoMINOR: stats: use tv_remain() to precisely compute the uptime
Willy Tarreau [Sat, 8 May 2021 05:40:52 +0000 (07:40 +0200)] 
MINOR: stats: use tv_remain() to precisely compute the uptime

We'll have to support reporting sub-second uptimes, so let's use the
appropriate function which will automatically adjust the tv_usec field.
In addition to this, it will also report a more accurate uptime thanks
to considering the sub-second part in the result.

4 years agoMINOR: stats: support an optional "float" option to "show info"
Willy Tarreau [Sat, 8 May 2021 05:54:24 +0000 (07:54 +0200)] 
MINOR: stats: support an optional "float" option to "show info"

This will allow some fields to be produced with a higher accuracy when
the requester indicates being able to parse floats. Rates and times are
among the elements which can make sense.

4 years agoMINOR: stats: pass the appctx flags to stats_fill_info()
Willy Tarreau [Sat, 8 May 2021 05:43:53 +0000 (07:43 +0200)] 
MINOR: stats: pass the appctx flags to stats_fill_info()

Currently the stats filling function knows nothing about the caller's
needs, so let's pass the STAT_* flags so that it can adapt to the
requester's constraints.

4 years agoMINOR: stats: add the HTML conversion for float types
Willy Tarreau [Sat, 8 May 2021 05:37:38 +0000 (07:37 +0200)] 
MINOR: stats: add the HTML conversion for float types

For the prometheus exporter, a new float type was added for the fields
and its conversion was added everywhere except for the HTML output.
Now that we have F2H() we can implement it for consistency.

4 years agoMINOR: stats: avoid excessive padding of float values with trailing zeroes
Willy Tarreau [Sat, 8 May 2021 08:38:20 +0000 (10:38 +0200)] 
MINOR: stats: avoid excessive padding of float values with trailing zeroes

When emitting stats, we don't need to have 6 zeroes after the decimal point
for each value, so let's trim floating point numbers to the longest needed
only.

4 years agoMINOR: freq_ctr: add new functions to report float measurements
Willy Tarreau [Sat, 8 May 2021 06:12:37 +0000 (08:12 +0200)] 
MINOR: freq_ctr: add new functions to report float measurements

For stats reporting it can be convenient to report floats at low rates
instead of discrete integers. We do have quite some precision since we
currently divide counters by number of milliseconds, so we can usually
add 3 digits after the decimal point.

4 years agoMINOR: tools: add a float-to-ascii conversion function
Willy Tarreau [Sat, 8 May 2021 05:35:00 +0000 (07:35 +0200)] 
MINOR: tools: add a float-to-ascii conversion function

We already had ultoa_r() and friends but nothing to emit inline floats.
This is now done with ftoa_r() and F2A/F2H. Note that the latter both use
the itoa_str[] as temporary storage and that the HTML format currently is
the exact same as the ASCII one. The trailing zeroes are always timmed so
these outputs are usable in user-visible output.

4 years agoMINOR: tools: implement trimming of floating point numbers
Willy Tarreau [Sat, 8 May 2021 08:28:53 +0000 (10:28 +0200)] 
MINOR: tools: implement trimming of floating point numbers

When using "%f" to print a float, it automatically gets 6 digits after
the decimal point and there's no way to automatically adjust to the
required ones by dropping trailing zeroes. This function does exactly
this and automatically drops the decimal point if all digits after it
were zeroes. This will make numbers more friendly in stats and makes
outputs shorter (e.g. JSON where everything is just a "number").

The function is designed to be easy to use with snprint() and chunks:

  snprintf:
    flt_trim(buf, 0, snprintf(buf, sizeof(buf), "%f", x));

  chunk_printf:
    out->data = flt_trim(out->area, 0, chunk_printf(out, "%f", x));

  chunk_appendf:
    size_t prev_data = out->data;
    out->data = flt_trim(out->area, prev_data, chunk_appendf(out, "%f", x));

4 years agoDOC: management: mention that some fields may be emitted as floats
Willy Tarreau [Sat, 8 May 2021 05:46:44 +0000 (07:46 +0200)] 
DOC: management: mention that some fields may be emitted as floats

Floats in stats output are currently not emitted but are technically
possible, so let's mention that.

4 years agoMINOR: sample: improve error reporting on missing arg to strcmp() converter
Willy Tarreau [Sat, 8 May 2021 04:50:28 +0000 (06:50 +0200)] 
MINOR: sample: improve error reporting on missing arg to strcmp() converter

Calling the strcmp() converter with no argument yields this strange error:

  [ALERT]    (31439) : parsing [test.cfg:3] : error detected in frontend 'f' while parsing 'http-request redirect' rule : failed to parse sample expression <src,strcmp]> : invalid args in converter 'strcmp' : failed to register variable name ''.

This is because the vars name check tries to see if it can create such a
variable having an empty name. Let's at least make a special case of the
missing argument. Now we can read a more explicit:

  [ALERT]    (31655) : parsing [test.cfg:3] : error detected in frontend 'f' while parsing 'http-request redirect' rule : failed to parse sample expression <src,strcmp]> : invalid args in converter 'strcmp' : missing variable name.

This was done for secure_strcmp() as well.

4 years agoDOC: ssl: Add information about crl-file option
Remi Tricot-Le Breton [Tue, 4 May 2021 10:22:34 +0000 (12:22 +0200)] 
DOC: ssl: Add information about crl-file option

When using the crl-file option with multiple Certificate Authority
levels in the CA chain, there must be one CRL per CA or the verify
function on the backend side will raise an "unagle to get certificate
CRL" error (error code 3).

This was required by GitHub issue #1201.

4 years agoADDONS: make addons/ discoverable by git via .gitignore
Willy Tarreau [Fri, 7 May 2021 14:46:52 +0000 (16:46 +0200)] 
ADDONS: make addons/ discoverable by git via .gitignore

When the contrib/ parts were moved to addons/, no rule was added in
.gitignore to make addons/ searchable for new files, let's fix it.

4 years agoDOC: ssl: Extra files loading now works for backends too
Remi Tricot-Le Breton [Fri, 7 May 2021 13:28:08 +0000 (15:28 +0200)] 
DOC: ssl: Extra files loading now works for backends too

When implementing the server side certificate hot update, the ckch
mechanism was used on the backend side in order to mimic the frontend
certificate management and to enable server line certificate update via
the CLI (see GitHub issue #427). As an unexpected side effect, we now
also look for ssl extra files (cert.pem.key, cert.pem.ocsp ...) for the
backend side.
This patch updates the documentation accordingly.

This answers to GitHub issue #845.

4 years agoBUG/MINOR: server: do not report diag for peer servers with null weight
Amaury Denoyelle [Fri, 7 May 2021 13:13:51 +0000 (15:13 +0200)] 
BUG/MINOR: server: do not report diag for peer servers with null weight

Only check servers attached to a proxy with PR_CAP_LB.

This does not need to be backported as the diag message was added in the
current 2.4-dev branch.

4 years agoMINOR: proxy: define PR_CAP_LB
Amaury Denoyelle [Fri, 7 May 2021 13:12:20 +0000 (15:12 +0200)] 
MINOR: proxy: define PR_CAP_LB

Add a new proxy capability for proxy with load-balancing capabilities.
This help to differentiate listen/frontend/backend with special proxies
such as peer proxies.

4 years agoBUILD: fix usage of ha_alert without format string
Amaury Denoyelle [Fri, 7 May 2021 13:07:21 +0000 (15:07 +0200)] 
BUILD: fix usage of ha_alert without format string

The compilation is failing due to no format string used in ha_alert.
This does not need to be backported.

4 years agoMINOR: http_act: mark normalize-uri as experimental
Amaury Denoyelle [Thu, 6 May 2021 13:50:12 +0000 (15:50 +0200)] 
MINOR: http_act: mark normalize-uri as experimental

normalize-uri http rule is marked as experimental, so it cannot be
activated without the global 'expose-experimental-directives'. The
associated vtc is updated to be able to use it.

4 years agoMINOR: stats: report tainted on show info
Amaury Denoyelle [Wed, 5 May 2021 15:09:12 +0000 (17:09 +0200)] 
MINOR: stats: report tainted on show info

Add a new info field ST_F_TAINTED to dump tainted status at the end of
the 'show info' output.

4 years agoMINOR: cli: set tainted when using CLI expert/experimental mode
Amaury Denoyelle [Wed, 5 May 2021 14:29:23 +0000 (16:29 +0200)] 
MINOR: cli: set tainted when using CLI expert/experimental mode

Mark the process as tainted as soon as a command command only accessible
in expert or experimental mode is executed.

4 years agoMINOR: action: implement experimental actions
Amaury Denoyelle [Fri, 7 May 2021 12:25:01 +0000 (14:25 +0200)] 
MINOR: action: implement experimental actions

Support experimental actions. It is mandatory to use
'expose-experimental-directives' before to be able to use them.

If such action is present in the config file, the tainted status of the
process is updated. Another tainted status is set when an experimental
action is executed.

4 years agoMINOR: action: replace match_pfx by a keyword flags field
Amaury Denoyelle [Thu, 6 May 2021 13:33:09 +0000 (15:33 +0200)] 
MINOR: action: replace match_pfx by a keyword flags field

Define a new keyword flag KWF_MATCH_PREFIX. This is used to replace the
match_pfx field of action struct.

This has the benefit to have more explicit action declaration, and now
it is possible to quickly implement experimental actions.

4 years agoMINOR: cfgparse: implement experimental config keywords
Amaury Denoyelle [Thu, 6 May 2021 14:21:39 +0000 (16:21 +0200)] 
MINOR: cfgparse: implement experimental config keywords

Add a new flag to mark a keyword as experimental. An experimental
keyword cannot be used if the global 'expose-experimental-directives' is
not present first.

Only keywords parsed through a standard cfg_keywords lists in
global/proxies section will be automatically detected if declared
experimental. To support a keyword outside of these lists,
check_kw_experimental must be called manually during its parsing.

If an experimental keyword is present in the config, the tainted flag is
updated.

For the moment, no keyword is marked as experimental.

4 years agoMINOR: cfgparse: add a new field flags in cfg_keyword
Amaury Denoyelle [Thu, 6 May 2021 15:33:29 +0000 (17:33 +0200)] 
MINOR: cfgparse: add a new field flags in cfg_keyword

This field will be used to add various mechanism to config parsing.
Currently no flag value is implemented. The following commit will
implement experimental keywords.

4 years agoMINOR: global: define tainted flag
Amaury Denoyelle [Wed, 5 May 2021 14:18:45 +0000 (16:18 +0200)] 
MINOR: global: define tainted flag

Add a global flag named 'tainted'. Its purpose is to report various
status about experimental features used for the current process
lifetime.

By default it is initialized to 0. It can be set/retrieve by a couple of
new functions mark_tainted()/get_tainted(). Once a flag is set, it
cannot be resetted.

Currently, no tainted status is implemented, it will be the subject of
the following commits.

4 years agoBUG/MINOR: checks: Reschedule check on observe mode only if fastinter is set
Christopher Faulet [Fri, 7 May 2021 09:45:26 +0000 (11:45 +0200)] 
BUG/MINOR: checks: Reschedule check on observe mode only if fastinter is set

On observe mode, if a server is marked as DOWN, the server's health-check is
rescheduled using the fastinter timeout if the new expiration date is newer
that the current one. But this must only be performed if the fastinter
timeout is defined.

Internally, tick_is_lt() function only checks the date and does not perform any
verification on the provided args. Thus, we must take care of it. However, it is
possible to disable the server health-check by setting its task expiration date
to TICK_ETERNITY.

This patch must be backported as far as 2.2. It is related to

4 years agoBUG/MINOR: checks: Handle synchronous connect when a tcpcheck is started
Christopher Faulet [Thu, 6 May 2021 14:01:18 +0000 (16:01 +0200)] 
BUG/MINOR: checks: Handle synchronous connect when a tcpcheck is started

A connection may be synchronously established. In the tcpcheck context, it
may be a problem if several connections come one after another. In this
case, there is no event to close the very first connection before starting
the next one. The checks is thus blocked and timed out, a L7 timeout error
is reported.

To fix the bug, when a tcpcheck is started, we immediately evaluate its
state. Most of time, nothing is performed and we must wait. But it is thus
possible to handle the result of a successfull connection.

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

4 years agoBUG/MINOR: stream: Reset stream final state and si error type on L7 retry
Christopher Faulet [Wed, 5 May 2021 19:05:09 +0000 (21:05 +0200)] 
BUG/MINOR: stream: Reset stream final state and si error type on L7 retry

Thanks to a previous fix, the stream error mask is now cleared on L7
retry. But the stream final state (SF_FINST_*) and the stream-interface
error type must also be reset to properly restart a new connection and be
sure to not inherit errors from the previous connection attempt.

In addition, SF_ADDR_SET flag is not systematically removed.
stream_choose_redispatch() already takes care to unset it if necessary. When
the connection is not redispatch, the server address can be preserved.

This patch must be backported as far as 2.0.

4 years agoCLEANUP: cli/tree-wide: properly re-align the CLI commands' help messages
Willy Tarreau [Fri, 7 May 2021 09:38:37 +0000 (11:38 +0200)] 
CLEANUP: cli/tree-wide: properly re-align the CLI commands' help messages

There were 102 CLI commands whose help were zig-zagging all along the dump
making them unreadable. This patch realigns all these messages so that the
command now uses up to 40 characters before the delimiting colon. About a
third of the commands did not correctly list their arguments which were
added after the first version, so they were all updated. Some abuses of
the term "id" were fixed to use a more explanatory term. The
"set ssl ocsp-response" command was not listed because it lacked a help
message, this was fixed as well. The deprecated enable/disable commands
for agent/health/server were prominently written as deprecated. Whenever
possible, clearer explanations were provided.