]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMEDIUM: stconn: move the RXBLK flags to the stream connector
Willy Tarreau [Wed, 25 May 2022 14:36:21 +0000 (16:36 +0200)] 
MEDIUM: stconn: move the RXBLK flags to the stream connector

The following flags are not at all related to the endpoint but to the
connector itself:
  - SE_FL_RXBLK_ROOM
  - SE_FL_RXBLK_BUFF
  - SE_FL_RXBLK_CHAN

As such they have no business staying in the endpoint descriptor and
they must move to the stream connector. They've also been renamed
accordingly to better match what they correspond to (the same name
as the function that sets them).

The rare occurrences of cs_rx_blocked() were replaced by an explicit
test on the list of flags. The reason is that cs_rx_blocked() used to
preserve some tests that are not needed at certain places since already
known. For the same reason SE_FL_RXBLK_ANY wasn't converted. As such it
will later be possible to carefully review these few locations and
eliminate the unneeded flags from the tests. No particular function
was made to test them since they're explicit enough.

It now looks like ci_putchk() and friends could very well place the flag
themselves on the connector when they detect a buffer full condition, as
this would significantly simplify the high-level API. But all usages must
first be reviewed before this simplification can be done. For now it
remains done by applet_put*() instead.

3 years agoCLEANUP: stconn: rename SE_FL_RX_WAIT_EP to SE_FL_HAVE_NO_DATA
Willy Tarreau [Wed, 25 May 2022 14:01:38 +0000 (16:01 +0200)] 
CLEANUP: stconn: rename SE_FL_RX_WAIT_EP to SE_FL_HAVE_NO_DATA

It's more explicit this way. The cs_rx_endp_ready() function could be
removed so that the flag is directly tested. In the future it should
be inverted and the few places where it's set (or preserved via
SE_FL_APP_MASK) could be dropped.

3 years agoMINOR: stconn: add sc_is_recv_allowed() to check for ability to receive
Willy Tarreau [Wed, 25 May 2022 13:00:44 +0000 (15:00 +0200)] 
MINOR: stconn: add sc_is_recv_allowed() to check for ability to receive

At plenty of places we combine multiple flags checks to determine if we
can receive (endp_ready, rx_blocked, cf_shutr etc). Let's group them
under a single function that is meant to replace existing tests.

Some tests were only checking the rxblk flags at the connection level,
so for now they were not converted, this requires a bit of auditing
first, and probably a test to determine whether or not to check for
cf_shutr (e.g. there is none if no stream is present).

3 years agoMINOR: stconn: start to rename cs_rx_endp_{more,done}() to se_have_{no_,}more_data()
Willy Tarreau [Wed, 25 May 2022 13:42:03 +0000 (15:42 +0200)] 
MINOR: stconn: start to rename cs_rx_endp_{more,done}() to se_have_{no_,}more_data()

The analysis of cs_rx_endp_more() showed that the purpose is for a stream
endpoint to inform the connector that it's ready to deliver more data to
that one, and conversely cs_rx_endp_done() that it's done delivering data
so it should not be bothered again for this.

This was modified two ways:
  - the operation is no longer performed on the connector but on the
    endpoint so that there is no more doubt when reading applet code
    about what this rx refers to; it's the endpoint that has more or
    no more data.

  - an applet implementation is also provided and mostly used from
    applet code since it saves the caller from having to access the
    endpoint descriptor.

It's visible that the flag ought to be inverted because some places
have to set it by default for no reason.

3 years agoCLEANUP: stconn: rename cs_rx_buff_{blk,rdy} to sc_{need,have}_buff()
Willy Tarreau [Wed, 25 May 2022 05:48:07 +0000 (07:48 +0200)] 
CLEANUP: stconn: rename cs_rx_buff_{blk,rdy} to sc_{need,have}_buff()

These functions are used by the application layer to disable or enable
reading at the stream connector's level when the input buffer failed to
be allocated (or was finally allocated). The new names makes things
clearer.

3 years agoCLEANUP: stconn: rename cs_rx_chan_{blk,rdy} to sc_{wont,will}_read()
Willy Tarreau [Wed, 25 May 2022 05:35:53 +0000 (07:35 +0200)] 
CLEANUP: stconn: rename cs_rx_chan_{blk,rdy} to sc_{wont,will}_read()

These functions were used by the channel to inform the lower layer
whether reading was acceptable or not. Usually this directly mimmicks
the CF_DONT_READ flag from the channel, which may be set when it's
desired not to buffer incoming data that will not be processed, or
that the buffer wants to be flushed before starting to read again,
or that bandwidth limiting might be enforced, etc. It's always a
policy reason, not a purely resource-based one.

3 years agoCLEANUP: stconn: rename cs_rx_room_{blk,rdy} to sc_{need,have}_room()
Willy Tarreau [Wed, 25 May 2022 05:29:36 +0000 (07:29 +0200)] 
CLEANUP: stconn: rename cs_rx_room_{blk,rdy} to sc_{need,have}_room()

The new name mor eclearly indicates that a stream connector cannot make
any more progress because it needs room in the channel buffer, or that
it may be unblocked because the buffer now has more room available. The
testing function is sc_waiting_room(). This is mostly used by applets.
Note that the flags will change soon.

3 years agoMEDIUM: stconn: take SE_FL_APPLET_NEED_CONN out of the RXBLK_ANY flags
Willy Tarreau [Tue, 24 May 2022 14:56:55 +0000 (16:56 +0200)] 
MEDIUM: stconn: take SE_FL_APPLET_NEED_CONN out of the RXBLK_ANY flags

This makes SE_FL_APPLET_NEED_CONN autonomous, in that we check for it
everywhere we have a relevant cs_rx_blocked(), so that the flag doesn't
need anymore to be covered by cs_rx_blocked(). Indeed, this flag doesn't
really translate a receive blocking condition but rather a refusal to
wake up an applet that is waiting for a connection to finish to setup.

This also ensures we will not risk to set it back on a new endpoint
after cs_reset_endp() via SE_FL_APP_MASK, because the flag being
specific to the endpoint only and not to the connector, we don't
want to preserve it when replacing the endpoint.

It's possible that cs_chk_rcv() could later be further simplified if
we can demonstrate that the two tests in it can be merged.

3 years agoMINOR: stconn: rename SE_FL_RXBLK_CONN to SE_FL_APPLET_NEED_CONN
Willy Tarreau [Tue, 24 May 2022 14:49:03 +0000 (16:49 +0200)] 
MINOR: stconn: rename SE_FL_RXBLK_CONN to SE_FL_APPLET_NEED_CONN

This flag is exclusively used when a front applet needs to wait for the
other side to connect (or fail to). Let's give it a more explicit name
and remove the ambiguous function that was used only once.

This also ensures we will not risk to set it back on a new endpoint
after cs_reset_endp() via SE_FL_APP_MASK, because the flag being
specific to the endpoint only and not to the connector, we don't
want to preserve it when replacing the endpoint.

3 years agoMEDIUM: stconn: remove SE_FL_RXBLK_SHUT
Willy Tarreau [Tue, 24 May 2022 14:22:24 +0000 (16:22 +0200)] 
MEDIUM: stconn: remove SE_FL_RXBLK_SHUT

This flag is no more needed, it was only set on shut read to be tested
by cs_rx_blocked() which is now properly tested for shutr as well. The
cs_rx_blk_shut() calls were removed. Interestingly it allowed to remove
a special case in the L7 retry code.

This also ensures we will not risk to set it back on a new endpoint
after cs_reset_endp() via SE_FL_APP_MASK.

3 years agoMEDIUM: stconn: always rely on CF_SHUTR in addition to cs_rx_blocked()
Willy Tarreau [Tue, 24 May 2022 14:18:11 +0000 (16:18 +0200)] 
MEDIUM: stconn: always rely on CF_SHUTR in addition to cs_rx_blocked()

