]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMINOR: ssl: Set connection error code in case of SSL read or write fatal failure
Remi Tricot-Le Breton [Wed, 29 Sep 2021 16:56:51 +0000 (18:56 +0200)] 
MINOR: ssl: Set connection error code in case of SSL read or write fatal failure

In case of a connection error happening after the SSL handshake is
completed, the error code stored in the connection structure would not
always be set, hence having some connection failures being described as
successful in the fc_conn_err or bc_conn_err sample fetches.
The most common case in which it could happen is when the SSL server
rejects the client's certificate. The SSL_do_handshake call on the
client side would be sucessful because the client effectively sent its
client hello and certificate information to the server, but the next
call to SSL_read on the client side would raise an SSL_ERROR_SSL code
(through the SSL_get_error function) which is decribed in OpenSSL
documentation as a non-recoverable and fatal SSL error.
This patch ensures that in such a case, the connection's error code is
set to a special CO_ERR_SSL_FATAL value.

3 years agoMINOR: Makefile: add MEMORY_POOLS to the list of DEBUG_xxx options
William Lallemand [Wed, 29 Sep 2021 14:03:35 +0000 (16:03 +0200)] 
MINOR: Makefile: add MEMORY_POOLS to the list of DEBUG_xxx options

Add the DEBUG_MEMORY_POOLS option to the list of DEBUG_xxx options in
the Makefile.

3 years agoDOC: peers: fix doc "enable" statement on "peers" sections
Emeric Brun [Wed, 29 Sep 2021 08:29:52 +0000 (10:29 +0200)] 
DOC: peers: fix doc "enable" statement on "peers" sections

Checking in code the right keyword is "enabled" and not "enable".

In addition the comment was also completed:

This could appear useless because the "defaults" sections not
yet apply on "peers" sections, but it could be the case in the future.
This statement can currently cancel a previous "disabled" keyword in
the same section.

This patch should be backported in all supported branches (keyword
is present since 1.5)

3 years agoREORG: pools: move default settings to defaults.h
Willy Tarreau [Mon, 27 Sep 2021 17:29:30 +0000 (19:29 +0200)] 
REORG: pools: move default settings to defaults.h

There's no reason CONFIG_HAP_POOLS and its opposite are located into
pools-t.h, it forces those that depend on them to inlcude the file.
Other similar options are normally dealt with in defaults.h, which is
part of the default API, so let's do that.

3 years agoREGTESTS: Add script to validate T-E header parsing
Christopher Faulet [Tue, 28 Sep 2021 13:55:55 +0000 (15:55 +0200)] 
REGTESTS: Add script to validate T-E header parsing

Some changes were pushed to improve parsing of the Transfer-Encoding header
parsing annd all related stuff. This new script adds some tests to validate
these changes.

3 years agoBUG/MEDIUM: mux-h1/mux-fcgi: Reject messages with unknown transfer encoding
Christopher Faulet [Tue, 28 Sep 2021 07:50:07 +0000 (09:50 +0200)] 
BUG/MEDIUM: mux-h1/mux-fcgi: Reject messages with unknown transfer encoding

HAproxy only handles "chunked" encoding internally. Because it is a gateway,
we stated it was not a problem if unknown encodings were applied on a
message because it is the recipient responsibility to accept the message or
not. And indeed, it is not a problem if both the client and the server
connections are using H1. However, Transfer-Encoding headers are dropped
from H2 messages. It is not a problem for chunk-encoded payload because
dechunking is performed during H1 parsing. But, for any other encodings, the
xferred H2 message is invalid.

It is also a problem for internal payload manipulations (lua,
filters...). Because the TE request headers are now sanitiezd, unsupported
encoding should not be used by servers. Thus it is only a problem for the
request messages. For this reason, such messages are now rejected. And if a
server decides to use an unknown encoding, the response will also be
rejected.

Note that it is pretty uncommon to use other encoding than "chunked" on the
request payload. So it is not necessary to backport it.

This patch should fix the issue #1301. No backport is needed.

3 years agoMINOR: h1: Change T-E header parsing to fail if chunked encoding is found twice
Christopher Faulet [Tue, 28 Sep 2021 07:36:25 +0000 (09:36 +0200)] 
MINOR: h1: Change T-E header parsing to fail if chunked encoding is found twice

According to the RFC7230, "chunked" encoding must not be applied more than
once to a message body. To handle this case, h1_parse_xfer_enc_header() is
now responsible to fail when a parsing error is found. It also fails if the
"chunked" encoding is not the last one for a request.

To help the parsing, two H1 parser flags have been added: H1_MF_TE_CHUNKED
and H1_MF_TE_OTHER. These flags are set, respectively, when "chunked"
encoding and any other encoding are found. H1_MF_CHNK flag is used when
"chunked" encoding is the last one.

3 years agoMINOR: http: Add 422-Unprocessable-Content error message
Christopher Faulet [Tue, 28 Sep 2021 06:48:51 +0000 (08:48 +0200)] 
MINOR: http: Add 422-Unprocessable-Content error message

The last HTTP/1.1 draft adds the 422 status code in the list of client
errors. It normalizes the WebDav specific one (422-Unprocessable-Entity).

3 years agoBUG/MINOR: mux-h1/mux-fcgi: Sanitize TE header to only send "trailers"
Christopher Faulet [Tue, 28 Sep 2021 08:56:36 +0000 (10:56 +0200)] 
BUG/MINOR: mux-h1/mux-fcgi: Sanitize TE header to only send "trailers"

Only chunk-encoded response payloads are supported by HAProxy. All other
transfer encodings are not supported and will be an issue if the HTTP
compression is enabled. So be sure only "trailers" is send in TE request
headers.

The patch is related to the issue #1301. It must be backported to all stable
versions. Be carefull for 2.0 and lower because the HTTP legacy must also be
fixed.

3 years agoMEDIUM: h1: Force close mode for invalid uses of T-E header
Christopher Faulet [Mon, 27 Sep 2021 07:47:03 +0000 (09:47 +0200)] 
MEDIUM: h1: Force close mode for invalid uses of T-E header

Transfer-Encoding header is not supported in HTTP/1.0. However, softwares
dealing with HTTP/1.0 and HTTP/1.1 messages may accept it and transfer
it. When a Content-Length header is also provided, it must be
ignored. Unfortunately, this may lead to vulnerabilities (request smuggling
or response splitting) if an intermediary is only implementing
HTTP/1.0. Because it may ignore Transfer-Encoding header and only handle
Content-Length one.

To avoid any security issues, when Transfer-Encoding and Content-Length
headers are found in a message, the close mode is forced. The same is
performed for HTTP/1.0 message with a Transfer-Encoding header only. This
change is conform to what it is described in the last HTTP/1.1 draft. See
also httpwg/http-core#879.

Note that Content-Length header is also removed from any incoming messages
if a Transfer-Encoding header is found. However it is not true (not yet) for
responses generated by HAProxy.

3 years agoMEDIUM: mux-h1: Reject HTTP/1.0 GET/HEAD/DELETE requests with a payload
Christopher Faulet [Tue, 21 Sep 2021 16:44:55 +0000 (18:44 +0200)] 
MEDIUM: mux-h1: Reject HTTP/1.0 GET/HEAD/DELETE requests with a payload

This kind of requests is now forbidden and rejected with a
413-Payload-Too-Large error.

It is unexpected to have a payload for GET/HEAD/DELETE requests. It is
explicitly allowed in HTTP/1.1 even if some servers may reject such
requests. However, HTTP/1.0 is not clear on this point and some old servers
don't expect any payload and never look for body length (via Content-Length
or Transfer-Encoding headers).

