haproxy-2.1.git
4 years agoSCRIPTS: improve announce-release to support different tag and versions
Willy Tarreau [Wed, 6 Jan 2021 14:16:46 +0000 (15:16 +0100)]
SCRIPTS: improve announce-release to support different tag and versions

By having three variables it will be easier to preset the version and
the tag separately. One contains the announced version, another one the
associated tag and the last one the final commit ID (used as the ending
point before the release). This initially allows to check for the HEAD
matching the tag only when the version was not forced, hence re-announce
already tagged versions after some extra commits were added for example.

(cherry picked from commit 0c612936b2f4319dcc55567af4aa425b1d6d52c7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d1754b6f0c0578569cf4673e01dfb547e2558bc3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 64028f4e8f55c3734c35a4355ac5138b87290cf6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: cfgparse: Fail if the strdup() for `rule->be.name` for `use_backend` fails
Tim Duesterhus [Sun, 3 Jan 2021 21:54:43 +0000 (22:54 +0100)]
BUG/MINOR: cfgparse: Fail if the strdup() for `rule->be.name` for `use_backend` fails

This patch fixes GitHub issue #1024.

I could track the `strdup` back to commit
3a1f5fda109fc56ae127d03eaf34ce027c9542e1 which is 1.9-dev8. It's probably not
worth the effort to backport it across this refactoring.

This patch should be backported to 1.9+.

(cherry picked from commit 5ce5a1586d8c67affa604dedf0faa2c5a02ecab5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f46d9cd735d1664c113c041d85179a81bded8fc6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit fdca7df8181de29a661be4e8f91160b087843167)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: atomic: don't use ; to separate instruction on aarch64.
Olivier Houchard [Wed, 23 Dec 2020 00:23:41 +0000 (01:23 +0100)]
MINOR: atomic: don't use ; to separate instruction on aarch64.

The assembler on MacOS aarch64 interprets ; as the beginning of comments,
so it is not suitable for separating instructions in inline asm. Use \n
instead.

This should be backported to 2.3, 2.2, 2.1, 2.0 and 1.9.

(cherry picked from commit 63ee28185430cbf5bdce21f82484f7de70fe4654)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ffc781b1eda8d4a66e899d3a40a37094ad4f674f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7c6634adcfbfa3c92bd8a51a688762df0969d8ce)
[cf: patch applied on common/hathreads.h because haproxy/atomic.h does not
     exist]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUILD: hpack: hpack-tbl-t.h uses VAR_ARRAY but does not include compiler.h
Christian Ruppert [Mon, 9 Nov 2020 08:15:21 +0000 (09:15 +0100)]
BUILD: hpack: hpack-tbl-t.h uses VAR_ARRAY but does not include compiler.h

This fixes building hpack from contrib, which failed because of the
undeclared VAR_ARRAY:

make -C contrib/hpack
...
cc -O2 -Wall -g -I../../include -fwrapv -fno-strict-aliasing -c -o gen-enc.o gen-enc.c
In file included from gen-enc.c:18:
../../include/haproxy/hpack-tbl-t.h:105:23: error: 'VAR_ARRAY' undeclared here (not in a function)
  105 |  struct hpack_dte dte[VAR_ARRAY]; /* dynamic table entries */
...

As discussed in the thread below, let's redefine VAR_ARRAY in this file
so that it remains self-sustaining:

   https://www.mail-archive.com/haproxy@formilux.org/msg39212.html

(cherry picked from commit b67e1558955c1c88dc2a3530322802ce3710bc88)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e2802e78038a3e3154fcc3f87eab62b6c81d23db)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 987bd0afd206af9d6ae113b01e1bd472e95ea1af)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: mux_h2: Add missing braces in h2_snd_buf()around trace+wakeup
Tim Duesterhus [Mon, 21 Dec 2020 18:40:16 +0000 (19:40 +0100)]
BUG/MEDIUM: mux_h2: Add missing braces in h2_snd_buf()around trace+wakeup

This is a regression in 7838a79ba ("MEDIUM: mux-h2/trace: add lots of traces
all over the code"). The issue was found using -Wmisleading-indentation.
This patch fixes GitHub issue #1015.

The impact of this bug is that it could in theory cause occasional delays
on some long responses for connections having otherwise no traffic.

This patch should be backported to 2.1+, the commit was first tagged in
v2.1-dev2.

(cherry picked from commit 12a08d8849166ec0a779bbdee2ce9d768d5aa824)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6dca14490dffcd7aff69b71d3fefbf3b3dcf7c12)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 769ba9391e77ebf3492a1910b6273090bbeb81c8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUILD: plock: remove dead code that causes a warning in gcc 11
Willy Tarreau [Mon, 21 Dec 2020 09:27:18 +0000 (10:27 +0100)]
BUILD: plock: remove dead code that causes a warning in gcc 11

As Ilya reported in issue #998, gcc 11 complains about misleading code
indentation which is in fact caused by dead assignments to zero after
a loop which stops on zero. Let's clean both of these.

(cherry picked from commit b1f54925fc17b00ddbe25e30c2207a8d68d47f34)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 775c665f20c695ad92fdb4318d5c77097ba15d7a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 78c677589e423f703cd9f5caefb28ed23bfba2a1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoCONTRIB: debug: address "poll" utility build on non-linux platforms
Willy Tarreau [Mon, 21 Dec 2020 07:43:50 +0000 (08:43 +0100)]
CONTRIB: debug: address "poll" utility build on non-linux platforms

MSG_NOSIGNAL and MSG_MORE are not defined everywhere, let's make them
zero when not defined. It will roughly result in the same behavior,
albeit a bit less optimal, which is no big deal when debugging. This
should fix issue #1014.

(cherry picked from commit 79d2e7bbbd56455f5f73c030df41e8e1ed621df4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 361e90eb459f9e9418c93c3cc2da5d6bc02c159d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2e8e6b1a53124265fe186730ed5cd0109c7a04de)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoCONTRIB: halog: fix signed/unsigned build warnings on counts and timestamps
Willy Tarreau [Mon, 21 Dec 2020 07:40:04 +0000 (08:40 +0100)]
CONTRIB: halog: fix signed/unsigned build warnings on counts and timestamps

Some variables were signed while they were compared to unsigned ones,
causing warnings to be issued when -Wextra is enabled.

(cherry picked from commit 03ca6054d02350e83cb5227608ccec13efdd3ade)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f87775390a22880b0f6b979d35343988fdd109a2)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 52381396cfe73d65c7ee841e674a6897fe81db19)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoCONTRIB: halog: mark the has_zero* functions unused
Willy Tarreau [Mon, 21 Dec 2020 07:35:24 +0000 (08:35 +0100)]
CONTRIB: halog: mark the has_zero* functions unused

These ones will depend on the use of memchr() or not, let's mark them unused
to avoid the warning reported in issue #1013.

(cherry picked from commit f531dfff18becc87a3855ae6bc987afe9bffccc3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9080ac02583d90f99544a389353538c1e68ad8cf)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0c2916b0c7462fab24a2ccea87dcc8b6f123c2ac)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoCONTRIB: halog: fix build issue caused by %L printf format
Willy Tarreau [Mon, 21 Dec 2020 07:29:09 +0000 (08:29 +0100)]
CONTRIB: halog: fix build issue caused by %L printf format

%Ld isn't standard, %lld is more portable. In addition, the format
should be %llu since the printed values are unsigned. This should
address issue #1013.

(cherry picked from commit 2df860cb13e503fc8d80889bb93c20d5e8b24cd5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6b20b8b4fa5f9e3cc465a78a42b12fb1456489b7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e7ec110111ed1b52b258421edc0d472171fbc52c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: http-ana: Never for sending data in TUNNEL mode
Christopher Faulet [Tue, 15 Dec 2020 12:32:55 +0000 (13:32 +0100)]
BUG/MEDIUM: http-ana: Never for sending data in TUNNEL mode

When a channel is set in TUNNEL mode, we now always set the CF_NEVER_WAIT flag,
to be sure to never wait for sending data. It is important because in TUNNEL
mode, we have no idea if more data are expected or not. Setting this flag
prevent the MSG_MORE flag to be set on the connection.

It is only a problem with the HTX, since the 2.2. On previous versions, the
MSG_MORE flag is only set on the mux initiative. In fact, the problem arises
because there is an ambiguity in tunnel mode about the HTX_FL_EOI flag. In this
mode, from the mux point of view, while the SHUTR is not received more data are
expected. But from the channel point of view, we want to send data asap.

At short term, this fix is good enough and is valid anyway. But for the long
term more reliable solution must be found. At least, the to_forward field must
regain its original meaning.

This patch must be backported as far as 2.2.

(cherry picked from commit 198ef8b1de3ddac116baeaf5b86f2f8335e69e62)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0d4da8c908526e919c103e9ff39786decc5ec787)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ee20c8c89296474109906a5260a1ca17de533a7f)
[cf: In fact, it should be backported as far as 2.0 to avoid future bugs]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: mux-h1: Don't set CS_FL_EOI too early for protocol upgrade requests
Christopher Faulet [Mon, 7 Dec 2020 17:21:27 +0000 (18:21 +0100)]
BUG/MINOR: mux-h1: Don't set CS_FL_EOI too early for protocol upgrade requests

When a protocol upgrade request is received, once parsed, it is waiting for
the response in the DONE state. But we must not set the flag CS_FL_EOI
because we don't know if a protocol upgrade will be performed or not.

Now, it is set on the response path, if both sides reached the DONE
state. If a protocol upgrade is finally performed, both side are switched in
TUNNEL state. Thus the CS_FL_EOI flag is not set.

If backported, this patch must be adapted because for now it relies on last
2.4-dev changes. It may be backported as far as 2.0.

(cherry picked from commit 3e1748bbf30bc06407bda36517c00c0b97bfeb50)
[cf: context adjustment]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit fe2d5b11f4aec0c8effd4ec4a2c9c1f07a9dc919)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d13afbcce5e664f9cfe797eee8c527e5fa947f1b)
[cf: context adjustment]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUILD: Makefile: have "make clean" destroy .o/.a/.s in contrib subdirs as well
Willy Tarreau [Wed, 16 Dec 2020 13:14:38 +0000 (14:14 +0100)]
BUILD: Makefile: have "make clean" destroy .o/.a/.s in contrib subdirs as well

Now that we sometimes link some contrib subparts directly into the
haproxy binary, it's becoming a real problem that they're not cleaned
on make clean.  Some of the tools there are useful as .so or pure
binaries and we don't want to remove them, but anything intermediary
susceptible to be linked into haproxy should be clenaed. This is what
this patch does for 3 levels of subdirs into contrib/, without touching
the rest. It should be sufficient for the vast majority of use cases.

