]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoMINOR: time: change the global timeval and the the global tick at once
Willy Tarreau [Sun, 11 Apr 2021 13:34:25 +0000 (15:34 +0200)] 
MINOR: time: change the global timeval and the the global tick at once

Instead of using two CAS loops, better compute the two units
simultaneously and update them at once. There is no guarantee that
the update will be synchronous, but we don't care, what matters is
that both are monotonically updated and that global_now_ms always
follows the last known value of global_now.

4 years agoMINOR: time: remove useless variable copies in tv_update_date()
Willy Tarreau [Sun, 11 Apr 2021 13:17:48 +0000 (15:17 +0200)] 
MINOR: time: remove useless variable copies in tv_update_date()

In the global_now loop, we used to set tmp_adj from adjusted, then
set update it from tmp_now, then set adjusted back to tmp_adj, and
finally set now from adjusted. This is a long and unneeded set of
moves resulting from years of code changes. Let's just set now
directly in the loop, stop using adjusted and remove tmp_adj.

4 years agoMINOR: time: move the time initialization out of tv_update_date()
Willy Tarreau [Sun, 11 Apr 2021 13:00:34 +0000 (15:00 +0200)] 
MINOR: time: move the time initialization out of tv_update_date()

The time initialization was made a bit complex because we rely on a
dummy negative argument to reset all fields, leaving no distinction
between process-level initialization and thread-level initialization.
This patch changes this by introducing two functions, one for the
process and the second one for the threads. This removes ambigous
test and makes sure that the relevant fields are always initialized
exactly once. This also offers a better solution to the bug fixed in
commit b48e7c001 ("BUG/MEDIUM: time: make sure to always initialize
the global tick") as there is no more special values for global_now_ms.

It's simple enough to be backported if any other time-related issues
are encountered in stable versions in the future.

4 years agoCLEANUP: time: remove the now unused ms_left_scaled
Willy Tarreau [Sat, 10 Apr 2021 23:40:13 +0000 (01:40 +0200)] 
CLEANUP: time: remove the now unused ms_left_scaled

It was only used by freq_ctr and is not used anymore. In addition the
local curr_sec_ms was removed, as well as the equivalent extern
definitions which did not exist anymore either.

4 years agoMINOR: freq_ctr: simplify and improve the update function
Willy Tarreau [Sun, 11 Apr 2021 11:51:58 +0000 (13:51 +0200)] 
MINOR: freq_ctr: simplify and improve the update function

update_freq_ctr_period() was still not very clean and didn't wait for
the rotation lock to be dropped before trying again, thus maintaining
the contention at a high level. In addition, the rotation update was
made in three steps, which are not very efficient in terms of bus
cycles.

Here the wait loop was reworked so that the fast path remains short
and that the contended path waits for the lock to be dropped before
attempting another write, but it only waits a relax cycle before
attempting a read. The rotation block was simplified to remove a
test that was already validated by the first loop, and so that the
retrieval of the current period, its reset and its increment are all
performed in a single atomic op and the store to the previous period
is performed immediately after.

All this results in significantly smaller code for the inline function
(~1kB total) and a shorter critical path.

4 years agoMINOR: freq_ctr: add cpu_relax in the rotation loop of update_freq_ctr_period()
Willy Tarreau [Sat, 10 Apr 2021 23:18:39 +0000 (01:18 +0200)] 
MINOR: freq_ctr: add cpu_relax in the rotation loop of update_freq_ctr_period()

When counters are rotated, there is contention between the threads which
can slow down the operation of the thread performing the rotation. Let's
apply a cpu_relax there to let the first thread finish faster.

4 years agoMEDIUM: freq_ctr: replace the per-second counters with the generic ones
Willy Tarreau [Sat, 10 Apr 2021 21:41:25 +0000 (23:41 +0200)] 
MEDIUM: freq_ctr: replace the per-second counters with the generic ones

It remains cumbersome to preserve two versions of the freq counters and
two different internal clocks just for this. In addition, the savings
from using two different mechanisms are not that important as the only
saving is a divide that is replaced by a multiply, but now thanks to
the freq_ctr_total() unificaiton the code could also be simplified to
optimize it in case of constants.

This patch turns all non-period freq_ctr functions to static inlines
which call the period-based ones with a period of 1 second. A direct
benefit is that a single internal clock is now needed for any counter
and that they now all rely on ticks.

These 1-second counters are essentially used to report request rates
and to enforce a connection rate limitation in listeners. It was
verified that these continue to work like before.

4 years agoMINOR: freq_ctr: unify freq_ctr and freq_ctr_period into freq_ctr
Willy Tarreau [Sat, 10 Apr 2021 21:00:53 +0000 (23:00 +0200)] 
MINOR: freq_ctr: unify freq_ctr and freq_ctr_period into freq_ctr

Both structures are identical except the name of the field starting
the period and its description. Let's call them all freq_ctr and the
period's start "curr_tick" which is generic.

This is only a temporary change and fields are expected to remain
the same with no code change (verified).

4 years agoMINOR: freq_ctr: add the missing next_event_delay_period()
Willy Tarreau [Sat, 10 Apr 2021 21:36:07 +0000 (23:36 +0200)] 
MINOR: freq_ctr: add the missing next_event_delay_period()

There was still no function to compute a wait time for periods, let's
implement it on top of freq_ctr_total() as we'll soon need it for the
per-second one. The divide here is applied on the frequency so that it
will be replaced with a reciprocal multiply when constant.

4 years agoMEDIUM: freq_ctr: reimplement freq_ctr_remain_period() from freq_ctr_total()
Willy Tarreau [Sun, 11 Apr 2021 08:42:28 +0000 (10:42 +0200)] 
MEDIUM: freq_ctr: reimplement freq_ctr_remain_period() from freq_ctr_total()

Now the function becomes an inline one and only contains a divide and
a max. The divide will automatically go away with constant periods.

4 years agoMEDIUM: freq_ctr: make read_freq_ctr_period() use freq_ctr_total()
Willy Tarreau [Sat, 10 Apr 2021 22:57:33 +0000 (00:57 +0200)] 
MEDIUM: freq_ctr: make read_freq_ctr_period() use freq_ctr_total()

This one is the easiest to implement, it just requires a call and a
divide of the result. Anti-flapping correction for low-rates was
preserved.

Now calls using a constant period will be able to use a reciprocal
multiply for the period instead of a divide.

4 years agoMINOR: freq_ctr: add a generic function to report the total value
Willy Tarreau [Sat, 10 Apr 2021 22:38:06 +0000 (00:38 +0200)] 
MINOR: freq_ctr: add a generic function to report the total value

Most of the functions designed to read a counter over a period go through
the same complex loop and only differ in the way they use the returned
values, so it was worth implementing all this into freq_ctr_total() which
returns the total number of events over a period so that the caller can
finish its operation using a divide or a remaining time calculation. As
a special case, read_freq_ctr_period() doesn't take pending events but
requires to enable an anti-flapping correction at very low frequencies.
Thus the function implements it when pend<0.

Thanks to this function it will be possible to reimplement the other ones
as inline and merge the per-second ones with the arbitrary period ones
without always adding the cost of a 64 bit divide.

4 years agoMINOR: trace: make trace sources read_mostly
Willy Tarreau [Sat, 10 Apr 2021 17:29:26 +0000 (19:29 +0200)] 
MINOR: trace: make trace sources read_mostly

The trace sources are checked at plenty of places in the code and their
contents only change when trace status changes, let's mark them read_mostly.

4 years agoMINOR: pattern: make the pat_lru_seed read_mostly
Willy Tarreau [Sat, 10 Apr 2021 15:42:04 +0000 (17:42 +0200)] 
MINOR: pattern: make the pat_lru_seed read_mostly

This seed is created once at boot and is used in every LRU hash when
caching results. Let's mark it read_mostly.

4 years agoMINOR: protocol: move __protocol_by_family to read_mostly
Willy Tarreau [Sat, 10 Apr 2021 15:38:05 +0000 (17:38 +0200)] 
MINOR: protocol: move __protocol_by_family to read_mostly

This one is used for each outgoing connection and never changes after
boot, move it to read_mostly.

4 years agoMINOR: server: move idle_conn_task to read_mostly
Willy Tarreau [Sat, 10 Apr 2021 15:33:15 +0000 (17:33 +0200)] 
MINOR: server: move idle_conn_task to read_mostly

This pointer is used when adding connections to the idle list and is
never changed, let's move it to the read_mostly section.

4 years agoMINOR: threads: mark all_threads_mask as read_mostly
Willy Tarreau [Sat, 10 Apr 2021 15:28:18 +0000 (17:28 +0200)] 
MINOR: threads: mark all_threads_mask as read_mostly

This variable almost never changes and is read a lot in time-critical
sections. threads_want_rdv_mask is read very often as well in
thread_harmless_end() and is almost never changed (only when someone
uses thread_isolate()). Let's move both to read_mostly.

4 years agoMINOR: pool: move pool declarations to read_mostly
Willy Tarreau [Sat, 10 Apr 2021 15:23:00 +0000 (17:23 +0200)] 
MINOR: pool: move pool declarations to read_mostly

All pool heads are accessed via a pointer and should not be shared with
highly written variables. Move them to the read_mostly section.

4 years agoMINOR: kqueue: move kqueue_fd to read_mostly
Willy Tarreau [Sat, 10 Apr 2021 15:09:53 +0000 (17:09 +0200)] 
MINOR: kqueue: move kqueue_fd to read_mostly

This one only contains the list of per-thread kqueue FDs, and is used
a lot during updates. Let's mark it read_mostly to avoid false sharing
of FDs placed at the extremities.

4 years agoMINOR: epoll: move epoll_fd to read_mostly
Willy Tarreau [Sat, 10 Apr 2021 15:06:40 +0000 (17:06 +0200)] 
MINOR: epoll: move epoll_fd to read_mostly

This one only contains the list of per-thread epoll FDs, and is used
a lot during updates. Let's mark it read_mostly to avoid false sharing
of FDs placed at the extremities.

4 years agoMINOR: fd: move a few read-mostly variables to their own section
Willy Tarreau [Sat, 10 Apr 2021 14:58:13 +0000 (16:58 +0200)] 
MINOR: fd: move a few read-mostly variables to their own section

Some pointer to arrays such as fdtab, fdinfo, polled_mask etc are never
written to at run time but are used a lot. fdtab accesses appear a lot in
perf top because ha_used_fds is in the same cache line and is modified
all the time. This patch moves all these read-mostly variables to the
read_mostly section when defined. This way their cache lines will be
able to remain in shared state in all CPU caches.

4 years agoMINOR: global: declare a read_mostly section
Willy Tarreau [Sat, 10 Apr 2021 14:53:05 +0000 (16:53 +0200)] 
MINOR: global: declare a read_mostly section

Some variables are mostly read (mostly pointers) but they tend to be
merged with other ones in the same cache line, slowing their access down
in multi-thread setups. This patch declares an empty, aligned variable
in a section called "read_mostly". This will force a cache-line alignment
on this section so that any variable declared in it will be certain to
avoid false sharing with other ones. The section will be eliminated at
link time if not used.

A __read_mostly attribute was added to compiler.h to ease use of this
section.

4 years agoCLEANUP: initcall: rely on HA_SECTION_* instead of defining its own
Willy Tarreau [Sat, 10 Apr 2021 14:02:20 +0000 (16:02 +0200)] 
CLEANUP: initcall: rely on HA_SECTION_* instead of defining its own

Now initcalls are defined using the regular section definitions from
compiler.h in order to ease maintenance.

4 years agoMINOR: compiler: add macros to declare section names
Willy Tarreau [Sat, 10 Apr 2021 13:53:45 +0000 (15:53 +0200)] 
MINOR: compiler: add macros to declare section names

HA_SECTION() is used as an attribute to force a section name. This is
required because OSX prepends "__DATA, " in front of the declaration.
HA_SECTION_START() and HA_SECTION_STOP() are used as post-attribute on
variable declaration to designate the section start/end (needed only on
OSX, empty on others).

For platforms with an obsolete linker, all macros are left empty. It would
possibly still work on some of them but this will not be needed anyway.

4 years agoCLEANUP: initcall: rename HA_SECTION to HA_INIT_SECTION
Willy Tarreau [Sat, 10 Apr 2021 13:17:21 +0000 (15:17 +0200)] 
CLEANUP: initcall: rename HA_SECTION to HA_INIT_SECTION

The HA_SECTION name is too generic and will be reused globally. Let's
rename this one.

4 years agoMINOR: initcall: uniformize the section names between MacOS and other unixes
Willy Tarreau [Sat, 10 Apr 2021 13:43:17 +0000 (15:43 +0200)] 
MINOR: initcall: uniformize the section names between MacOS and other unixes

Due to length restrictions on OSX the initcall sections are called "i_"
there while they're called "init_" on other OSes. However the start and
end of sections are still called "__start_init_" and "__stop_init_",
which forces to have distinct code between the OSes. Let's switch everyone
to "i_" and rename the symbols accordingly.

4 years agoMINOR: trace: replace the trace() inline function with an equivalent macro
Willy Tarreau [Sat, 10 Apr 2021 17:20:01 +0000 (19:20 +0200)] 
MINOR: trace: replace the trace() inline function with an equivalent macro

The trace() function is convenient to avoid calling trace() when traces
are not enabled, but there starts to be some callers which place complex
expressions in their trace calls, which results in all of them to be
evaluated before being passed as arguments to the trace() function. This
needlessly wastes precious CPU cycles.

Let's change the function for a macro, so that the arguments are now only
evaluated when the surce has traces enabled. However having a generic
macro being called "trace()" can easily cause conflicts with innocent
code so we rename it "_trace".

Just doing this has resulted in a 2.5% increase of the HTTP/1 request rate.

4 years agoCLEANUP: pattern: make all pattern tables read-only
Willy Tarreau [Sat, 10 Apr 2021 15:44:27 +0000 (17:44 +0200)] 
CLEANUP: pattern: make all pattern tables read-only

Interestingly, all arrays used to declare patterns were read-write while
only hard-coded. Let's mark them const so that they move from data to
rodata and don't risk to experience false sharing.

4 years agoCI: travis: Drastically clean up .travis.yml
Tim Duesterhus [Fri, 9 Apr 2021 18:21:35 +0000 (20:21 +0200)] 
CI: travis: Drastically clean up .travis.yml

Now travis should only run on cron, on non-amd64, with a configuration that
only has the standard features enabled. This should reduce the number of
valuable build minutes consumed while providing as much value as possible.

4 years agoBUG/MINOR: mux-pt: Fix a possible UAF because of traces in mux_pt_io_cb
Christopher Faulet [Sat, 10 Apr 2021 07:02:32 +0000 (09:02 +0200)] 
BUG/MINOR: mux-pt: Fix a possible UAF because of traces in mux_pt_io_cb

In mux_pt_io_cb(), if a connection error or a shutdown is detected, the mux
is destroyed. Thus we must be careful to not use it in a trace message once
destroyed.

No backport needed. This patch should fix the issue #1220.

4 years agoMINOIR: mux-pt/trace: Register a new trace source with its events
Christopher Faulet [Thu, 8 Apr 2021 14:45:11 +0000 (16:45 +0200)] 
MINOIR: mux-pt/trace: Register a new trace source with its events

As for the other muxes, traces are now supported in the pt mux. All parts of
the multiplexer is covered by these traces. Events are splitted by
categories (connection, stream, rx and tx).

In traces, the first argument is always a connection. So it is easy to get
the mux context (conn->ctx). The second argument is always a conn-stream and
mau be NUUL. The third one is a buffer and it may also be NULL. Depending on
the context it is the request or the response. In all cases it is owned by a
channel. Finally, the fourth argument is an integer value. Its meaning
depends on the calling context.

4 years ago[RELEASE] Released version 2.4-dev16 v2.4-dev16
Willy Tarreau [Fri, 9 Apr 2021 15:10:39 +0000 (17:10 +0200)] 
[RELEASE] Released version 2.4-dev16

Released version 2.4-dev16 with the following main changes :
    - CLEANUP: dev/flags: remove useless test in the stdin number parser
    - MINOR: No longer rely on deprecated sample fetches for predefined ACLs
    - MINOR: acl: Add HTTP_2.0 predefined macro
    - BUG/MINOR: hlua: Detect end of request when reading data for an HTTP applet
    - BUG/MINOR: tools: fix parsing "us" unit for timers
    - MINOR: server/bind: add support of new prefixes for addresses.
    - MINOR: log: register config file and line number on log servers.
    - MEDIUM: log: support tcp or stream addresses on log lines.
    - BUG/MEDIUM: log: fix config parse error logging on stdout/stderr or any raw fd
    - CLEANUP: fd: remove FD_POLL_DATA and FD_POLL_STICKY
    - MEDIUM: fd: prepare FD_POLL_* to move to bits 8-15
    - MEDIUM: fd: merge fdtab[].ev and state for FD_EV_* and FD_POLL_* into state
    - MINOR: fd: move .linger_risk into fdtab[].state
    - MINOR: fd: move .cloned into fdtab[].state
    - MINOR: fd: move .initialized into fdtab[].state
    - MINOR: fd: move .et_possible into fdtab[].state
    - MINOR: fd: move .exported into fdtab[].state
    - MINOR: fd: implement an exclusive syscall bit to remove the ugly "log" lock
    - MINOR: cli/show-fd: slightly reorganize the FD status flags
    - MINOR: atomic/arm64: detect and use builtins for the double-word CAS
    - CLEANUP: atomic: add an explicit _FETCH variant for add/sub/and/or
    - CLEANUP: atomic: make all standard add/or/and/sub operations return void
    - CLEANUP: atomic: add a fetch-and-xxx variant for common operations
    - CLEANUP: atomic: add HA_ATOMIC_INC/DEC for unit increments
    - CLEANUP: atomic/tree-wide: replace single increments/decrements with inc/dec
    - CLEANUP: atomic: use the __atomic variant of BTS/BTR on modern compilers
    - MINOR: atomic: implement native BTS/BTR for x86
    - MINOR: ist: Add `istappend(struct ist, char)`
    - MINOR: ist: Add `istshift(struct ist*)`
    - MINOR: ist: Add `istsplit(struct ist*, char)`
    - BUG/MAJOR: fd: switch temp values to uint in fd_stop_both()
    - MINOR: opentracing: register config file and line number on log servers
    - MEDIUM: resolvers: add support of tcp address on nameserver line.
    - MINOR: ist: Rename istappend() to __istappend()
    - CLEANUP: htx: Make http_get_stline take a `const struct`
    - CLEANUP: ist: Remove unused `count` argument from `ist2str*`
    - CLEANUP: Remove useless malloc() casts

4 years agoCLEANUP: Remove useless malloc() casts
Tim Duesterhus [Thu, 8 Apr 2021 18:05:23 +0000 (20:05 +0200)] 
CLEANUP: Remove useless malloc() casts

This is not C++.

4 years agoCLEANUP: ist: Remove unused `count` argument from `ist2str*`
Tim Duesterhus [Sat, 3 Apr 2021 18:39:21 +0000 (20:39 +0200)] 
CLEANUP: ist: Remove unused `count` argument from `ist2str*`

This argument is not being used inside the function (and the functions
themselves are unused as well) and not documented. Its purpose is not clear.
Just remove it.

4 years agoCLEANUP: htx: Make http_get_stline take a `const struct`
Tim Duesterhus [Sat, 3 Apr 2021 18:39:20 +0000 (20:39 +0200)] 
CLEANUP: htx: Make http_get_stline take a `const struct`

Nothing is being modified there, so this can be `const`.

4 years agoMINOR: ist: Rename istappend() to __istappend()
Tim Duesterhus [Thu, 8 Apr 2021 17:28:16 +0000 (19:28 +0200)] 
MINOR: ist: Rename istappend() to __istappend()

Indicate that this function is not inherently safe by adding two underscores as
a prefix.

4 years agoMEDIUM: resolvers: add support of tcp address on nameserver line.
Emeric Brun [Wed, 7 Apr 2021 14:04:54 +0000 (16:04 +0200)] 
MEDIUM: resolvers: add support of tcp address on nameserver line.

This patch re-works configuration parsing, it removes the "server"
lines from "resolvers" sections introduced in commit 56fc5d9eb:
MEDIUM: resolvers: add supports of TCP nameservers in resolvers.

It also extends the nameserver lines to support stream server
addresses such as:

resolvers
  nameserver localhost tcp@127.0.0.1:53

Doing so, a part of nameserver's init code was factorized in
function 'parse_resolvers' and removed from 'post_parse_resolvers'.

4 years agoMINOR: opentracing: register config file and line number on log servers
Miroslav Zagorac [Wed, 7 Apr 2021 09:14:23 +0000 (11:14 +0200)] 
MINOR: opentracing: register config file and line number on log servers

In commit 9533a7038 new parameters have been added to the declaration
of function parse_logsrv().

This patch should be backported to all branches where the OpenTracing
filter is located.

4 years agoBUG/MAJOR: fd: switch temp values to uint in fd_stop_both()
Willy Tarreau [Wed, 7 Apr 2021 18:46:26 +0000 (20:46 +0200)] 
BUG/MAJOR: fd: switch temp values to uint in fd_stop_both()

With latest commit f50906519 ("MEDIUM: fd: merge fdtab[].ev and state
for FD_EV_* and FD_POLL_* into state") one occurrence of a pair of
chars was missed in fd_stop_both(), resulting in the operation to
fail if the upper flags were set. Interestingly it managed to fail
2 tests in all setups in the CI while all used to work fine on my
local machines. Probably that the reason is that the chars had enough
room above them for the CAS to fail then refill "old" overwriting the
upper parts of the stack, and that thanks to this the subsequent tests
worked. With ASAN being used on lots of tests, it very likely caught
it but used to only report failed tests with no more info.

No backport is needed, as this was never released nor backported.

4 years agoMINOR: ist: Add `istsplit(struct ist*, char)`
Tim Duesterhus [Mon, 5 Apr 2021 15:53:56 +0000 (17:53 +0200)] 
MINOR: ist: Add `istsplit(struct ist*, char)`

istsplit is a combination of iststop + istadv.

4 years agoMINOR: ist: Add `istshift(struct ist*)`
Tim Duesterhus [Mon, 5 Apr 2021 15:53:55 +0000 (17:53 +0200)] 
MINOR: ist: Add `istshift(struct ist*)`

istshift() returns the first character and advances the ist by 1.

4 years agoMINOR: ist: Add `istappend(struct ist, char)`
Tim Duesterhus [Mon, 5 Apr 2021 15:53:54 +0000 (17:53 +0200)] 
MINOR: ist: Add `istappend(struct ist, char)`

This function appends the given char to the given `ist` and returns
the resulting `ist`.

4 years agoMINOR: atomic: implement native BTS/BTR for x86
Willy Tarreau [Tue, 6 Apr 2021 12:24:51 +0000 (14:24 +0200)] 
MINOR: atomic: implement native BTS/BTR for x86

The current BTS/BTR operations on x86 are ugly because they rely on a
CAS, so they may be unfair and take time to converge. Fortunately,
where they are currently used (mostly FDs) the contention is expected
to be rare (mostly listeners). But this also limits their use to such
few low-load cases.

On x86 there is a set of BTS/BTR instructions which help for this,
but before the FD's state migrated to 32 bits there was little use of
them since they do not exist in 8 bits.

Now at least it makes sense to use them, at the very least in order
to significantly reduce the code size (one BTS instead of a CMPXCHG
loop). The implementation relies on modern gcc's ability to return
condition flags and limit code inflation and register spilling. The
fall back is retained on the old implementation for all other situations
(inappropriate target size or non-capable compiler). The code shrank
by 1.6 kB on the fast path.

As expected, for now on up to 4 threads there is no measurable difference
of performance.

4 years agoCLEANUP: atomic: use the __atomic variant of BTS/BTR on modern compilers
Willy Tarreau [Tue, 6 Apr 2021 12:04:22 +0000 (14:04 +0200)] 
CLEANUP: atomic: use the __atomic variant of BTS/BTR on modern compilers

Probably due to the result of an old copy-paste, HA_ATOMIC_BTS/BTR were
still implemented using the __sync_*  builtins instead of the more
modern __atomic_* which allow to specify the memory model. Let's update
this to use the newer there and also implement the relaxed variants
(which are not used for now).

4 years agoCLEANUP: atomic/tree-wide: replace single increments/decrements with inc/dec
Willy Tarreau [Tue, 6 Apr 2021 11:53:36 +0000 (13:53 +0200)] 
CLEANUP: atomic/tree-wide: replace single increments/decrements with inc/dec

This patch replaces roughly all occurrences of an HA_ATOMIC_ADD(&foo, 1)
or HA_ATOMIC_SUB(&foo, 1) with the equivalent HA_ATOMIC_INC(&foo) and
HA_ATOMIC_DEC(&foo) respectively. These are 507 changes over 45 files.

4 years agoCLEANUP: atomic: add HA_ATOMIC_INC/DEC for unit increments
Willy Tarreau [Tue, 6 Apr 2021 10:11:04 +0000 (12:11 +0200)] 
CLEANUP: atomic: add HA_ATOMIC_INC/DEC for unit increments

Most ADD/SUB callers use them for a single unit (e.g. refcounts) and
it's a pain to always pass ",1". Let's add them to simplify the API.
However we currently don't add any return value. If needed in the future
better report zero/non-zero than a real value for the sake of efficiency
at the instruction level.

4 years agoCLEANUP: atomic: add a fetch-and-xxx variant for common operations
Willy Tarreau [Tue, 6 Apr 2021 09:57:41 +0000 (11:57 +0200)] 
CLEANUP: atomic: add a fetch-and-xxx variant for common operations

The fetch_and_xxx variant is often missing for add/sub/and/or. In fact
it was only provided for ADD under the name XADD which corresponds to
the x86 instruction name. But for destructive operations like AND and
OR it's missing even more as it's not possible to know the value before
modifying it.

This patch explicitly adds HA_ATOMIC_FETCH_{OR,AND,ADD,SUB} which
cover these standard operations, and renames XADD to FETCH_ADD (there
were only 6 call places).

In the future, backport of fixes involving such operations could simply
remap FETCH_ADD(x) to XADD(x), FETCH_SUB(x) to XADD(-x), and for the
OR/AND if needed, these could possibly be done using BTS/BTR.

It's worth noting that xchg could have been renamed to fetch_and_store()
but xchg already has well understood semantics and it wasn't needed to
go further.

4 years agoCLEANUP: atomic: make all standard add/or/and/sub operations return void
Willy Tarreau [Tue, 6 Apr 2021 09:46:58 +0000 (11:46 +0200)] 
CLEANUP: atomic: make all standard add/or/and/sub operations return void

In order to make sure these ones will not be used anymore in an expression,
let's make them always void. New callers will now be forced to use the
explicit _FETCH variant if required.

4 years agoCLEANUP: atomic: add an explicit _FETCH variant for add/sub/and/or
Willy Tarreau [Tue, 6 Apr 2021 09:44:07 +0000 (11:44 +0200)] 
CLEANUP: atomic: add an explicit _FETCH variant for add/sub/and/or

Currently our atomic ops return a value but it's never known whether
the fetch is done before or after the operation, which causes some
confusion each time the value is desired. Let's create an explicit
variant of these operations suffixed with _FETCH to explicitly mention
that the fetch occurs after the operation, and make use of it at the
few call places.

4 years agoMINOR: atomic/arm64: detect and use builtins for the double-word CAS
Willy Tarreau [Tue, 6 Apr 2021 07:21:33 +0000 (09:21 +0200)] 
MINOR: atomic/arm64: detect and use builtins for the double-word CAS

Gcc 10.2 implements outline atomics on aarch64. The replace all inline
atomic ops with a function call that checks if the machine supports LSE
atomics. This comes with a small cost but allows modern machines to scale
much better than with the old LL/SC ones even when built for full 8.0
compatibility.

This patch enables the use of the __atomic_compare_exchange() builtin
for the double-word CAS when detected as available instead of using the
hand-written LL/SC version. The extra cost is negligible because we do
very few DWCAS operations (essentially FD migrations and shared pools)
so the cost is low but under high contention it can still be beneficial.
As expected no performance difference was measured in either direction
on 4-core machines with this change.

This could be backported to 2.3 if it was shown that FD migrations were
representing a significant source of contention, but for now it does
not appear to be needed.

4 years agoMINOR: cli/show-fd: slightly reorganize the FD status flags
Willy Tarreau [Wed, 7 Apr 2021 06:48:12 +0000 (08:48 +0200)] 
MINOR: cli/show-fd: slightly reorganize the FD status flags

Slightly reorder the status flags to better match their order in the
"state" field, and also decode the "shut" state which is particularly
useful and already part of this field.

4 years agoMINOR: fd: implement an exclusive syscall bit to remove the ugly "log" lock
Willy Tarreau [Wed, 7 Apr 2021 15:36:57 +0000 (17:36 +0200)] 
MINOR: fd: implement an exclusive syscall bit to remove the ugly "log" lock

There is a function called fd_write_frag_line() that's essentially used
by loggers and that is used to write an atomic message line over a file
descriptor using writev(). However a lock is required around the writev()
call to prevent messages from multiple threads from being interleaved.
Till now a SPIN_TRYLOCK was used on a dedicated lock that was common to
all FDs. This is quite not pretty as if there are multiple output pipes
to collect logs, there will be quite some contention. Now that there
are empty flags left in the FD state and that we can finally use atomic
ops on them, let's add a flag to indicate the FD is locked for exclusive
access by a syscall. At least the locking will now be on an FD basis and
not the whole process, so we can remove the log_lock.

4 years agoMINOR: fd: move .exported into fdtab[].state
Willy Tarreau [Tue, 6 Apr 2021 16:09:06 +0000 (18:09 +0200)] 
MINOR: fd: move .exported into fdtab[].state

No need to keep this flag apart any more, let's merge it into the global
state.

4 years agoMINOR: fd: move .et_possible into fdtab[].state
Willy Tarreau [Tue, 6 Apr 2021 16:05:48 +0000 (18:05 +0200)] 
MINOR: fd: move .et_possible into fdtab[].state

No need to keep this flag apart any more, let's merge it into the global
state.

4 years agoMINOR: fd: move .initialized into fdtab[].state
Willy Tarreau [Tue, 6 Apr 2021 15:57:12 +0000 (17:57 +0200)] 
MINOR: fd: move .initialized into fdtab[].state

No need to keep this flag apart any more, let's merge it into the global
state. The bit was not cleared in fd_insert() because the only user is
the function used to create and atomically send a log message to a pipe
FD, which never registers the fd. Here we clear it nevertheless for the
sake of clarity.

Note that with an extra cleaning pass we could have a bit number
here and simply use a BTS to test and set it.

4 years agoMINOR: fd: move .cloned into fdtab[].state
Willy Tarreau [Tue, 6 Apr 2021 15:53:33 +0000 (17:53 +0200)] 
MINOR: fd: move .cloned into fdtab[].state

No need to keep this flag apart any more, let's merge it into the global
state.

4 years agoMINOR: fd: move .linger_risk into fdtab[].state
Willy Tarreau [Tue, 6 Apr 2021 15:49:19 +0000 (17:49 +0200)] 
MINOR: fd: move .linger_risk into fdtab[].state

No need to keep this flag apart any more, let's merge it into the global
state. The CLI's output state was extended to 6 digits and the linger/cloned
flags moved inside the parenthesis.

4 years agoMEDIUM: fd: merge fdtab[].ev and state for FD_EV_* and FD_POLL_* into state
Willy Tarreau [Tue, 6 Apr 2021 15:23:40 +0000 (17:23 +0200)] 
MEDIUM: fd: merge fdtab[].ev and state for FD_EV_* and FD_POLL_* into state

For a long time we've had fdtab[].ev and fdtab[].state which contain two
arbitrary sets of information, one is mostly the configuration plus some
shutdown reports and the other one is the latest polling status report
which also contains some sticky error and shutdown reports.

These ones used to be stored into distinct chars, complicating certain
operations and not even allowing to clearly see concurrent accesses (e.g.
fd_delete_orphan() would set the state to zero while fd_insert() would
only set the event to zero).

This patch creates a single uint with the two sets in it, still delimited
at the byte level for better readability. The original FD_EV_* values
remained at the lowest bit levels as they are also known by their bit
value. The next step will consist in merging the remaining bits into it.

The whole bits are now cleared both in fd_insert() and _fd_delete_orphan()
because after a complete check, it is certain that in both cases these
functions are the only ones touching these areas. Indeed, for
_fd_delete_orphan(), the thread_mask has already been zeroed before a
poller can call fd_update_event() which would touch the state, so it
is certain that _fd_delete_orphan() is alone. Regarding fd_insert(),
only one thread will get an FD at any moment, and it as this FD has
already been released by _fd_delete_orphan() by definition it is certain
that previous users have definitely stopped touching it.

Strictly speaking there's no need for clearing the state again in
fd_insert() but it's cheap and will remove some doubts during some
troubleshooting sessions.

4 years agoMEDIUM: fd: prepare FD_POLL_* to move to bits 8-15
Willy Tarreau [Tue, 6 Apr 2021 14:55:17 +0000 (16:55 +0200)] 
MEDIUM: fd: prepare FD_POLL_* to move to bits 8-15

In preparation of merging FD_POLL* and FD_EV*, this only changes the
value of FD_POLL_* to use bits 8-15 (the second byte). The size of the
field has been temporarily extended to 32 bits already, as well as
the temporary variables that carry the new composite value inside
fd_update_events(). The resulting fdtab entry becomes temporarily
unaligned. All places making access to .ev or FD_POLL_* were carefully
inspected to make sure they were safe regarding this change. Only one
temporary update was needed for the "show fd" code. The code was only
slightly inflated at this step.

4 years agoCLEANUP: fd: remove FD_POLL_DATA and FD_POLL_STICKY
Willy Tarreau [Tue, 6 Apr 2021 14:48:02 +0000 (16:48 +0200)] 
CLEANUP: fd: remove FD_POLL_DATA and FD_POLL_STICKY

The former was not used and the second was used only as a positive mask
of the flags to keep instead of having the flags that are updated. Both
were removed in favor of a new FD_POLL_UPDT_MASK that only mentions the
updated flags. This will ease merging of state and ev later.

4 years agoBUG/MEDIUM: log: fix config parse error logging on stdout/stderr or any raw fd
Emeric Brun [Wed, 7 Apr 2021 12:26:44 +0000 (14:26 +0200)] 
BUG/MEDIUM: log: fix config parse error logging on stdout/stderr or any raw fd

The regression was introduced by commit previous commit 94aab06:
MEDIUM: log: support tcp or stream addresses on log lines.

This previous patch tries to retrieve the used protocol parsing
the address using the str2sa_range function but forgets that
the raw file descriptor adresses don't specify a protocol
and str2sa_range probes an error.

This patch re-work the str2sa_range function to stop
probing error if an authorized RAW_FD address is parsed
whereas the caller request also a protocol.

It also modify the code of parse_logsrv to switch on stream
logservers only if a protocol was detected.

4 years agoMEDIUM: log: support tcp or stream addresses on log lines.
Emeric Brun [Fri, 2 Apr 2021 08:41:36 +0000 (10:41 +0200)] 
MEDIUM: log: support tcp or stream addresses on log lines.

An explicit stream address prefix such as "tcp6@" "tcp4@"
"stream+ipv6@" "stream+ipv4@" or "stream+unix@" will
allocate an implicit ring buffer with a forward server
targeting the given address.

This is usefull to simply send logs to a log server in tcp
and It doesn't need to declare a ring section in configuration.

4 years agoMINOR: log: register config file and line number on log servers.
Emeric Brun [Fri, 2 Apr 2021 08:13:43 +0000 (10:13 +0200)] 
MINOR: log: register config file and line number on log servers.

This patch registers the parsed file and the line where a log server
is declared to make those information available in configuration
post check.

Those new informations were added on error messages probed resolving
ring names on post configuration check.

4 years agoMINOR: server/bind: add support of new prefixes for addresses.
Emeric Brun [Fri, 2 Apr 2021 15:05:09 +0000 (17:05 +0200)] 
MINOR: server/bind: add support of new prefixes for addresses.

Since the internal function str2sa_range is used to addresses
for different objects ('server', 'bind' but also 'log' or
'nameserver') we notice that some combinations are missing.

"ip@" is introduced to authorize the prefix "dgram+ip@" or
"stream+ip@" which dectects automatically IP version but
specify dgram or stream.

"tcp@" was introduced and is an alias for "stream+ip@".
"tcp6" and "tcp4" are now aliases for "stream+ipv6@" and
"stream+ipv4@".

"uxst@" and "uxdg@" are now aliases for "stream+unix@" and
"dgram+unix@".

This patch also adds a complete section in documentation to
describe adresses and their prefixes.

4 years agoBUG/MINOR: tools: fix parsing "us" unit for timers
Thayne McCombs [Fri, 2 Apr 2021 20:12:43 +0000 (14:12 -0600)] 
BUG/MINOR: tools: fix parsing "us" unit for timers

Commit c20ad0d8dbd1bb5707bbfe23632415c3062e046c (BUG/MINOR: tools:  make
parse_time_err() more strict on the timer validity) broke parsing the "us"
unit in timers. It caused `parse_time_err()` to return the string "s",
which indicates an error.

Now if the "u" is followed by an "s" we properly continue processing the
time instead of immediately failing.

This fixes #1209. It must be backported to all stable versions.

4 years agoBUG/MINOR: hlua: Detect end of request when reading data for an HTTP applet
Christopher Faulet [Fri, 2 Apr 2021 12:24:56 +0000 (14:24 +0200)] 
BUG/MINOR: hlua: Detect end of request when reading data for an HTTP applet

When a script retrieves request data from an HTTP applet, line per line or
not, we must be sure to properly detect the end of the request by checking
HTX_FL_EOM flag when everything was consumed. Otherwise, the script may
hang.

It is pretty easy to reproduce the bug by calling applet:receive() without
specifying any length. If the request is not chunked, the function never
returns.

The bug was introduced when the EOM block was removed. Thus, it is specific
to the 2.4. This patch should fix the issue #1207. No backport needed.

4 years agoMINOR: acl: Add HTTP_2.0 predefined macro
Christopher Faulet [Fri, 26 Mar 2021 15:00:54 +0000 (16:00 +0100)] 
MINOR: acl: Add HTTP_2.0 predefined macro

HTTP_2.0 predefined macro returns true for HTTP/2 requests. HTTP/2 doen't
convey a version information, so this macro may seem a bit strange. But for
compatiblity reasons, internally, the "HTTP/2.0" version is set. Thus, it is
handy to rely on it to differenciate HTTP/1 and HTTP/2 requests.

4 years agoMINOR: No longer rely on deprecated sample fetches for predefined ACLs
Christopher Faulet [Thu, 1 Apr 2021 15:24:04 +0000 (17:24 +0200)] 
MINOR: No longer rely on deprecated sample fetches for predefined ACLs

Some predefined ACLs were still based on deprecated sample fetches, like
req_proto_http or req_ver. Now, they use non-deprecated sample fetches. In
addition, the usage lines in the configuration manual have been updated to
be more explicit.

4 years agoCLEANUP: dev/flags: remove useless test in the stdin number parser
Willy Tarreau [Sat, 3 Apr 2021 13:26:56 +0000 (15:26 +0200)] 
CLEANUP: dev/flags: remove useless test in the stdin number parser

The test on "if (err)" after parsing a number was meant to be
"if (*err)" but in practise it will always be true since we at least
have a '\n' there, so no need for testing before writing zero.
This fixes issue #1211.

4 years ago[RELEASE] Released version 2.4-dev15 v2.4-dev15
Willy Tarreau [Fri, 2 Apr 2021 17:16:32 +0000 (19:16 +0200)] 
[RELEASE] Released version 2.4-dev15

Released version 2.4-dev15 with the following main changes :
    - BUG/MINOR: payload: Wait for more data if buffer is empty in payload/payload_lv
    - BUG/MINOR: stats: Apply proper styles in HTML status page.
    - BUG/MEDIUM: time: make sure to always initialize the global tick
    - BUG/MINOR: tcp: fix silent-drop workaround for IPv6
    - BUILD: tcp: use IPPROTO_IPV6 instead of SOL_IPV6 on FreeBSD/MacOS
    - CLEANUP: socket: replace SOL_IP/IPV6/TCP with IPPROTO_IP/IPV6/TCP
    - BUG/MINOR: http_fetch: make hdr_ip() resistant to empty fields
    - BUG/MINOR: mux-h2: Don't emit log twice if an error occurred on the preface
    - MINOR: stream: Don't trigger errors on destructive HTTP upgrades
    - MINOR: frontend: Create HTTP txn for HTX streams
    - MINOR: stream: Be sure to set HTTP analysers when creating an HTX stream
    - BUG/MINOR: stream: Properly handle TCP>H1>H2 upgrades in http_wait_for_request
    - BUG/MINOR: config: Add warning for http-after-response rules in TCP mode
    - MINOR: muxes: Add a flag to notify a mux does not support any upgrade
    - MINOR: mux-h1: Don't perform implicit HTTP/2 upgrade if not supported by mux
    - MINOR: mux-pt: Don't perform implicit HTTP upgrade if not supported by mux
    - MEDIUM: mux-h1: Expose h1 in the list of supported mux protocols
    - MEDIUM: mux-pt: Expose passthrough in the list of supported mux protocols
    - MINOR: muxes: Show muxes flags when the mux list is displayed
    - DOC: config: Improve documentation about proto/check-proto keywords
    - MINOR: stream: Use stream type instead of proxy mode when appropriate
    - MINOR: filters/http-ana: Decide to filter HTTP headers in HTTP analysers
    - MINOR: http-ana: Simplify creation/destruction of HTTP transactions
    - MINOR: stream: Handle stream HTTP upgrade in a dedicated function
    - MEDIUM: Add tcp-request switch-mode action to perform HTTP upgrade
    - MINOR: config/proxy: Don't warn for HTTP rules in TCP if 'switch-mode http' set
    - MINOR: config/proxy: Warn if a TCP proxy without backend is upgradable to HTTP
    - DOC: config: Add documentation about TCP to HTTP upgrades
    - REGTESTS: Add script to tests TCP to HTTP upgrades
    - BUG/MINOR: payload/htx: Ingore L6 sample fetches for HTX streams/checks
    - MINOR: htx: Make internal.strm.is_htx an internal sample fetch
    - MINOR: action: Use a generic function to check validity of an action rule list
    - MINOR: payload/config: Warn if a L6 sample fetch is used from an HTTP proxy
    - MEDIUM: http-rules: Add wait-for-body action on request and response side
    - REGTESTS: Add script to tests the wait-for-body HTTP action
    - BUG/MINOR: http-fetch: Fix test on message state to capture the version
    - CLEANUP: vars: always pre-initialize smp in vars_parse_cli_get_var()
    - MINOR: global: define diagnostic mode of execution
    - MINOR: cfgparse: diag for multiple nbthread statements
    - MINOR: server: diag for 0 weight server
    - MINOR: diag: create cfgdiag module
    - MINOR: diag: diag if servers use the same cookie value
    - MINOR: config: diag if global section after non-global
    - TESTS: slightly reorganize the code in the tests/ directory
    - TESTS: move tests/*.cfg to tests/config
    - REGTESTS: ssl: "set ssl cert" and multi-certificates bundle
    - REGTESTS: ssl: mark set_ssl_cert_bundle.vtc as broken
    - CONTRIB: halog: fix issue with array of type char
    - CONTRIB: tcploop: add a shutr command
    - CONTRIB: debug: add the show-fd-to-flags script
    - CONTRIB: debug: split poll from flags
    - CONTRIB: move some dev-specific tools to dev/
    - BUILD: makefile: always build the flags utility
    - DEV: flags: replace the unneeded makefile with a README
    - BUILD: makefile: integrate the hpack tools
    - CONTRIB: merge ip6range with iprange
    - CONTRIB: move some admin-related sub-projects to admin/
    - CONTRIB: move halog to admin/
    - ADMIN: halog: automatically enable USE_MEMCHR on the right glibc version
    - BUILD: makefile: build halog with the correct flags
    - BUILD: makefile: add a "USE_PROMEX" variable to ease building prometheus-exporter
    - CONTRIB: move prometheus-exporter to addons/promex
    - DOC: add a few words about USE_* and the addons directory
    - CONTRIB: move 51Degrees to addons/51degrees
    - CONTRIB: move src/da.c and contrib/deviceatlas to addons/deviceatlas
    - CONTRIB: move src/wurfl.c and contrib/wurfl to addons/wurfl
    - CONTRIB: move contrib/opentracing to addons/ot
    - BUG/MINOR: opentracing: initialization after establishing daemon mode
    - DOC: clarify that compression works for HTTP/2

4 years agoDOC: clarify that compression works for HTTP/2
Julien Pivotto [Mon, 29 Mar 2021 10:41:40 +0000 (12:41 +0200)] 
DOC: clarify that compression works for HTTP/2

This patch clarifies that compression also works with HTTP/2. I have
picked the wording "HTTP/1.1 or above" because it is already used
elsewhere in the documentation.

I have tested that compression indeed works in HTTP/2.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
4 years agoBUG/MINOR: opentracing: initialization after establishing daemon mode
Miroslav Zagorac [Fri, 2 Apr 2021 02:25:47 +0000 (04:25 +0200)] 
BUG/MINOR: opentracing: initialization after establishing daemon mode

This patch solves the problem reported in github issue #1204, where the
OpenTracing filter cannot communicate with the selected tracer if HAProxy
is run in daemon mode.  The author of the reported issue uses Zipkin
tracer, while in this example Jaeger tracer is used (see gdb output below).

The problem is that the OpenTracing library is initialized before HAProxy
initialize the daemon mode.  Establishing this mode kills the OpenTracing
thread, after which the correct operation of the OpenTracing filter is no
longer possible.  Also, HAProxy crashes on deinitialization of the
OpenTracing library.

The initialization of the OpenTracing library has been moved from the
flt_ot_init() function (which is started before switching the HAProxy to
daemon mode) to the flt_ot_init_per_thread() function (which is run after
switching the HAProxy to daemon mode).

Gdb output of crashed HAProxy process:

  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
  Core was generated by `../../../haproxy -f sa/haproxy.cfg'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  0x00007f8131fd5629 in pthread_join (threadid=140192831239936, thread_return=0x0) at pthread_join.c:45
  45      pthread_join.c: No such file or directory.
  (gdb) where
  #0  0x00007f8131fd5629 in pthread_join (threadid=140192831239936, thread_return=0x0) at pthread_join.c:45
  #1  0x00007f812f15abc7 in std::thread::join() ()
     from /tmp/haproxy-os-master/contrib/opentracing/test/libjaeger_opentracing_plugin-0.5.0.so
  #2  0x00007f812f0fb6f7 in jaegertracing::reporters::RemoteReporter::close() ()
        from /tmp/haproxy-os-master/contrib/opentracing/test/libjaeger_opentracing_plugin-0.5.0.so
  #3  0x00007f812f0b7055 in jaegertracing::reporters::CompositeReporter::close() ()
           from /tmp/haproxy-os-master/contrib/opentracing/test/libjaeger_opentracing_plugin-0.5.0.so
  #4  0x00007f812f0b9136 in jaegertracing::Tracer::Close() ()
              from /tmp/haproxy-os-master/contrib/opentracing/test/libjaeger_opentracing_plugin-0.5.0.so
  #5  0x00007f81309def32 in ot_tracer_close (tracer=0x55fb48057390) at ../../src/tracer.cpp:91
  #6  0x000055fb41785705 in ot_close (tracer=0x55fb48061168) at contrib/opentracing/src/opentracing.c:208
  #7  0x000055fb4177fc64 in flt_ot_deinit (p=<optimized out>, fconf=<optimized out>) at contrib/opentracing/src/filter.c:215
  #8  0x000055fb418bc038 in flt_deinit (proxy=proxy@entry=0x55fb4805ce50) at src/filters.c:360
  #9  0x000055fb41893ed1 in free_proxy (p=0x55fb4805ce50) at src/proxy.c:315
  #10 0x000055fb41888809 in deinit () at src/haproxy.c:2217
  #11 0x000055fb41889078 in deinit_and_exit (status=0) at src/haproxy.c:2343
  #12 0x000055fb4173d809 in main (argc=<optimized out>, argv=<optimized out>) at src/haproxy.c:3230

This patch should be backported to all branches where the OpenTracing
filter is located.

4 years agoCONTRIB: move contrib/opentracing to addons/ot
Willy Tarreau [Fri, 2 Apr 2021 15:16:46 +0000 (17:16 +0200)] 
CONTRIB: move contrib/opentracing to addons/ot

This one is the last optional module to build with haproxy, so let's move
it to addons/. It was renamed to "ot" as it was the only one whose USE_*
option did not match the directory name, now this is consistent.

Few changes were required, only the Makefile, and doc were adjusted, as
the directory was already self-contained and relocatable.

4 years agoCONTRIB: move src/wurfl.c and contrib/wurfl to addons/wurfl
Willy Tarreau [Fri, 2 Apr 2021 14:39:44 +0000 (16:39 +0200)] 
CONTRIB: move src/wurfl.c and contrib/wurfl to addons/wurfl

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, and vtest matrix were updated.

4 years agoCONTRIB: move src/da.c and contrib/deviceatlas to addons/deviceatlas
Willy Tarreau [Fri, 2 Apr 2021 14:19:39 +0000 (16:19 +0200)] 
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.

4 years agoCONTRIB: move 51Degrees to addons/51degrees
Willy Tarreau [Fri, 2 Apr 2021 14:12:32 +0000 (16:12 +0200)] 
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.

4 years agoDOC: add a few words about USE_* and the addons directory
Willy Tarreau [Fri, 2 Apr 2021 13:53:34 +0000 (15:53 +0200)] 
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.

4 years agoCONTRIB: move prometheus-exporter to addons/promex
Willy Tarreau [Fri, 2 Apr 2021 13:35:19 +0000 (15:35 +0200)] 
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.

4 years agoBUILD: makefile: add a "USE_PROMEX" variable to ease building prometheus-exporter
Willy Tarreau [Fri, 2 Apr 2021 13:31:10 +0000 (15:31 +0200)] 
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.

4 years agoBUILD: makefile: build halog with the correct flags
Willy Tarreau [Fri, 2 Apr 2021 12:46:21 +0000 (14:46 +0200)] 
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.

4 years agoADMIN: halog: automatically enable USE_MEMCHR on the right glibc version
Willy Tarreau [Fri, 2 Apr 2021 12:57:42 +0000 (14:57 +0200)] 
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.

4 years agoCONTRIB: move halog to admin/
Willy Tarreau [Fri, 2 Apr 2021 12:45:06 +0000 (14:45 +0200)] 
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.

4 years agoCONTRIB: move some admin-related sub-projects to admin/
Willy Tarreau [Fri, 2 Apr 2021 12:36:15 +0000 (14:36 +0200)] 
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/

4 years agoCONTRIB: merge ip6range with iprange
Willy Tarreau [Fri, 2 Apr 2021 12:33:40 +0000 (14:33 +0200)] 
CONTRIB: merge ip6range with iprange

No need to have two separate sub-projects doing the same thing, let's
merge them.

4 years agoBUILD: makefile: integrate the hpack tools
Willy Tarreau [Fri, 2 Apr 2021 12:27:26 +0000 (14:27 +0200)] 
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.

4 years agoDEV: flags: replace the unneeded makefile with a README
Willy Tarreau [Fri, 2 Apr 2021 12:16:00 +0000 (14:16 +0200)] 
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.

4 years agoBUILD: makefile: always build the flags utility
Willy Tarreau [Fri, 2 Apr 2021 11:59:17 +0000 (13:59 +0200)] 
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.

4 years agoCONTRIB: move some dev-specific tools to dev/
Willy Tarreau [Fri, 2 Apr 2021 11:31:46 +0000 (13:31 +0200)] 
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/

4 years agoCONTRIB: debug: split poll from flags
Willy Tarreau [Fri, 2 Apr 2021 11:43:49 +0000 (13:43 +0200)] 
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.

4 years agoCONTRIB: debug: add the show-fd-to-flags script
Willy Tarreau [Fri, 2 Apr 2021 11:40:03 +0000 (13:40 +0200)] 
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".

4 years agoCONTRIB: tcploop: add a shutr command
Willy Tarreau [Thu, 5 Oct 2017 04:31:10 +0000 (06:31 +0200)] 
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.

4 years agoCONTRIB: halog: fix issue with array of type char
Willy Tarreau [Fri, 2 Apr 2021 15:47:21 +0000 (17:47 +0200)] 
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.

4 years agoREGTESTS: ssl: mark set_ssl_cert_bundle.vtc as broken
William Lallemand [Fri, 2 Apr 2021 15:01:25 +0000 (17:01 +0200)] 
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.

4 years agoREGTESTS: ssl: "set ssl cert" and multi-certificates bundle
William Lallemand [Fri, 2 Apr 2021 13:23:14 +0000 (15:23 +0200)] 
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.

4 years agoTESTS: move tests/*.cfg to tests/config
Willy Tarreau [Fri, 2 Apr 2021 08:49:34 +0000 (10:49 +0200)] 
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.

4 years agoTESTS: slightly reorganize the code in the tests/ directory
Willy Tarreau [Fri, 2 Apr 2021 08:33:38 +0000 (10:33 +0200)] 
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.

4 years agoMINOR: config: diag if global section after non-global
Amaury Denoyelle [Wed, 31 Mar 2021 09:43:47 +0000 (11:43 +0200)] 
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.

4 years agoMINOR: diag: diag if servers use the same cookie value
Amaury Denoyelle [Tue, 30 Mar 2021 15:35:19 +0000 (17:35 +0200)] 
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.

4 years agoMINOR: diag: create cfgdiag module
Amaury Denoyelle [Tue, 30 Mar 2021 15:34:24 +0000 (17:34 +0200)] 
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.

4 years agoMINOR: server: diag for 0 weight server
Amaury Denoyelle [Tue, 30 Mar 2021 08:26:27 +0000 (10:26 +0200)] 
MINOR: server: diag for 0 weight server

Output a diagnostic report if a server has been configured with a null
weight.