It means that some intermediaries may properly handle the payload for
HTTP/1.0 GET/HEAD/DELETE requests, while some others may totally ignore
it. That may lead to security issues because a request smuggling attack is
possible.

To prevent any issue, those requests are now rejected.

See also httpwg/http-core#904

3 years agoMINOR: mux-h1: Be able to set custom status code on parsing error
Christopher Faulet [Tue, 21 Sep 2021 16:38:20 +0000 (18:38 +0200)] 
MINOR: mux-h1: Be able to set custom status code on parsing error

When a parsing error is triggered, the status code may be customized by
setting H1C .errcode field. By default a 400-Bad-Request is returned. The
function h1_handle_bad_req() has been renamed to h1_handle_parsing_error()
to be more generic.

3 years agoMINOR: mux-h1: Set error code if possible when MUX_EXIT_STATUS is returned
Christopher Faulet [Tue, 28 Sep 2021 09:45:05 +0000 (11:45 +0200)] 
MINOR: mux-h1: Set error code if possible when MUX_EXIT_STATUS is returned

In h1_ctl(), if output parameter is provided when MUX_EXIT_STATUS is
returned, it is used to set the error code. In addition, any client errors
(4xx), except for 408 ones, are handled as invalid errors
(MUX_ES_INVALID_ERR). This way, it will be possible to customize the parsing
error code for request messages.

3 years agoMINOR: log: Try to get the status code when MUX_EXIT_STATUS is retrieved
Christopher Faulet [Tue, 28 Sep 2021 09:36:28 +0000 (11:36 +0200)] 
MINOR: log: Try to get the status code when MUX_EXIT_STATUS is retrieved

The mux .ctl callback can provide some information about the mux to the
caller if the third parameter is provided. Thus, when MUX_EXIT_STATUS is
retrieved, a pointer on the status is now passed. The mux may fill it. It
will be pretty handy to provide custom error code from h1 mux instead of
default ones (400/408/500/501).

3 years agoMINOR: init: extract the setup and end of threads to their own functions
Willy Tarreau [Tue, 28 Sep 2021 08:36:57 +0000 (10:36 +0200)] 
MINOR: init: extract the setup and end of threads to their own functions

The startup code was still ugly with tons of unreadable nested ifdefs.
Let's just have one function to set up the extra threads and another one
to wait for their completion. The ifdefs are isolated into their own
functions now and are more readable, just like the end of main(), which
now uses the same statements to start thread 0 with and without threads.

3 years agoMEDIUM: init: de-uglify the per-thread affinity setting
Willy Tarreau [Tue, 28 Sep 2021 08:15:47 +0000 (10:15 +0200)] 
MEDIUM: init: de-uglify the per-thread affinity setting

Till now the threads startup was quite messy:
  - we would start all threads but one
  - then we would change all threads' CPU affinities
  - then we would manually start the poll loop for the current thread

Let's change this by moving the CPU affinity setting code to a function
set_thread_cpu_affinity() that does this job for the current thread only,
and that is called during the thread's initialization in the polling loop.

It takes care of not doing this for the master, and will result in all
threads to be properly bound earlier and with cleaner code. It also
removes some ugly nested ifdefs.

3 years agoCLEANUP: init: remove useless test against MAX_THREADS in affinity loop
Willy Tarreau [Tue, 28 Sep 2021 07:56:44 +0000 (09:56 +0200)] 
CLEANUP: init: remove useless test against MAX_THREADS in affinity loop

The test i < MAX_THREADS is pointless since the loop boundary is bound
to global.nbthread which is already not greater.

3 years agoMINOR: config: use a standard parser for the "nbthread" keyword
Willy Tarreau [Wed, 22 Sep 2021 09:55:22 +0000 (11:55 +0200)] 
MINOR: config: use a standard parser for the "nbthread" keyword

Probably because of some copy-paste from "nbproc", "nbthread" used to
be parsed in cfgparse instead of using a registered parser. Let's fix
this to clean up the code base now.

3 years agoBUG/MEDIUM: httpclient: replace ist0 by istptr
William Lallemand [Sun, 26 Sep 2021 16:12:43 +0000 (18:12 +0200)] 
BUG/MEDIUM: httpclient: replace ist0 by istptr

ASAN reported a buffer overflow in the httpclient. This overflow is the
consequence of ist0() which is incorrect here.

Replace all occurences of ist0() by istptr() which is more appropried
here since all ist in the httpclient were created from strings.

3 years agoRevert "head-truc"
William Lallemand [Fri, 24 Sep 2021 17:13:04 +0000 (19:13 +0200)] 
Revert "head-truc"

This reverts commit fe67e091859b07dca4622981a8d98a0b64de3cab.

Revert a development/test patch which was accidentely introduced.

3 years agoREGTESTS: lua: test the httpclient:get() feature
William Lallemand [Fri, 24 Sep 2021 17:02:50 +0000 (19:02 +0200)] 
REGTESTS: lua: test the httpclient:get() feature

This reg-test is heavily inspired by the lua_socket.vtc one.

It replaces the HTTP/1.1 request made manually with a socket object with
an httpclient object.

3 years agohead-truc
William Lallemand [Fri, 24 Sep 2021 14:51:55 +0000 (16:51 +0200)] 
head-truc

3 years ago[RELEASE] Released version 2.5-dev8 v2.5-dev8
Willy Tarreau [Fri, 24 Sep 2021 13:52:17 +0000 (15:52 +0200)] 
[RELEASE] Released version 2.5-dev8