(cherry picked from commit da867d8d68f19f9034a47d42d16db78a84a12299)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f25b487b1f4b9acb14010293f1e85cbb911caab7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 345df01dbc4da0f320a7c6844156e9f277294d19)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoREGTESTS: make use of HAPROXY_ARGS and pass -dM by default
Willy Tarreau [Wed, 16 Dec 2020 09:39:20 +0000 (10:39 +0100)]
REGTESTS: make use of HAPROXY_ARGS and pass -dM by default

Enabling memory poisonning is often pretty effective for detecting
uninitialized structure fields. Let's enable it by default and let
the user change the arguments at will (e.g. forcing some memory limits
or disabling a poller). This will work with the latest vtest version
to date (02a9bc1).

(cherry picked from commit a4009cd6103a92752db27c3a85051c6adcc832c1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f13c7dbe51f3eda453c6aa596b3b56e2274c106d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 4652c51bf24d5c17c7a441c17994c46c72600bf5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoCLEANUP: contrib/prometheus-exporter: typo fixes for ssl reuse metric
Pierre Cheynier [Tue, 7 Jul 2020 17:14:08 +0000 (19:14 +0200)]
CLEANUP: contrib/prometheus-exporter: typo fixes for ssl reuse metric

A typo I identified while having a look to our metric inventory.
(s/frontent/frontend)

(cherry picked from commit 1e3697635292b0f194171958a26766ae3e8d8453)
[wt: actually it fixes a real issue as the typo was user-visible]
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 2e50e5d1ea9b3af6cb87c52f23c6fc7b0e140b37)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoCLEANUP: lua: Remove declaration of an inexistant function
Christopher Faulet [Mon, 14 Dec 2020 12:27:02 +0000 (13:27 +0100)]
CLEANUP: lua: Remove declaration of an inexistant function

action_http_after_res_custom() is declared but never defined. The declaration
was introduced by the commit 86f8f6f78 ("MINOR: actions: Export actions lookup
functions"). But the definition does not exist because the HTTP after-response
ruleset only exist since the 2.2.

This patch must be backported where the above patch is, as far as 1.8. There is
no upstream commit ID for this patch.

4 years agoBUG/MEDIUM: lb-leastconn: Reposition a server using the right eweight
Christopher Faulet [Fri, 11 Dec 2020 14:36:01 +0000 (15:36 +0100)]
BUG/MEDIUM: lb-leastconn: Reposition a server using the right eweight

Depending on the context, the current eweight or the next one must be used
to reposition a server in the tree. When the server state is updated, for
instance its weight, the next eweight must be used because it is not yet
committed. However, when the server is used, on normal conditions, the
current eweight must be used.

In fact, it is only a bug on the 1.8. On newer versions, the changes on a
server are performed synchronously. But it is safer to rely on the right
eweight value to avoid any futur bugs.

On the 1.8, it is important to do so, because the server state is updated
and committed inside the rendez-vous point. Thus, the next server state may
be unsync with the current state for a short time, waiting all threads join
the rendez-vous point. It is especially a problem if the next eweight is set
to 0. Because otherwise, it must not be used to reposition the server in the
tree, leading to a divide by 0.

This patch must be backported as far as 1.8.

(cherry picked from commit cb33d3ac7f8dbc3f7323606a521d29dc100adbda)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0881842bf7a8de3e3cf93bece19f160945ba984a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 8498c5fe48b36371f2bf8e12217d57b76adde561)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: tools: Reject size format not starting by a digit
Christopher Faulet [Fri, 11 Dec 2020 08:30:45 +0000 (09:30 +0100)]
BUG/MINOR: tools: Reject size format not starting by a digit

parse_size_err() function is now more strict on the size format. The first
character must be a digit. Otherwise an error is returned. Thus "size k" is
now rejected.

This patch must be backported to all stable versions.

(cherry picked from commit 82635a0fc1d8196e5b199e2948d2bea4b1217ace)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7f955e66b93625ad405405f10bd51b94ffff72fe)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9a1194430a7d3a967c75775a801e99303b85dbc3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: tools: make parse_time_err() more strict on the timer validity
Christopher Faulet [Fri, 11 Dec 2020 08:23:07 +0000 (09:23 +0100)]
BUG/MINOR: tools: make parse_time_err() more strict on the timer validity

First, an error is now reported if the first character is not a digit. Thus,
"timeout client s" triggers an error now. Then 'u' is also rejected
now. 'us' is valid and should be used set the timer in microseconds. However
'u' alone is not a valid unit. It was just ignored before (default to
milliseconds). Now, it is an error. Finally, a warning is reported if the
end of the text is not reached after the timer parsing. This warning will
probably be switched to an error in a futur version.

This patch must be backported to all stable versions.

(cherry picked from commit c20ad0d8dbd1bb5707bbfe23632415c3062e046c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 761d1fb53d20b75f403c1b2032649fcab0e7f280)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6c689a0aa32745becc1fa327ba358be7dafa160f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoDOC: email change of the DeviceAtlas maintainer
David Carlier [Thu, 10 Dec 2020 09:56:09 +0000 (09:56 +0000)]
DOC: email change of the DeviceAtlas maintainer

(cherry picked from commit 1470b9d0459306c4784285cc7f16b150a5b4b17a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 4ce4adc4cd7438785ea59ce8f376f11e891d049c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e0661002b611c7ed92e1c03d70bc9a54e6de5de7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: spoa/python: Fixing references to None
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:14 +0000 (14:37 +0000)]
BUG/MEDIUM: spoa/python: Fixing references to None

As per https://docs.python.org/3/c-api/none.html, None has to be treated
exactly like other objects for reference counting.
So, when we use it, we need to INCREF and when we are done, DECREF

This patch must be backported as far as 2.0.

(cherry picked from commit bdd034947c4a3a6f8c41af9bf6e62b7a74b4ebbc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 30189a6e056799f38d57478b04baded0868a431b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 752e24a9e42cd9fe76f6b0d070562dc180c92555)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: spoa/python: Fixing PyObject_Call positional arguments
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:13 +0000 (14:37 +0000)]
BUG/MEDIUM: spoa/python: Fixing PyObject_Call positional arguments

As per https://docs.python.org/3/c-api/object.html#c.PyObject_Call,
positional arguments should be an empty tuple when not used.
Previously the code had a dictionary instead of tuple. This commit is to
fix it and use tuple to avoid unexpected consequences

This patch must be backported as far as 2.0.

(cherry picked from commit 042f697a0fce0255b569786d29e929a4a41cbc46)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 789fb20542c76e14d68b916efe0dba6b012858b8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 712c28d00e23f21127eb0c4809e40fc5b19e223b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: spoa/python: Cleanup ipaddress objects if initialization fails
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:12 +0000 (14:37 +0000)]
BUG/MINOR: spoa/python: Cleanup ipaddress objects if initialization fails

This change is to ensure objects from the ipaddress module are cleaned
up when spoa module initialization fails.
In general the interpreter would just crash, but in a code where import
is conditional (try/except), then we would keep those objects around

This patch must be backported as far as 2.0.

(cherry picked from commit d1c0cf80bceb352b6bf33064b352f6dbe2b0b39c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7dde8ae61ee58ef8457f9c9ab6d908fa8c01ea2b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f090f0e357fd97fabd99465d2084a5d1e77e77f5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: spoa/python: Cleanup references for failed Module Addobject operations
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:11 +0000 (14:37 +0000)]
BUG/MINOR: spoa/python: Cleanup references for failed Module Addobject operations

As per https://docs.python.org/3/c-api/module.html#c.PyModule_AddObject,
references are stolen by the function only for success. We must do
cleanup manually if there is a failure

This patch must be backported as far as 2.0.

(cherry picked from commit 132d8f61e9440b9254069ca2c4bcff67df29bb6f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2efe413b82d4fd35178ecb96e7b5f4336deb4cc5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e795c1f99bb9c99369aac2a97e2447a215176089)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoDOC: spoa/python: Fixing typos in comments
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:10 +0000 (14:37 +0000)]
DOC: spoa/python: Fixing typos in comments

Fixing a missing letter in a comment

This patch must be backported as far as 2.0.

(cherry picked from commit c7485ac1013e32e79d692230a65be082c995f683)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d809b3c32c61b5804e47b38cb61a54da4beec73c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a43aae171df9dcffdb2bd67a09d57babc76cc0f0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoDOC: spoa/python: Rephrasing memory related error messages
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:09 +0000 (14:37 +0000)]
DOC: spoa/python: Rephrasing memory related error messages

The old message "No more space left available" was redundant with "left
available". This commit is to rephrase that sentence and make it more
explicit we are talking about memory

This patch must be backported as far as 2.0.

(cherry picked from commit 85b25829bce67a8d8338350a9bc8845f0ed9c2ad)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6426fb39e7adabb89e93263290ac9e62740c7bb2)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 235b799c4ae7734c56cae9ea96beed8b770ee37d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoDOC: spoa/python: Fixing typo in IP related error messages
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:08 +0000 (14:37 +0000)]
DOC: spoa/python: Fixing typo in IP related error messages

This commit fixes typos in the ps_python_set_var_ip* byte manipulation error
messages

This patch must be backported as far as 2.0.

(cherry picked from commit 6884742c651e65d065be9fc10cfaf258dae353f0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit fad025b4f6b416928f5487c88782bef19e797d01)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6ab490e0d62c95e0e345511db2e20c6c5700902b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MAJOR: spoa/python: Fixing return None
Gilchrist Dadaglo [Tue, 8 Dec 2020 14:37:07 +0000 (14:37 +0000)]
BUG/MAJOR: spoa/python: Fixing return None

As per https://docs.python.org/3/c-api/none.html, None requires to be
incremented before being returned to prevent deallocating none

This patch must be backported as far as 2.0.

(cherry picked from commit d5c428e761796317fdfa9c7f9bf3f6280e218a98)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bd9abd2ca8246ef37225485298af9f59831e3af3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 1c6e7507d646c165c31de4ca46034237b249ef83)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoDOC/MINOR: Fix formatting in Management Guide
Phil Scherer [Wed, 2 Dec 2020 19:36:08 +0000 (19:36 +0000)]
DOC/MINOR: Fix formatting in Management Guide

section numbering used '9.2)' instead of '9.2.'.

