Commit Graph

17969 Commits

Author SHA1 Message Date
Willy Tarreau
c6b7a97e54 BUG/MINOR: cli/stats: add missing trailing LF after "show info json"
This is the continuation of commit 5a0e7ca5d ("BUG/MINOR: cli/stats: add
missing trailing LF after JSON outputs"). There's also a "show info json"
command which was also missing the trailing LF. It's constructed exactly
like the "show stat json", in that it dumps a series of fields without any
LF. The difference however is that for the stats output, everything was
enclosed in an array which required an LF *after* the closing bracket,
while here there's no such array so we have to emit the LF after the loop.
That makes the two functions a bit inconsistent, it's quite annoying, but
making them better would require sending one LF per line in the stats
output, which is not particularly interesting.

Given that it took 5+ years to spot that this code wasn't working as
expected it doesn't seem worth investing much time trying to refactor
it to make it look cleaner at the risk of breaking other obscure parts.
2022-06-10 15:12:21 +02:00
Willy Tarreau
9b46fb4cca BUG/MINOR: server: do not enable DNS resolution on disabled proxies
Leonhard Wimmer reported an interesting bug in github issue #1742.
Servers in disabled proxies that are configured for resolution are still
subscribed to DNS resolutions, but the LB algos are not initialized at
all since the proxy is disabled, so when the server state changes,
attempts to update its status cause a crash when the server's weight
is recalculated via a divide by the proxy's total weight which is zero.

This should be backported to all versions. Beware that before 2.5 or
so, there's no PR_FL_DISABLED flag, instead px->disabled should be
used (2.3-2.4) or PR_STSTOPPED for older versions.

Thanks to Leonhard for his report and quick test!
2022-06-10 11:17:27 +02:00
Willy Tarreau
5a0e7ca5d0 BUG/MINOR: cli/stats: add missing trailing LF after JSON outputs
Patrick Hemmer reported that we have a bug in the CLI commands
"show stat json" and "show schema json" in that they forget the trailing
LF that's required to mark the end of the response. This has been the
case since the introduction of the feature in 1.8-dev1 by commit 6f6bb380e
("MEDIUM: stats: Add show json schema"), so this fix may be backported to
all versions.
2022-06-10 09:23:44 +02:00
Amaury Denoyelle
3a2fcfd58d BUG/MEDIUM: h3: fix SETTINGS parsing
Function used to parse SETTINGS frame is incorrect as it does not stop
at the frame length but continue to parse beyond it. In most cases, it
will result in a connection closed with error H3_FRAME_ERROR.

This bug can be reproduced with clients that sent more than just a
SETTINGS frame on the H3 control stream. This is notably the case with
aioquic which emit a MAX_PUSH_ID after SETTINGS.

This bug has been introduced in the current dev release, by the
following patch
  62eef85961
  MINOR: mux-quic: simplify decode_qcs API
thus, it does not need to be backported.
2022-06-09 14:34:43 +02:00
Amaury Denoyelle
c715eb7898 BUG/MINOR: h3: fix frame type definition
Frame type has changed during HTTP/3 specification process. Adjust it to
reflect the latest RFC 9114 status.

Concretly, type for GOAWAY and MAX_PUSH_ID frames has been adjusted.
The impact of this bug is limited as currently these frames are not
handled by haproxy and are ignored.

This can be backported up to 2.6.
2022-06-09 14:34:43 +02:00
Glenn Strauss
0012f899dd OPTIM: mux-h2: increase h2_settings_initial_window_size default to 64k
This changes the default from RFC 7540's default 65535 (64k-1) to avoid
avoid some degenerative WINDOW_UPDATE behaviors in the wild observed with
clients using 65536 as their buffer size, and have to complete each block
with a 1-byte frame, which with some servers tend to degenerate in 1-byte
WU causing more 1-byte frames to be sent until the transfer almost only
uses 1-byte frames.

More details here: https://github.com/nghttp2/nghttp2/issues/1722

As mentioned in previous commit (MEDIUM: mux-h2: try to coalesce outgoing
WINDOW_UPDATE frames) the issue could not be reproduced with haproxy but
individual WU frames are sent so theoretically nothing prevents this from
happening. As such it should be backported as a workaround for already
deployed clients after watching for any possible side effect with rare
clients. As an added benefit, uploads from curl now use less DATA frames
(all are 16384 now). Note that the previous patch alone is sufficient to
stop the issue with curl in case this one would need to be reverted.

[wt: edited commit messaged, updated doc]
2022-06-09 09:28:21 +02:00
Willy Tarreau
617592c9eb MEDIUM: mux-h2: try to coalesce outgoing WINDOW_UPDATE frames
Glenn Strauss from Lighttpd reported a corner case affecting curl+lighttpd
that causes some uploads to degenerate to extremely suboptimal conditions
under certain circumstances, and noted that many other implementations
were possibly not safe against this degradation.

Glenn's detailed analysis is available here:

   https://github.com/nghttp2/nghttp2/issues/1722

In short, curl uses a 65536 bytes buffer and the default stream window
is 65535, with 16384 bytes per frame. Curl will then send 3 frames of
16384 bytes followed by one of 16383, will wait for a window update to
send the last byte before recycling the buffer to read the next 64kB.
On each round like this, one extra single-byte frame will be sent, and
if ACKs for these single-byte frames are not aggregated, this will only
allow the client to send one extra byte at a time. At some point it is
possible (at least Glenn observed it) to have mostly 1-byte frames in
the transfer, resulting in huge CPU usage and a long transfer.

It was not possible to reproduce this with haproxy, even when playing
with frame sizes, buffer sizes nor window sizes. One reason seems to
be that we're using the same buffer size for the connection and the
stream and that the frame headers prevent the filling of the window
from happening on the same boundaries as on the sender. However it
does occasionally happen to see up to two 1-byte data frames in a row,
indicating that there's definitely room for improvement.

The WINDOW_UPDATE frames for the connection are sent at the end of the
demuxing, but the ones for the streams are currently sent immediately
after a DATA frame is processed, mostly for convenience. But we don't
need to proceed like this, we already have the counter of unacked bytes
in rcvd_s, so we can simply use that to decide when to send an ACK. It
must just be done before processing a new frame. The benefit is that
contiguous frames for the same stream will now only produce a single
WU, like for the connection. On complicated tests involving a client
that was limited to 100 Mbps transfers and a dummy Lua-based payload
consumer, it was possible to see the number of stream WU frames being
halved for a 100 MB transfer, which is already a nice saving anyway.

Glenn proposed a better workaround consisting in increasing the
default window size to 65536. This will be done in a separate patch
so that both can be studied independently in field and backported as
needed.

This patch is not much complicated and shold be backportable. It just
needs to be tested in development first.
2022-06-09 09:28:21 +02:00
Amaury Denoyelle
1cd43aa194 BUG/MINOR: h3: fix incorrect BUG_ON assert on SETTINGS parsing
BUG_ON() assertion to check for incomplete SETTINGS frame is incorrect.
It should check if frame length is greater, not smaller, than current
buffer data. Anyway, this BUG_ON() is useless as h3_decode_qcs()
prevents parsing of an incomplete frame, except for H3 DATA. Remove it
to fix this bug.

This bug was introduced in the current dev tree by commit
  commit 62eef85961
  MINOR: mux-quic: simplify decode_qcs API
Thus it does not need to be backported.

This fixes crashes which happen with DEBUG_STRICT=2. Most notably, this
is reproducible with clients that emit more than just a SETTINGS frame
on the H3 control stream. It can be reproduced with aioquic for example.
2022-06-08 18:26:06 +02:00
Christopher Faulet
af936762d0 REGTESTS: healthcheckmail: Relax health-check failure condition
The info field in the log message may change. For instance, on FreeBSD, a
"broken pipe" is reported. Thus, the expected log message must be more
generic.
2022-06-08 16:58:07 +02:00
Christopher Faulet
52912579ee REGTESTS: healthcheckmail: Update the test to be functionnal again
This reg-test is broken since a while. It was simplified to be
functionnal. Now, it only test email alerts.
2022-06-08 15:28:38 +02:00
Christopher Faulet
58e3501910 BUG/MEDIUM: mailers: Set the object type for check attached to an email alert
The health-check attached to an email alert has no type. It is unexpected,
and since the 2.6, it is important because we rely on it to know the
application type in front of a connection at the stream-connector
level. Because the object type is not set, the SE descriptor is not properly
initialized, leading to a segfault when a connection to the SMTP server is
established.

This patch must be backported to 2.6 and may be backported as far as
2.0. However, it is only an issue for the 2.6 and upper.
2022-06-08 15:28:38 +02:00
Christopher Faulet
4f1825c5db BUG/MINOR: checks: Properly handle email alerts in trace messages
There is no server for email alerts. So the trace messages must be adapted
to handle this case. Information related to the server are now skipped for
email alerts and "[EMAIL]" prefix is used.

This patch must be backported as far as 2.4.
2022-06-08 15:28:38 +02:00
Christopher Faulet
e3b2574796 BUG/MINOR: trace: Test server existence for health-checks to get proxy
Email alerts are based on health-checks but with no server. Thus, in
__trace() function, responsible to write a trace message, we must be
prepared to have no server and thus no proxy.

This patch must be backported as far as 2.4.
2022-06-08 15:28:38 +02:00
Willy Tarreau
2d7cd3e4ca DEV: tcploop: add minimal UDP support
Passing "-u" turns to SOCK_DGRAM + IPPROTO_UDP, which still allows
bind/connect()/recv()/send() and can be convenient for experimentation
purposes.
2022-06-08 14:42:15 +02:00
Willy Tarreau
d493331d47 DEV: tcploop: add a new "bind" command to bind to ip/port.
The Listen command automatically relies on it (without passing its
argument), and both Listen and Connect now support working with the
existing socket, so that it's possible to Bind an ip:port on an
existing socket or to create a new one for the purpose of listening
or connecting. It now becomes possible to do:

   tcploop 0 L1234 C8888

to connect from port 1234 to port 8888.
2022-06-08 14:42:15 +02:00
Willy Tarreau
cb284c7a62 DEV: tcploop: permit port 0 to ease handling of default options
This will also be convenient when binding to an IP and no port.
2022-06-08 14:42:15 +02:00
Willy Tarreau
ff13dadaa5 DEV: tcploop: factor out the socket creation
This will later permit to separately bind() before connect(). Let's
first deal with existing sockets.
2022-06-08 14:42:15 +02:00
Willy Tarreau
542bf0a7bb DEV: tcploop: make it possible to change the target address of a connect()
Sometimes it's more convenient to be able to specify where to connect on
the connect() statement, let's make it possible to pass it in argument to
the C command.
2022-06-08 14:42:15 +02:00
Willy Tarreau
7184ca23c6 DEV: tcploop: make the current address the default address
It's difficult to refine bind/connect right now, let's make the address
optionall by turning it to the default one.
2022-06-08 14:42:15 +02:00
Willy Tarreau
98028c8d0a DEV: tcploop: reorder options in the usage message
Options have become difficult to find, let's reorder them alphabetically.
2022-06-08 14:42:15 +02:00
Willy Tarreau
7d318ed8cc BUILD: compiler: implement unreachable for older compilers too
Benoit Dolez reported that gcc-4.4 emits several "may be used
uninitialized" warnings around places where there are BUG_ON()
or ABORT_NOW(). The reason is that __builtin_unreachable() was
introduced in gcc-4.5 thus older ones do not know that the code
after such statements is not reachable.

This patch solves the problem by deplacing the statement with
an infinite loop on older versions. The compiler knows that the
code following it cannot be reached, and this is quite cheap
(2 to 4 bytes depending on architectures). It even reduces the
code size a little bit as the compiler doesn't have to optimize
for branches that do not exist.

This may be backported to older versions.
2022-06-08 12:17:22 +02:00
Benoit DOLEZ
69e3f05b15 BUILD: quic: fix anonymous union for gcc-4.4
Building QUIC with gcc-4.4 on el6 shows this error:

src/xprt_quic.c: In function 'qc_release_lost_pkts':
src/xprt_quic.c:1905: error: unknown field 'loss' specified in initializer
compilation terminated due to -Wfatal-errors.
make: *** [src/xprt_quic.o] Error 1
make: *** Waiting for unfinished jobs....

Initializing an anonymous form of union like :
     struct quic_cc_event ev = {
          (...)
          .loss.time_sent = newest_lost->time_sent,
          (...)
     };

generates an error with gcc-4.4 but not when initializing the
fields outside of the declaration.
2022-06-08 11:24:36 +02:00
Amaury Denoyelle
dca4c53a95 BUG/MINOR: h3: fix return value on decode_qcs on error
Convert return code to -1 when an error has been detected. This is
required since the previous API change on return value from the patch :

  1f21ebdd76
  MINOR: mux-quic/h3: adjust demuxing function return values

Without this, QUIC MUX won't consider the call as an error and will try
to remove one byte from the buffer. This may cause a BUG_ON failure if
the buffer is empty at this stage.

This bug was introduced in the current dev tree. Does not need to be
backported.
2022-06-07 18:26:46 +02:00
Amaury Denoyelle
1f21ebdd76 MINOR: mux-quic/h3: adjust demuxing function return values
Clean the API used by decode_qcs() and transcoder internal functions.
Parsing functions now returns a ssize_t which represents the number of
consumed bytes or a negative error code. The total consumed bytes is
returned via decode_qcs().

The API is now unified and cleaner. The MUX can thus simply use the
return value of decode_qcs() instead of substracting the data bytes in
the buffer before and after the call. Transcoders functions are not
anymore obliged to remove consumed bytes from the buffer which was not
obvious.
2022-06-07 18:15:47 +02:00
Amaury Denoyelle
62eef85961 MINOR: mux-quic: simplify decode_qcs API
Slightly modify decode_qcs function used by transcoders. The MUX now
gives a buffer instance on which each transcoder is free to work on it.
At the return of the function, the MUX removes consume data from its own
buffer.

This reduces the number of invocation to qcs_consume at the end of a
full demuxing process. The API is also cleaner with the transcoders not
responsible of calling it with the risk of having the input buffer
freed if empty.
2022-06-07 18:15:47 +02:00
Amaury Denoyelle
c0156790e6 MINOR: h3: add h3c pointer into h3s instance
As a mirror to qcc/qcs types, add a h3c pointer into h3s struct. This
should help to clean up H3 code and avoid to use qcs.qcc.ctx to retrieve
the h3c instance.
2022-06-07 18:13:11 +02:00
Amaury Denoyelle
16f3da4624 MINOR: connection: support HTTP/3.0 for smp_*_http_major fetch
smp_fc_http_major may be used to return the http version as an integer
used on the frontend or backend side. Previously, the handler only
checked for version 2 or 1 as a fallback. Extend it to support version 3
with the QUIC mux.
2022-06-07 12:04:12 +02:00
Christopher Faulet
fdf693477a REGTESTS: restrict_req_hdr_names: Extend supported versions
This reg-test was backported as far as 2.0. Thus, extend supported versions
accordingly.

This patch must be backported as far as 2.0.
2022-06-07 08:22:15 +02:00
Christopher Faulet
3d1da9a440 REGTESTS: http_abortonclose: Extend supported versions
This reg-test was backported as far as 2.0. Thus, extend supported versions
accordingly.

This patch must be backported as far as 2.0.
2022-06-07 08:21:54 +02:00
Christopher Faulet
1f90f33b69 BUG/MINOR: ssl_ckch: Fix another possible uninitialized value
Commit d6c66f06a ("MINOR: ssl_ckch: Remove service context for "set ssl
crl-file" command") introduced a regression leading to a build error because
of a possible uninitialized value. It is now fixed.

This patch must be backported as far as 2.5.
2022-06-03 16:49:53 +02:00
Christopher Faulet
ea2c8c6ba7 BUILD: ssl_ckch: Fix build error about a possible uninitialized value
A build error is reported about the path variable in the switch statement on
the commit type, in cli_io_handler_commit_cafile_crlfile() function. The
enum contains only 2 values, but a default clause has been added to return an
error to make GCC happy.

This patch must be backported as far as 2.5.
2022-06-03 16:41:11 +02:00
Christopher Faulet
88041b35c3 BUG/MINOR: ssl_ckch: Fix possible uninitialized value in show_crlfile I/O handler
Commit 9a99e5478 ("BUG/MINOR: ssl_ckch: Dump CRL transaction only once if
show command yield") introduced a regression leading to a build error
because of a possible uninitialized value. It is now fixed.

This patch must be backported as far as 2.5.
2022-06-03 16:28:11 +02:00
Christopher Faulet
677cb4fa91 BUG/MINOR: ssl_ckch: Fix possible uninitialized value in show_cafile I/O handler
Commit 5a2154bf7 ("BUG/MINOR: ssl_ckch: Dump CA transaction only once if
show command yield") introduced a regression leading to a build error
because of a possible uninitialized value. It is now fixed.

This patch must be backported as far as 2.5.
2022-06-03 16:27:49 +02:00
Christopher Faulet
d1d2e4dfe5 BUG/MINOR: ssl_ckch: Fix possible uninitialized value in show_cert I/O handler
Commit 3e94f5d4b ("BUG/MINOR: ssl_ckch: Dump cert transaction only once if
show command yield") introduced a regression leading to a build error
because of a possible uninitialized value. It is now fixed.

This patch must be backported as far as 2.2.
2022-06-03 16:27:41 +02:00
Christopher Faulet
d6c66f06ac MINOR: ssl_ckch: Remove service context for "set ssl crl-file" command
This command does not have I/O handle function. All is done in the command
parsing function. So there is no reason to have dedicated context.
2022-06-03 12:12:04 +02:00
Christopher Faulet
132c595673 MINOR: ssl_ckch: Remove service context for "set ssl ca-file" command
This command does not have I/O handle function. All is done in the command
parsing function. So there is no reason to have dedicated context.
2022-06-03 12:12:04 +02:00
Christopher Faulet
24a20b9808 MINOR: ssl_ckch: Remove service context for "set ssl cert" command
This command does not have I/O handle function. All is done in the command
parsing function. So there is no reason to have dedicated context.
2022-06-03 12:12:04 +02:00
Christopher Faulet
6af2fc6a3f MINOR: ssl_ckch: Simplify structure used to commit changes on CA/CRL entries
The same type is used for CA and CRL entries. So, in commit_cert_ctx
structure, there is no reason to have different fields for the CA and CRL
entries.
2022-06-03 12:12:04 +02:00
Christopher Faulet
dd0c4834ef CLEANUP: ssl_ckch: Remove unused field in commit_cacrlfile_ctx structure
.next_ckchi field is not used by functions responsible to commit changes on
CA/CRL entries. It can be removed.
2022-06-03 12:12:04 +02:00
Christopher Faulet
f814c4aa98 BUG/MINOR: ssl_ckch: Init right field when parsing "commit ssl crl-file" cmd
.next_ckchi_link field must be initialized to NULL instead of .next_ckchi in
cli_parse_commit_crlfile() function. Only '.nex_ckchi_link' is used in the
I/O handler.

This patch must be backported as far as 2.5 with some adaptations for the 2.5.
2022-06-03 12:12:04 +02:00
Christopher Faulet
3e94f5d4b6 BUG/MINOR: ssl_ckch: Dump cert transaction only once if show command yield
When loaded SSL certificates are displayed via "show ssl cert" command, the
in-progess transaction, if any, is also displayed. However, if the command
yield, the transaction is re-displayed again and again.

To fix the issue, old_ckchs field is used to remember the transaction was
already displayed.

This patch must be backported as far as 2.2.
2022-06-03 11:20:41 +02:00
Christopher Faulet
5a2154bf7c BUG/MINOR: ssl_ckch: Dump CA transaction only once if show command yield
When loaded CA files are displayed via "show ssl ca-file" command, the
in-progress transaction, if any, is also displayed. However, if the command
yield, the transaction is re-displayed again and again.

To fix the issue, old_cafile_entry field is used to remember the transaction
was already displayed.

This patch must be backported as far as 2.5.
2022-06-03 11:20:38 +02:00
Christopher Faulet
9a99e54787 BUG/MINOR: ssl_ckch: Dump CRL transaction only once if show command yield
When loaded CRL files are displayed via "show ssl crl-file" command, the
in-progess transaction, if any, is also displayed. However, if the command
yield, the transaction is re-displayed again and again.

To fix the issue, old_crlfile_entry field is used to remember the transaction
was already displayed.

This patch must be backported as far as 2.5.
2022-06-03 11:20:34 +02:00
Christopher Faulet
51095ee236 BUG/MINOR: ssl_ckch: Use right type for old entry in show_crlfile_ctx
Because of a typo (I guess), an unknown type is used for the old entry in
show_crlfile_ctx structure. Because this field is unused, there is no
compilation error. But it must be a cafile_entry and not a crlfile_entry.

Note this field is not used for now, but it will be used.

This patch must be backported to 2.6.
2022-06-03 11:20:16 +02:00
Christopher Faulet
ddc8e1cf8b MINOR: ssl_ckch: Simplify I/O handler to commit changes on CA/CRL entry
Simplify cli_io_handler_commit_cafile_crlfile() handler function by
retrieving old and new entries at the beginning. In addition the path is
also retrieved at this stage. This removes several switch statements.

Note that the ctx was already validated by the corresponding parsing
function. Thus there is no reason to test the pointers.

While it is not a bug, this patch may help to fix issue #1731.
2022-06-03 09:21:47 +02:00
Christopher Faulet
14df913400 CLEANUP: ssl_ckch: Use corresponding enum for commit_cacrlfile_ctx.cafile_type
There is an enum to determine the entry entry type when changes are
committed on a CA/CRL entry. So use it in the service context instead of an
integer.

This patch may help to fix issue #1731.
2022-06-03 09:21:47 +02:00
Christopher Faulet
33a2745c87 REGTESTS: http_request_buffer: Increase client timeout to wait "slow" clients
The default client timeout is too small to be sure to always wait end of
slow clients (the last 2 clients use a delay to send their request). But it
cannot be increased because it will slow down the regtest execution. So a
dedicated frontend with a higher client timeout has been added. This
frontend is used by "slow" clients. The other one is used for normal
requests.
2022-06-02 14:12:18 +02:00
Christopher Faulet
0f98a156a7 REGTESTS: abortonclose: Add a barrier to not mix up log messages
Depending on the timing, time to time, the log message for "/c4" request can
be received before the one for "/c2" request. To (hopefully) fix the issue,
a barrier has been added to wait "/c2" log message before sending other
requests.
2022-06-02 14:12:18 +02:00
Tim Duesterhus
9fb57e8c17 CLEANUP: Re-apply xalloc_size.cocci (2)
This reapplies the xalloc_size.cocci patch across the whole `src/` tree.

see 16cc16dd82
see 63ee0e4c01
2022-06-02 14:12:18 +02:00
Christopher Faulet
d649b57519 MEDIUM: http-ana: Always report rewrite failures as PRXCOND in logs
Rewrite failures in http rules are reported as proxy errors (PRXCOND) in
logs. However, other rewrite errors are reported as internal errors. For
instance, it happens when we fail to add X-Forwarded-For header. It is not
consistent and it is confusing. So now, all rewite failures are reported as
proxy errors.

This patch may be backported if necessary.
2022-06-02 12:21:32 +02:00