One flag (RXBLK_SHUT) is always set with CF_SHUTR, so in order to remove
it, we first need to make sure we always check for CF_SHUTR where
cs_rx_blocked() is being used.

3 years agoMINOR: stconn: remove calls to cs_done_get()
Willy Tarreau [Tue, 24 May 2022 08:39:15 +0000 (10:39 +0200)] 
MINOR: stconn: remove calls to cs_done_get()

It was only called after setting SHUTW on the output channel, and since
it's now handled by sc_is_send_allowed() we don't need it anymore.

3 years agoMINOR: stconn: consider CF_SHUTW for sc_is_send_allowed()
Willy Tarreau [Tue, 24 May 2022 07:11:17 +0000 (09:11 +0200)] 
MINOR: stconn: consider CF_SHUTW for sc_is_send_allowed()

When a shutdown(WR) is performed, send is no longer allowed, and that is
currently handled by the explicit cs_done_get() in the various shutw()
calls. That's a bit ugly and complicated for no reason, let's simply
integrate the test of SHUTW in sc_is_send_allowed().

Note that the test could also be added wherever sc_is_send_allowed() is
used but for now proceeding like this limits the changes.

3 years agoCLEANUP: stconn: use a single function to know if SC may send to SE
Willy Tarreau [Tue, 24 May 2022 06:49:24 +0000 (08:49 +0200)] 
CLEANUP: stconn: use a single function to know if SC may send to SE

sc_is_send_allowed() is now used everywhere instead of the combination
of cs_tx_endp_ready() && !cs_tx_blocked(). There's no place where we
need them individually thus it's simpler. The test was placed in cs_util
as we'll complete it later.

3 years agoCLEANUP: stconn: make a few functions take a const argument
Willy Tarreau [Tue, 24 May 2022 07:08:33 +0000 (09:08 +0200)] 
CLEANUP: stconn: make a few functions take a const argument

A number of functions in cs_utils.h are not usable from functions taking
a const because they're not declared as using const, despite never
modifying the stconn. Let's address this for the following ones:

  sc_ic(), sc_oc(), sc_ib(), sc_ob(), sc_strm_task(),
  cs_opposite(), sc_conn_ready(), cs_src(), cs_dst(),

3 years agoCLEANUP: stconn: rename cs_ep_set_error() to se_fl_set_error()
Willy Tarreau [Wed, 18 May 2022 16:15:18 +0000 (18:15 +0200)] 
CLEANUP: stconn: rename cs_ep_set_error() to se_fl_set_error()

First it applies to the stream endpoint and not the conn_stream, and
second it only tests and touches the flags so it makes sense to call
it se_fl_ like other functions which only manipulate the flags, as
it's just a special case of flags.

3 years agoCLEANUP: stconn: rename cs_conn_get_first() to conn_get_first_sc()
Willy Tarreau [Wed, 18 May 2022 16:11:27 +0000 (18:11 +0200)] 
CLEANUP: stconn: rename cs_conn_get_first() to conn_get_first_sc()

It returns an stconn from a connection and not the opposite, so the name
change was more appropriate. In addition it was moved to connection.h
which manipulates the connection stuff, and it happens that only
connection.c uses it.

3 years agoCLEANUP: stconn: rename cs_conn_*() to sc_conn_*()
Willy Tarreau [Wed, 18 May 2022 16:06:53 +0000 (18:06 +0200)] 
CLEANUP: stconn: rename cs_conn_*() to sc_conn_*()

The following functions which act on a connection-based stream connector
were renamed to sc_conn_* (~60 places):

  cs_conn_drain_and_shut
  cs_conn_process
  cs_conn_read0
  cs_conn_ready
  cs_conn_recv
  cs_conn_send
  cs_conn_shut
  cs_conn_shutr
  cs_conn_shutw

3 years agoCLEANUP: stconn: rename cs_get_data_name() to sc_get_data_name()
Willy Tarreau [Wed, 18 May 2022 16:00:31 +0000 (18:00 +0200)] 
CLEANUP: stconn: rename cs_get_data_name() to sc_get_data_name()

Only used twice to dump stream debug info.

3 years agoCLEANUP: stconn: rename __cs_endp_target() to __sc_endp()
Willy Tarreau [Wed, 18 May 2022 15:56:13 +0000 (17:56 +0200)] 
CLEANUP: stconn: rename __cs_endp_target() to __sc_endp()

The function returns the real stream endpoint so since there's no more
confusion around the terminology, let's drop "target".

3 years agoCLEANUP: stconn: rename cs_appctx() to sc_appctx()
Willy Tarreau [Wed, 18 May 2022 15:58:02 +0000 (17:58 +0200)] 
CLEANUP: stconn: rename cs_appctx() to sc_appctx()

Nothing special, just s/cs/sc/, roughly 50-60 entries.

3 years agoCLEANUP: stconn: rename cs_conn_mux() to sc_mux_ops()
Willy Tarreau [Wed, 18 May 2022 15:51:19 +0000 (17:51 +0200)] 
CLEANUP: stconn: rename cs_conn_mux() to sc_mux_ops()

This effectively returns the mux_ops from the connection when it exists
on an stconn.

3 years agoCLEANUP: stconn: rename cs_mux() to sc_mux_strm()
Willy Tarreau [Wed, 18 May 2022 14:28:02 +0000 (16:28 +0200)] 
CLEANUP: stconn: rename cs_mux() to sc_mux_strm()

The function doesn't return a pointer to the mux but to the mux stream
(h1s, h2s etc). Let's adjust its name to reflect this. It's rarely used,
the name can be enlarged a bit. And of course s/cs/sc to accommodate for
the updated name.

3 years agoCLEANUP: stconn: rename cs_conn() to sc_conn()
Willy Tarreau [Wed, 18 May 2022 14:23:22 +0000 (16:23 +0200)] 
CLEANUP: stconn: rename cs_conn() to sc_conn()

It's mostly used from upper layers. Both the checked and unchecked
functions were updated, or ~150 entries.

3 years agoCLEANUP: stconn: rename cs_{check,strm,strm_task} to sc_strm_*
Willy Tarreau [Wed, 18 May 2022 14:10:52 +0000 (16:10 +0200)] 
CLEANUP: stconn: rename cs_{check,strm,strm_task} to sc_strm_*

These functions return the app-layer associated with an stconn, which
is a check, a stream or a stream's task. They're used a lot to access
channels, flags and for waking up tasks. Let's just name them
appropriately for the stream connector.

3 years agoCLEANUP: stconn: rename cs_{i,o}{b,c} to sc_{i,o}{b,c}
Willy Tarreau [Wed, 18 May 2022 13:55:18 +0000 (15:55 +0200)] 
CLEANUP: stconn: rename cs_{i,o}{b,c} to sc_{i,o}{b,c}

We're starting to propagate the stream connector's new name through the
API. Most call places of these functions that retrieve the channel or its
buffer are in applets. The local variable names are not changed in order
to keep the changes small and reviewable. There were ~92 uses of cs_ic(),
~96 of cs_oc() (due to co_get*() being less factorizable than ci_put*),
and ~5 accesses to the buffer itself.

3 years agoCLEANUP: applet: use applet_put*() everywhere possible
Willy Tarreau [Wed, 18 May 2022 13:07:19 +0000 (15:07 +0200)] 
CLEANUP: applet: use applet_put*() everywhere possible

This applies the change so that the applet code stops using ci_putchk()
and friends everywhere possible, for the much saferapplet_put*() instead.
The change is mechanical but large. Two or three functions used to have no
appctx and a cs derived from the appctx instead, which was a reminiscence
of old times' stream_interface. These were simply changed to directly take
the appctx. No sensitive change was performed, and the old (more complex)
API is still usable when needed (e.g. the channel is already known).