(cherry picked from commit b931f964e13700bbf43419c05a37a503bcfb555b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e85c4cbc82a758fe84c1f18797b89797bcf2c8fc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 84edc9f68789363b3e0101031fa5508b2d07050e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: lua: warn when registering action, conv, sf, cli or applet multiple times
Thierry Fournier [Sat, 28 Nov 2020 19:41:07 +0000 (20:41 +0100)]
BUG/MINOR: lua: warn when registering action, conv, sf, cli or applet multiple times

Lua allows registering multiple sample-fetches, converters, action, cli,
applet/services with the same name. This is absolutely useless since only
the first registration will be used. This patch sends a warning if the case
is encountered.

This pach could be backported until 1.8, with the 3 associated patches:
 - MINOR: actions: Export actions lookup functions
 - MINOR: actions: add a function returning a service pointer from its name
 - MINOR: cli: add a function to look up a CLI service description

(cherry picked from commit f67442efdb509d5d15f530a536b13f29fa7f48b7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 04cbfd7cc0138575caf53e9710a49f1ed0a2ebbd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a9bca65df7674d2091ad753bad4e689d76a4a9db)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: cli: add a function to look up a CLI service description
Thierry Fournier [Sat, 28 Nov 2020 19:10:08 +0000 (20:10 +0100)]
MINOR: cli: add a function to look up a CLI service description

This function will be useful to check if the keyword is already registered.
Also add a define for the max number of args.

This will be needed by a next patch to fix a bug and will have to be
backported.

(cherry picked from commit a51a1fd17420a96bb766afbae354e041fc9e1d9b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit b2239a79344a24e0e04aaa159020e4681aadf631)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit fce9e8164b7d305eea87cd4a95b133f8cf0369cf)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: actions: add a function returning a service pointer from its name
Thierry Fournier [Sat, 28 Nov 2020 18:32:14 +0000 (19:32 +0100)]
MINOR: actions: add a function returning a service pointer from its name

This function simply calls action_lookup() on the private service_keywords,
to look up a service name. This will be used to detect double registration
of a same service from Lua.

This will be needed by a next patch to fix a bug and will have to be
backported.

(cherry picked from commit 87e539906b13ed1d86684d9d3eab82b550fae02d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 4b5382db22b39c168131c0d6335b0711dbb0b16d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit df7ddc887d66c2849c1d27dcd26348e5eec1aed3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: actions: Export actions lookup functions
Thierry Fournier [Sat, 28 Nov 2020 16:40:24 +0000 (17:40 +0100)]
MINOR: actions: Export actions lookup functions

These functions will be useful to check if a keyword is already registered.
This will be needed by a next patch to fix a bug, and will need to be
backported.

(cherry picked from commit 7a71a6d9d262d7a0f7c3d208ab339d469958011d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ab93f7c5d88bd43aa857043129f7997f5ad4f6c8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3f3b931f0c4cc012c56530caef7b0182a793c26b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: lua: Some lua init operation are processed unsafe
Thierry Fournier [Sat, 28 Nov 2020 15:08:02 +0000 (16:08 +0100)]
BUG/MINOR: lua: Some lua init operation are processed unsafe

Operation luaL_openlibs() and lua_prepend path are processed whithout
the safe context, so in case of failure Haproxy aborts or stops without
error message.

This patch could be backported until 1.8

(cherry picked from commit 2f05cc6f86ee6beda9c42a6bb99a9a96fad37b68)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2b7983c78dc9bb0d143280a813ea75ad985b4167)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e1968054851cc40be520493c51be7d2bf50297c5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: lua: Post init register function are not executed beyond the first one
Thierry Fournier [Sat, 28 Nov 2020 10:02:58 +0000 (11:02 +0100)]
BUG/MINOR: lua: Post init register function are not executed beyond the first one

Just because if the first init is a success we return success in place
of continuing the loop.

This patch could be backported until 1.8

(cherry picked from commit 13d08b73eb99741ca5903e8414b85a1d0b919594)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5a964670d5c1bf45b7660afbfdd078f745fa0bf9)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 093c9ed1f3b9ba2efe5b1c9c90276357309dd2a6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: lua: lua-load doesn't check its parameters
Thierry Fournier [Sun, 29 Nov 2020 00:06:24 +0000 (01:06 +0100)]
BUG/MINOR: lua: lua-load doesn't check its parameters

"lua-load" doesn't check if the expected parameter is present. It tries to
open() directly the argument at second position. So if the filename is
omitted, it tries to load an empty filename.

This patch could be backported until 1.8

(cherry picked from commit 77a88943d6a0d7852c25a03541d60ccf44aa5c6d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ad6e9c5e4f1d815dbac0861458c4f228ca2d4a01)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2a1dcc1b1c93075d477d13ec2cc271fa826fbc9e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: lua: missing "\n" in error message
Thierry Fournier [Sat, 28 Nov 2020 23:55:53 +0000 (00:55 +0100)]
BUG/MINOR: lua: missing "\n" in error message

Just replace ".n" by "\n"

This could be backported until 1.9, but it is not so important.

(cherry picked from commit de6145f747e38a5da455ccb8a84ebfc1cd2f517f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 518017fb119b11fa3f0ceaba3258ea237513fadc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2a7ab9b27392cea15f36db16cdf9f1f0343c25af)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: plock: use an ARMv8 instruction barrier for the pause instruction
Your Name [Sat, 28 Nov 2020 15:37:14 +0000 (15:37 +0000)]
MINOR: plock: use an ARMv8 instruction barrier for the pause instruction

As suggested by @AGSaidi in issue #958, on ARMv8 its convenient to use
an "isb" instruction in pl_cpu_relax() to improve fairness. Without it
I've met a few watchdog conditions on valid locks with 16 threads,
indicating that some threads couldn't manage to get it in 2 seconds. I
never happened again with it. In addition, the performance increased
by slightly more than 5% thanks to the reduced contention.

This should be backported as far as 2.2, possibly even 2.0.

(cherry picked from commit 1e237d037b3a45ec92d1dfa80dfd2c6bd7fc3af9)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 367c1dbed1e3c5493c22e974fa01cef0f5238ebc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 909dc3e911d1fba2317b2a1f77895932e3a7da60)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoDOC: config: Move req.hdrs and req.hdrs_bin in L7 samples fetches section
Christopher Faulet [Tue, 24 Nov 2020 16:13:24 +0000 (17:13 +0100)]
DOC: config: Move req.hdrs and req.hdrs_bin in L7 samples fetches section

req.hdrs and req.hdrs_bin are L7 sample fetches, not L6. They were in the wrong
section.

This patch may be backported as far as 1.8.

(cherry picked from commit 687a68e2d04900e84317d066de80891a7f848747)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 2616784a08c83f65b0e451bba8dcba5a844e8dac)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5e3d0a0c0a4b3ca32dd11c82276750e880c4ed34)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoDOC: Clarify %HP description in log-format
Maciej Zdeb [Thu, 26 Nov 2020 10:45:52 +0000 (10:45 +0000)]
DOC: Clarify %HP description in log-format

%HP is used to report HTTP request URI in logs, which might be relative
or absolute. Description in documentation should not suggest that it
behaves exactly the same as "path" sample fetch.

This is even more important after 30ee1efe676e8264af16bab833c621d60a72a4d7
because right now, when HTTP2 is a standard, %HP usually returns absolute
URI.

This might be backported as far as 2.1

(cherry picked from commit 21acc33266cc04eac5e70c22839d622284a6f46a)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit f9f0f94f6a5c281d0f02056951fac098585537a5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0930d35b53706baff84361320b1571ec0473ba0f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MAJOR: peers: fix partial message decoding
Willy Tarreau [Thu, 26 Nov 2020 16:06:04 +0000 (17:06 +0100)]
BUG/MAJOR: peers: fix partial message decoding

Another bug in the peers message parser was uncovered by last commit
1dfd4f106 ("BUG/MEDIUM: peers: fix decoding of multi-byte length in
stick-table messages"): the function return on incomplete message does
not check if the channel has a pending close before deciding to return
0. It did not hurt previously because the loop calling co_getblk() once
per character would have depleted the buffer and hit the end, causing
<0 to be returned and matching the condition. But now that we process
at once what is available this cannot be relied on anymore and it's
now clearly visible that the final check is missing.

What happens when this strikes is that if a peer connection breaks in
the middle of a message, the function will return 0 (missing data) but
the caller doesn't check for the closed buffer, subscribes to reads,
and the applet handler is immediately called again since some data are
still available. This is detected by the loop prevention and the process
dies complaining that an appctx is spinning.

This patch simply adds the check for closed channel. It must be
backported to the same versions as the fix above.

(cherry picked from commit 345ebcfc010e397cb718400a32b4db845dda7a2f)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 46af74a61973413d417b2e7e6741dd0469317c58)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cafa1e274b11c6994e480bec8235ed4d778c1e62)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MAJOR: filters: Always keep all offsets up to date during data filtering
Christopher Faulet [Tue, 24 Nov 2020 08:49:01 +0000 (09:49 +0100)]
BUG/MAJOR: filters: Always keep all offsets up to date during data filtering

When at least one data filter is registered on a channel, the offsets of all
filters must be kept up to date. For data filters but also for others. It is
safer to do it in that way. Indirectly, this patch fixes 2 hidden bugs
revealed by the commit 22fca1f2c ("BUG/MEDIUM: filters: Forward all filtered
data at the end of http filtering").

The first one, the worst of both, happens at the end of http filtering when
at least one data filtered is registered on the channel. We call the
http_end() callback function on the filters, when defined, to finish the
http filtering. But it is performed for all filters. Before the commit
22fca1f2c, the only risk was to call the http_end() callback function
unexpectedly on a filter. Now, we may have an overflow on the offset
variable, used at the end to forward all filtered data. Of course, from the
moment we forward an arbitrary huge amount of data, all kinds of bad things
may happen. So offset computation is performed for all filters and
http_end() callback function is called only for data filters.

The other one happens when a data filter alter the data of a channel, it
must update the offsets of all previous filters. But the offset of non-data
filters must be up to date, otherwise, here too we may have an integer
overflow.

Another way to fix these bugs is to always ignore non-data filters from the
offsets computation. But this patch is safer and probably easier to
maintain.

This patch must be backported in all versions where the above commit is. So
as far as 2.0.

(cherry picked from commit 401e6dbff3ee0b1932f6a16e3f280246752a7edf)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bd2dc87051aafe9c415c32673c37c3b02f5acf10)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bb96e0b885e44b8f5e4084e657a8bc50a60de8bd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: http-ana: Don't wait for the body of CONNECT requests
Christopher Faulet [Mon, 16 Nov 2020 15:03:35 +0000 (16:03 +0100)]
BUG/MINOR: http-ana: Don't wait for the body of CONNECT requests

CONNECT requests are bodyless messages but with no EOM blocks. Thus, conditions
to stop waiting for the message payload are not suited to this kind of
messages. Indeed, the message finishes on an EOH block. But the tunnel mode at
the stream level is only set in HTTP_XFER_BODY analyser. So, the stream is
blocked, waiting for a body that does not exist till a timeout expires.

To fix this bug, we just stop waiting for a body for CONNECT requests. Another
solution is to rely on HTX_SL_F_BODYLESS/HTTP_MSGF_BODYLESS flags. But this one
is less intrusive.

This message must be backported as far as 2.0. For the 2.0, only the HTX part
must be fixed.