Released version 2.5-dev8 with the following main changes :
    - BUILD: compiler: fixed a missing test on  defined(__GNUC__)
    - BUILD: halog: fix a -Wundef warning on non-glibc systems
    - BUILD: threads: fix -Wundef for _POSIX_PRIORITY_SCHEDULING on libmusl
    - BUG/MINOR: compat: make sure __WORDSIZE is always defined
    - BUILD: sample: fix format warning on 32-bit archs in sample_conv_be2dec_check()
    - CLEANUP: pools: factor all malloc_trim() calls into trim_all_pools()
    - MINOR: pools: automatically disable malloc_trim() with external allocators
    - MINOR: pools: report it when malloc_trim() is enabled
    - DOC: Add .mailmap
    - CLEANUP: tree-wide: fix prototypes for functions taking no arguments.
    - CLEANUP: Remove prototype for non-existent thread_get_default_count()
    - CLEANUP: acl: Remove unused variable when releasing an acl expression
    - BUG/MAJOR: mux-h1: Don't eval input data if an error was reported
    - DOC: update Tim's address in .mailmap
    - MINOR: pools: use mallinfo2() when available instead of mallinfo()
    - BUG/MINOR: tcpcheck: Improve LDAP response parsing to fix LDAP check
    - DOC: management: certificate files must be sanitized before injection
    - BUG/MINOR: connection: prevent null deref on mux cleanup task allocation
    - BUILD: ist: prevent gcc11 maybe-uninitialized warning on istalloc
    - BUG/MINOR: cli/payload: do not search for args inside payload
    - BUILD: sockpair: do not set unused flag
    - BUILD: proto_uxst: do not set unused flag
    - BUILD: fd: remove unused variable totlen in fd_write_frag_line()
    - MINOR: applet: remove the thread mask from appctx_new()
    - REORG: threads: move ha_get_pthread_id() to tinfo.h
    - CLEANUP: Apply ist.cocci
    - DEV: coccinelle: Add ist.cocci
    - CLEANUP: Apply bug_on.cocci
    - DEV: coccinelle: Add xalloc_size.cocci
    - DEV: coccinelle: Add bug_on.cocci
    - CLEANUP: Apply xalloc_size.cocci
    - DEV: coccinelle: Add xalloc_cast.cocci
    - BUG/MINOR: flt-trace: fix an infinite loop when random-parsing is set
    - MINOR: httpclient: add the EOH when no headers where provided
    - CLEANUP: Include check.h in flt_spoe.c
    - CLEANUP: Remove unreachable `break` from parse_time_err()
    - BUG/MINOR: server: allow 'enable health' only if check configured
    - BUG/MINOR: server: alloc dynamic srv ssl ctx if proxy uses ssl chk rule
    - MINOR: server: enable more keywords for ssl checks for dynamic servers
    - MINOR: server: enable more check related keywords for dynamic servers
    - REORG: server: move slowstart init outside of checks
    - MINOR: server: enable slowstart for dynamic server
    - MEDIUM: listener: deprecate "process" in favor of "thread" on bind lines
    - BUG/MEDIUM: leastconn: fix rare possibility of divide by zero
    - BUG/MINOR: quic: Possible NULL pointer dereferencing when dumping streams.
    - MINOR: quic: Move transport parmaters to anynomous struct.
    - MINOR: mux_quic: Add QUIC mux layer.
    - MINOR: connection: Add callbacks definitions for QUIC.
    - MINOR: quic: Attach QUIC mux connection objet to QUIC connection.
    - MINOR: quic: Add a new definition to store STREAM frames.
    - MINOR: h3: Add HTTP/3 definitions.
    - MINOR: qpack: Add QPACK compression.
    - MINOR: quic_sock: Finalize the QUIC connections.
    - MINOR: quic: Disable the action of ->rcv_buf() xprt callback
    - MINOR: quic: Add callbacks for (un)scribing to QUIC xprt.
    - MINOR: quic: Variable-length integer encoding/decoding into/from buffer struct.
    - BUG/MINOR: quic: Wrong ->accept() error handling
    - MINOR: quic: Add a wrapper function to update transport parameters.
    - MINOR: quic: Update the streams transport parameters.
    - MINOR: quic: Avoid header collisions
    - MINOR: quic: Replace max_packet_size by max_udp_payload size.
    - MINOR: quic: Enable some quic, h3 and qpack modules compilation.
    - MINOR: quic: Move an SSL func call from QUIC I/O handler to the xprt init.
    - MINOR: quic: Initialize the session before starting the xprt.
    - BUG/MINOR: quic: Do not check the acception of a new conn from I/O handler.
    - MINOR: quic: QUIC conn initialization from I/O handler
    - MINOR: quic: Remove header protection for conn with context
    - MINOR: quic: Derive the initial secrets asap
    - MINOR: quic: Remove header protection also for Initial packets
    - BUG/MINOR: quic: Wrong memory free in quic_update_ack_ranges_list()
    - MINOR: quic: quic_update_ack_ranges_list() code factorization
    - MINOR: quic: Useless test in quic_update_ack_ranges_list()
    - MINOR: quic: Remove a useless variable in quic_update_ack_ranges_list()
    - BUG/MINOR: quic: Missing cases treatement when updating ACK ranges
    - CLEAUNUP: quic: Usage of a useless variable in qc_treat_rx_pkts()
    - BUG/MINOR: quic: Wrong RX packet reference counter usage
    - MINOR: quic: Do not stop the packet parsing too early in qc_treat_rx_packets()
    - MINOR: quic: Add a lock for RX packets
    - MINOR: quic: Move the connection state
    - MINOR: quic: Replace quic_conn_ctx struct by ssl_sock_ctx struct
    - MINOR: quic: Replace the RX list of packet by a thread safety one.
    - MINOR: quic: Replace the RX unprotected packet list by a thread safety one.
    - MINOR: quic: Add useful traces for I/O dgram handler
    - MINOR: quic: Do not wakeup the xprt task on ACK receipt
    - MINOR: quic: Connection allocations rework
    - MINOR: quic: Move conn_prepare() to ->accept_conn() callback
    - MINOR: quic: Make qc_lstnr_pkt_rcv() be thread safe.
    - MINOR: quic: Add a ring buffer implementation for QUIC
    - MINOR: quic: Prefer x25519 as ECDH preferred parametes.
    - MINOR: quic: Add the QUIC v1 initial salt.
    - BUG/MINOR: quic: Too much reduced computed space to build handshake packets
    - MINOR: net_helper: add functions for pointers
    - MINOR: quic: Add ring buffer definition (struct qring) for QUIC
    - MINOR: proto_quic: Allocate TX ring buffers for listeners
    - MINOR: quic: Initialize pointers to TX ring buffer list
    - MINOR: quic: Make use of TX ring buffers to send QUIC packets
    - MINOR: quic_tls: Make use of the QUIC V1 salt.
    - MINOR: quic: Remove old TX buffer implementation
    - MINOR: Add function for TX packets reference counting
    - MINOR: quic: Add TX packets at the very last time to their tree.
    - MINOR: quic: Unitialized mux context upon Client Hello message receipt.
    - MINOR: quic: Missing encryption level rx.crypto member initialization and lock.
    - MINOR: quic: Rename ->rx.rwlock of quic_enc_level struct to ->rx.pkts_rwlock
    - MINOR: quic: Make qc_treat_rx_pkts() be thread safe.
    - MINOR: quic: Make ->tx.frms quic_pktns struct member be thread safe
    - MINOR: quic: Replace quic_tx_frm struct by quic_frame struct
    - MINOR: quic: Add a mask for TX frame builders and their authorized packet types
    - MINOR: quic: Add a useful function to compute any frame length.
    - MINOR: quic: Add the QUIC connection state to traces
    - MINOR: quic: Store post handshake frame in ->pktns.tx.frms MT_LIST
    - MINOR: quic: Add the packet type to quic_tx_packet struct
    - MINOR: quic: Modify qc_do_build_hdshk_pkt() to accept any packet type
    - MINOR: quic: Atomically handle packet number space ->largest_acked_pn variable
    - MINOR: quic: Modify qc_build_cfrms() to support any frame
    - MINOR: quic: quic_conn_io_cb() task rework
    - MINOR: quic: Make qc_build_hdshk_pkt() atomically consume a packet number
    - MINOR: quic: qc_do_build_hdshk_pkt() does not  need to pass a copy of CRYPTO frame
    - MINOR: quic: Remove Application level related functions
    - MINOR: quic: Rename functions which do not build only Handshake packets
    - MINOR: quic: Make circular buffer internal buffers be variable-sized.
    - MINOR: quic: Add a pool for TX ring buffer internal buffer
    - MINOR: quic: Make use of the last cbuf API when initializing TX ring buffers
    - MINOR: quic: Missing acks encoded size updates.
    - MINOR: quic: Evaluate the packet lengths in advance
    - MINOR: quic: Update the TLS extension for QUIC transport parameters
    - MINOR: quic: Fix handshake state debug strings
    - MINOR: quic: Atomically get/set the connection state
    - MINOR: quic: Missing QUIC encryption level for qc_build_pkt()
    - MINOR: quic: Coalesce Application level packets with Handshake packets.
    - MINOR: quic: Wrong flags handling for acks
    - MINOR: quic: Missing case when discarding HANDSHAKE secrets
    - MINOR: quic: Post handshake packet building improvements
    - MINOR: quic: Prepare Application level packet asap.
    - MINOR: h3: Send h3 settings asap
    - MINOR: quic: Wrong STREAM frame length computing
    - MINOR: quic: Wrong short packet minimum length
    - MINOR: quic: Prepare STREAM frames to fill QUIC packets
    - MINOR: h3: change default settings
    - MINOR: quic-enc: fix varint encoding
    - MINOR: qpack: fix wrong comment
    - MINOR: qpack: generate headers list on decoder
    - MINOR: h3: parse headers to htx
    - MINOR: h3: allocate stream on headers
    - MEDIUM: mux-quic: implement ring buffer on stream tx
    - MINOR: mux-quic: send SETTINGS on uni stream
    - MINOR: h3: define snd_buf callback and divert mux ops
    - MINOR: mux-quic: define FIN stream flag
    - MINOR: qpack: create qpack-enc module
    - MINOR: qpack: encode headers functions
    - MINOR: h3: encode htx headers to QPACK
    - MINOR: h3: send htx data
    - MINOR: h3/mux: detect fin on last h3 frame of the stream
    - MINOR: quic: Shorten some handshakes
    - MINOR: quic: Make QUIC-TLS support at least two initial salts
    - MINOR: quic: Attach the QUIC connection to a thread.
    - MINOR: quic: Missing active_connection_id_limit default value
    - MINOR: quic_sock: Do not flag QUIC connections as being set
    - MINOR: buf: Add b_force_xfer() function
    - MINOR: quic: Make use of buffer structs to handle STREAM frames
    - MINOR: mux_quic: move qc_process() code to qc_send()
    - MINOR: quic: Add a typedef for unsigned long long
    - MINOR: quic: Confusion between TX/RX for the frame builders
    - MINOR: quic: Wrong packet flags settings during frame building
    - MINOR: quic: Constantness fixes for frame builders/parsers.
    - MINOR: quic_tls: Client/serveur state reordering
    - MINOR: quic: Wrong packet loss detection due to wrong pktns order
    - MINOR: quic: Wrong packet number space selection in quic_loss_pktns()
    - MINOR: quic: Initial packet number spaced not discarded
    - MINOR: quic: Add useful trace about pktns discarding
    - MINOR: mux_quic: Export the mux related flags
    - MINOR: quic: Implement quic_conn_subscribe()
    - MINOR: quic: Wake up the mux upon ACK receipt
    - MINOR: quic: Stream FIN bit fix in qcs_push_frame()
    - MINOR: quic: Implement qc_process_mux()
    - MINOR: quic: Wake up the xprt from mux
    - CLEANUP: quic: Remove useless inline functions
    - MINOR: quic: RX packets memory leak
    - MINOR: quic: Possible endless loop in qc_treat_rx_pkts()
    - MINOR: quic: Crash upon too big packets receipt
    - MINOR: quic: define close handler
    - MEDIUM: quic: implement mux release/conn free
    - MINOR: quic: fix qcc subs initialization
    - BUG/MINOR: h1-htx: Fix a typo when request parser is reset
    - BUG/MEDIUM: mux-h1: Adjust conditions to ask more space in the channel buffer
    - BUG/MEDIUM: stream-int: Notify stream that the mux wants more room to xfer data
    - BUG/MEDIUM: stream: Stop waiting for more data if SI is blocked on RXBLK_ROOM
    - MINOR: stream-int: Set CO_RFL transient/persistent flags apart in si_cs_rcv()
    - MINOR: htx: Add an HTX flag to know when a message is fragmented
    - MINOR: htx: Add a function to know if the free space wraps
    - BUG/MEDIUM: stream-int: Defrag HTX message in si_cs_recv() if necessary
    - MINOR: stream-int: Notify mux when the buffer is not stuck when calling rcv_buf
    - BUG/MINOR: http-ana: increment internal_errors counter on response error
    - MINOR: stats: Enable dark mode on stat web page
    - CLEANUP: stats: Fix some alignment mistakes
    - MINOR: httpclient: httpclient_data() returns the available data
    - MINOR: httpclient: httpclient_ended() returns 1 if the client ended
    - MINOR: httpclient/lua: httpclient:get() API in lua
    - MINOR: httpclient/lua: implement the headers in the response object
    - BUG/MINOR: httpclient/lua: return an error on argument check
    - CLEANUP: slz: Mark `reset_refs` as static