The change touched roughly a hundred of locations, with no less than 124
lines removed.

It's worth noting that the stats applet, the oldest of the series, could
get a serious lifting, as it's still very channel-centric instead of
propagating the appctx along the chain. Given that this code doesn't
change often, there's no emergency to clean it up but it would look
better.

3 years agoMINOR: applet: add new wrappers to put chk/blk/str/chr to channel from appctx
Willy Tarreau [Wed, 18 May 2022 09:38:31 +0000 (11:38 +0200)] 
MINOR: applet: add new wrappers to put chk/blk/str/chr to channel from appctx

The vast majority of calls to ci_putchk() etc are performed from applets
which directly know an endpoint. Figuring the correct API (writing into
input channel etc) isn't trivial for newcomers, and knowing that they
must mark the flag indicating a buffer full condition isn't trivial
either.

Here we're adding wrappers to these functions but to be used directly
from the appctx. That's already what is being done in multiple steps in
the applet code, where the endp is derived from the appctx, then the cs
from the endp, then the stream from the cs, then the channel from the
stream, and so on. But this time the function doesn't require to know
much of the internals, applet_putchr() writes a char from the appctx,
and marks the buffer full if needed. Period. This will allow to remove
a significant amount of obscure ci_putchk() and cs_ic() calls from the
code, hence a significant number of possible mistakes.

3 years agoMEDIUM: stconn: merge the app_ops and the data_cb fields
Willy Tarreau [Wed, 18 May 2022 08:17:16 +0000 (10:17 +0200)] 
MEDIUM: stconn: merge the app_ops and the data_cb fields

For historical reasons (stream-interface and connections), we used to
require two independent fields for the application level callbacks and
the transport-level functions. Over time the distinction faded away so
much that the low-level functions became specific to the application
and conversely. For example, applets may only work with streams on top
since they rely on the channels, and the stream-level functions differ
between applets and connections. Right now the application level only
contains a wake() callback and the low-level ones contain the functions
that act at the lower level to perform the shutr/shutw and at the upper
level to notify about readability and writability. Let's just merge them
together into a single set and get rid of this confusing distinction.
Note that the check ops do not define any app-level function since these
are only called by streams.

3 years agoMINOR: conn_stream: test the various ops functions before calling them
Willy Tarreau [Tue, 24 May 2022 06:17:58 +0000 (08:17 +0200)] 
MINOR: conn_stream: test the various ops functions before calling them

We currently call all ->shutr, ->chk_snd etc from ->ops unconditionally,
while the ->wake() call from data_cb is checked. Better check ops as
well for consistency, this will help get them merged.

3 years agoMINOR: check: export wake_srv_chk()
Willy Tarreau [Wed, 18 May 2022 07:11:52 +0000 (09:11 +0200)] 
MINOR: check: export wake_srv_chk()

We'll need it to centralize the stream connectors definitions.

3 years agoCLEANUP: stconn: tree-wide rename stconn states CS_ST/SB_* to SC_ST/SB_*
Willy Tarreau [Tue, 17 May 2022 17:47:17 +0000 (19:47 +0200)] 
CLEANUP: stconn: tree-wide rename stconn states CS_ST/SB_* to SC_ST/SB_*

This also follows the natural naming. There are roughly 238 changes, all
totally trivial. conn_stream-t.h has become completely void of any
"conn_stream" related stuff now (except its name).

3 years agoCLEANUP: stconn: tree-wide rename stream connector flags CS_FL_* to SC_FL_*
Willy Tarreau [Tue, 17 May 2022 17:44:42 +0000 (19:44 +0200)] 
CLEANUP: stconn: tree-wide rename stream connector flags CS_FL_* to SC_FL_*

This follows the natural naming. There are roughly 100 changes, all
totally trivial.

3 years agoCLEANUP: stream: rename "csf" and "csb" to "scf" and "scb"
Willy Tarreau [Tue, 17 May 2022 17:40:40 +0000 (19:40 +0200)] 
CLEANUP: stream: rename "csf" and "csb" to "scf" and "scb"

These are the stream connectors, let's give them consistent names. The
patch is large (405 locations) but totally trivial.

3 years agoCLEANUP: stdesc: rename the stream connector ->cs field to ->sc
Willy Tarreau [Wed, 18 May 2022 05:43:52 +0000 (07:43 +0200)] 
CLEANUP: stdesc: rename the stream connector ->cs field to ->sc

This is a rename of this field. Most of the places were in muxes, but
were already factored with the previous series adding *_sc().

3 years agoCLEANUP: mux-pt: add and use pt_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:36:10 +0000 (07:36 +0200)] 
CLEANUP: mux-pt: add and use pt_sc() to retrieve the stream connector

This is better and easier to adapt than pt->endp->cs.

3 years agoCLEANUP: mux-fcgi: add and use fcgi_strm_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:34:16 +0000 (07:34 +0200)] 
CLEANUP: mux-fcgi: add and use fcgi_strm_sc() to retrieve the stream connector

This is better and easier to adapt than fstrm->endp->cs.

3 years agoCLEANUP: mux-h2: add and use h2s_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:31:41 +0000 (07:31 +0200)] 
CLEANUP: mux-h2: add and use h2s_sc() to retrieve the stream connector

This is better and easier to adapt than h2s->endp->cs.

3 years agoCLEANUP: mux-h1: add and use h1s_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:27:14 +0000 (07:27 +0200)] 
CLEANUP: mux-h1: add and use h1s_sc() to retrieve the stream connector

This is better and easier to adapt than h1s->endp->cs.

3 years agoCLEANUP: conn_stream: tree-wide rename to stconn (stream connector)
Willy Tarreau [Tue, 17 May 2022 17:07:51 +0000 (19:07 +0200)] 
CLEANUP: conn_stream: tree-wide rename to stconn (stream connector)

This renames the "struct conn_stream" to "struct stconn" and updates
the descriptions in all comments (and the rare help descriptions) to
"stream connector" or "connector". This touches a lot of files but
the change is minimal. The local variables were not even renamed, so
there's still a lot of "cs" everywhere.

3 years agoCLEANUP: conn_stream: rename cs_app_* to sc_app_*
Willy Tarreau [Tue, 17 May 2022 16:28:19 +0000 (18:28 +0200)] 
CLEANUP: conn_stream: rename cs_app_* to sc_app_*

Let's start to introduce the stream connector at the app_ops level.
This is entirely self-contained into conn_stream.c. The functions
were also updated to reflect the new name, and the comments were
updated.

3 years agoCLEANUP: conn_stream: rename the conn_stream's endp to sedesc
Willy Tarreau [Tue, 17 May 2022 16:20:02 +0000 (18:20 +0200)] 
CLEANUP: conn_stream: rename the conn_stream's endp to sedesc

Just like for the appctx, this is a pointer to a stream endpoint descriptor,
so let's make this explicit and not confuse it with the full endpoint. There
are very few changes thanks to the preliminary refactoring of the flags
manipulation.

3 years agoCLEANUP: applet: rename the sedesc pointer from "endp" to "sedesc"
Willy Tarreau [Tue, 17 May 2022 16:05:31 +0000 (18:05 +0200)] 
CLEANUP: applet: rename the sedesc pointer from "endp" to "sedesc"

Now at least it makes it obvious that it's the stream endpoint descriptor
and not an endpoint. There were few changes thanks to the previous refactor
of the flags.

3 years agoCLEANUP: conn_stream: rename cs_endpoint to sedesc (stream endpoint descriptor)
Willy Tarreau [Tue, 17 May 2022 15:53:22 +0000 (17:53 +0200)] 
CLEANUP: conn_stream: rename cs_endpoint to sedesc (stream endpoint descriptor)

After some discussion we found that the cs_endpoint was precisely the
descriptor for a stream endpoint, hence the naturally coming name,
stream endpoint constructor.

