Commit Graph

17861 Commits

Author SHA1 Message Date
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
Christopher Faulet
89f2626c19 MEDIUM: httpclient: Don't close CLI applet at the end of a response
There is no reason to close the CLI applet when the whole response was
dumped. This prevent anyone to use the CLI in interactive mode.
2022-06-01 17:20:57 +02:00
Christopher Faulet
0158bb23d7 BUG/MEDIUM: httpclient: Rework CLI I/O handler to handle full buffer cases
'httpclient' command does not properly handle full buffer cases. When the
response buffer is full, we exit to retry later. However, the context flags
are updated. It means when this happens, we may loose a part of the
response.

So now, flags are preserved when we fail to push data into the response
buffer. In addition, instead of dumping one part per call, we now try to
dump as much data as possible.

Finally, when there is no more data, because everything was dumped or
because we are waiting for more data from the HTTP client, the applet is
updated accordingly by calling applet_have_no_more_data(). Otherwise, when
some data are blocked, applet_putchk() already takes care to update the SE
flags. So, it is useless to call sc_need_room().

This patch should fix the issue #1723. It must be backported as far as
2.5. But a massive refactoring was performed in 2.6. So, for the 2.5 and
below, the patch will have to be adapted.
2022-06-01 17:20:57 +02:00
Christopher Faulet
18de6f2880 BUG/MEDIUM: httpclient: Don't remove HTX header blocks before duplicating them
Commit 534645d6 ("BUG/MEDIUM: httpclient: Fix loop consuming HTX blocks from
the response channel") introduced a regression. When the response is
consumed, The HTX header blocks are removed before duplicating them. Thus,
the first header block is always lost.

This patch must be backported as far as 2.5.
2022-06-01 17:20:57 +02:00
Christopher Faulet
c642d7c131 BUG/MEDIUM: ssl/crt-list: Rework 'add ssl crt-list' to handle full buffer cases
'add ssl crt-list' command is also concerned. This patch is similar to the
previous ones. Full buffer cases when we try to push the reply are not
properly handled. To fix the issue, the functions responsible to add a
crt-list entry were reworked.

First, the error message is now part of the service context. This way, if we
cannot push the error message in the reponse buffer, we may retry later. To
do so, a dedicated state was created (ADDCRT_ST_ERROR,). Then, the success
message is also handled in a dedicated state (ADDCRT_ST_SUCCESS). This way
we are able to retry to push it if necessary. Finally, the dot displayed for
each new instance is now immediatly pushed in the response buffer, and
before the update. This way, we are able to retry too if necessary.

This patch should fix the issue #1724. It must be backported as far as
2.2. But a massive refactoring was performed in 2.6. So, for the 2.5 and
below, the patch will have to be adapted.
2022-06-01 17:20:57 +02:00
Christopher Faulet
e9c3bd1395 BUG/MEDIUM: ssl_ckch: Rework 'commit ssl ca-file' to handle full buffer cases
'commit ssl crl-file' command is also concerned. This patch is similar to
the previous one. Full buffer cases when we try to push the reply are not
properly handled. To fix the issue, the functions responsible to commit CA
or CRL entry changes were reworked.

First, the error message is now part of the service context. This way, if we
cannot push the error message in the reponse buffer, we may retry later. To
do so, a dedicated state was created (CACRL_ST_ERROR). Then, the success
message is also handled in a dedicated state (CACRL_ST_SUCCESS). This way we
are able to retry to push it if necessary. Finally, the dot displayed for
each updated CKCH instance is now immediatly pushed in the response buffer,
and before the update. This way, we are able to retry too if necessary.

This patch should fix the issue #1722. It must be backported as far as
2.5. But a massive refactoring was performed in 2.6. So, for the 2.5, the
patch will have to be adapted.
2022-06-01 17:20:57 +02:00
Christopher Faulet
9d56e248a6 BUG/MEDIUM: ssl_ckch: Rework 'commit ssl cert' to handle full buffer cases
When changes on a certificate are commited, a trash buffer is used to create
the response. Once done, the message is copied in the response buffer.
However, if the buffer is full, there is no way to retry and the message is
lost. The same issue may happen with the error message. It is a design issue
of cli_io_handler_commit_cert() function.

To fix it, the function was reworked. First, the error message is now part
of the service context. This way, if we cannot push the error message in the
reponse buffer, we may retry later. To do so, a dedicated state was created
(CERT_ST_ERROR). Then, the success message is also handled in a dedicated
state (CERT_ST_SUCCESS). This way we are able to retry to push it if
necessary. Finally, the dot displayed for each updated CKCH instance is now
immediatly pushed in the response buffer, and before the update. This way,
we are able to retry too if necessary.

This patch should fix the issue #1725. It must be backported as far as
2.2. But massive refactoring was performed in 2.6. So, for the 2.5 and
below, the patch must be adapted.
2022-06-01 17:20:57 +02:00
Christopher Faulet
1e00c7e8f4 BUG/MINOR: ssl_ckch: Don't duplicate path when replacing a CA/CRL entry
When a CA or CRL entry is replaced (via 'set ssl ca-file' or 'set ssl
crl-file' commands), the path is duplicated and used to identify the ongoing
transaction. However, if the same command is repeated, the path is still
duplicated but the transaction is not changed and the duplicated path is not
released. Thus there is a memory leak.

By reviewing the code, it appears there is no reason to duplicate the
path. It is always the filename path of the old entry. So, a reference on it
is now used. This simplifies the code and this fixes the memory leak.

This patch must be backported as far as 2.5.
2022-06-01 16:28:15 +02:00
Christopher Faulet
e2ef4dd3c5 BUG/MINOR: ssl_ckch: Don't duplicate path when replacing a cert entry
When a certificate entry is replaced (via 'set ssl cert' command), the path
is duplicated and used to identify the ongoing transaction. However, if the
same command is repeated, the path is still duplicated but the transaction
is not changed and the duplicated path is not released. Thus there is a
memory leak.

By reviewing the code, it appears there is no reason to duplicate the
path. It is always the path of the old entry. So, a reference on it is now
used. This simplifies the code and this fixes the memory leak.

This patch must be backported as far as 2.2.
2022-06-01 16:28:15 +02:00