(cherry picked from commit 63c69a9b4ef1136c66967463b9e4b3538e35c016)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9ded6fab3298e5974a1fd7c0eb4491ff3fef3987)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 1e6896eb4c0a4d39a3ae6d746d6d1f671696041c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: filters: Forward all filtered data at the end of http filtering
Christopher Faulet [Mon, 16 Nov 2020 09:10:38 +0000 (10:10 +0100)]
BUG/MEDIUM: filters: Forward all filtered data at the end of http filtering

When http filtering ends, if there are some filtered data not forwarded yet, we
forward them, in flt_http_end(). Most of time, this doesn't happen, except when
a tunnel is established using a CONNECT. In this case, there is not EOM on the
request and there is no body. Thus the headers are never forwarded, blocking the
stream.

This patch must be backported as far as 2.0. Prior versions don't suffer of this
bug because there is no HTX support. On the 2.0, the change is only applicable
on HTX streams. A special test must be performed to make sure.

(cherry picked from commit 22fca1f2c84334096e38d78ffc674be19c3e0292)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 44ba5dbe6ee29b7c37630bca57a2f2c1fd1daa35)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 4986f0fbc882c132a174464c7a12314ca9f48846)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUILD: http-htx: fix build warning regarding long type in printf
Willy Tarreau [Fri, 6 Nov 2020 13:24:02 +0000 (14:24 +0100)]
BUILD: http-htx: fix build warning regarding long type in printf

Commit a66adf41e ("MINOR: http-htx: Add understandable errors for the
errorfiles parsing") added a warning when loading malformed error files,
but this warning may trigger another build warning due to the %lu format
used. Let's simply cast it for output since it's just used for end user
output.

This must be backported to 2.0 like the commit above.

(cherry picked from commit 431a12cafeeec7300b7cea7e19b892d4e8c4900d)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 37b9630d0a93ff2ffc89a85a095e41db72de1c5b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5d74de59f9428b2e1a3a8b58505bf9e7d187ea76)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: cfgparse: tighten the scope of newnameserver variable, free it on error.
Eric Salama [Fri, 13 Nov 2020 14:56:36 +0000 (15:56 +0100)]
MINOR: cfgparse: tighten the scope of newnameserver variable, free it on error.

This should fix issue GH #931.

Also remove a misleading comment.

This commit can be backported as far as 1.9

(cherry picked from commit 9139ec34ed7aae4fe63926ca5c87a5b32b376488)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6057016df764c7e7f218dcdd39d024ef65cd1d43)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3f2053a0a243690afa685011e3e04458869567e8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: spoe: Don't close connection in sync mode on processing timeout
Christopher Faulet [Tue, 10 Nov 2020 13:31:39 +0000 (14:31 +0100)]
MINOR: spoe: Don't close connection in sync mode on processing timeout

In sync mode, if an applet receives a ack while the processing delay has already
expired, there is not frame waiting for this ack. But there is no reason to
close the connection in this case. The ack may be ignored and the connection may
be reused to process another frame. The only reason to trigger an error and
close the connection is when the wrong ack is received while there is still a
frame waiting for its ack. In sync mode, this should never happen.

This patch may be backported in all versions supporting the SPOE.

(cherry picked from commit c7ba91039a7b0703971efd791ca2ca609afedb96)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d9eb3c3de3211478b512ee7f8e548bb78211adf5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3217a352a6d99b3b23b2f552aa7505a64389ac1e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MAJOR: spoe: Be sure to remove all references on a released spoe applet
Christopher Faulet [Tue, 10 Nov 2020 17:45:34 +0000 (18:45 +0100)]
BUG/MAJOR: spoe: Be sure to remove all references on a released spoe applet

When a SPOE applet is used to send a frame, a reference on this applet is saved
in the spoe context of the offladed stream. But, if the applet is released
before receving the corresponding ack, we must be sure to remove this
reference. This was performed for fragmented frames only. But it must also be
performed for a spoe contexts in the applet waiting_queue and in the thread
waiting_queue (used in async mode).

This bug leads to a memory corruption when an offloaded stream try to update the
state of a released applet because it still have a reference on it. There are
many ways to trigger this bug. The easiest is probably during reloads. On the
old process, all applets are woken up to be released ASAP.

Many thanks to Maciej Zdeb to report the bug and to work on it for 2
months. Without his help, it would have been much more difficult to fix the
bug. It is always a huge pleasure to see how some users are enthousiast and
helpful. Thanks again Maciej !

This patch must be backported to all versions where the spoe is supported (>=
1.7).

(cherry picked from commit cf181c76e341f2d49f6cae0ca8200158058073f1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit abe894d2c91da5f57ae7704eba59c41b409fc1a0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a2cf638010c841aa28c9d5a3ef57155fdc74cff5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: http-fetch: Fix calls w/o parentheses of the cookie sample fetches
Christopher Faulet [Fri, 13 Nov 2020 12:41:04 +0000 (13:41 +0100)]
BUG/MINOR: http-fetch: Fix calls w/o parentheses of the cookie sample fetches

req.cook, req.cook_val, req.cook_cnt and and their response counterparts may be
called without cookie name. In this case, empty parentheses may be used, or no
parentheses at all. In both, the result must be the same. But only the first one
works. The second one always returns a failure. This patch fixes this bug.

Note that on old versions (< 2.2), both cases fail.

This patch must be backported in all stable versions.

(cherry picked from commit 97fc8da2643531ade4163d6662f13f76fa59d677)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 934630a682fc4b5fb4902c254de17fcbe2ac84ee)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d6e7b958dfde326932e63a5840e4f2623fb76505)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: http-fetch: Extract cookie value even when no cookie name
Maciej Zdeb [Fri, 13 Nov 2020 09:38:06 +0000 (09:38 +0000)]
BUG/MINOR: http-fetch: Extract cookie value even when no cookie name

HTTP sample fetches dealing with the cookies (req/res.cook,
req/res.cook_val and req/res.cook_cnt) must be prepared to be called
without cookie name. For the first two, the first cookie value is
returned, regardless its name. For the last one, all cookies are counted.

To do so, http_extract_cookie_value() may now be called with no cookie
name (cookie_name_l set to 0). In this case, the matching on the cookie
name is ignored and the first value found is returned.

Note this patch also fixes matching on cookie values in ACLs.

This should be backported in all stable versions.

(cherry picked from commit dea7c209f8a77b471323dd97bdc1ac4d7a17b812)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 8cac341124e2b79c2a924ad186a114b39546298e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 02b89eadd7a7ddbaad88c5725b0a215d2d8c1d81)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: peers: fix decoding of multi-byte length in stick-table messages
Willy Tarreau [Fri, 13 Nov 2020 13:10:20 +0000 (14:10 +0100)]
BUG/MEDIUM: peers: fix decoding of multi-byte length in stick-table messages

There is a bug in peer_recv_msg() due to an incorrect cast when trying
to decode the varint length of a stick-table message, causing lengths
comprised between 128 and 255 to consume one extra byte, ending in
protocol errors.  The root cause of this is that peer_recv_msg() tries
hard to reimplement all the parsing and control that is already done in
intdecode() just to measure the length before calling it. And it got it
wrong.

Let's just get rid of this unneeded code duplication and solely rely on
intdecode() instead. The bug was introduced in 2.0 as part of a cleanup
pass on this code with commit 95203f218 ("MINOR: peers: Move high level
receive code to reduce the size of I/O handler."), so this patch must
be backported to 2.0.

Thanks to Yves Lafon for reporting the problem.

(cherry picked from commit 1dfd4f106f15bc4e6e992f8babbc863c12975b5a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d4913917c6e471b1d18c0574711768b3b47ea151)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 13bd9d4ef093df43e74d44f14a24f0ad25b170d8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: peers: Missing TX cache entries reset.
Frédéric Lécaille [Thu, 12 Nov 2020 20:01:54 +0000 (21:01 +0100)]
BUG/MINOR: peers: Missing TX cache entries reset.

The TX part of a cache for a dictionary is made of an reserved array of ebtree nodes
which are pointers to dictionary entries. So when we flush the TX part of such a
cache, we must not only remove these nodes to dictionary entries from their ebtree.
We must also reset their values. Furthermore, the LRU key and the last lookup
result must also be reset.

(cherry picked from commit ea875e62e6b2f69c50533c5cd52eb5284c69723f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9650ee94b3cc5bc2e6c2a7cf67ef66c0273c1404)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit c65161466af0bbf1cce39727ffff1bbaefcfa9ec)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: peers: Do not ignore a protocol error for dictionary entries.
Frédéric Lécaille [Thu, 12 Nov 2020 18:53:11 +0000 (19:53 +0100)]
BUG/MINOR: peers: Do not ignore a protocol error for dictionary entries.

If we could not decode the ID of a dictionary entry from a peer update message,
we must inform the remote peer about such an error as this is done for
any other decoding error.

(cherry picked from commit f9e51beec118f1bbd558ed689fdad35046160529)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cd24d5cfbe58bf2b25a76d077a0923053cbf7838)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit c4b0ea55b105ae65d9580e7b915460645f0be2fa)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: lua: set buffer size during map lookups
Thierry Fournier [Tue, 10 Nov 2020 19:38:20 +0000 (20:38 +0100)]
BUG/MINOR: lua: set buffer size during map lookups

This size is used by some pattern matching to determine if there
is sufficient room in the buffer to add final \0 if necessary.
If the size is not set, the conditions use uninitialized value.

Note: it seems this bug can't cause a crash.

Should be backported until 2.2 (at least)