3 years agoCLEANUP: slz: Mark `reset_refs` as static
Tim Duesterhus [Mon, 20 Sep 2021 17:59:42 +0000 (19:59 +0200)] 
CLEANUP: slz: Mark `reset_refs` as static

This function has no prototype and is not used outside of slz.c.

3 years agoBUG/MINOR: httpclient/lua: return an error on argument check
William Lallemand [Fri, 24 Sep 2021 12:51:44 +0000 (14:51 +0200)] 
BUG/MINOR: httpclient/lua: return an error on argument check

src/hlua.c:7074:6: error: variable 'url_str' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (lua_type(L, -1) == LUA_TSTRING)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hlua.c:7079:36: note: uninitialized use occurs here
        hlua_hc->hc->req.url = istdup(ist(url_str));
                                          ^~~~~~~

Return an error on the stack if the argument is not a string.

3 years agoMINOR: httpclient/lua: implement the headers in the response object
William Lallemand [Thu, 23 Sep 2021 15:54:00 +0000 (17:54 +0200)] 
MINOR: httpclient/lua: implement the headers in the response object

Provide a new field "headers" in the response of the HTTPClient, which
contains all headers of the response.

This field is a multi-dimensionnal table which could be represented this
way in lua:

    headers = {
       ["content-type"] = { "text/html" },
       ["cache-control"] = { "no-cache" }
    }

3 years agoMINOR: httpclient/lua: httpclient:get() API in lua
William Lallemand [Tue, 21 Sep 2021 14:25:15 +0000 (16:25 +0200)] 
MINOR: httpclient/lua: httpclient:get() API in lua

This commit provides an hlua_httpclient object which is a bridge between
the httpclient and the lua API.

The HTTPClient is callable in lua this way:

    local httpclient = core.httpclient()
    local response = httpclient:get("http://127.0.0.1:9000/?s=9999")
    core.Debug("Status: ".. res.status .. ", Reason : " .. res.reason .. ", Len:" .. string.len(res.body) .. "\n")

The resulting response object will provide a "status" field which
contains the status code, a "reason" string which contains the reason
string, and a "body" field which contains the response body.

The implementation uses the httpclient callback to wake up the lua task
which yield each time it pushes some data. The httpclient works in the
same thread as the lua task.

3 years agoMINOR: httpclient: httpclient_ended() returns 1 if the client ended
William Lallemand [Tue, 21 Sep 2021 08:58:10 +0000 (10:58 +0200)] 
MINOR: httpclient: httpclient_ended() returns 1 if the client ended

httpclient_ended() returns 1 if there is no more data to collect,
because the client received everything or the connection ended.

3 years agoMINOR: httpclient: httpclient_data() returns the available data
William Lallemand [Tue, 21 Sep 2021 08:45:34 +0000 (10:45 +0200)] 
MINOR: httpclient: httpclient_data() returns the available data

httpclient_data() returns the available data in the httpclient.

3 years agoCLEANUP: stats: Fix some alignment mistakes
Thierry Fournier [Thu, 23 Sep 2021 22:03:07 +0000 (00:03 +0200)] 
CLEANUP: stats: Fix some alignment mistakes

This patch fix some broken alignements. Code is not modified
The command `git show -w` whows nothing.

3 years agoMINOR: stats: Enable dark mode on stat web page
Thierry Fournier [Thu, 23 Sep 2021 21:59:49 +0000 (23:59 +0200)] 
MINOR: stats: Enable dark mode on stat web page

According with the W3 CSS specification, media queries 5 allow
the browser to enable some CSS when dark mode is enabled. This
patch defines dark mode CSS for the stats page.

https://www.w3.org/TR/mediaqueries-5/#prefers-color-scheme