This patch renames only the type everywhere and the new/init/free functions
to remain consistent with it. Future patches will address field names and
argument names in various code areas.

3 years agoCLEANUP: conn_stream: rename the cs_endpoint's target to "se"
Willy Tarreau [Mon, 16 May 2022 15:29:42 +0000 (17:29 +0200)] 
CLEANUP: conn_stream: rename the cs_endpoint's target to "se"

That's the "stream endpoint" pointer. Let's change it now while it's
not much spread. The function __cs_endp_target() wasn't yet renamed
because that will change more globally soon.

3 years agoCLEANUP: conn_stream: rename the stream endpoint flags CS_EP_* to SE_FL_*
Willy Tarreau [Tue, 17 May 2022 15:04:55 +0000 (17:04 +0200)] 
CLEANUP: conn_stream: rename the stream endpoint flags CS_EP_* to  SE_FL_*

Let's now use the new flag names for the stream endpoint.

3 years agoCLEANUP: conn_stream: apply endp_flags.cocci tree-wide
Willy Tarreau [Tue, 17 May 2022 14:31:36 +0000 (16:31 +0200)] 
CLEANUP: conn_stream: apply endp_flags.cocci tree-wide

This changes all main uses of endp->flags to the se_fl_*() equivalent
by applying coccinelle script endp_flags.cocci. The se_fl_*() functions
themselves were manually excluded from the change, of course.

Note: 144 locations were touched, manually reviewed and found to be OK.

The script was applied with all includes:

  spatch --in-place --recursive-includes -I include --sp-file $script $files

3 years agoDEV: coccinelle: add endp_flags.cocci
Willy Tarreau [Tue, 17 May 2022 14:30:44 +0000 (16:30 +0200)] 
DEV: coccinelle: add endp_flags.cocci

This one turns the various forms of "endp->flags <op> value" to their
se_fl_<op>(cs) equivalent. That's basically the same as the previous
one except that it acts on the stream endpoint itself instead of the
conn_stream.

3 years agoCLEANUP: conn_stream: apply cs_endp_flags.cocci tree-wide
Willy Tarreau [Tue, 17 May 2022 14:10:17 +0000 (16:10 +0200)] 
CLEANUP: conn_stream: apply cs_endp_flags.cocci tree-wide

This changes all main uses of cs->endp->flags to the sc_ep_*() equivalent
by applying coccinelle script cs_endp_flags.cocci.

Note: 143 locations were touched, manually reviewed and found to be OK,
except a single one that was adjusted in cs_reset_endp() where the flags
are read and filtered to be used as-is and not as a boolean, hence was
replaced with sc_ep_get() & $FLAGS.

The script was applied with all includes:

  spatch --in-place --recursive-includes -I include --sp-file $script $files

3 years agoDEV: coccinelle: add cs_endp_flags.cocci
Willy Tarreau [Tue, 17 May 2022 14:08:36 +0000 (16:08 +0200)] 
DEV: coccinelle: add cs_endp_flags.cocci

This one turns the various forms of "cs->endp->flags <op> value" to
their sc_ep_<op>(cs) equivalent.

3 years agoMINOR: conn_stream: add new sets of functions to set/get endpoint flags
Willy Tarreau [Tue, 17 May 2022 13:39:33 +0000 (15:39 +0200)] 
MINOR: conn_stream: add new sets of functions to set/get endpoint flags

At plenty of places we need to manipulate the conn_stream's endpoint just
to set or clear a flag. This patch adds a handful of functions to perform
the common operations (clr/set/get etc) on these flags at both the endpoint
and at the conn_stream level.

The functions were named after the target names, i.e. se_fl_*() to act on
the stream endpoint flags, and sc_ep_* to manipulate the endpoint flags
from the stream connector (currently conn_stream).

For now they're not used.

3 years agoCLEANUP: conn_stream: rename the cs_endpoint's context to "conn"
Willy Tarreau [Mon, 16 May 2022 15:17:16 +0000 (17:17 +0200)] 
CLEANUP: conn_stream: rename the cs_endpoint's context to "conn"

This one is exclusively used by the connection, regardless its generic
name "ctx" is rather confusing. Let's make it a struct connection* and
call it "conn". This way there's no doubt about what it is and there's
no way it will be used by accident by being taken for something else.

3 years agoCLEANUP: conn_stream: remove unneeded exclusion of RX_WAIT_EP from RXBLK_ANY
Willy Tarreau [Tue, 24 May 2022 06:03:26 +0000 (08:03 +0200)] 
CLEANUP: conn_stream: remove unneeded exclusion of RX_WAIT_EP from RXBLK_ANY