(cherry picked from commit 91dc0c0d8fdc2fb091b49699ebb323d01aa1d9f6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 66e9ff531481d6a043ea402cb303f36b3d9ca9e1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 4fa0bdfbb3357af1d08b55ed5f7db912225c25f3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: pattern: a sample marked as const could be written
Thierry Fournier [Tue, 10 Nov 2020 19:51:36 +0000 (20:51 +0100)]
BUG/MINOR: pattern: a sample marked as const could be written

The functions add final 0 to string if the final 0 is not set,
but don't check the flag CONST. This patch duplicates the strings
if the final zero is not set and the string is CONST.

Should be backported until 2.2 (at least)

(cherry picked from commit a68affeaa9377f88f773ef62a9bb2541dfb672d3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9633f444ac3ae540f6ce5dd0b0880fb40fabe9d5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit b982485900e4f20f9c4a0ef2521da1c223acb30d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: http-htx: Just warn if payload of an errorfile doesn't match the C-L
Christopher Faulet [Fri, 6 Nov 2020 08:33:36 +0000 (09:33 +0100)]
BUG/MINOR: http-htx: Just warn if payload of an errorfile doesn't match the C-L

During startup, when an errorfile is parsed, if its payload does not match the
announced content-length, an error is triggered. This change was introduced in
the 2.3, which is ok. But for a stable release it may be seen as a
regression. Thus, now a warning is emitted, instead of an error. And the
content-length header is updated with the real payload length.

This patch depends on 58f55acf4e ("MINOR: http-htx: Add understandable errors
for the errorfiles parsing"). Both must be backported as far as 2.0. This bug
only exists in the 2.2, 2.1 and 2.0. Thus, there is no upstream commit ID for
this patch.

(cherry picked from commit 7bf3d81d3cf4b9f4587cee061c2ef4a533125002)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: http-htx: Add understandable errors for the errorfiles parsing
Christopher Faulet [Thu, 5 Nov 2020 21:43:41 +0000 (22:43 +0100)]
MINOR: http-htx: Add understandable errors for the errorfiles parsing

No details are provided when an error occurs during the parsing of an errorfile,
Thus it is a bit hard to diagnose where the problem is. Now, when it happens, an
understandable error message is reported.

This patch is not a bug fix in itself. But it will be required to change an
fatal error into a warning in last stable releases. Thus it must be backported
as far as 2.0.

(cherry picked from commit a66adf41ea28a0fa29437d1675f225b5cc589b59)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3a10710b777370ef36763b8b6658ae63ef5c4ec4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 58f55acf4eafd19ed35ad8506064198229ba69c3)
[cf: Adapted for the 2.1]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years ago[RELEASE] Released version 2.1.10 v2.1.10
Christopher Faulet [Thu, 5 Nov 2020 14:40:11 +0000 (15:40 +0100)]
[RELEASE] Released version 2.1.10

Released version 2.1.10 with the following main changes :
    - BUG/MEDIUM: ssl: crt-list negative filters don't work
    - MINOR: ssl: reach a ckch_store from a sni_ctx
    - BUILD: makefile: Fix building with closefrom() support enabled
    - BUG/MINOR: Fix several leaks of 'log_tag' in init().
    - DOC: tcp-rules: Refresh details about L7 matching for tcp-request content rules
    - BUG/MEDIUM: queue: make pendconn_cond_unlink() really thread-safe
    - MINOR: counters: fix a typo in comment
    - BUG/MINOR: stats: fix validity of the json schema
    - MINOR: hlua: Display debug messages on stderr only in debug mode
    - BUG/MINOR: peers: Inconsistency when dumping peer status codes.
    - BUG/MINOR: mux-h1: Always set the session on frontend h1 stream
    - BUG/MEDIUM: mux-fcgi: Don't handle pending read0 too early on streams
    - BUG/MEDIUM: mux-h2: Don't handle pending read0 too early on streams
    - BUG/MINOR: http-htx: Expect no body for 204/304 internal HTTP responses
    - BUG/MINOR: init: only keep rlim_fd_cur if max is unlimited
    - BUG/MINOR: mux-h2: do not stop outgoing connections on stopping
    - MINOR: fd: report an error message when failing initial allocations
    - BUG/MEDIUM: task: bound the number of tasks picked from the wait queue at once
    - BUG/MEDIUM: spoe: Unset variable instead of set it if no data provided
    - BUG/MEDIUM: mux-h1: Get the session from the H1S when capturing bad messages
    - BUG/MEDIUM: lb: Always lock the server when calling server_{take,drop}_conn
    - BUG/MINOR: peers: Possible unexpected peer seesion reset after collisions.
    - BUILD: ssl: make BoringSSL use its own version numbers
    - BUG/MINOR: disable dynamic OCSP load with BoringSSL
    - BUG/MEDIUM: ssl: OCSP must work with BoringSSL
    - BUG/MINOR: queue: properly report redistributed connections
    - BUG/MEDIUM: server: support changing the slowstart value from state-file
    - BUG/MINOR: http-ana: Don't send payload for internal responses to HEAD requests
    - BUG/MAJOR: mux-h2: Don't try to send data if we know it is no longer possible
    - BUG/MINOR: extcheck: add missing checks on extchk_setenv()
    - BUG/MINOR: log: fix memory leak on logsrv parse error
    - BUG/MINOR: server: fix srv downtime calcul on starting
    - BUG/MINOR: server: fix down_time report for stats
    - BUG/MINOR: lua: initialize sample before using it
    - MINOR: ist: Add a case insensitive istmatch function
    - BUG/MINOR: cache: Manage multiple values in cache-control header value
    - BUG/MINOR: cache: Inverted variables in http_calc_maxage function
    - BUG/MEDIUM: filters: Don't try to init filters for disabled proxies
    - BUG/MINOR: proxy/server: Skip per-proxy/server post-check for disabled proxies
    - BUG/MINOR: server: Set server without addr but with dns in RMAINT on startup
    - MINOR: server: Copy configuration file and line for server templates
    - BUG/MEDIUM: mux-pt: Release the tasklet during an HTTP upgrade
    - BUG/MINOR: filters: Skip disabled proxies during startup only
    - BUG/MEDIUM: stick-table: limit the time spent purging old entries
    - CLEANUP: mux-h2: Remove the h1 parser state from the h2 stream

4 years agoCLEANUP: mux-h2: Remove the h1 parser state from the h2 stream
Christopher Faulet [Tue, 3 Nov 2020 17:25:52 +0000 (18:25 +0100)]
CLEANUP: mux-h2: Remove the h1 parser state from the h2 stream

Since the h2 multiplexer no longer relies on the legacy HTTP representation, and
uses exclusively the HTX, the H1 parser state (h1m) is no longer used by the h2
streams. Thus it can be removed.

This patch may be backported as far as 2.1.

(cherry picked from commit fafd1b0a5b3b6ee0c7d7dd288629c992fc63ef10)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit aa3c7001cb32cd9c5bb7b5258459bb971e956438)
[wt: include file is in common/h1.h in 2.1]
Signed-off-by: Willy Tarreau <w@1wt.eu>

4 years agoBUG/MEDIUM: stick-table: limit the time spent purging old entries
Willy Tarreau [Tue, 3 Nov 2020 16:47:41 +0000 (17:47 +0100)]
BUG/MEDIUM: stick-table: limit the time spent purging old entries

An interesting case was reported with threads and moderately sized
stick-tables. Sometimes the watchdog would trigger during the purge.
It turns out that the stick tables were sized in the 10s of K entries
which is the order of magnitude of the possible number of connections,
and that threads were used over distinct NUMA nodes. While at first
glance nothing looks problematic there, actually there is a risk that
a thread trying to purge the table faces 100% of entries still in use
by a connection with (ts->ref_cnt > 0), and ends up scanning the whole
table, while other threads on the other NUMA node are causing the
cache lines to bounce back and forth and considerably slow down its
progress to the point of possibly spending hundreds of milliseconds
there, multiplied by the number of queued threads all failing on the
same point.

Interestingly, smaller tables would not trigger it because the scan
would be faster, and larger ones would not trigger it because plenty
of entries would be idle!

The most efficient solution is to increase the table size to be large
enough for this never to happen, but this is not reliable. We could
have a parallel list of idle entries but that would significantly
increase the storage and processing cost only to improve a few rare
corner cases.

This patch takes a more pragmatic approach, it considers that it will
not visit more than twice the number of nodes to be deleted, which
means that it accepts to fail up to 50% of the time. Given that very
small batches are programmed each time (1/256 of the table size), this
means the operation will finish quickly (128 times faster than now),
and will reduce the inter-thread contention. If this needs to be
reconsidered, it will probably mean that the batch size needs to be
fixed differently.

This needs to be backported to stable releases which extensively use
threads, typically 2.0.

Kudos to Nenad Merdanovic for figuring the root cause triggering this!

(cherry picked from commit dfe79251dab0346fe4c71e7e3da7bb87d41c880c)
Signed-off-by: Willy Tarreau <w@1wt.eu>

4 years agoBUG/MINOR: filters: Skip disabled proxies during startup only
Christopher Faulet [Tue, 3 Nov 2020 15:40:37 +0000 (16:40 +0100)]
BUG/MINOR: filters: Skip disabled proxies during startup only

This partially reverts the patch 400829cd2 ("BUG/MEDIUM: filters: Don't try to
init filters for disabled proxies"). Disabled proxies must not be skipped in
flt_deinit() and flt_deinit_all_per_thread() when HAProxy is stopped because,
obvioulsy, at this step, all proxies appear as disabled (or stopped, it is the
same state). It is safe to do so because, during startup, filters declared on
disabled proxies are removed. Thus they don't exist anymore during shutdown.

This patch must be backported in all versions where the patch above is.

(cherry picked from commit 743bd6adc8a7657b324ac59376311d23d65bb4ed)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 59e7ab350d06542493d4da0467da8738c406dde8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: mux-pt: Release the tasklet during an HTTP upgrade
Christopher Faulet [Tue, 3 Nov 2020 08:11:43 +0000 (09:11 +0100)]
BUG/MEDIUM: mux-pt: Release the tasklet during an HTTP upgrade

When a TCP connection is upgraded to HTTP, the passthrough multiplexer owning
the client connection is detroyed and replaced by an HTTP multiplexer. When it
happens, the connection context is changed (it is in fact the mux itself). Thus,
when the mux-pt is destroyed, the connection is not released. But, only the
connection must be kept. Everything else concerning the mux must be
released. Especially, the tasklet used for I/O subscriptions. In this part,
there was a bug and the tasklet was never released.

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

(cherry picked from commit 5a7ca29061dbc5736b53d45b9561e71807a0d05a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 827b4fc10101847da0953a556120884f96c38aa2)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: server: Copy configuration file and line for server templates
Christopher Faulet [Mon, 2 Nov 2020 21:04:55 +0000 (22:04 +0100)]
MINOR: server: Copy configuration file and line for server templates

When servers based on server templates are initialized, the configuration file
and line are now copied. This helps to emit understandable warning and alert
messages.

This patch may be backported if needed, as far as 1.8.

(cherry picked from commit 75bef00538eebc00c22309c7f9391c0f6d502ac0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 97ae0cf4b20b50fa668e641126c6a65b587359d9)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: server: Set server without addr but with dns in RMAINT on startup
Christopher Faulet [Mon, 26 Oct 2020 09:31:17 +0000 (10:31 +0100)]
BUG/MINOR: server: Set server without addr but with dns in RMAINT on startup

On startup, if a server has no address but the dns resolutions are configured,
"none" method is added to the default init-addr methods, in addition to "last"
and "libc". Thus on startup, this server is set to RMAINT mode if no address is
found. It is only performed if no other init-addr method is configured.

Setting the RMAINT mode on startup is important to inhibit the health checks.

For instance, following servers will now be set to RMAINT mode on startup :

  server srv nofound.tld:80 check resolvers mydns
  server srv _http._tcp.service.local check resolvers mydns
  server-template srv 1-3 _http._tcp.service.local check resolvers mydns

while followings ones will trigger an error :

  server srv nofound.tld:80 check
  server srv nofound.tld:80 check resolvers mydns init-addr libc
  server srv _http._tcp.service.local check
  server srv _http._tcp.service.local check resolvers mydns init-addr libc
  server-template srv 1-3 _http._tcp.service.local check resolvers mydns init-addr libc

This patch must be backported as far as 1.8.

(cherry picked from commit ac1c60fd9c63dd9ac4bab7e9a9f24fb347a5fbdf)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 13704ca2d0de919935c91246ce582d7f22160051)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: proxy/server: Skip per-proxy/server post-check for disabled proxies
Christopher Faulet [Mon, 2 Nov 2020 15:20:13 +0000 (16:20 +0100)]
BUG/MINOR: proxy/server: Skip per-proxy/server post-check for disabled proxies

per-proxy and per-server post-check callback functions must be skipped for
disabled proxies because most of the configuration validity check is skipped for
these proxies.

This patch must be backported as far as 2.1.

(cherry picked from commit d5bd824b81cda4c02e967b05af920f455d4b3712)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit eb20100fe1be0f2641de331ddcc8b1246cd4db2b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: filters: Don't try to init filters for disabled proxies
Christopher Faulet [Mon, 2 Nov 2020 15:08:09 +0000 (16:08 +0100)]
BUG/MEDIUM: filters: Don't try to init filters for disabled proxies

Configuration is parsed for such proxies but not validated. Concretely, it means
check_config_validity() function does almost nothing for such proxies. Thus, we
must be careful to not initialize filters for disabled proxies because the check
callback function is not called. In fact, to be sure to avoid any trouble,
filters for disabled proxies are released.

This patch fixes a segfault at startup if the SPOE is configured for a disabled
proxy. It must be backported as far as 1.7 (maybe with some adaptations).

(cherry picked from commit 400829cd2c6d734dbdd073d7a30d1e258fd2d1a0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9dd9e01e0d63bff1cb5592237db66cd22c04cf24)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: cache: Inverted variables in http_calc_maxage function
Remi Tricot-Le Breton [Fri, 30 Oct 2020 13:26:13 +0000 (14:26 +0100)]
BUG/MINOR: cache: Inverted variables in http_calc_maxage function

The maxage and smaxage variables were inadvertently assigned the
Cache-Control s-maxage and max-age values respectively when it should
have been the other way around.

This can be backported on all branches after 1.8 (included).

(cherry picked from commit 8c2db71326addbcf9d6c8ae4d2048247031f9e4c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2185f7e2b809889310efdf087da6777583607597)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: cache: Manage multiple values in cache-control header value
Remi Tricot-Le Breton [Wed, 28 Oct 2020 10:35:15 +0000 (11:35 +0100)]
BUG/MINOR: cache: Manage multiple values in cache-control header value

If an HTTP request or response had a "Cache-Control" header that had
multiple comma-separated subparts in its value (like "max-age=1,
no-store" for instance), we did not process the values correctly and
only parsed the first one. That made us store some HTTP responses in the
cache when they were explicitely uncacheable.
This patch replaces the way the values are parsed by an http_find_header
loop that manages every sub part of the value independently.

This patch should be backported to 2.2 and 2.1. The bug also exists on
previous versions but since the sources changed, a new commit will have
to be created.

[wla: This patch requires bb4582c ("MINOR: ist: Add a case insensitive
istmatch function"). Backporting for < 2.1 is not a requirement since it
works well enough for most cases, it was a known limitation of the
implementation of non-htx version too]

(cherry picked from commit 40ed97b04b930c76c77c09c0cafc8781f94b66ee)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 23b37d0aa491a8c1bdd1a8bc204f7e4d86a25ac3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoMINOR: ist: Add a case insensitive istmatch function
Remi Tricot-Le Breton [Wed, 28 Oct 2020 10:35:14 +0000 (11:35 +0100)]
MINOR: ist: Add a case insensitive istmatch function

Add a helper function that checks if a string starts with another string
while ignoring case.

(cherry picked from commit bb4582cf719bcf9facf4e9b459fd3a68a97fffbd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit fce0402a3bebcfae35ce2f7bff00b2e24174d89e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: lua: initialize sample before using it
Amaury Denoyelle [Thu, 29 Oct 2020 16:21:20 +0000 (17:21 +0100)]
BUG/MINOR: lua: initialize sample before using it

Memset the sample before using it through hlua_lua2smp. This function is
ORing the smp.flags, so this field need to be cleared before its use.
This was reported by a coverity warning.

Fixes the github issue #929.
This bug can be backported up to 1.8.

(cherry picked from commit bc0af6a19947c7ab76bd226beaaaafedc0648be4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 42cd304165f9afa2050f169e7c852f2f637bcc70)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: server: fix down_time report for stats
Amaury Denoyelle [Thu, 29 Oct 2020 14:59:05 +0000 (15:59 +0100)]
BUG/MINOR: server: fix down_time report for stats

Adjust condition used to report down_time for statistics. There was a
tiny probabilty to have a negative downtime if last_change was superior
to now. If this is the case, return only down_time.

This bug can backported up to 1.8.

(cherry picked from commit e6ba7915ebdfb79d1d74eb402bbc2747c4a1c6dd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 36f3e9bb61a06c1afce27474bbc357b52590ec96)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: server: fix srv downtime calcul on starting
Amaury Denoyelle [Thu, 29 Oct 2020 14:59:04 +0000 (15:59 +0100)]
BUG/MINOR: server: fix srv downtime calcul on starting

When a server is up after a failure, its downtime was reset to 0 on the
statistics. This is due to a wrong condition that causes srv.down_time
to never be set. Fix this by updating down_time each time the server is in
STARTING state.

Fixes the github issue #920.
This bug can be backported up to 1.8.

(cherry picked from commit fe2bf091f6f2c155b5d7b1372a43b73bb034002f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 774d5a3b69bf8c588c26ce09a6acbf29997a82ac)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: log: fix memory leak on logsrv parse error
Willy Tarreau [Tue, 27 Oct 2020 08:51:37 +0000 (09:51 +0100)]
BUG/MINOR: log: fix memory leak on logsrv parse error

In case of parsing error on logsrv, we can leave parse_logsrv() without
releasing logsrv->ring_name or smp_rgs. Let's free them on the error path.
This should fix issue #926 detected by Coverity.

The impact is only a tiny leak just before reporting a fatal error, so it
will essentially annoy valgrind.

This can be backported to 2.0 (just drop the ring part).

(cherry picked from commit ae32ac74dbc2cb93a07d7d29b4c20a075bc7741a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ad6e92761d877d872414ccbcf408d5f5f92c3b91)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: extcheck: add missing checks on extchk_setenv()
Willy Tarreau [Sat, 24 Oct 2020 11:07:39 +0000 (13:07 +0200)]
BUG/MINOR: extcheck: add missing checks on extchk_setenv()

Issue #910 reports that we fail to check a few extchk_setenv() in the
child process. These are mostly harmless, but instead of counting on
the external check script to fail the dirty way, better fail cleanly
when detecting the failure.

This could probably be backported to all stable branches.

(cherry picked from commit b3250a268b66ec686142f01ef04bef9e3db58532)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f1c1481296da08a3ac7d4dcbd8ec7e035b89fbf8)
[cf: changes applied in src/checks.c because src/extcheck.c does not exist]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MAJOR: mux-h2: Don't try to send data if we know it is no longer possible
Christopher Faulet [Thu, 22 Oct 2020 14:24:58 +0000 (16:24 +0200)]
BUG/MAJOR: mux-h2: Don't try to send data if we know it is no longer possible

In h2_send(), if we are in a state where we know it is no longer possible to
send data, we must exit the sending loop to avoid any possiblity to loop
forever. It may happen if the mbuf ring is released while the H2_CF_MUX_MFULL
flag is still set. Here is a possible scenario to trigger the bug :

  1) The mbuf ring is full because we are unable to send data. The
     H2_CF_MUX_MFULL flag is set on the H2 connection.

  2) At this stage, the task timeout expires because the H2 connection is
     blocked. We enter in h2_timeout_task() function. Because the mbuf ring is
     full, we cannot send the GOAWAY frame. Thus the H2_CF_GOAWAY_FAILED flag is
     set. The H2 connection is not released yet because there is still a stream
     attached. Here we leave h2_timeout_task() function.

  3) A bit later, the H2 connection is woken up. If h2_process(), nothing is
     performed by the first attempt to send data, in h2_send(). Then, because
     the H2_CF_GOAWAY_FAILED flag is set, the mbuf ring is released. But the
     H2_CF_MUX_MFULL flag is still there. At this step a second attempt to send
     data is performed.

  4) In h2_send(), we try to send data in a loop. To exist this loop, done
     variable must be set to 1. Because the H2_CF_MUX_MFULL flag is set, we
     don't call h2_process_mux() and done is not updated. Because the mbuf ring
     is now empty, nothing is sent and the H2_CF_MUX_MFULL flag is never
     removed. Now, we loop forever... waiting for the watchdog.