3 years agoBUG/MINOR: http-ana: increment internal_errors counter on response error
Dragan Dosen [Tue, 21 Sep 2021 11:02:09 +0000 (13:02 +0200)] 
BUG/MINOR: http-ana: increment internal_errors counter on response error

A bug was introduced in the commit cff0f739e51 ("MINOR: counters: Review
conditions to increment counters from analysers"). The internal_errors
counter for the target server was incremented twice. The counter for the
session listener needs to be incremented instead.

This must be backported everywhere the commit cff0f739e51 is.

3 years agoMINOR: stream-int: Notify mux when the buffer is not stuck when calling rcv_buf
Christopher Faulet [Tue, 21 Sep 2021 13:50:55 +0000 (15:50 +0200)] 
MINOR: stream-int: Notify mux when the buffer is not stuck when calling rcv_buf

The transient flag CO_RFL_BUF_NOT_STUCK should now be set when the mux's
rcv_buf() function is called, in si_cs_recv(), to be sure the mux is able to
perform some optimisation during data copy. This flag is set when we are
sure the channel buffer is not stuck. Concretely, it happens when there are
data scheduled to be sent.

It is not a fix and this flag is not used for now. But it makes sense to have
this info to be sure to be able to do some optimisations if necessary.

This patch is related to the issue #1362. It may be backported to 2.4 to
ease future backports.

3 years agoBUG/MEDIUM: stream-int: Defrag HTX message in si_cs_recv() if necessary
Christopher Faulet [Tue, 21 Sep 2021 13:22:12 +0000 (15:22 +0200)] 
BUG/MEDIUM: stream-int: Defrag HTX message in si_cs_recv() if necessary

The stream interface is now responsible for defragmenting the HTX message of
the input channel if necessary, before calling the mux's .rcv_buf()
function. The defrag is performed if the underlying buffer contains only
input data while the HTX message free space is not contiguous.

The defrag is important here to be sure the mux and the app layer have the
same criteria to decide if a buffer is full or not. Otherwise, the app layer
may wait for more data because the buffer is not full while the mux is
blocked because it needs more space to proceed.

This patch depends on following commits:

  * MINOR: htx: Add an HTX flag to know when a message is fragmented
  * MINOR: htx: Add a function to know if the free space wraps

This patch is related to the issue #1362. It may be backported as far as 2.0
after some observation period (not sure it is required or not).

3 years agoMINOR: htx: Add a function to know if the free space wraps
Christopher Faulet [Tue, 21 Sep 2021 13:45:05 +0000 (15:45 +0200)] 
MINOR: htx: Add a function to know if the free space wraps

the htx_space_wraps() function may now be used to know if the free space of
an HTX message wraps. It does the same as b_space_wraps().

3 years agoMINOR: htx: Add an HTX flag to know when a message is fragmented
Christopher Faulet [Tue, 21 Sep 2021 13:39:30 +0000 (15:39 +0200)] 
MINOR: htx: Add an HTX flag to know when a message is fragmented

HTX_FL_FRAGMENTED flag is now set on an HTX message when it is
fragmented. It happens when an HTX block is removed in the middle of the
message and flagged as unused. HTX_FL_FRAGMENTED flag is removed when all
data are removed from the message or when the message is defragmented.

Note that some optimisations are still possible because the flag can be
avoided in other situations. For instance when the last header of a bodyless
message is removed.

3 years agoMINOR: stream-int: Set CO_RFL transient/persistent flags apart in si_cs_rcv()
Christopher Faulet [Tue, 21 Sep 2021 13:14:57 +0000 (15:14 +0200)] 
MINOR: stream-int: Set CO_RFL transient/persistent flags apart in si_cs_rcv()

In si_cs_recv(), some CO_RFL flags are set when the mux's .rcv_buf()
function is called. Some are persitent inside si_cs_recv() scope, some
others must be computed at each call to rcv_buf(). This patch takes care of
distinguishing them.

Among others, CO_RFL_KEEP_RECV is a persistent flag while CO_RFL_BUF_WET is
transient.

3 years agoBUG/MEDIUM: stream: Stop waiting for more data if SI is blocked on RXBLK_ROOM
Christopher Faulet [Thu, 23 Sep 2021 12:46:32 +0000 (14:46 +0200)] 
BUG/MEDIUM: stream: Stop waiting for more data if SI is blocked on RXBLK_ROOM

If the stream-interface is waiting for more buffer room to store incoming
data, it is important at the stream level to stop to wait for more data to
continue. Thanks to the previous patch ("BUG/MEDIUM: stream-int: Notify
stream that the mux wants more room to xfer data"), the stream is woken up
when this happens. In this patch, we take care to interrupt the
corresponding tcp-content ruleset or to stop waiting for the HTTP message
payload.

To ease detection of the state, si_rx_blocked_room() helper function has
been added. It returns non-zero if the stream interface's Rx path is blocked
because of lack of room in the input buffer.

This patch is part of a series related to the issue #1362. It should be
backported as ar as 2.0, probably with some adaptations. So be careful
during backports.

3 years agoBUG/MEDIUM: stream-int: Notify stream that the mux wants more room to xfer data
Christopher Faulet [Thu, 23 Sep 2021 12:17:20 +0000 (14:17 +0200)] 
BUG/MEDIUM: stream-int: Notify stream that the mux wants more room to xfer data

When the mux failed to transfer data to the upper layer because of a lack of
room, it is important to wake the stream up to let it handle this
event. Otherwise, if the stream is waiting for more data, both the stream
and the mux reamin blocked waiting for each other.

When this happens, the mux set the CS_FL_WANT_ROOM flag on the
conn-stream. Thus, in si_cs_recv() we are able to detect this event. Today,
the stream-interface is blocked. But, it is not enough to wake the stream
up. To fix the bug, CF_READ_PARTIAL flag is extended to also handle cases
where a read exception occurred. This flag should idealy be renamed. But for
now, it is good enough. By setting this flag, we are sure the stream will be
woken up.

This patch is part of a series related to the issue #1362. It should be
backported as far as 2.0, probably with some adaptations. So be careful
during backports.

3 years agoBUG/MEDIUM: mux-h1: Adjust conditions to ask more space in the channel buffer
Christopher Faulet [Mon, 20 Sep 2021 05:47:27 +0000 (07:47 +0200)] 
BUG/MEDIUM: mux-h1: Adjust conditions to ask more space in the channel buffer

When a message is parsed and copied into the channel buffer, in
h1_process_demux(), more space is requested if some pending data remain
after the parsing while the channel buffer is not empty. To do so,
CS_FL_WANT_ROOM flag is set. It means the H1 parser needs more space in the
channel buffer to continue. In the stream-interface, when this flag is set,
the SI is considered as blocked on the RX path. It is only unblocked when
some data are sent.

However, it is not accurrate because the parsing may be stopped because
there is not enough data to continue. For instance in the middle of a chunk
size. In this case, some data may have been already copied but the parser is
blocked because it must receive more data to continue. If the calling SI is
blocked on RX at this stage when the stream is waiting for the payload
(because http-buffer-request is set for instance), the stream remains stuck
infinitely.

To fix the bug, we must request more space to the app layer only when it is
not possible to copied more data. Actually, this happens when data remain in
the input buffer while the H1 parser is in states MSG_DATA or MSG_TUNNEL, or
when we are unable to copy headers or trailers into a non-empty buffer.

The first condition is quite easy to handle. The second one requires an API
refactoring. h1_parse_msg_hdrs() and h1_parse_msg_tlrs() fnuctions have been
updated. Now it is possible to know when we need more space in the buffer to
copy headers or trailers (-2 is returned). In the H1 mux, a new H1S flag
(H1S_F_RX_CONGESTED) is used to track this state inside h1_process_demux().

This patch is part of a series related to the issue #1362. It should be
backported as far as 2.0, probably with some adaptations. So be careful
during backports.

3 years agoBUG/MINOR: h1-htx: Fix a typo when request parser is reset
Christopher Faulet [Thu, 23 Sep 2021 13:38:26 +0000 (15:38 +0200)] 
BUG/MINOR: h1-htx: Fix a typo when request parser is reset

In h1_postparse_req_hdrs(), if we need more space to copy headers, the request
parser is reset. However, because of a typo, it was reset as a response parser
instead of a request one. h1m_init_req() must be called.

This patch must be backported as far as 2.2.

3 years agoMINOR: quic: fix qcc subs initialization
Amaury Denoyelle [Wed, 22 Sep 2021 13:28:27 +0000 (15:28 +0200)] 
MINOR: quic: fix qcc subs initialization

3 years agoMEDIUM: quic: implement mux release/conn free
Amaury Denoyelle [Wed, 22 Sep 2021 12:48:32 +0000 (14:48 +0200)] 
MEDIUM: quic: implement mux release/conn free

3 years agoMINOR: quic: define close handler
Amaury Denoyelle [Wed, 22 Sep 2021 09:14:37 +0000 (11:14 +0200)] 
MINOR: quic: define close handler

3 years agoMINOR: quic: Crash upon too big packets receipt
Frédéric Lécaille [Thu, 23 Sep 2021 05:33:20 +0000 (07:33 +0200)] 
MINOR: quic: Crash upon too big packets receipt

This bug came with this commit:
    ("MINOR: quic: RX packets memory leak")
Too big packets were freed twice.

3 years agoMINOR: quic: Possible endless loop in qc_treat_rx_pkts()
Frédéric Lécaille [Wed, 22 Sep 2021 13:15:46 +0000 (15:15 +0200)] 
MINOR: quic: Possible endless loop in qc_treat_rx_pkts()

Ensure we do not endlessly treat always the same encryption level
in qc_treat_rx_pkts().

3 years agoMINOR: quic: RX packets memory leak
Frédéric Lécaille [Wed, 22 Sep 2021 13:10:49 +0000 (15:10 +0200)] 
MINOR: quic: RX packets memory leak

Missing RX packet reference counter decrementation at the lowest level.
This leaded the memory reserved for RX packets to never be released.

3 years agoCLEANUP: quic: Remove useless inline functions
Frédéric Lécaille [Wed, 22 Sep 2021 06:34:21 +0000 (08:34 +0200)] 
CLEANUP: quic: Remove useless inline functions

We want to track the packet reference counting more easily, so without
inline functions.

3 years agoMINOR: quic: Wake up the xprt from mux
Frédéric Lécaille [Mon, 20 Sep 2021 15:58:22 +0000 (17:58 +0200)] 
MINOR: quic: Wake up the xprt from mux

We wake up the xprt as soon as STREAM frames have been pushed to
the TX mux buffer (->tx.buf).
We also make the mux subscribe() to the xprt layer if some data
remain in its ring buffer after having try to transfer them to the
xprt layer (TX mux buffer for the stream full).
Also do not consider a buffer in the ring if not allocated (see b_size(buf))
condition in the for(;;) loop.
Make a call to qc_process_mux() if possible when entering qc_send() to
fill the mux with data from streams in the send or flow control lists.

3 years agoMINOR: quic: Implement qc_process_mux()
Frédéric Lécaille [Mon, 20 Sep 2021 15:53:17 +0000 (17:53 +0200)] 
MINOR: quic: Implement qc_process_mux()

At this time, we only add calls to qc_resume_each_sending_qcs()
which handle the flow control and send lists.

3 years agoMINOR: quic: Stream FIN bit fix in qcs_push_frame()
Frédéric Lécaille [Mon, 20 Sep 2021 15:50:03 +0000 (17:50 +0200)] 
MINOR: quic: Stream FIN bit fix in qcs_push_frame()

The FIN of a STREAM frame to be built must be set if there is no more
at all data in the ring buffer.
Do not do anything if there is nothing to transfer the ->tx.buf mux
buffer via b_force_xfer() (without zero copy)

3 years agoMINOR: quic: Wake up the mux upon ACK receipt
Frédéric Lécaille [Mon, 20 Sep 2021 14:59:51 +0000 (16:59 +0200)] 
MINOR: quic: Wake up the mux upon ACK receipt

When ACK have been received by the xprt, it must wake up the
mux if this latter has subscribed to SEND events. This is the
role of qcs_try_to_consume() to detect such a situation. This
is the function which consumes the buffer filled by the mux.

3 years agoMINOR: quic: Implement quic_conn_subscribe()
Frédéric Lécaille [Mon, 20 Sep 2021 13:23:17 +0000 (15:23 +0200)] 
MINOR: quic: Implement quic_conn_subscribe()

We implement ->subscribe() xprt callback which should be used only by the mux.

3 years agoMINOR: mux_quic: Export the mux related flags
Frédéric Lécaille [Mon, 20 Sep 2021 13:11:51 +0000 (15:11 +0200)] 
MINOR: mux_quic: Export the mux related flags

These flags should be available from the xprt which must be able to
wake up the mux when blocked.

3 years agoMINOR: quic: Add useful trace about pktns discarding
Frédéric Lécaille [Mon, 20 Sep 2021 09:18:24 +0000 (11:18 +0200)] 
MINOR: quic: Add useful trace about pktns discarding

It is important to know if the packet number spaces used during the
handshakes have really been discarding. If not, this may have a
significant impact on the packet loss detection.

3 years agoMINOR: quic: Initial packet number spaced not discarded
Frédéric Lécaille [Mon, 20 Sep 2021 09:00:46 +0000 (11:00 +0200)] 
MINOR: quic: Initial packet number spaced not discarded

There were cases where the Initial packet number space was not discarded.
This leaded the packet loss detection to continue to take it into
considuration during the connection lifetime. Some Application level
packets could not be retransmitted.

3 years agoMINOR: quic: Wrong packet number space selection in quic_loss_pktns()
Frédéric Lécaille [Fri, 17 Sep 2021 15:17:16 +0000 (17:17 +0200)] 
MINOR: quic: Wrong packet number space selection in quic_loss_pktns()

Ensure the tick is set for a packet number space loss time before
selecting it.

3 years agoMINOR: quic: Wrong packet loss detection due to wrong pktns order
Frédéric Lécaille [Fri, 17 Sep 2021 15:12:56 +0000 (17:12 +0200)] 
MINOR: quic: Wrong packet loss detection due to wrong pktns order

During the packet loss detection we must treat the paquet number
in this order Initial -> Handshake -> O1RTT. This was not the case
due to the chosen order to implement the array of packet number space
which was there before the packet loss detection implementation.

3 years agoMINOR: quic_tls: Client/serveur state reordering
Frédéric Lécaille [Fri, 17 Sep 2021 15:08:03 +0000 (17:08 +0200)] 
MINOR: quic_tls: Client/serveur state reordering

This is to ensure that expressions which compare the current
state with others are not polluted by the "handshake failed"
special state.

3 years agoMINOR: quic: Constantness fixes for frame builders/parsers.
Frédéric Lécaille [Fri, 17 Sep 2021 15:05:44 +0000 (17:05 +0200)] 
MINOR: quic: Constantness fixes for frame builders/parsers.

This is to ensure we do not modify important static variables:
the QUIC frame builders and parsers.

3 years agoMINOR: quic: Wrong packet flags settings during frame building
Frédéric Lécaille [Fri, 17 Sep 2021 14:57:14 +0000 (16:57 +0200)] 
MINOR: quic: Wrong packet flags settings during frame building

We flag the packet as being ack-eliciting when building the frame.
But a wrong variable was used to to so.

3 years agoMINOR: quic: Confusion between TX/RX for the frame builders
Frédéric Lécaille [Fri, 17 Sep 2021 14:51:51 +0000 (16:51 +0200)] 
MINOR: quic: Confusion between TX/RX for the frame builders

QUIC_FL_TX_PACKET_ACK_ELICITING was replaced by QUIC_FL_RX_PACKET_ACK_ELICITING
by this commit due to a copy and paste:
   e5b47b637 ("MINOR: quic: Add a mask for TX frame builders and their authorized packet types")
Furthermore the flags for the PADDING frame builder was not initialized.

3 years agoMINOR: quic: Add a typedef for unsigned long long
Frédéric Lécaille [Thu, 16 Sep 2021 09:04:49 +0000 (11:04 +0200)] 
MINOR: quic: Add a typedef for unsigned long long

As we manipulate very uint64_t variables which must be cast to
unsigned long long to be printed, let's add this useful type definition.

3 years agoMINOR: mux_quic: move qc_process() code to qc_send()
Frédéric Lécaille [Mon, 13 Sep 2021 14:13:00 +0000 (16:13 +0200)] 
MINOR: mux_quic: move qc_process() code to qc_send()

qc_process is supposed to be run for each I/O handler event, not
only for "send" events.

3 years agoMINOR: quic: Make use of buffer structs to handle STREAM frames
Frédéric Lécaille [Fri, 10 Sep 2021 07:13:39 +0000 (09:13 +0200)] 
MINOR: quic: Make use of buffer structs to handle STREAM frames

The STREAM data to send coming from the upper layer must be stored until
having being acked by the peer. To do so, we store them in buffer structs,
one by stream (see qcs.tx.buf). Each time a STREAM is built by quic_push_frame(),
its offset must match the offset of the first byte added to the buffer (modulo
the size of the buffer) by the frame. As they are not always acknowledged in
order, they may be stored in eb_trees ordered by their offset to be sure
to sequentially delete the STREAM data from their buffer, in the order they
have been added to it.

3 years agoMINOR: buf: Add b_force_xfer() function
Frédéric Lécaille [Thu, 9 Sep 2021 14:53:33 +0000 (16:53 +0200)] 
MINOR: buf: Add b_force_xfer() function

This function does exactly the same thing as b_xfer() which transfers
data from a struct buffer to another one but without zero copy when
the destination buffer is empty. This is at least useful to transfer
h3 data to the QUIC mux from buffer with garbage medata which have
been used to build h3 frames without too much memcopy()/memmove().

3 years agoMINOR: quic_sock: Do not flag QUIC connections as being set
Frédéric Lécaille [Wed, 8 Sep 2021 15:08:17 +0000 (17:08 +0200)] 
MINOR: quic_sock: Do not flag QUIC connections as being set

This is to let conn_get_src() or conn_get_src() set the source
or destination addresses for the connection.

3 years agoMINOR: quic: Missing active_connection_id_limit default value
Frédéric Lécaille [Fri, 3 Sep 2021 14:42:19 +0000 (16:42 +0200)] 
MINOR: quic: Missing active_connection_id_limit default value

The peer transport parameter values were not initialized with
the default ones (when absent), especially the
"active_connection_id_limit" parameter with 2 as default value
when absent from received remote transport parameters. This
had as side effect to send too much NEW_CONNECTION_ID frames.
This was the case for curl which does not announce any
"active_connection_id_limit" parameter.
Also rename ->idle_timeout to ->max_idle_timeout to reflect the RFC9000.

3 years agoMINOR: quic: Attach the QUIC connection to a thread.
Frédéric Lécaille [Fri, 3 Sep 2021 13:56:18 +0000 (15:56 +0200)] 
MINOR: quic: Attach the QUIC connection to a thread.

Compute a thread ID from a QUIC CID and attach the I/O handler to this
thread.

3 years agoMINOR: quic: Make QUIC-TLS support at least two initial salts
Frédéric Lécaille [Tue, 31 Aug 2021 17:10:40 +0000 (19:10 +0200)] 
MINOR: quic: Make QUIC-TLS support at least two initial salts

These salts are used to derive initial secrets to decrypt the first Initial packet.
We support draft-29 and v1 QUIC version initial salts.
Add parameters to our QUIC-TLS API functions used to derive these secret for
these salts.
Make our xprt_quic use the correct initial salt upon QUIC version field found in
the first paquet. Useful to support connections with curl which use draft-29
QUIC version.

3 years agoMINOR: quic: Shorten some handshakes
Frédéric Lécaille [Mon, 30 Aug 2021 15:16:07 +0000 (17:16 +0200)] 
MINOR: quic: Shorten some handshakes

Move the "ACK required" bit from the packet number space to the connection level.
Force the "ACK required" option when acknowlegding Handshake or Initial packet.
A client may send three packets with a different encryption level for each. So,
this patch modifies qc_treat_rx_pkts() to consider two encryption level passed
as parameters, in place of only one.
Make qc_conn_io_cb() restart its process after the handshake has succeeded
so that to process any Application level packets which have already been received
in the same datagram as the last CRYPTO frames in Handshake packets.

3 years agoMINOR: h3/mux: detect fin on last h3 frame of the stream
Amaury Denoyelle [Tue, 24 Aug 2021 14:28:47 +0000 (16:28 +0200)] 
MINOR: h3/mux: detect fin on last h3 frame of the stream

3 years agoMINOR: h3: send htx data
Amaury Denoyelle [Tue, 24 Aug 2021 14:24:37 +0000 (16:24 +0200)] 
MINOR: h3: send htx data

3 years agoMINOR: h3: encode htx headers to QPACK
Amaury Denoyelle [Tue, 24 Aug 2021 14:20:27 +0000 (16:20 +0200)] 
MINOR: h3: encode htx headers to QPACK

3 years agoMINOR: qpack: encode headers functions
Amaury Denoyelle [Tue, 24 Aug 2021 14:17:38 +0000 (16:17 +0200)] 
MINOR: qpack: encode headers functions

3 years agoMINOR: qpack: create qpack-enc module
Amaury Denoyelle [Tue, 24 Aug 2021 13:50:32 +0000 (15:50 +0200)] 
MINOR: qpack: create qpack-enc module

3 years agoMINOR: mux-quic: define FIN stream flag
Amaury Denoyelle [Fri, 27 Aug 2021 12:55:39 +0000 (14:55 +0200)] 
MINOR: mux-quic: define FIN stream flag

3 years agoMINOR: h3: define snd_buf callback and divert mux ops
Amaury Denoyelle [Tue, 24 Aug 2021 14:33:53 +0000 (16:33 +0200)] 
MINOR: h3: define snd_buf callback and divert mux ops

3 years agoMINOR: mux-quic: send SETTINGS on uni stream
Amaury Denoyelle [Fri, 27 Aug 2021 13:05:29 +0000 (15:05 +0200)] 
MINOR: mux-quic: send SETTINGS on uni stream

3 years agoMEDIUM: mux-quic: implement ring buffer on stream tx
Amaury Denoyelle [Tue, 24 Aug 2021 14:11:18 +0000 (16:11 +0200)] 
MEDIUM: mux-quic: implement ring buffer on stream tx

3 years agoMINOR: h3: allocate stream on headers
Amaury Denoyelle [Tue, 24 Aug 2021 13:36:02 +0000 (15:36 +0200)] 
MINOR: h3: allocate stream on headers

3 years agoMINOR: h3: parse headers to htx
Amaury Denoyelle [Tue, 24 Aug 2021 13:30:12 +0000 (15:30 +0200)] 
MINOR: h3: parse headers to htx

3 years agoMINOR: qpack: generate headers list on decoder
Amaury Denoyelle [Tue, 24 Aug 2021 13:13:20 +0000 (15:13 +0200)] 
MINOR: qpack: generate headers list on decoder

TMP -> non-free strdup
TMP -> currently only support indexed field line or literal field line
with name reference

3 years agoMINOR: qpack: fix wrong comment
Amaury Denoyelle [Tue, 24 Aug 2021 13:36:39 +0000 (15:36 +0200)] 
MINOR: qpack: fix wrong comment

3 years agoMINOR: quic-enc: fix varint encoding
Amaury Denoyelle [Tue, 24 Aug 2021 14:29:49 +0000 (16:29 +0200)] 
MINOR: quic-enc: fix varint encoding

3 years agoMINOR: h3: change default settings
Amaury Denoyelle [Tue, 24 Aug 2021 13:16:58 +0000 (15:16 +0200)] 
MINOR: h3: change default settings

In particular, advertise a 0-length dynamic table for QPACK.

3 years agoMINOR: quic: Prepare STREAM frames to fill QUIC packets
Frédéric Lécaille [Wed, 25 Aug 2021 15:56:22 +0000 (17:56 +0200)] 
MINOR: quic: Prepare STREAM frames to fill QUIC packets

We must take as most as possible data from STREAM frames to be encapsulated
in QUIC packets, almost as this is done for CRYPTO frames whose fields are
variable length fields. The difference is that STREAM frames are only accepted
for short packets without any "Length" field. So it is sufficient to call
max_available_room() for that in place of max_stream_data_size() as this
is done for CRYPTO data.

3 years agoMINOR: quic: Wrong short packet minimum length
Frédéric Lécaille [Wed, 25 Aug 2021 14:11:00 +0000 (16:11 +0200)] 
MINOR: quic: Wrong short packet minimum length

There is no destination connection ID length field in the short packet header.

3 years agoMINOR: quic: Wrong STREAM frame length computing
Frédéric Lécaille [Wed, 25 Aug 2021 14:08:47 +0000 (16:08 +0200)] 
MINOR: quic: Wrong STREAM frame length computing

The ->len and ->offset field of STREAM frame are optional.

3 years agoMINOR: h3: Send h3 settings asap
Frédéric Lécaille [Mon, 23 Aug 2021 07:50:29 +0000 (09:50 +0200)] 
MINOR: h3: Send h3 settings asap

As it is possible to send Application level packets during the handshake,
let's send the h3 settings asaps.

3 years agoMINOR: quic: Prepare Application level packet asap.
Frédéric Lécaille [Mon, 23 Aug 2021 06:54:28 +0000 (08:54 +0200)] 
MINOR: quic: Prepare Application level packet asap.

It is possible the TLS stack stack provides us with 1-RTT TX secrets
at the same time as Handshake secrets are provided. Thanks to this
simple patch we can build Application level packets during the handshake.

3 years agoMINOR: quic: Post handshake packet building improvements
Frédéric Lécaille [Thu, 19 Aug 2021 15:35:21 +0000 (17:35 +0200)] 
MINOR: quic: Post handshake packet building improvements

Make qc_prep_hdshk_pkts() and qui_conn_io_cb() handle the case
where we enter them with QUIC_HS_ST_COMPLETE or QUIC_HS_ST_CONFIRMED
as connection state with QUIC_TLS_ENC_LEVEL_APP and QUIC_TLS_ENC_LEVEL_NONE
to consider to prepare packets.
quic_get_tls_enc_levels() is modified to return QUIC_TLS_ENC_LEVEL_APP
and QUIC_TLS_ENC_LEVEL_NONE as levels to consider when coalescing
packets in the same datagram.

3 years agoMINOR: quic: Missing case when discarding HANDSHAKE secrets
Frédéric Lécaille [Thu, 19 Aug 2021 13:35:59 +0000 (15:35 +0200)] 
MINOR: quic: Missing case when discarding HANDSHAKE secrets

With very few packets received by the listener, it is possible
that its state may move from QUIC_HS_ST_SERVER_INITIAL to
QUIC_HS_ST_COMPLETE without transition to QUIC_HS_ST_SERVER_HANDSHAKE state.
This latter state is not mandatory.

3 years agoMINOR: quic: Wrong flags handling for acks
Frédéric Lécaille [Thu, 19 Aug 2021 13:19:09 +0000 (15:19 +0200)] 
MINOR: quic: Wrong flags handling for acks

Fixes several concurrent accesses issue regarding QUIC_FL_PKTNS_ACK_RECEIVED and
QUIC_FL_PKTNS_ACK_REQUIRED flags.

3 years agoMINOR: quic: Coalesce Application level packets with Handshake packets.
Frédéric Lécaille [Thu, 19 Aug 2021 05:53:27 +0000 (07:53 +0200)] 
MINOR: quic: Coalesce Application level packets with Handshake packets.

This simple enable use to coalesce Application level packet with
Handshake ones at the end of the handshake. This is highly useful
if we do want to send a short Handshake packet followed by Application
level ones.

3 years agoMINOR: quic: Missing QUIC encryption level for qc_build_pkt()
Frédéric Lécaille [Thu, 19 Aug 2021 05:33:08 +0000 (07:33 +0200)] 
MINOR: quic: Missing QUIC encryption level for qc_build_pkt()

qc_build_pkt() has recently been modified to support any type of
supported frame at any encryption level (assuming that an encryption level does
not support any type of frame) but quic_tls_level_pkt_type()
prevented it from building application level packet type because it was written
only for the handshake.
This patch simply adds the remaining encryption level QUIC_TLS_ENC_LEVEL_APP
which must be supported by quic_tls_level_pkt_type().

3 years agoMINOR: quic: Atomically get/set the connection state
Frédéric Lécaille [Wed, 18 Aug 2021 07:16:01 +0000 (09:16 +0200)] 
MINOR: quic: Atomically get/set the connection state

As ->state quic_conn struct member field is shared between threads
we must atomically get and set its value.

3 years agoMINOR: quic: Fix handshake state debug strings
Frédéric Lécaille [Wed, 18 Aug 2021 07:10:48 +0000 (09:10 +0200)] 
MINOR: quic: Fix handshake state debug strings

There was a collision between QUIC_HS_ST_CLIENT_HANDSHAKE_FAILED
and QUIC_HS_ST_CONFIRMED states.

3 years agoMINOR: quic: Update the TLS extension for QUIC transport parameters
Frédéric Lécaille [Mon, 16 Aug 2021 15:08:26 +0000 (17:08 +0200)] 
MINOR: quic: Update the TLS extension for QUIC transport parameters

0xffa5 value was a draft one. Let's update this extension to the one
defined by the QUIC-TLS RFC 9001.
(See https://www.rfc-editor.org/rfc/rfc9001.html#name-quic-transport-parameters-e).

3 years agoMINOR: quic: Evaluate the packet lengths in advance
Frédéric Lécaille [Mon, 16 Aug 2021 10:06:46 +0000 (12:06 +0200)] 
MINOR: quic: Evaluate the packet lengths in advance

We must evaluate the packet lenghts in advance to be sure we do not
consume a packet number for nothing. The packet building must always
succeeds. This is the role of qc_eval_pkt() implemented by this patch
called before calling qc_do_build_pkt() which was previously modified to
always succeed.