This test in cs_update_rx() was introduced in 1.9 by commit b26a6f970
("MEDIUM: stream-int: make use of si_rx_chan_{rdy,blk} to control the
stream-int from the channel"), but by then already it was not needed
because the RX_WAIT_EP flag has never been part of RXBLK_ANY so there's
no point doing "flags & RXBLK_ANY & ~RX_WAIT_EP", that part is already
complicated enough like this.

3 years agoREGTESTS: Do not use REQUIRE_VERSION for HAProxy 2.5+ (2)
Tim Duesterhus [Mon, 23 May 2022 20:45:36 +0000 (22:45 +0200)] 
REGTESTS: Do not use REQUIRE_VERSION for HAProxy 2.5+ (2)

Introduced in:

18c13d3bd MEDIUM: http-ana: Add a proxy option to restrict chars in request header names

see also:

fbbbc33df REGTESTS: Do not use REQUIRE_VERSION for HAProxy 2.5+

3 years agoBUG/MEDIUM: sample: Fix adjusting size in word converter
Thayne McCombs [Thu, 26 May 2022 04:58:51 +0000 (22:58 -0600)] 
BUG/MEDIUM: sample: Fix adjusting size in word converter

Adjust the size of the sample buffer before we change the "area"
pointer. Otherwise, we end up not changing the size, because the area
pointer is already the same as "start" before we compute the difference
between the two.

This is similar to the change in b28430591d18f7fda5bac2e0ea590b3a34f04601
but for the word converter instead of field.

3 years agoBUG/MINOR: ssl/lua: use correctly cert_ext in CertCache.set()
William Lallemand [Thu, 26 May 2022 09:20:13 +0000 (11:20 +0200)] 
BUG/MINOR: ssl/lua: use correctly cert_ext in CertCache.set()

Fix a typo that lead to using the wrong pointer when loading a
certificate, which lead to always using the pem loader for every
parameeter.

Use the cert_ext->load() ptr instead of cert_exts->load() which was the
first element of the cert_exts[] array.

Enhance the error message with the field name.

Should fix issue #1716

3 years agoCLEANUP: init: address another coverity warning about a possible multiply overflow
Willy Tarreau [Thu, 26 May 2022 06:55:05 +0000 (08:55 +0200)] 
CLEANUP: init: address another coverity warning about a possible multiply overflow

Commit 2cb3be76b ("CLEANUP: init: address a coverity warning about
possible multiply overflow") was incomplete, two other locations were
present. This should address issue #1585.

3 years agoDOC: configuration: add a warning for @system-ca on bind
William Lallemand [Wed, 25 May 2022 22:18:46 +0000 (00:18 +0200)] 
DOC: configuration: add a warning for @system-ca on bind

Add a warning on @system-ca on the bind line so people don't use it this
way.

3 years agoRevert "BUG/MINOR: task: Don't defer tasks release when HAProxy is stopping"
Christopher Faulet [Wed, 25 May 2022 14:30:41 +0000 (16:30 +0200)] 
Revert "BUG/MINOR: task: Don't defer tasks release when HAProxy is stopping"

This reverts commit d9404b464faae3340ac1745b594929e4b7edd650.

In fact, there is a BUG_ON() in __task_free() function to be sure the task
is no longer in the wait-queue or the run-queue. Because the patch tries to
fix a "leak" on deinit, it is safer to revert it. there is no reason to
introduce potential bug for this kind of issues. And there is no reason to
impact the normal use-cases at runtime with additionnal conditions to only
remove a task on deinit.

3 years agoMINOR: h3: refactor SETTINGS parsing/error reporting
Amaury Denoyelle [Tue, 24 May 2022 16:16:49 +0000 (18:16 +0200)] 
MINOR: h3: refactor SETTINGS parsing/error reporting

Bring some improvment to h3_parse_settings_frm() function. The first one
is the parsing which now manipulates a buffer instead of a plain char*.
This is more to unify with other parsing functions rather than dealing
with data wrapping : it's unlikely to happen as SETTINGS is only
received as the first frame on the control STREAM.

Various errors are now properly reported as connection error :
* on incomplete frame payload
* on a duplicated settings in the same frame
* on reserved settings receive

3 years agoMINOR: h3: abort read on unknown uni stream
Amaury Denoyelle [Tue, 24 May 2022 15:22:07 +0000 (17:22 +0200)] 
MINOR: h3: abort read on unknown uni stream

As specified by HTTP/3 draft, an unknown unidirectional stream can be
aborted. To do this, use a new flag QC_SF_READ_ABORTED. When the MUX
detects this flag, QCS instance is automatically freed.

Previously, such streams were instead automatically drained. By aborting
them, we economize some useless memcpy instruction. On future data
reception, QCS instance is not found in the tree and considered as
already closed. The frame payload is thus deleted without copying it.

3 years agoCLEANUP: h3: remove h3 uni tasklet
Amaury Denoyelle [Tue, 24 May 2022 14:27:41 +0000 (16:27 +0200)] 
CLEANUP: h3: remove h3 uni tasklet

Remove all unnecessary bits of code for H3 unidirectional streams. Most
notable, an individual tasklet is not require anymore for each stream.
This is useless since the merge of RX/TX uni streams handling with
bidirectional streams code.

3 years agoMEDIUM: quic: refactor uni streams RX
Amaury Denoyelle [Tue, 24 May 2022 13:26:07 +0000 (15:26 +0200)] 
MEDIUM: quic: refactor uni streams RX

The whole QUIC stack is impacted by this change :
* at quic-conn level, a single function is now used to handle uni and
  bidirectional streams. It uses qcc_recv() function from MUX.
* at MUX level, qc_recv() io-handler function does not skip uni streams
* most changes are conducted at app layer. Most notably, all received
  data is handle by decode_qcs operation.

Now that decode_qcs is the single app read function, the H3 layer can be
simplified. Uni streams parsing was extracted from h3_attach_ruqs() to
h3_decode_qcs().

h3_decode_qcs() is able to deal with all HTTP/3 frame types. It first
check if the frame is valid for the H3 stream type. Most notably,
SETTINGS parsing was moved from h3_control_recv() into h3_decode_qcs().

This commit has some major benefits besides removing duplicated code.
Mainly, QUIC flow control is now enforced for uni streams as with bidi
streams. Also, an unknown frame received on control stream does not set
an error : it is now silently ignored as required by the specification.

Some cleaning in H3 code is already done with this patch :
h3_control_recv() and h3_attach_ruqs() are removed as they are now
unused. A final patch should clean up the unneeded remaining bit.

3 years agoMINOR: h3: define non-h3 generic parsing function
Amaury Denoyelle [Tue, 24 May 2022 13:25:19 +0000 (15:25 +0200)] 
MINOR: h3: define non-h3 generic parsing function

Define a new function h3_parse_uni_stream_no_h3(). It can be used to
handle the payload of streams which does not convey H3 frames. This is
mainly useful for QPACK encoder/decoder streams. It can also be used for
a stream of unknown type which should be drain without parsing it.

This patch is useful to extract code in a dedicated function. It will be
simple to reuse it in h3_decode_qcs() when uni-streams reception is
unify with bidirectional streams, without using dedicated stream tasklet.

3 years agoMINOR: h3: check if frame is valid for stream type
Amaury Denoyelle [Tue, 24 May 2022 13:24:32 +0000 (15:24 +0200)] 
MINOR: h3: check if frame is valid for stream type

Define a new function h3_is_frame_valid(). It returns if a frame is
valid or not depending on the stream which received it.

For the moment, it is used in h3_decode_qcs() which only deals with
bidirectional streams. Soon, uni streams will use the same function,
rendering the frame type check useful.

3 years agoMINOR: h3: refactor uni streams initialization
Amaury Denoyelle [Tue, 24 May 2022 13:14:53 +0000 (15:14 +0200)] 
MINOR: h3: refactor uni streams initialization

Define a new function h3_init_uni_stream(). This can be used to read the
stream type of an unidirectional stream. There is no functional change
with previous code.

This patch will be useful to unify reception for uni streams with
bidirectional ones.

3 years agoMINOR: h3: define stream type
Amaury Denoyelle [Tue, 24 May 2022 13:24:03 +0000 (15:24 +0200)] 
MINOR: h3: define stream type

Define a new enum h3s_t. This is used to differentiate between the
different stream types used in a HTTP/3 connection, including the QPACK
encoder/decoder streams.

For the moment, only bidirectional streams is positioned. This patch
will be useful to unify reception of uni streams with bidirectional
ones.

3 years agoMINOR: h3/qpack: use qcs as type in decode callbacks
Amaury Denoyelle [Mon, 23 May 2022 12:25:53 +0000 (14:25 +0200)] 
MINOR: h3/qpack: use qcs as type in decode callbacks

Replace h3_uqs type by qcs in stream callbacks. This change is done in
the context of unification between bidi and uni-streams. h3_uqs type
will be unneeded when this is achieved.

3 years agoBUG/MINOR: mux-quic: refactor uni streams TX/send H3 SETTINGS
Amaury Denoyelle [Mon, 23 May 2022 09:39:14 +0000 (11:39 +0200)] 
BUG/MINOR: mux-quic: refactor uni streams TX/send H3 SETTINGS

Remove the unneeded skip over unidirectional streams in qc_send(). This
unify sending for both uni and bidi streams.

In fact, the only local unidirectional streams in use for the moment is
the H3 Control stream responsible of SETTINGS emission. The frame was
already properly generated in qcs.tx.buf, but not send due to stream
skip in qc_send(). Now, there is no need to ignore uni streams so remove
this condition.

This fixes the emission of H3 settings which is now properly emitted.

Uni and bidi streams use the same set of funtcions for sending. One of
the most notable gain is that flow-control is now enforced for uni
streams.

3 years agoMINOR: mux-quic: emit STREAM_STATE_ERROR in qcc_recv
Amaury Denoyelle [Mon, 23 May 2022 14:12:49 +0000 (16:12 +0200)] 
MINOR: mux-quic: emit STREAM_STATE_ERROR in qcc_recv

Emit STREAM_STATE_ERROR connection error in two cases :
* if receiving data for send-only stream
* if receiving data on a locally initiated stream not open yet

For the moment the first case cannot be encoutered as uni streams
reception does not use qcc_recv(). However, this will be soon
implemented with the unification between bidi and uni streams.

3 years agoMINOR: h3: reject too big frames
Amaury Denoyelle [Tue, 24 May 2022 09:13:46 +0000 (11:13 +0200)] 
MINOR: h3: reject too big frames

The whole frame payload must have been received to demux a H3 frames,
except for H3 DATA which can be fragmented into multiple HTX blocks.

If the frame is bigger than the buffer and is not a DATA frame, a
connection error is reported with error H3_EXCESSIVE_LOAD.

This should be completed in the future with the H3 settings to limit the
size of uncompressed header section.

This code is more generic : it can handle every H3 frames. This is done
in order to be able to use h3_decode_qcs() to demux both uni and bidir
streams.

3 years agoMINOR: mux-quic: disable read on CONNECTION_CLOSE emission
Amaury Denoyelle [Tue, 24 May 2022 12:47:48 +0000 (14:47 +0200)] 
MINOR: mux-quic: disable read on CONNECTION_CLOSE emission

Similar to sending, read operations are disabled when a CONNECTION_CLOSE
frame has been emitted.

Most notably, this prevents unneeded loop demuxing when the H3 layer has
issue an error and cannot process the buffer payload anymore.

Note that read is not prevented for unidirectional streams for the
moment. This will supported soon with the unification of bidir and uni
streams treatment.

3 years agoMINOR: quic: support CONNECTION_CLOSE_APP emission
Amaury Denoyelle [Mon, 23 May 2022 14:12:15 +0000 (16:12 +0200)] 
MINOR: quic: support CONNECTION_CLOSE_APP emission

Complete quic-conn API for error reporting. A new parameter <app> is
defined in the function quic_set_connection_close(). This will transform
the frame into a CONNECTION_CLOSE_APP type.

This type of frame will be generated by the applicative layer, h3 or
hq-interop for the moment. A new function qcc_emit_cc_app() is exported
by the MUX layer for them.

3 years agoMINOR: h3: refactor h3_control_send()
Amaury Denoyelle [Tue, 24 May 2022 13:06:10 +0000 (15:06 +0200)] 
MINOR: h3: refactor h3_control_send()

The only change is that the H3_CF_SETTINGS_SENT flag if-condition is
replaced by a BUG_ON statement. This may help to catch multiple calls on
h3_control_send() instead of silently ignore them.

3 years agoBUG/MINOR: h3: prevent overflow when parsing SETTINGS
Amaury Denoyelle [Tue, 24 May 2022 14:30:11 +0000 (16:30 +0200)] 
BUG/MINOR: h3: prevent overflow when parsing SETTINGS

h3_parse_settings_frm() read one byte after the frame payload. Fix the
parsing code. In most cases, this has no impact as we are inside an
allocated buffer but it could cause a segfault depending on the buffer
alignment.

3 years agoCLEANUP: h3: rename uni stream type constants
Amaury Denoyelle [Mon, 23 May 2022 12:35:15 +0000 (14:35 +0200)] 
CLEANUP: h3: rename uni stream type constants

Cosmetic fix which reduce the name of unidirectional stream constants.
No impact on the code.

3 years agoCLEANUP: h3: rename struct h3 -> h3c
Amaury Denoyelle [Tue, 24 May 2022 12:55:43 +0000 (14:55 +0200)] 
CLEANUP: h3: rename struct h3 -> h3c

struct h3 represents the whole HTTP/3 connection. A new type h3s was
recently introduced to represent a single HTTP/3 stream. To facilitate
the analogy with other haproxy code, most notable in MUX, rename h3 type
to h3c.

3 years agoMINOR: mux-quic: adjust return value of decode_qcs
Amaury Denoyelle [Tue, 24 May 2022 09:07:28 +0000 (11:07 +0200)] 
MINOR: mux-quic: adjust return value of decode_qcs

Use 0 for success of decode_qcs operation else non-zero. This is to
follow the same model which is in use in most of the function in MUX/H3
code.

3 years agoMINOR: mux-quic: add traces in qc_recv()
Amaury Denoyelle [Mon, 23 May 2022 16:52:11 +0000 (18:52 +0200)] 
MINOR: mux-quic: add traces in qc_recv()

Just add traces in qc_recv() similarly to qc_send() function.

3 years agoMINOR: mux-quic: delay cs_endpoint allocation
Amaury Denoyelle [Tue, 24 May 2022 14:53:56 +0000 (16:53 +0200)] 
MINOR: mux-quic: delay cs_endpoint allocation

Do not allocate cs_endpoint for every QCS instances in qcs_new().
Instead, this is delayed to qc_attach_cs() function.

In effect, with H3 as app protocol, cs_endpoint will be allocated on
HEADERS parsing. Thus, no cs_endpoint is allocated for H3 unidirectional
streams which do not convey any HTTP data.

3 years agoMINOR: mux-quic: do not alloc quic_stream_desc for uni remote stream
Amaury Denoyelle [Tue, 24 May 2022 14:53:14 +0000 (16:53 +0200)] 
MINOR: mux-quic: do not alloc quic_stream_desc for uni remote stream

qc_stream_desc type is required for sending. Thus, it is not required
for an unidirectional remote stream where only receive will be
performed.

3 years agoMINOR: h3: mark ncbuf as const on h3_b_dup
Amaury Denoyelle [Tue, 24 May 2022 16:14:28 +0000 (18:14 +0200)] 
MINOR: h3: mark ncbuf as const on h3_b_dup

h3_b_dup() is used to obtains a ncbuf representation into a struct
buffer. ncbuf can thus be marked as a const parameter. This will allows
function which already manipulates a const ncbuf to use it.

3 years agoBUG/MINOR: task: Don't defer tasks release when HAProxy is stopping
Christopher Faulet [Wed, 25 May 2022 07:31:20 +0000 (09:31 +0200)] 
BUG/MINOR: task: Don't defer tasks release when HAProxy is stopping

A running or queued task is not released when task_destroy() is called,
except if it is the current task. Its process function is set to NULL and we
let the scheduler to release the task. However, when HAProxy is stopping, it
never happens and some tasks may leak. To fix the issue, we now also rely on
the global MODE_STOPPING flag. When this flag is set, the task is always
immediately released.

This patch should fix the issue #1714. It could be backported as far as 2.4
but it's not a real problem in practice because it only happens on
deinit. The leak exists on previous versions but not MODE_STOPPING flag.

3 years agoBUG/MEDIUM: peers: prevent unitialized multiple listeners on peers section
Emeric Brun [Wed, 25 May 2022 08:25:45 +0000 (10:25 +0200)] 
BUG/MEDIUM: peers: prevent unitialized multiple listeners on peers section

The previous fix:
BUG/MEDIUM: peers: fix segfault using multiple bind on peers

Prevents to declare multiple listeners on a peers sections but if
peers protocol is extended to support this we could raise the bug
again.

Indeed, after allocating a new listener and adding it to a list the
code mistakenly re-configure the first element of the list instead
of the new added one, and the last one remains finally uninitialized.
The previous fix assure there is no more than one listener in this
list but this could be changed in futur.

This patch patch assures we configure and initialize the newly added
listener instead of the first one in the list.

This patch could be backported until version 2.0 to complete
BUG/MEDIUM: peers: fix segfault using multiple bind on peers

3 years agoBUG/MEDIUM: peers: fix segfault using multiple bind on peers sections
Emeric Brun [Wed, 25 May 2022 08:12:07 +0000 (10:12 +0200)] 
BUG/MEDIUM: peers: fix segfault using multiple bind on peers sections

If multiple "bind" lines were present on the "peers" section, multiple
listeners were added to a list but the code mistakenly initialize
the first member and this first listener was re-configured instead of
the newly created one. The last one remains uninitialized causing a null
dereference a soon a connection is received.

In addition, the 'peers' sections and protocol are not currently designed to
handle multiple listeners.

This patch check if there is already a listener configured on the 'peers'
section when we want to create a new one. This is rising an error if
a listener is already present showing the file and line in the error
message.

To keep the file and line number of the previous listener available
for the error message, the 'bind_conf_uniq_alloc' function was modified
to keep the file/line data the struct 'bind_conf' was firstly
allocated (previously it was updated each time the 'bind_conf' was
reused).

This patch should be backported until version 2.0

3 years agoBUG/MEDIUM: resolvers: Don't defer resolutions release in deinit function
Christopher Faulet [Tue, 24 May 2022 16:10:42 +0000 (18:10 +0200)] 
BUG/MEDIUM: resolvers: Don't defer resolutions release in deinit function

resolvers_deinit() function is called on error, during post-parsing stage,
or on deinit, when HAProxy is stopped. It releases all entities: resolvers,
resolutions and SRV requests. There is no reason to defer the resolutions
release by moving them in the death_row list because this function is
terminal. And it is in fact a bug. Resolutions must not be released at the
end of the function because resolvers were already freed. However some
resolutions may still be attached to a reolver. Thus, when we try to remove
it from the resolver's tree, in resolv_reset_resolution(), this resolver was
already released.

So now, resolution are immediately released. It means there is no more
reason to track this function. calls to
enter_resolver_code()/leave_resolver_code() have been removed.

This patch should fix the issue #1680 and may be related to #1485. It must
be backported as far as 2.2.

3 years agoMEDIUM: h1: enlarge the scope of accepted version chars with accept-invalid-http...
Willy Tarreau [Tue, 24 May 2022 13:34:26 +0000 (15:34 +0200)] 
MEDIUM: h1: enlarge the scope of accepted version chars with accept-invalid-http-request

We used to support both RTSP and HTTP protocol version names with and
without accept-invalid-http-request, but since this is based on the
characters themselves, any protocol made of chars {0-9/.HPRST} was
possible and not others. Now that such non-standard protocols are
restricted to accept-invalid-http-request, there's no reason for not
allowing other letters. With this patch, characters {0-9./A-Z} are
permitted when the option is set.

3 years agoBUG/MEDIUM: http: Properly reject non-HTTP/1.x protocols
Tim Duesterhus [Mon, 9 Mar 2020 23:55:40 +0000 (00:55 +0100)] 
BUG/MEDIUM: http: Properly reject non-HTTP/1.x protocols

This patch hardens the verification of the HTTP/1.x version line
(i.e. the first line within an HTTP/1.x request) to verify that
the protocol name within the version actually reads "HTTP".

Previously protocols that superficially resembled the wire-format
of HTTP/1.x and having a 4-letter acronym as the protocol name, such
as RTSP would pass this check.

This patch fixes GitHub issue #540, it must be backported to all
supported versions. The legacy, non-HTX parser is affected as well,
a fix must be created for it as well.

Note that such protocols can still be used when option
accept-invalid-http-request is set.

3 years agoCLEANUP: init: address a coverity warning about possible multiply overflow
Willy Tarreau [Tue, 24 May 2022 05:43:57 +0000 (07:43 +0200)] 
CLEANUP: init: address a coverity warning about possible multiply overflow

In issue #1585 Coverity suspects a risk of multiply overflow when
calculating the SSL cache size, though in practice the cache is
limited to 2^32 anyway thus it cannot really happen. Nevertheless,
casting the operation should be sufficient to avoid marking it as a
false positive.

3 years agoRevert "MINOR: mux-quic: activate qmux traces on stdout via macro"
Amaury Denoyelle [Mon, 23 May 2022 07:25:19 +0000 (09:25 +0200)] 
Revert "MINOR: mux-quic: activate qmux traces on stdout via macro"

This reverts commit 251eadfce55b8e5d7a2ac2d87d17ba36147cb4ad.

This patch is similar to the previous revert for QUIC-MUX traces.

3 years agoRevert "MINOR: quic: activate QUIC traces at compilation"
Amaury Denoyelle [Mon, 23 May 2022 07:01:56 +0000 (09:01 +0200)] 
Revert "MINOR: quic: activate QUIC traces at compilation"

This reverts commit 118b2cbf8430a9513947c27a8403ff380e1dcaf2.

This patch was useful mainly for the docker image of QUIC interop to
have traces on stdout.

A better solution has been found by integrating this patch directly in
the qns repository which is used to build the docker image. Thus, this
hack is not require anymore in the main repository.

3 years agoBUG/MEDIUM: mux-quic: adjust buggy proxy closing support
Amaury Denoyelle [Mon, 23 May 2022 06:52:58 +0000 (08:52 +0200)] 
BUG/MEDIUM: mux-quic: adjust buggy proxy closing support

The wake handler detects if the frontend is closed. This can happen if
the proxy has been disabled individually or even on process soft-stop.
Before this patch, in this condition QCS instances were freed before
being detached from the cs_endpoint. This clearly violates the haproxy
connection architecture and cause a BUG_ON statement crash in cs_free().

To handle this properly, cs_endpoint is notified by setting RD_SH|WR_SH
on connection flags. The cs_endpoint will thus use the detach operation
which allows the QCS instance to be freed.

This code allows the soft-stop process to complete as soon as possible.
However, the client is not notified about the connection closing. It
should be done by emitting a H3 GOAWAY + CONNECTION_CLOSE. Sadly, this
is impossible at this stage because the listener sockets are closed so
the quic-conn cannot use it to emit new frames. At this stage the client
will most probably detect connection closing on its idle timeout
expiration.

Thus, to completely support proxy closing/soft-stop, important
architecture changes are required in QUIC socket management. This is
also linked with the reload feature.

3 years agoCLEANUP: tools: Crash if inet_ntop fails due to ENOSPC in sa2str
Tim Duesterhus [Mon, 23 May 2022 07:30:49 +0000 (09:30 +0200)] 
CLEANUP: tools: Crash if inet_ntop fails due to ENOSPC in sa2str

This is impossible, because we pass a destination buffer that is appropriately
sized to hold an IPv6 address.

This is related to GitHub issue #1599.

3 years agoBUG/MEDIUM: tools: Fix `inet_ntop` usage in sa2str
Tim Duesterhus [Sun, 22 May 2022 11:06:27 +0000 (13:06 +0200)] 
BUG/MEDIUM: tools: Fix `inet_ntop` usage in sa2str

The given size must be the size of the destination buffer, not the size of the
(binary) address representation.

This fixes GitHub issue #1599.

The bug was introduced in 92149f9a82a9b55c598f1cc815bc330c555f3561 which is in
2.4+. The fix must be backported there.

3 years agoCLEANUP: tools: Clean up non-QUIC error message handling in str2sa_range()
Tim Duesterhus [Sun, 22 May 2022 10:40:58 +0000 (12:40 +0200)] 
CLEANUP: tools: Clean up non-QUIC error message handling in str2sa_range()

If QUIC support is enabled both branches of the ternary conditional are
identical, upsetting Coverity. Move the full conditional into the non-QUIC
preprocessor branch to make the code more clear.

This resolves GitHub issue #1710.

3 years ago[RELEASE] Released version 2.6-dev11 v2.6-dev11
Willy Tarreau [Fri, 20 May 2022 21:31:51 +0000 (23:31 +0200)] 
[RELEASE] Released version 2.6-dev11

Released version 2.6-dev11 with the following main changes :
    - CI: determine actual LibreSSL version dynamically
    - BUG/MEDIUM: ncbuf: fix null buffer usage
    - MINOR: ncbuf: fix warnings for testing build
    - MEDIUM: http-ana: Add a proxy option to restrict chars in request header names
    - MEDIUM: ssl: Delay random generator initialization after config parsing
    - MINOR: ssl: Add 'ssl-propquery' global option
    - MINOR: ssl: Add 'ssl-provider' global option
    - CLEANUP: Add missing header to ssl_utils.c
    - CLEANUP: Add missing header to hlua_fcn.c
    - CLEANUP: Remove unused function hlua_get_top_error_string
    - BUILD: fix build warning on solaris based systems with __maybe_unused.
    - MINOR: tools: add get_exec_path implementation for solaris based systems.
    - BUG/MINOR: ssl: Fix crash when no private key is found in pem
    - CLEANUP: conn-stream: Remove cs_applet_shut declaration from header file
    - MINOR: applet: Prepare appctx to own the session on frontend side
    - MINOR: applet: Let the frontend appctx release the session
    - MINOR: applet: Change return value for .init callback function
    - MINOR: stream: Export stream_free()
    - MINOR: applet: Add appctx_init() helper fnuction
    - MINOR: applet: Add a function to finalize frontend appctx startup
    - MINOR: applet: Add function to release appctx on error during init stage
    - MEDIUM: dns: Refactor dns appctx creation
    - MEDIUM: spoe: Refactor SPOE appctx creation
    - MEDIUM: lua: Refactor cosocket appctx creation
    - MEDIUM: httpclient: Refactor http-client appctx creation
    - MINOR: sink: Add a ref to sink in the sink_forward_target structure
    - MEDIUM: sink: Refactor sink forwarder appctx creation
    - MINOR: peers: Add a ref to peers section in the peer structure
    - MEDIUM: peers: Refactor peer appctx creation
    - MINOR: applet: Add API to start applet on a thread subset
    - MEDIUM: applet: Add support for async appctx startup on a thread subset
    - MINOR: peers: Track number of applets run by thread
    - MEDIUM: peers: Balance applets across threads
    - MINOR: conn-stream/applet: Stop setting appctx as the endpoint context
    - CLEANUP: proxy: Remove dead code when parsing "http-restrict-req-hdr-names" option
    - REGTESTS: abortonclose: Fix some race conditions
    - MINOR: ssl: Add 'ssl-provider-path' global option
    - CLEANUP: http_ana: Make use of the return value of stream_generate_unique_id()
    - BUG/MINOR: spoe: Fix error handling in spoe_init_appctx()
    - CLEANUP: peers: Remove unreachable code in peer_session_create()
    - CLEANUP: httpclient: Remove useless test on ss_dst in httpclient_applet_init()
    - BUG/MEDIUM: quic: fix Rx buffering
    - OPTIM: quic: realign empty Rx buffer
    - BUG/MINOR: ncbuf: fix ncb_is_empty()
    - MINOR: ncbuf: refactor ncb_advance()
    - BUG/MINOR: mux-quic: update session's idle delay before stream creation
    - MINOR: h3: do not wait a complete frame for demuxing
    - MINOR: h3: flag demux as full on HTX full
    - MEDIUM: mux-quic: implement recv on io-cb
    - MINOR: mux-quic: remove qcc_decode_qcs() call in XPRT
    - MINOR: mux-quic: reorganize flow-control frames emission
    - MINOR: mux-quic: implement MAX_STREAM_DATA emission
    - MINOR: mux-quic: implement MAX_DATA emission
    - BUG/MINOR: mux-quic: support nul buffer with qc_free_ncbuf()
    - MINOR: mux-quic: free RX buf if empty
    - BUG/MEDIUM: config: Reset outline buffer size on realloc error in readcfgfile()
    - BUG/MINOR: check: Reinit the buffer wait list at the end of a check
    - MEDIUM: check: No longer shutdown the connection in .wake callback function
    - REORG: check: Rename and export I/O callback function
    - MEDIUM: check: Use the CS to handle subscriptions for read/write events
    - BUG/MINOR: quic: break for error on sendto
    - MINOR: quic: abort on unlisted errno on sendto()
    - MINOR: quic: detect EBADF on sendto()
    - BUG/MEDIUM: quic: fix initialization for local/remote TPs
    - CLEANUP: quic: adjust comment/coding style for TPs init
    - BUG/MINOR: cfgparse: abort earlier in case of allocation error
    - MINOR: quic: Dump initial derived secrets
    - MINOR: quic_tls: Add quic_tls_derive_retry_token_secret()
    - MINOR: quic_tls: Add quic_tls_decrypt2() implementation
    - MINOR: quic: Retry implementation
    - MINOR: cfgparse: Update for "cluster-secret" keyword for QUIC Retry
    - MINOR: quic: Move quic_lstnr_dgram_dispatch() out of xprt_quic.c
    - BUILD: stats: Missing headers inclusions from stats.h
    - MINOR: quic_stats: Add a new stats module for QUIC
    - MINOR: quic: Attach proxy QUIC stats counters to the QUIC connection
    - BUG/MINOR: quic: Fix potential memory leak during QUIC connection allocations
    - MINOR: quic: QUIC stats counters handling
    - MINOR: quic: Add tune.quic.retry-threshold keyword
    - MINOR: quic: Dynamic Retry implementation
    - MINOR: quic/mux-quic: define CONNECTION_CLOSE send API
    - MINOR: mux-quic: emit FLOW_CONTROL_ERROR
    - MINOR: mux-quic: emit STREAM_LIMIT_ERROR
    - MINOR: mux-quic: close connection on error if different data at offset
    - BUG/MINOR: peers: fix error reporting of "bind" lines
    - CLEANUP: config: improve address parser error report for unmatched protocols
    - CLEANUP: config: provide cleare hints about unsupported QUIC addresses
    - MINOR: protocol: replace ctrl_type with xprt_type and clarify it
    - MINOR: listener: provide a function to process all of a bind_conf's arguments
    - MINOR: config: use the new bind_parse_args_list() to parse a "bind" line
    - CLEANUP: listener: add a comment about what the BC_SSL_O_* flags are for
    - MINOR: listener: add a new "options" entry in bind_conf
    - CLEANUP: listener: replace all uses of bind_conf->is_ssl with BC_O_USE_SSL
    - CLEANUP: listener: replace bind_conf->generate_cers with BC_O_GENERATE_CERTS
    - CLEANUP: listener: replace bind_conf->quic_force_retry with BC_O_QUIC_FORCE_RETRY
    - CLEANUP: listener: store stream vs dgram at the bind_conf level
    - MINOR: listener: detect stream vs dgram conflict during parsing
    - MINOR: listener: set the QUIC xprt layer immediately after parsing the args
    - MINOR: listener/ssl: set the SSL xprt layer only once the whole config is known
    - MINOR: connection: add flag MX_FL_FRAMED to mark muxes relying on framed xprt
    - MINOR: config: detect and report mux and transport incompatibilities
    - MINOR: listener: automatically select a QUIC mux with a QUIC transport
    - MINOR: listener: automatically enable SSL if a QUIC transport is found
    - BUG/MINOR: quic: Fixe a typo in qc_idle_timer_task()
    - BUG/MINOR: quic: Missing <conn_opening> stats counter decrementation
    - BUILD/MINOR: cpuset fix build for FreeBSD 13.1
    - CI: determine actual OpenSSL version dynamically

3 years agoCI: determine actual OpenSSL version dynamically
Ilya Shipitsin [Fri, 20 May 2022 18:02:38 +0000 (23:02 +0500)] 
CI: determine actual OpenSSL version dynamically

this change introduce "OPENSSL_VERSION=latest" semantic, which scans
https://api.github.com/repos/openssl/openssl/tags and detects latest release.

3 years agoBUILD/MINOR: cpuset fix build for FreeBSD 13.1
David CARLIER [Wed, 18 May 2022 14:45:40 +0000 (15:45 +0100)] 
BUILD/MINOR: cpuset fix build for FreeBSD 13.1

the cpuset api changes done fir the future 14 release had been
backported to the 13.1 release so changing the cpuset api of choice
condition change accordingly.

3 years agoBUG/MINOR: quic: Missing <conn_opening> stats counter decrementation
Frédéric Lécaille [Fri, 20 May 2022 18:53:20 +0000 (20:53 +0200)] 
BUG/MINOR: quic: Missing <conn_opening> stats counter decrementation

When we receive a CONNECTION_CLOSE frame, we should decrement this counter
if the handshake state was not successful and if we have not received
a TLS alert from the TLS stack.

3 years agoBUG/MINOR: quic: Fixe a typo in qc_idle_timer_task()
Frédéric Lécaille [Fri, 20 May 2022 18:50:59 +0000 (20:50 +0200)] 
BUG/MINOR: quic: Fixe a typo in qc_idle_timer_task()

The & operator was confused with | operator :-(