To fix the bug, we now exit the loop if one of these conditions is true :

  - The H2_CF_GOAWAY_FAILED flag is set on the H2 connection
  - The CO_FL_SOCK_WR_SH flag is set on the underlying connection
  - The H2 connection is in the H2_CS_ERROR2 state

This patch should fix the issue #912 and most probably #875. It must be
backported as far as the 1.8.

(cherry picked from commit 9a3d3fcb5d980bd1034e04222769452cc68ecc9b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 180a616caf65ba398a1c74e07e9b26196bd94fb3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: http-ana: Don't send payload for internal responses to HEAD requests
Christopher Faulet [Mon, 19 Oct 2020 16:01:38 +0000 (18:01 +0200)]
BUG/MINOR: http-ana: Don't send payload for internal responses to HEAD requests

When an internal response is returned to a client, the message payload must be
skipped if it is a reply to a HEAD request. The payload is removed from the HTX
message just before the message forwarding.

This bugs has been around for a long time. It was already there in the pre-HTX
versions. In legacy HTTP mode, internal errors are not parsed. So this bug
cannot be easily fixed. Thus, this patch should only be backported in all HTX
versions, as far as 2.0. However, the code has significantly changed in the
2.2. Thus in the 2.1 and 2.0, the patch must be entirely reworked.

(cherry picked from commit d6c48366b81e4f95676b038db32d23cdc541735e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0471ef6514cc9f07e1096b878f3e47baf3692d08)
[cf: adapted for the 2.1, as expected. ]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: server: support changing the slowstart value from state-file
Willy Tarreau [Thu, 22 Oct 2020 09:30:59 +0000 (11:30 +0200)]
BUG/MEDIUM: server: support changing the slowstart value from state-file

If the slowstart value in a state file implies the latest state change
is within the slowstart period, we end up calling srv_update_status()
to reschedule the server's state change but its task is not yet
allocated and remains null, causing a crash on startup.

Make sure srv_update_status() supports being called with partially
initialized servers which do not yet have a task. If the task has to
be scheduled, it will necessarily happen after initialization since
it will result from a state change.

This should be backported wherever server-state is present.

(cherry picked from commit 1e690bb6c49590cd3b4fae11c2f85f37e958635e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 550a2f16abb0ef88e75b30c85319a989192de7cd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MINOR: queue: properly report redistributed connections
Willy Tarreau [Wed, 21 Oct 2020 09:54:38 +0000 (11:54 +0200)]
BUG/MINOR: queue: properly report redistributed connections

In commit 5cd4bbd7a ("BUG/MAJOR: threads/queue: Fix thread-safety issues
on the queues management") the counter of transferred connections was
accidently lost, so that when a server goes down with connections in its
queue, it will always be reported that 0 connection were transferred.

This should be backported as far as 1.8 since the patch above was
backported there.

(cherry picked from commit ef71f0194cfdaa9c201bece65e8c1ab3d16ed8a0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e6985c91c3dd1100950987a5bf98eaeb863c97b8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

4 years agoBUG/MEDIUM: ssl: OCSP must work with BoringSSL
Emmanuel Hocdet [Mon, 26 Oct 2020 12:55:30 +0000 (13:55 +0100)]
BUG/MEDIUM: ssl: OCSP must work with BoringSSL

It's a regression from b3201a3e "BUG/MINOR: disable dynamic OCSP load
with BoringSSL". The origin bug is link to 76b4a12 "BUG/MEDIUM: ssl:
memory leak of ocsp data at SSL_CTX_free()": ssl_sock_free_ocsp()
shoud be in #ifndef OPENSSL_IS_BORINGSSL.
To avoid long #ifdef for small code, the BoringSSL part for ocsp load
is isolated in a simple #ifdef.

This must be backported in 2.2 and 2.1

(cherry picked from commit a73a222a9863e5f6763786845c1ff9e7e1038c3c)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit f495e5d6a597e2e1caa965e963ef16103da545db)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>

4 years agoBUG/MINOR: disable dynamic OCSP load with BoringSSL
Ilya Shipitsin [Sun, 18 Oct 2020 04:11:50 +0000 (09:11 +0500)]
BUG/MINOR: disable dynamic OCSP load with BoringSSL

it was accidently enabled on BoringSSL while
actually it is not supported

wla: Fix part of the issue mentionned in #895.
It fixes build of boringSSL versions prior to commit
https://boringssl.googlesource.com/boringssl/+/49e9f67d8b7cbeb3953b5548ad1009d15947a523

Could be backported in 2.2, 2.1, 2.0, 1.8. Where the patch fcb69d7
("BUILD: ssl: make BoringSSL use its own version numbers") is also
relevant.

Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit b3201a3e077198b3f75ebe8661aa45589b811552)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>

4 years agoBUILD: ssl: make BoringSSL use its own version numbers
Ilya Shipitsin [Sun, 18 Oct 2020 03:55:39 +0000 (08:55 +0500)]
BUILD: ssl: make BoringSSL use its own version numbers

BoringSSL is a fork of OpenSSL 1.1.0, however in
49e9f67d8b7cbeb3953b5548ad1009d15947a523 it has changed version to 1.1.1.

Should fix issue #895.

This must be backported to 2.2, 2.1, 2.0, 1.8

(cherry picked from commit fcb69d768bc5fc3bde98131ae27d7f8de847ca57)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 2da43ac33319e05a30cbef5a9fd757c615b173ed)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>

5 years agoBUG/MINOR: peers: Possible unexpected peer seesion reset after collisions.
Frédéric Lécaille [Wed, 14 Oct 2020 09:50:26 +0000 (11:50 +0200)]
BUG/MINOR: peers: Possible unexpected peer seesion reset after collisions.

During a peers session collision (two peer sessions opened on both side) we must
mark the peer the session of which will be shutdown as alive, if not ->reconnect
timer will be set with a wrong value if the synchro task expires after the peer
has been reconnected. This possibly leads to unexpected deconnections during handshakes.
Furthermore, this patch cancels any heartbeat tranmimission when a reconnection
is prepared.

(cherry picked from commit 6e1a9c57c938360e95f445e800f0d22782bb6c22)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MEDIUM: lb: Always lock the server when calling server_{take,drop}_conn
Christopher Faulet [Fri, 16 Oct 2020 14:27:17 +0000 (16:27 +0200)]
BUG/MEDIUM: lb: Always lock the server when calling server_{take,drop}_conn

The server lock must be held when server_take_conn() and server_drop_conn()
lbprm callback functions are called. It is a documented prerequisite but it is
not always performed. It only affects leastconn and fas lb algorithm. Others
don't use these callback functions.

A race condition on the next pending effecive weight (next_eweight) may be
encountered with the leastconn lb algorithm. An agent check may set it to 0
while fwlc_srv_reposition() is called. The server is locked during the
next_eweight update. But because the server lock is not acquired when
fwlc_srv_reposition() is called, we may use it to recompute the server key,
leading to a division by 0.

This patch must be backported as far as 1.8.

(cherry picked from commit 26a52af642c3fcfd6a637aef019b78147c05e126)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e50dd9f3dd622937e0b7bb4cbe7067c50e9a1f13)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MEDIUM: mux-h1: Get the session from the H1S when capturing bad messages
Christopher Faulet [Thu, 15 Oct 2020 15:19:46 +0000 (17:19 +0200)]
BUG/MEDIUM: mux-h1: Get the session from the H1S when capturing bad messages

It is not guaranteed that the backend connection has an owner. It is set when
the connection is created. But when the connection is moved in a server idle
list, the connection owner is set to NULL and may never be set again. On the
other hand, when a mux is created or when a CS is attached, the session is
always defined. The H1 stream always keep a reference on it when it is
created. Thus, when a bad message is captured we should not rely on the
connection owner to retrieve the session. Instead we should get it from the H1
stream.

(cherry picked from commit db2c17da60e80091615ddbe8d97cb964d1f00ac7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9d99d5d06863c9ecb1d59de9f3964c8e3b35c298)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MEDIUM: spoe: Unset variable instead of set it if no data provided
Christopher Faulet [Thu, 15 Oct 2020 14:08:30 +0000 (16:08 +0200)]
BUG/MEDIUM: spoe: Unset variable instead of set it if no data provided

If an agent try to set a variable with the NULL data type, an unset is perform
instead to avoid undefined behaviors. Once decoded, such data are translated to
a sample with the type SMP_T_ANY. It is unexpected in HAProxy. When a variable
is set with such sample, no data are attached to the variable. Thus, when the
variable is retrieved later in the transaction, the sample data are
uninitialized, leading to undefined behaviors depending on how it is used. For
instance, it leads to a crash if the debug converter is used on such variable.

This patch should fix the issue #855. It must be backported as far as 1.8.

(cherry picked from commit 2469eba20fdc01f8ca95726a8c11feaaa8825027)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit dee726c36d3ee620f6564f1b6e53930c1f97481c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MEDIUM: task: bound the number of tasks picked from the wait queue at once
Willy Tarreau [Fri, 16 Oct 2020 07:26:22 +0000 (09:26 +0200)]
BUG/MEDIUM: task: bound the number of tasks picked from the wait queue at once

There is a theorical problem in the wait queue, which is that with many
threads, one could spend a lot of time looping on the newly expired tasks,
causing a lot of contention on the global wq_lock and on the global
rq_lock. This initially sounds bening, but if another thread does just
a task_schedule() or task_queue(), it might end up waiting for a long
time on this lock, and this wait time will count on its execution budget,
degrading the end user's experience and possibly risking to trigger the
watchdog if that lasts too long.

The simplest (and backportable) solution here consists in bounding the
number of expired tasks that may be picked from the global wait queue at
once by a thread, given that all other ones will do it as well anyway.

We don't need to pick more than global.tune.runqueue_depth tasks at once
as we won't process more, so this counter is updated for both the local
and the global queues: threads with more local expired tasks will pick
less global tasks and conversely, keeping the load balanced between all
threads. This will guarantee a much lower latency if/when wakeup storms
happen (e.g. hundreds of thousands of synchronized health checks).

Note that some crashes have been witnessed with 1/4 of the threads in
wake_expired_tasks() and, while the issue might or might not be related,
not having reasonable bounds here definitely justifies why we can spend
so much time there.

This patch should be backported, probably as far as 2.0 (maybe with
some adaptations).

(cherry picked from commit 3cfaa8d1e075b5037b15775ec6b81ef16c4d81ce)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 563eede2418274f28a72a926362b11e21341c32f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoMINOR: fd: report an error message when failing initial allocations
Willy Tarreau [Tue, 13 Oct 2020 13:45:07 +0000 (15:45 +0200)]
MINOR: fd: report an error message when failing initial allocations

When starting with a huge maxconn (say 1 billion), the only error seen
is "No polling mechanism available". This doesn't help at all to resolve
the problem. Let's add specific alerts for the failed mallocs. Now we can
get this instead:

  [ALERT] 286/154439 (23408) : Not enough memory to allocate 2000000033 entries for fdtab!

This may be backported as far as 2.0 as it helps debugging bad configurations.

(cherry picked from commit 7c9f756dcc51b9974d5e81116e1d8a34a6152040)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2e0c88d6418bd90877a30ef5db414fe412f5a1b6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MINOR: mux-h2: do not stop outgoing connections on stopping
Willy Tarreau [Tue, 13 Oct 2020 16:09:15 +0000 (18:09 +0200)]
BUG/MINOR: mux-h2: do not stop outgoing connections on stopping

There are reports of a few "SC" in logs during reloads when H2 is used
on the backend side. Christopher analysed this as being caused by the
proxy disabled test in h2_process(). As the comment says, this was done
for frontends only, and must absolutely not send a GOAWAY to the backend,
as all it will result in is to make newly queued streams fail.

The fix consists in simply testing the connection side before deciding
to send the GOAWAY.

This may be backported as far as 2.0, though for whatever reason it seems
to manifest itself only since 2.2 (probably due to changes in the outgoing
connection setup sequence).

(cherry picked from commit b1e600c9c5e4a20a6de1f3b9593f20dc50f01315)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 403168c3787cc7098fe31640089bd508d3448115)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MINOR: init: only keep rlim_fd_cur if max is unlimited
Willy Tarreau [Tue, 13 Oct 2020 13:36:08 +0000 (15:36 +0200)]
BUG/MINOR: init: only keep rlim_fd_cur if max is unlimited

On some operating systems, RLIM_INFINITY is set to -1 so that when the
hard limit on the number of FDs is set to unlimited, taking the MAX
of both values keeps rlim_fd_cur and everything works. But on other
systems this values is defined as the highest positive integer. This
is what was observed on a 32-bit AIX 5.1. The effect is that maxsock
becomes 2^31-1 and that fdtab allocation fails.

Note that a simple workaround consists in manually setting maxconn in
the global section.

Let's ignore unlimited as soon as we retrieve rlim_fd_max so that all
systems behave consistently.

This may be backported as far as 2.0, though it doesn't seem like it
has annoyed anyone.

(cherry picked from commit 2bd0f8147b0682ec962f59a5c38f03314f43a4f5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bd2d932842afa5af41672f7e66483714537fcb3a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MINOR: http-htx: Expect no body for 204/304 internal HTTP responses
Christopher Faulet [Fri, 9 Oct 2020 06:50:26 +0000 (08:50 +0200)]
BUG/MINOR: http-htx: Expect no body for 204/304 internal HTTP responses

204 and 304 HTTP responses must no contain message body. These status codes are
correctly handled when the responses are received from a server. But there is no
specific processing for internal HTTP reponses (errorfile and http replies).

Now, when errorfiles or an http replies are parsed during the configuration
parsing, an error is triggered if a 204/304 message contains a body. An extra
check is also performed to ensure the body length matches the announce
content-length.

This patch should fix the issue #891. It must be backported as far as 2.0. For
2.1 and 2.0, only the http_str_to_htx() function must be fixed.
http_parse_http_reply() function does not exist.

(cherry picked from commit b8d148a93f0daff9821cb9ecc5934499f8d128a2)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit dde6c42da611badbf515c687a69c457aa8ecc40b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MEDIUM: mux-h2: Don't handle pending read0 too early on streams
Christopher Faulet [Thu, 8 Oct 2020 13:38:41 +0000 (15:38 +0200)]
BUG/MEDIUM: mux-h2: Don't handle pending read0 too early on streams

This patch is similar to the previous one on the fcgi. Same is true for the
H2. But the bug is far harder to trigger because of the protocol cinematic. But
it may explain strange aborts in some edge cases.

A read0 received on the connection must not be handled too early by H2 streams.
If the demux buffer is not empty, the pending read0 must not be considered. The
H2 streams must not be passed in half-closed remote state in
h2s_wake_one_stream() and the CS_FL_EOS flag must not be set on the associated
conn-stream in h2_rcv_buf(). To sum up, it means, if there are still data
pending in the demux buffer, no abort must be reported to the streams.

To fix the issue, a dedicated function has been added, responsible for detecting
pending read0 for a H2 connection. A read0 is reported only if the demux buffer
is empty. This function is used instead of conn_xprt_read0_pending() at some
places.

Note that the HREM stream state should not be used to report aborts. It is
performed on h2s_wake_one_stream() function and it is a legacy of the very first
versions of the mux-h2.

This patch should be backported as far as 2.0. In the 1.8, the code is too
different to apply it like that. But it is probably useless because the mux-h2
can only be installed on the client side.

(cherry picked from commit aade4edc1a8d148447953e279c6a83bf3dea6661)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 36840d8ca8e298b4da4bd24d0f6128b46e0757e3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MEDIUM: mux-fcgi: Don't handle pending read0 too early on streams
Christopher Faulet [Thu, 8 Oct 2020 13:26:33 +0000 (15:26 +0200)]
BUG/MEDIUM: mux-fcgi: Don't handle pending read0 too early on streams

A read0 received on the connection must not be handled too early by FCGI
streams. If the demux buffer is not empty, the pending read0 must not be
considered. The FCGI streams must not be passed in half-closed remote state in
fcgi_strm_wake_one_stream() and the CS_FL_EOS flag must not be set on the
associated conn-stream in fcgi_rcv_buf(). To sum up, it means, if there are
still data pending in the demux buffer, no abort must be reported to the
streams.

To fix the issue, a dedicated function has been added, responsible for detecting
pending read0 for a FCGI connection. A read0 is reported only if the demux
buffer is empty. This function is used instead of conn_xprt_read0_pending() at
some places.

This patch should fix the issue #886. It must be backported as far as 2.1.

(cherry picked from commit 6670e3e2bf64d4273c164cd5a70bb9acde2820b2)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 071c3f1d68c6b1b97e5cc93a6793d4106618f9f9)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MINOR: mux-h1: Always set the session on frontend h1 stream
Christopher Faulet [Wed, 30 Sep 2020 13:00:13 +0000 (15:00 +0200)]
BUG/MINOR: mux-h1: Always set the session on frontend h1 stream

The session is always defined for a frontend connection. When a new client
connection is established, the session is set for the first H1 stream. But on
keep-alived connections, it is not set for the followings H1 streams while it is
possible.

This patch is tagged as a bug because it fixes an inconsistency in the H1
streams creation. But it does not fixed a known bug.

This patch must be backported as far as 2.0.

(cherry picked from commit e9da975aabb0f2137bde7afbd020b300029ef28f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 595a3f3b14ca1e5cae02d3e8530c88dc4bbbe6e4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MINOR: peers: Inconsistency when dumping peer status codes.
Frédéric Lécaille [Mon, 5 Oct 2020 10:33:07 +0000 (12:33 +0200)]
BUG/MINOR: peers: Inconsistency when dumping peer status codes.

A peer connection status must be considered as valid only if there is an applet
which has been instantiated for the connection to the peer. So, ->statuscode
should be considered as the last known peer connection status from the last
connection to this peer if any. To reflect this, "statuscode" field of peer dump
is renamed to "last_statuscode".
This patch also add "active"/"inactive" field after the peer location type
("remote" or "local") if an applet has been instantiated for this peer connection
or not.

Thank you to Emeric for having noticed this issue.

Must be backported in >=1.9 version.

(cherry picked from commit e7e2b21d274ef48da4e45d09786568d2239c9b2a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 186bee02a9722e22f0b95f150869ae8e1c3794a9)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoMINOR: hlua: Display debug messages on stderr only in debug mode
Christopher Faulet [Fri, 2 Oct 2020 16:13:52 +0000 (18:13 +0200)]
MINOR: hlua: Display debug messages on stderr only in debug mode

Debug Messages emitted in lua using core.Debug() or core.log() are now only
displayed on stderr if HAProxy is started in debug mode (-d parameter on the
command line). There is no change for other message levels.

This patch should fix the issue #879. It may be backported to all stable
versions.

(cherry picked from commit f98d821b942b4f392e77431c320aa895ca97369e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 604a647d4d7ff310d0ed1e9f98531b6a0c9e332e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MINOR: stats: fix validity of the json schema
Amaury Denoyelle [Fri, 2 Oct 2020 16:31:59 +0000 (18:31 +0200)]
BUG/MINOR: stats: fix validity of the json schema

The json schema seems to be invalid when checking using the validator
from https://www.jsonschemavalidator.net/. Correct it using the
following specification :
http://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.1

The impact of the bug it not well known as I am not sure of how useful
the json schema is for users. It is probably not used at all or else
this bug would have been reported.

This should be backported up to 1.8.

(cherry picked from commit a53ce4cc011250a0e561f4e5bb62f46719813534)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a9299e1f56f65ce89d45690a2356d5f59eed6bdd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoMINOR: counters: fix a typo in comment
Amaury Denoyelle [Fri, 2 Oct 2020 16:31:58 +0000 (18:31 +0200)]
MINOR: counters: fix a typo in comment

Wrong copy/paste comment, replace listeners/frontends by
servers/backends

This may be backported up to 1.7.

(cherry picked from commit cd3de507794b4f063aa1e7f43b55b27998d7ee7d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit dc0b2880d87458ceafedbbeb5051ece149adfa6e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MEDIUM: queue: make pendconn_cond_unlink() really thread-safe
Willy Tarreau [Fri, 2 Oct 2020 15:52:49 +0000 (17:52 +0200)]
BUG/MEDIUM: queue: make pendconn_cond_unlink() really thread-safe

A crash reported in github issue #880 looks impossible unless
pendconn_cond_unlink() occasionally sees a null leaf_p when attempting
to remove an entry, which seems to be confirmed by the reporter. What
seems to be happening is that depending on compiler optimizations,
this pointer can appear as null while pointers are moved if one of
the node's parents is removed from or inserted into the tree. There's
no explicit null of the pointer during these operations but those
pointers are rewritten in multiple steps and nothing prevents this
situation from happening, and there are no particular barrier nor
atomic ops around this.

This test was used to avoid unnecessary locking, for already deleted
entries, but looking at the code it appears that pendconn_free() already
resets s->pend_pos that's used as <p> there, and that the other call
reasons are after an error where the connection will be dropped as
well. So we don't save anything by doing this test, and make it
unsafe. The older code used to check for list emptiness there and
not inside pendconn_unlink(), which explains why the code has stayed
there. Let's just remove this now.

Thanks to @jaroslawr for reporting this issue in great details and for
testing the proposed fix.

This should be backpored to 1.8, where the test on LIST_ISEMPTY should
be moved to pendconn_unlink() instead (inside the lock, just like 2.0+).

(cherry picked from commit fac0f645dff9fb1854db32da9fa7c317eaaeede1)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 3376d9f52e047214061aeedaf117a2006ce60d70)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoDOC: tcp-rules: Refresh details about L7 matching for tcp-request content rules
Christopher Faulet [Fri, 2 Oct 2020 09:38:46 +0000 (11:38 +0200)]
DOC: tcp-rules: Refresh details about L7 matching for tcp-request content rules

Because the parsing of HTTP message is now performed in the HTTP multiplexers,
the content is immediatly available when "tcp-request content" rules are
evaluated for an HTTP frontend. So, it is a good idea to make the documentation
explicit on this point. In addition, because in all cases, the parsing is
already performed, there is no reason to still use "tcp-request content" rules
based on L7 matching, although it is still valid. The recommended way is to use
"http-request" rules instead. Again, it is a good idea to update the
documentation on this point.

(cherry picked from commit 7ea509e15f6fe3390a969f6eec29d76b8732d3aa)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit e821fbde4a7b75ad52fb98a1ea3d77b3ff483054)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

5 years agoBUG/MINOR: Fix several leaks of 'log_tag' in init().
Eric Salama [Fri, 2 Oct 2020 09:58:19 +0000 (11:58 +0200)]
BUG/MINOR: Fix several leaks of 'log_tag' in init().

We use chunk_initstr() to store the program name as the default log-tag.

If we use the log-tag directive in the config file, this chunk will be
destroyed and replaced. chunk_initstr() sets the chunk size to 0 so we
will free the chunk itself, but not its content.

This happens for a global section and also for a proxy.

We fix this by using chunk_initlen() instead of chunk_initstr().
We also check that the memory allocation was successfull, otherwise we quit.

This fixes github issue #850.
It can be backported as far as 1.9, with minor adjustments to includes.

(cherry picked from commit 7cea6065aca04c91fc5109e581f124a46b2b5242)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 7566bcfa5a1d28e8c9d5f9ca1dfe0ebe791052eb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>