2022-11-11 18:45:34 +08:00
|
|
|
#ifndef HEADER_CURL_CFILTERS_H
|
|
|
|
#define HEADER_CURL_CFILTERS_H
|
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2023-01-02 20:51:48 +08:00
|
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2022-11-11 18:45:34 +08:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: curl
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
struct Curl_cfilter;
|
|
|
|
struct Curl_easy;
|
2022-11-22 16:55:41 +08:00
|
|
|
struct Curl_dns_entry;
|
|
|
|
struct connectdata;
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/* Callback to destroy resources held by this filter instance.
|
|
|
|
* Implementations MUST NOT chain calls to cf->next.
|
2022-11-11 18:45:34 +08:00
|
|
|
*/
|
2022-11-25 21:06:43 +08:00
|
|
|
typedef void Curl_cft_destroy_this(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-25 21:06:43 +08:00
|
|
|
typedef void Curl_cft_close(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-25 21:06:43 +08:00
|
|
|
typedef CURLcode Curl_cft_connect(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
bool blocking, bool *done);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/* Return the hostname and port the connection goes to.
|
|
|
|
* This may change with the connection state of filters when tunneling
|
|
|
|
* is involved.
|
|
|
|
* @param cf the filter to ask
|
|
|
|
* @param data the easy handle currently active
|
|
|
|
* @param phost on return, points to the relevant, real hostname.
|
|
|
|
* this is owned by the connection.
|
|
|
|
* @param pdisplay_host on return, points to the printable hostname.
|
|
|
|
* this is owned by the connection.
|
|
|
|
* @param pport on return, contains the port number
|
|
|
|
*/
|
2022-11-25 21:06:43 +08:00
|
|
|
typedef void Curl_cft_get_host(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
const char **phost,
|
|
|
|
const char **pdisplay_host,
|
|
|
|
int *pport);
|
2022-11-22 16:55:41 +08:00
|
|
|
|
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.
Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.
This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.
Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.
After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.
Example:
* transfer wants to send, adds POLLOUT
* http/2 filter has a flow control block, removes POLLOUT and adds
POLLIN (it is waiting on a WINDOW_UPDATE from the server)
* TLS filter is connected and changes nothing
* h2-proxy filter also has a flow control block on its tunnel stream,
removes POLLOUT and adds POLLIN also.
* socket filter is connected and changes nothing
* The resulting pollset is then mixed together with all other transfers
and their pollsets, just as before.
Use of `SEND_HOLD` is no longer necessary in the filters.
All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.
The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.
No noticeable difference in performance was detected in local scorecard
runs.
Closes #11833
2023-09-04 18:06:07 +08:00
|
|
|
struct easy_pollset;
|
|
|
|
|
|
|
|
/* Passing in an easy_pollset for monitoring of sockets, let
|
|
|
|
* filters add or remove sockets actions (CURL_POLL_OUT, CURL_POLL_IN).
|
|
|
|
* This may add a socket or, in case no actions remain, remove
|
|
|
|
* a socket from the set.
|
|
|
|
*
|
|
|
|
* Filter implementations need to call filters "below" *after* they have
|
|
|
|
* made their adjustments. This allows lower filters to override "upper"
|
|
|
|
* actions. If a "lower" filter is unable to write, it needs to be able
|
|
|
|
* to disallow POLL_OUT.
|
|
|
|
*
|
|
|
|
* A filter without own restrictions/preferences should not modify
|
|
|
|
* the pollset. Filters, whose filter "below" is not connected, should
|
|
|
|
* also do no adjustments.
|
|
|
|
*
|
|
|
|
* Examples: a TLS handshake, while ongoing, might remove POLL_IN
|
|
|
|
* when it needs to write, or vice versa. A HTTP/2 filter might remove
|
|
|
|
* POLL_OUT when a stream window is exhausted and a WINDOW_UPDATE needs
|
|
|
|
* to be received first and add instead POLL_IN.
|
|
|
|
*
|
|
|
|
* @param cf the filter to ask
|
|
|
|
* @param data the easy handle the pollset is about
|
|
|
|
* @param ps the pollset (inout) for the easy handle
|
2022-11-11 18:45:34 +08:00
|
|
|
*/
|
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.
Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.
This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.
Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.
After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.
Example:
* transfer wants to send, adds POLLOUT
* http/2 filter has a flow control block, removes POLLOUT and adds
POLLIN (it is waiting on a WINDOW_UPDATE from the server)
* TLS filter is connected and changes nothing
* h2-proxy filter also has a flow control block on its tunnel stream,
removes POLLOUT and adds POLLIN also.
* socket filter is connected and changes nothing
* The resulting pollset is then mixed together with all other transfers
and their pollsets, just as before.
Use of `SEND_HOLD` is no longer necessary in the filters.
All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.
The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.
No noticeable difference in performance was detected in local scorecard
runs.
Closes #11833
2023-09-04 18:06:07 +08:00
|
|
|
typedef void Curl_cft_adjust_pollset(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps);
|
2022-11-25 21:06:43 +08:00
|
|
|
|
|
|
|
typedef bool Curl_cft_data_pending(struct Curl_cfilter *cf,
|
|
|
|
const struct Curl_easy *data);
|
|
|
|
|
|
|
|
typedef ssize_t Curl_cft_send(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data, /* transfer */
|
|
|
|
const void *buf, /* data to write */
|
|
|
|
size_t len, /* amount to write */
|
|
|
|
CURLcode *err); /* error to return */
|
|
|
|
|
|
|
|
typedef ssize_t Curl_cft_recv(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data, /* transfer */
|
|
|
|
char *buf, /* store data here */
|
|
|
|
size_t len, /* amount to read */
|
|
|
|
CURLcode *err); /* error to return */
|
|
|
|
|
2022-12-30 16:14:55 +08:00
|
|
|
typedef bool Curl_cft_conn_is_alive(struct Curl_cfilter *cf,
|
2023-03-06 19:44:45 +08:00
|
|
|
struct Curl_easy *data,
|
|
|
|
bool *input_pending);
|
2022-12-30 16:14:55 +08:00
|
|
|
|
|
|
|
typedef CURLcode Curl_cft_conn_keep_alive(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
|
|
|
/**
|
2022-12-30 16:14:55 +08:00
|
|
|
* Events/controls for connection filters, their arguments and
|
|
|
|
* return code handling. Filter callbacks are invoked "top down".
|
|
|
|
* Return code handling:
|
|
|
|
* "first fail" meaning that the first filter returning != CURLE_OK, will
|
|
|
|
* abort further event distribution and determine the result.
|
|
|
|
* "ignored" meaning return values are ignored and the event is distributed
|
|
|
|
* to all filters in the chain. Overall result is always CURLE_OK.
|
2022-11-11 18:45:34 +08:00
|
|
|
*/
|
2022-12-30 16:14:55 +08:00
|
|
|
/* data event arg1 arg2 return */
|
|
|
|
#define CF_CTRL_DATA_ATTACH 1 /* 0 NULL ignored */
|
|
|
|
#define CF_CTRL_DATA_DETACH 2 /* 0 NULL ignored */
|
|
|
|
#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */
|
|
|
|
#define CF_CTRL_DATA_IDLE 5 /* 0 NULL first fail */
|
|
|
|
#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */
|
|
|
|
#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */
|
|
|
|
#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */
|
|
|
|
/* update conn info at connection and data */
|
|
|
|
#define CF_CTRL_CONN_INFO_UPDATE (256+0) /* 0 NULL ignored */
|
2023-10-26 23:02:45 +08:00
|
|
|
#define CF_CTRL_FORGET_SOCKET (256+1) /* 0 NULL ignored */
|
2022-12-30 16:14:55 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle event/control for the filter.
|
|
|
|
* Implementations MUST NOT chain calls to cf->next.
|
|
|
|
*/
|
|
|
|
typedef CURLcode Curl_cft_cntrl(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
int event, int arg1, void *arg2);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queries to ask via a `Curl_cft_query *query` method on a cfilter chain.
|
|
|
|
* - MAX_CONCURRENT: the maximum number of parallel transfers the filter
|
|
|
|
* chain expects to handle at the same time.
|
|
|
|
* default: 1 if no filter overrides.
|
connections: introduce http/3 happy eyeballs
New cfilter HTTP-CONNECT for h3/h2/http1.1 eyeballing.
- filter is installed when `--http3` in the tool is used (or
the equivalent CURLOPT_ done in the library)
- starts a QUIC/HTTP/3 connect right away. Should that not
succeed after 100ms (subject to change), a parallel attempt
is started for HTTP/2 and HTTP/1.1 via TCP
- both attempts are subject to IPv6/IPv4 eyeballing, same
as happens for other connections
- tie timeout to the ip-version HAPPY_EYEBALLS_TIMEOUT
- use a `soft` timeout at half the value. When the soft timeout
expires, the HTTPS-CONNECT filter checks if the QUIC filter
has received any data from the server. If not, it will start
the HTTP/2 attempt.
HTTP/3(ngtcp2) improvements.
- setting call_data in all cfilter calls similar to http/2 and vtls filters
for use in callback where no stream data is available.
- returning CURLE_PARTIAL_FILE for prematurely terminated transfers
- enabling pytest test_05 for h3
- shifting functionality to "connect" UDP sockets from ngtcp2
implementation into the udp socket cfilter. Because unconnected
UDP sockets are weird. For example they error when adding to a
pollset.
HTTP/3(quiche) improvements.
- fixed upload bug in quiche implementation, now passes 251 and pytest
- error codes on stream RESET
- improved debug logs
- handling of DRAIN during connect
- limiting pending event queue
HTTP/2 cfilter improvements.
- use LOG_CF macros for dynamic logging in debug build
- fix CURLcode on RST streams to be CURLE_PARTIAL_FILE
- enable pytest test_05 for h2
- fix upload pytests and improve parallel transfer performance.
GOAWAY handling for ngtcp2/quiche
- during connect, when the remote server refuses to accept new connections
and closes immediately (so the local conn goes into DRAIN phase), the
connection is torn down and a another attempt is made after a short grace
period.
This is the behaviour observed with nghttpx when we tell it to shut
down gracefully. Tested in pytest test_03_02.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
- new tests/tests-httpd/scorecard.py for testing h3/h2 protocol implementation.
Invoke:
python3 tests/tests-httpd/scorecard.py --help
for usage.
Improvements on gathering connect statistics and socket access.
- new CF_CTRL_CONN_REPORT_STATS cfilter control for having cfilters
report connection statistics. This is triggered when the connection
has completely connected.
- new void Curl_pgrsTimeWas(..) method to report a timer update with
a timestamp of when it happend. This allows for updating timers
"later", e.g. a connect statistic after full connectivity has been
reached.
- in case of HTTP eyeballing, the previous changes will update
statistics only from the filter chain that "won" the eyeballing.
- new cfilter query CF_QUERY_SOCKET for retrieving the socket used
by a filter chain.
Added methods Curl_conn_cf_get_socket() and Curl_conn_get_socket()
for convenient use of this query.
- Change VTLS backend to query their sub-filters for the socket when
checks during the handshake are made.
HTTP/3 documentation on how https eyeballing works.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
Scorecard with Caddy.
- configure can be run with `--with-test-caddy=path` to specify which caddy to use for testing
- tests/tests-httpd/scorecard.py now measures download speeds with caddy
pytest improvements
- adding Makfile to clean gen dir
- adding nghttpx rundir creation on start
- checking httpd version 2.4.55 for test_05 cases where it is needed. Skipping with message if too old.
- catch exception when checking for caddy existance on system.
Closes #10349
2023-02-02 00:13:12 +08:00
|
|
|
* - CONNECT_REPLY_MS: milliseconds until the first indication of a server
|
|
|
|
* response was received on a connect. For TCP, this
|
|
|
|
* reflects the time until the socket connected. On UDP
|
|
|
|
* this gives the time the first bytes from the server
|
|
|
|
* were received.
|
|
|
|
* -1 if not determined yet.
|
|
|
|
* - CF_QUERY_SOCKET: the socket used by the filter chain
|
2022-12-30 16:14:55 +08:00
|
|
|
*/
|
|
|
|
/* query res1 res2 */
|
|
|
|
#define CF_QUERY_MAX_CONCURRENT 1 /* number - */
|
connections: introduce http/3 happy eyeballs
New cfilter HTTP-CONNECT for h3/h2/http1.1 eyeballing.
- filter is installed when `--http3` in the tool is used (or
the equivalent CURLOPT_ done in the library)
- starts a QUIC/HTTP/3 connect right away. Should that not
succeed after 100ms (subject to change), a parallel attempt
is started for HTTP/2 and HTTP/1.1 via TCP
- both attempts are subject to IPv6/IPv4 eyeballing, same
as happens for other connections
- tie timeout to the ip-version HAPPY_EYEBALLS_TIMEOUT
- use a `soft` timeout at half the value. When the soft timeout
expires, the HTTPS-CONNECT filter checks if the QUIC filter
has received any data from the server. If not, it will start
the HTTP/2 attempt.
HTTP/3(ngtcp2) improvements.
- setting call_data in all cfilter calls similar to http/2 and vtls filters
for use in callback where no stream data is available.
- returning CURLE_PARTIAL_FILE for prematurely terminated transfers
- enabling pytest test_05 for h3
- shifting functionality to "connect" UDP sockets from ngtcp2
implementation into the udp socket cfilter. Because unconnected
UDP sockets are weird. For example they error when adding to a
pollset.
HTTP/3(quiche) improvements.
- fixed upload bug in quiche implementation, now passes 251 and pytest
- error codes on stream RESET
- improved debug logs
- handling of DRAIN during connect
- limiting pending event queue
HTTP/2 cfilter improvements.
- use LOG_CF macros for dynamic logging in debug build
- fix CURLcode on RST streams to be CURLE_PARTIAL_FILE
- enable pytest test_05 for h2
- fix upload pytests and improve parallel transfer performance.
GOAWAY handling for ngtcp2/quiche
- during connect, when the remote server refuses to accept new connections
and closes immediately (so the local conn goes into DRAIN phase), the
connection is torn down and a another attempt is made after a short grace
period.
This is the behaviour observed with nghttpx when we tell it to shut
down gracefully. Tested in pytest test_03_02.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
- new tests/tests-httpd/scorecard.py for testing h3/h2 protocol implementation.
Invoke:
python3 tests/tests-httpd/scorecard.py --help
for usage.
Improvements on gathering connect statistics and socket access.
- new CF_CTRL_CONN_REPORT_STATS cfilter control for having cfilters
report connection statistics. This is triggered when the connection
has completely connected.
- new void Curl_pgrsTimeWas(..) method to report a timer update with
a timestamp of when it happend. This allows for updating timers
"later", e.g. a connect statistic after full connectivity has been
reached.
- in case of HTTP eyeballing, the previous changes will update
statistics only from the filter chain that "won" the eyeballing.
- new cfilter query CF_QUERY_SOCKET for retrieving the socket used
by a filter chain.
Added methods Curl_conn_cf_get_socket() and Curl_conn_get_socket()
for convenient use of this query.
- Change VTLS backend to query their sub-filters for the socket when
checks during the handshake are made.
HTTP/3 documentation on how https eyeballing works.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
Scorecard with Caddy.
- configure can be run with `--with-test-caddy=path` to specify which caddy to use for testing
- tests/tests-httpd/scorecard.py now measures download speeds with caddy
pytest improvements
- adding Makfile to clean gen dir
- adding nghttpx rundir creation on start
- checking httpd version 2.4.55 for test_05 cases where it is needed. Skipping with message if too old.
- catch exception when checking for caddy existance on system.
Closes #10349
2023-02-02 00:13:12 +08:00
|
|
|
#define CF_QUERY_CONNECT_REPLY_MS 2 /* number - */
|
|
|
|
#define CF_QUERY_SOCKET 3 /* - curl_socket_t */
|
2023-03-04 00:54:44 +08:00
|
|
|
#define CF_QUERY_TIMER_CONNECT 4 /* - struct curltime */
|
|
|
|
#define CF_QUERY_TIMER_APPCONNECT 5 /* - struct curltime */
|
2022-12-30 16:14:55 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Query the cfilter for properties. Filters ignorant of a query will
|
|
|
|
* pass it "down" the filter chain.
|
|
|
|
*/
|
|
|
|
typedef CURLcode Curl_cft_query(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
connections: introduce http/3 happy eyeballs
New cfilter HTTP-CONNECT for h3/h2/http1.1 eyeballing.
- filter is installed when `--http3` in the tool is used (or
the equivalent CURLOPT_ done in the library)
- starts a QUIC/HTTP/3 connect right away. Should that not
succeed after 100ms (subject to change), a parallel attempt
is started for HTTP/2 and HTTP/1.1 via TCP
- both attempts are subject to IPv6/IPv4 eyeballing, same
as happens for other connections
- tie timeout to the ip-version HAPPY_EYEBALLS_TIMEOUT
- use a `soft` timeout at half the value. When the soft timeout
expires, the HTTPS-CONNECT filter checks if the QUIC filter
has received any data from the server. If not, it will start
the HTTP/2 attempt.
HTTP/3(ngtcp2) improvements.
- setting call_data in all cfilter calls similar to http/2 and vtls filters
for use in callback where no stream data is available.
- returning CURLE_PARTIAL_FILE for prematurely terminated transfers
- enabling pytest test_05 for h3
- shifting functionality to "connect" UDP sockets from ngtcp2
implementation into the udp socket cfilter. Because unconnected
UDP sockets are weird. For example they error when adding to a
pollset.
HTTP/3(quiche) improvements.
- fixed upload bug in quiche implementation, now passes 251 and pytest
- error codes on stream RESET
- improved debug logs
- handling of DRAIN during connect
- limiting pending event queue
HTTP/2 cfilter improvements.
- use LOG_CF macros for dynamic logging in debug build
- fix CURLcode on RST streams to be CURLE_PARTIAL_FILE
- enable pytest test_05 for h2
- fix upload pytests and improve parallel transfer performance.
GOAWAY handling for ngtcp2/quiche
- during connect, when the remote server refuses to accept new connections
and closes immediately (so the local conn goes into DRAIN phase), the
connection is torn down and a another attempt is made after a short grace
period.
This is the behaviour observed with nghttpx when we tell it to shut
down gracefully. Tested in pytest test_03_02.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
- new tests/tests-httpd/scorecard.py for testing h3/h2 protocol implementation.
Invoke:
python3 tests/tests-httpd/scorecard.py --help
for usage.
Improvements on gathering connect statistics and socket access.
- new CF_CTRL_CONN_REPORT_STATS cfilter control for having cfilters
report connection statistics. This is triggered when the connection
has completely connected.
- new void Curl_pgrsTimeWas(..) method to report a timer update with
a timestamp of when it happend. This allows for updating timers
"later", e.g. a connect statistic after full connectivity has been
reached.
- in case of HTTP eyeballing, the previous changes will update
statistics only from the filter chain that "won" the eyeballing.
- new cfilter query CF_QUERY_SOCKET for retrieving the socket used
by a filter chain.
Added methods Curl_conn_cf_get_socket() and Curl_conn_get_socket()
for convenient use of this query.
- Change VTLS backend to query their sub-filters for the socket when
checks during the handshake are made.
HTTP/3 documentation on how https eyeballing works.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
Scorecard with Caddy.
- configure can be run with `--with-test-caddy=path` to specify which caddy to use for testing
- tests/tests-httpd/scorecard.py now measures download speeds with caddy
pytest improvements
- adding Makfile to clean gen dir
- adding nghttpx rundir creation on start
- checking httpd version 2.4.55 for test_05 cases where it is needed. Skipping with message if too old.
- catch exception when checking for caddy existance on system.
Closes #10349
2023-02-02 00:13:12 +08:00
|
|
|
int query, int *pres1, void *pres2);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-12-30 16:14:55 +08:00
|
|
|
/**
|
|
|
|
* Type flags for connection filters. A filter can have none, one or
|
|
|
|
* many of those. Use to evaluate state/capabilities of a filter chain.
|
|
|
|
*
|
|
|
|
* CF_TYPE_IP_CONNECT: provides an IP connection or sth equivalent, like
|
|
|
|
* a CONNECT tunnel, a UNIX domain socket, a QUIC
|
|
|
|
* connection, etc.
|
|
|
|
* CF_TYPE_SSL: provide SSL/TLS
|
|
|
|
* CF_TYPE_MULTIPLEX: provides multiplexing of easy handles
|
|
|
|
*/
|
2022-11-21 22:40:26 +08:00
|
|
|
#define CF_TYPE_IP_CONNECT (1 << 0)
|
|
|
|
#define CF_TYPE_SSL (1 << 1)
|
2022-12-30 16:14:55 +08:00
|
|
|
#define CF_TYPE_MULTIPLEX (1 << 2)
|
2022-11-21 22:40:26 +08:00
|
|
|
|
2022-11-11 18:45:34 +08:00
|
|
|
/* A connection filter type, e.g. specific implementation. */
|
|
|
|
struct Curl_cftype {
|
2022-11-25 21:06:43 +08:00
|
|
|
const char *name; /* name of the filter type */
|
2023-01-11 17:30:42 +08:00
|
|
|
int flags; /* flags of filter type */
|
|
|
|
int log_level; /* log level for such filters */
|
2022-11-25 21:06:43 +08:00
|
|
|
Curl_cft_destroy_this *destroy; /* destroy resources of this cf */
|
2023-07-21 01:07:49 +08:00
|
|
|
Curl_cft_connect *do_connect; /* establish connection */
|
|
|
|
Curl_cft_close *do_close; /* close conn */
|
2022-11-25 21:06:43 +08:00
|
|
|
Curl_cft_get_host *get_host; /* host filter talks to */
|
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.
Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.
This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.
Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.
After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.
Example:
* transfer wants to send, adds POLLOUT
* http/2 filter has a flow control block, removes POLLOUT and adds
POLLIN (it is waiting on a WINDOW_UPDATE from the server)
* TLS filter is connected and changes nothing
* h2-proxy filter also has a flow control block on its tunnel stream,
removes POLLOUT and adds POLLIN also.
* socket filter is connected and changes nothing
* The resulting pollset is then mixed together with all other transfers
and their pollsets, just as before.
Use of `SEND_HOLD` is no longer necessary in the filters.
All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.
The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.
No noticeable difference in performance was detected in local scorecard
runs.
Closes #11833
2023-09-04 18:06:07 +08:00
|
|
|
Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */
|
2022-11-25 21:06:43 +08:00
|
|
|
Curl_cft_data_pending *has_data_pending;/* conn has data pending */
|
|
|
|
Curl_cft_send *do_send; /* send data */
|
|
|
|
Curl_cft_recv *do_recv; /* receive data */
|
2022-12-30 16:14:55 +08:00
|
|
|
Curl_cft_cntrl *cntrl; /* events/control */
|
|
|
|
Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */
|
|
|
|
Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */
|
|
|
|
Curl_cft_query *query; /* query filter chain */
|
2022-11-11 18:45:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* A connection filter instance, e.g. registered at a connection */
|
|
|
|
struct Curl_cfilter {
|
|
|
|
const struct Curl_cftype *cft; /* the type providing implementation */
|
|
|
|
struct Curl_cfilter *next; /* next filter in chain */
|
|
|
|
void *ctx; /* filter type specific settings */
|
|
|
|
struct connectdata *conn; /* the connection this filter belongs to */
|
2022-12-30 16:14:55 +08:00
|
|
|
int sockindex; /* the index the filter is installed at */
|
2022-11-11 18:45:34 +08:00
|
|
|
BIT(connected); /* != 0 iff this filter is connected */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Default implementations for the type functions, implementing nop. */
|
2022-11-22 16:55:41 +08:00
|
|
|
void Curl_cf_def_destroy_this(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
|
|
|
/* Default implementations for the type functions, implementing pass-through
|
|
|
|
* the filter chain. */
|
2022-11-22 16:55:41 +08:00
|
|
|
void Curl_cf_def_get_host(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|
|
|
const char **phost, const char **pdisplay_host,
|
|
|
|
int *pport);
|
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.
Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.
This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.
Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.
After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.
Example:
* transfer wants to send, adds POLLOUT
* http/2 filter has a flow control block, removes POLLOUT and adds
POLLIN (it is waiting on a WINDOW_UPDATE from the server)
* TLS filter is connected and changes nothing
* h2-proxy filter also has a flow control block on its tunnel stream,
removes POLLOUT and adds POLLIN also.
* socket filter is connected and changes nothing
* The resulting pollset is then mixed together with all other transfers
and their pollsets, just as before.
Use of `SEND_HOLD` is no longer necessary in the filters.
All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.
The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.
No noticeable difference in performance was detected in local scorecard
runs.
Closes #11833
2023-09-04 18:06:07 +08:00
|
|
|
void Curl_cf_def_adjust_pollset(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps);
|
2022-11-11 18:45:34 +08:00
|
|
|
bool Curl_cf_def_data_pending(struct Curl_cfilter *cf,
|
|
|
|
const struct Curl_easy *data);
|
|
|
|
ssize_t Curl_cf_def_send(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|
|
|
const void *buf, size_t len, CURLcode *err);
|
|
|
|
ssize_t Curl_cf_def_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|
|
|
char *buf, size_t len, CURLcode *err);
|
2022-12-30 16:14:55 +08:00
|
|
|
CURLcode Curl_cf_def_cntrl(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
int event, int arg1, void *arg2);
|
|
|
|
bool Curl_cf_def_conn_is_alive(struct Curl_cfilter *cf,
|
2023-03-06 19:44:45 +08:00
|
|
|
struct Curl_easy *data,
|
|
|
|
bool *input_pending);
|
2022-12-30 16:14:55 +08:00
|
|
|
CURLcode Curl_cf_def_conn_keep_alive(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data);
|
|
|
|
CURLcode Curl_cf_def_query(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
connections: introduce http/3 happy eyeballs
New cfilter HTTP-CONNECT for h3/h2/http1.1 eyeballing.
- filter is installed when `--http3` in the tool is used (or
the equivalent CURLOPT_ done in the library)
- starts a QUIC/HTTP/3 connect right away. Should that not
succeed after 100ms (subject to change), a parallel attempt
is started for HTTP/2 and HTTP/1.1 via TCP
- both attempts are subject to IPv6/IPv4 eyeballing, same
as happens for other connections
- tie timeout to the ip-version HAPPY_EYEBALLS_TIMEOUT
- use a `soft` timeout at half the value. When the soft timeout
expires, the HTTPS-CONNECT filter checks if the QUIC filter
has received any data from the server. If not, it will start
the HTTP/2 attempt.
HTTP/3(ngtcp2) improvements.
- setting call_data in all cfilter calls similar to http/2 and vtls filters
for use in callback where no stream data is available.
- returning CURLE_PARTIAL_FILE for prematurely terminated transfers
- enabling pytest test_05 for h3
- shifting functionality to "connect" UDP sockets from ngtcp2
implementation into the udp socket cfilter. Because unconnected
UDP sockets are weird. For example they error when adding to a
pollset.
HTTP/3(quiche) improvements.
- fixed upload bug in quiche implementation, now passes 251 and pytest
- error codes on stream RESET
- improved debug logs
- handling of DRAIN during connect
- limiting pending event queue
HTTP/2 cfilter improvements.
- use LOG_CF macros for dynamic logging in debug build
- fix CURLcode on RST streams to be CURLE_PARTIAL_FILE
- enable pytest test_05 for h2
- fix upload pytests and improve parallel transfer performance.
GOAWAY handling for ngtcp2/quiche
- during connect, when the remote server refuses to accept new connections
and closes immediately (so the local conn goes into DRAIN phase), the
connection is torn down and a another attempt is made after a short grace
period.
This is the behaviour observed with nghttpx when we tell it to shut
down gracefully. Tested in pytest test_03_02.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
- new tests/tests-httpd/scorecard.py for testing h3/h2 protocol implementation.
Invoke:
python3 tests/tests-httpd/scorecard.py --help
for usage.
Improvements on gathering connect statistics and socket access.
- new CF_CTRL_CONN_REPORT_STATS cfilter control for having cfilters
report connection statistics. This is triggered when the connection
has completely connected.
- new void Curl_pgrsTimeWas(..) method to report a timer update with
a timestamp of when it happend. This allows for updating timers
"later", e.g. a connect statistic after full connectivity has been
reached.
- in case of HTTP eyeballing, the previous changes will update
statistics only from the filter chain that "won" the eyeballing.
- new cfilter query CF_QUERY_SOCKET for retrieving the socket used
by a filter chain.
Added methods Curl_conn_cf_get_socket() and Curl_conn_get_socket()
for convenient use of this query.
- Change VTLS backend to query their sub-filters for the socket when
checks during the handshake are made.
HTTP/3 documentation on how https eyeballing works.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
Scorecard with Caddy.
- configure can be run with `--with-test-caddy=path` to specify which caddy to use for testing
- tests/tests-httpd/scorecard.py now measures download speeds with caddy
pytest improvements
- adding Makfile to clean gen dir
- adding nghttpx rundir creation on start
- checking httpd version 2.4.55 for test_05 cases where it is needed. Skipping with message if too old.
- catch exception when checking for caddy existance on system.
Closes #10349
2023-02-02 00:13:12 +08:00
|
|
|
int query, int *pres1, void *pres2);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/**
|
|
|
|
* Create a new filter instance, unattached to the filter chain.
|
|
|
|
* Use Curl_conn_cf_add() to add it to the chain.
|
|
|
|
* @param pcf on success holds the created instance
|
2023-02-08 05:50:36 +08:00
|
|
|
* @param cft the filter type
|
2022-11-22 16:55:41 +08:00
|
|
|
* @param ctx the type specific context to use
|
|
|
|
*/
|
|
|
|
CURLcode Curl_cf_create(struct Curl_cfilter **pcf,
|
|
|
|
const struct Curl_cftype *cft,
|
|
|
|
void *ctx);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/**
|
|
|
|
* Add a filter instance to the `sockindex` filter chain at connection
|
2022-12-30 16:14:55 +08:00
|
|
|
* `conn`. The filter must not already be attached. It is inserted at
|
2022-11-22 16:55:41 +08:00
|
|
|
* the start of the chain (top).
|
|
|
|
*/
|
|
|
|
void Curl_conn_cf_add(struct Curl_easy *data,
|
2022-11-26 19:43:56 +08:00
|
|
|
struct connectdata *conn,
|
2022-11-22 16:55:41 +08:00
|
|
|
int sockindex,
|
2022-11-11 18:45:34 +08:00
|
|
|
struct Curl_cfilter *cf);
|
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/**
|
2022-12-30 16:14:55 +08:00
|
|
|
* Insert a filter (chain) after `cf_at`.
|
|
|
|
* `cf_new` must not already be attached.
|
2022-11-22 16:55:41 +08:00
|
|
|
*/
|
2022-12-30 16:14:55 +08:00
|
|
|
void Curl_conn_cf_insert_after(struct Curl_cfilter *cf_at,
|
|
|
|
struct Curl_cfilter *cf_new);
|
2022-11-22 16:55:41 +08:00
|
|
|
|
|
|
|
/**
|
2023-04-06 15:54:57 +08:00
|
|
|
* Discard, e.g. remove and destroy `discard` iff
|
|
|
|
* it still is in the filter chain below `cf`. If `discard`
|
|
|
|
* is no longer found beneath `cf` return FALSE.
|
|
|
|
* if `destroy_always` is TRUE, will call `discard`s destroy
|
|
|
|
* function and free it even if not found in the subchain.
|
2022-11-22 16:55:41 +08:00
|
|
|
*/
|
2023-04-06 15:54:57 +08:00
|
|
|
bool Curl_conn_cf_discard_sub(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_cfilter *discard,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
bool destroy_always);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-12-30 16:14:55 +08:00
|
|
|
/**
|
|
|
|
* Discard all cfilters starting with `*pcf` and clearing it afterwards.
|
|
|
|
*/
|
|
|
|
void Curl_conn_cf_discard_chain(struct Curl_cfilter **pcf,
|
|
|
|
struct Curl_easy *data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove and destroy all filters at chain `sockindex` on connection `conn`.
|
|
|
|
*/
|
|
|
|
void Curl_conn_cf_discard_all(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn,
|
|
|
|
int sockindex);
|
|
|
|
|
2022-11-25 21:06:43 +08:00
|
|
|
|
2022-12-30 16:14:55 +08:00
|
|
|
CURLcode Curl_conn_cf_connect(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
bool blocking, bool *done);
|
|
|
|
void Curl_conn_cf_close(struct Curl_cfilter *cf, struct Curl_easy *data);
|
2022-11-25 21:06:43 +08:00
|
|
|
ssize_t Curl_conn_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|
|
|
const void *buf, size_t len, CURLcode *err);
|
|
|
|
ssize_t Curl_conn_cf_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|
|
|
char *buf, size_t len, CURLcode *err);
|
2022-12-30 16:14:55 +08:00
|
|
|
CURLcode Curl_conn_cf_cntrl(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
bool ignore_result,
|
|
|
|
int event, int arg1, void *arg2);
|
|
|
|
|
2023-04-06 15:54:57 +08:00
|
|
|
/**
|
|
|
|
* Determine if the connection filter chain is using SSL to the remote host
|
|
|
|
* (or will be once connected).
|
|
|
|
*/
|
|
|
|
bool Curl_conn_cf_is_ssl(struct Curl_cfilter *cf);
|
|
|
|
|
connections: introduce http/3 happy eyeballs
New cfilter HTTP-CONNECT for h3/h2/http1.1 eyeballing.
- filter is installed when `--http3` in the tool is used (or
the equivalent CURLOPT_ done in the library)
- starts a QUIC/HTTP/3 connect right away. Should that not
succeed after 100ms (subject to change), a parallel attempt
is started for HTTP/2 and HTTP/1.1 via TCP
- both attempts are subject to IPv6/IPv4 eyeballing, same
as happens for other connections
- tie timeout to the ip-version HAPPY_EYEBALLS_TIMEOUT
- use a `soft` timeout at half the value. When the soft timeout
expires, the HTTPS-CONNECT filter checks if the QUIC filter
has received any data from the server. If not, it will start
the HTTP/2 attempt.
HTTP/3(ngtcp2) improvements.
- setting call_data in all cfilter calls similar to http/2 and vtls filters
for use in callback where no stream data is available.
- returning CURLE_PARTIAL_FILE for prematurely terminated transfers
- enabling pytest test_05 for h3
- shifting functionality to "connect" UDP sockets from ngtcp2
implementation into the udp socket cfilter. Because unconnected
UDP sockets are weird. For example they error when adding to a
pollset.
HTTP/3(quiche) improvements.
- fixed upload bug in quiche implementation, now passes 251 and pytest
- error codes on stream RESET
- improved debug logs
- handling of DRAIN during connect
- limiting pending event queue
HTTP/2 cfilter improvements.
- use LOG_CF macros for dynamic logging in debug build
- fix CURLcode on RST streams to be CURLE_PARTIAL_FILE
- enable pytest test_05 for h2
- fix upload pytests and improve parallel transfer performance.
GOAWAY handling for ngtcp2/quiche
- during connect, when the remote server refuses to accept new connections
and closes immediately (so the local conn goes into DRAIN phase), the
connection is torn down and a another attempt is made after a short grace
period.
This is the behaviour observed with nghttpx when we tell it to shut
down gracefully. Tested in pytest test_03_02.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
- new tests/tests-httpd/scorecard.py for testing h3/h2 protocol implementation.
Invoke:
python3 tests/tests-httpd/scorecard.py --help
for usage.
Improvements on gathering connect statistics and socket access.
- new CF_CTRL_CONN_REPORT_STATS cfilter control for having cfilters
report connection statistics. This is triggered when the connection
has completely connected.
- new void Curl_pgrsTimeWas(..) method to report a timer update with
a timestamp of when it happend. This allows for updating timers
"later", e.g. a connect statistic after full connectivity has been
reached.
- in case of HTTP eyeballing, the previous changes will update
statistics only from the filter chain that "won" the eyeballing.
- new cfilter query CF_QUERY_SOCKET for retrieving the socket used
by a filter chain.
Added methods Curl_conn_cf_get_socket() and Curl_conn_get_socket()
for convenient use of this query.
- Change VTLS backend to query their sub-filters for the socket when
checks during the handshake are made.
HTTP/3 documentation on how https eyeballing works.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
Scorecard with Caddy.
- configure can be run with `--with-test-caddy=path` to specify which caddy to use for testing
- tests/tests-httpd/scorecard.py now measures download speeds with caddy
pytest improvements
- adding Makfile to clean gen dir
- adding nghttpx rundir creation on start
- checking httpd version 2.4.55 for test_05 cases where it is needed. Skipping with message if too old.
- catch exception when checking for caddy existance on system.
Closes #10349
2023-02-02 00:13:12 +08:00
|
|
|
/**
|
|
|
|
* Get the socket used by the filter chain starting at `cf`.
|
|
|
|
* Returns CURL_SOCKET_BAD if not available.
|
|
|
|
*/
|
|
|
|
curl_socket_t Curl_conn_cf_get_socket(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data);
|
2022-12-30 16:14:55 +08:00
|
|
|
|
2022-11-25 21:06:43 +08:00
|
|
|
|
2022-11-11 18:45:34 +08:00
|
|
|
#define CURL_CF_SSL_DEFAULT -1
|
|
|
|
#define CURL_CF_SSL_DISABLE 0
|
|
|
|
#define CURL_CF_SSL_ENABLE 1
|
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/**
|
|
|
|
* Bring the filter chain at `sockindex` for connection `data->conn` into
|
|
|
|
* connected state. Which will set `*done` to TRUE.
|
|
|
|
* This can be called on an already connected chain with no side effects.
|
|
|
|
* When not `blocking`, calls may return without error and `*done != TRUE`,
|
|
|
|
* while the individual filters negotiated the connection.
|
|
|
|
*/
|
|
|
|
CURLcode Curl_conn_connect(struct Curl_easy *data, int sockindex,
|
|
|
|
bool blocking, bool *done);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the filter chain at `sockindex` for connection `conn` is
|
|
|
|
* completely connected.
|
|
|
|
*/
|
|
|
|
bool Curl_conn_is_connected(struct connectdata *conn, int sockindex);
|
|
|
|
|
2022-11-21 22:40:26 +08:00
|
|
|
/**
|
|
|
|
* Determine if we have reached the remote host on IP level, e.g.
|
|
|
|
* have a TCP connection. This turns TRUE before a possible SSL
|
|
|
|
* handshake has been started/done.
|
|
|
|
*/
|
|
|
|
bool Curl_conn_is_ip_connected(struct Curl_easy *data, int sockindex);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-25 21:06:43 +08:00
|
|
|
/**
|
|
|
|
* Determine if the connection is using SSL to the remote host
|
|
|
|
* (or will be once connected). This will return FALSE, if SSL
|
|
|
|
* is only used in proxying and not for the tunnel itself.
|
|
|
|
*/
|
2022-12-30 16:14:55 +08:00
|
|
|
bool Curl_conn_is_ssl(struct connectdata *conn, int sockindex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Connection provides multiplexing of easy handles at `socketindex`.
|
|
|
|
*/
|
|
|
|
bool Curl_conn_is_multiplex(struct connectdata *conn, int sockindex);
|
2022-11-25 21:06:43 +08:00
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/**
|
|
|
|
* Close the filter chain at `sockindex` for connection `data->conn`.
|
|
|
|
* Filters remain in place and may be connected again afterwards.
|
|
|
|
*/
|
|
|
|
void Curl_conn_close(struct Curl_easy *data, int sockindex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return if data is pending in some connection filter at chain
|
|
|
|
* `sockindex` for connection `data->conn`.
|
|
|
|
*/
|
|
|
|
bool Curl_conn_data_pending(struct Curl_easy *data,
|
|
|
|
int sockindex);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
connections: introduce http/3 happy eyeballs
New cfilter HTTP-CONNECT for h3/h2/http1.1 eyeballing.
- filter is installed when `--http3` in the tool is used (or
the equivalent CURLOPT_ done in the library)
- starts a QUIC/HTTP/3 connect right away. Should that not
succeed after 100ms (subject to change), a parallel attempt
is started for HTTP/2 and HTTP/1.1 via TCP
- both attempts are subject to IPv6/IPv4 eyeballing, same
as happens for other connections
- tie timeout to the ip-version HAPPY_EYEBALLS_TIMEOUT
- use a `soft` timeout at half the value. When the soft timeout
expires, the HTTPS-CONNECT filter checks if the QUIC filter
has received any data from the server. If not, it will start
the HTTP/2 attempt.
HTTP/3(ngtcp2) improvements.
- setting call_data in all cfilter calls similar to http/2 and vtls filters
for use in callback where no stream data is available.
- returning CURLE_PARTIAL_FILE for prematurely terminated transfers
- enabling pytest test_05 for h3
- shifting functionality to "connect" UDP sockets from ngtcp2
implementation into the udp socket cfilter. Because unconnected
UDP sockets are weird. For example they error when adding to a
pollset.
HTTP/3(quiche) improvements.
- fixed upload bug in quiche implementation, now passes 251 and pytest
- error codes on stream RESET
- improved debug logs
- handling of DRAIN during connect
- limiting pending event queue
HTTP/2 cfilter improvements.
- use LOG_CF macros for dynamic logging in debug build
- fix CURLcode on RST streams to be CURLE_PARTIAL_FILE
- enable pytest test_05 for h2
- fix upload pytests and improve parallel transfer performance.
GOAWAY handling for ngtcp2/quiche
- during connect, when the remote server refuses to accept new connections
and closes immediately (so the local conn goes into DRAIN phase), the
connection is torn down and a another attempt is made after a short grace
period.
This is the behaviour observed with nghttpx when we tell it to shut
down gracefully. Tested in pytest test_03_02.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
- new tests/tests-httpd/scorecard.py for testing h3/h2 protocol implementation.
Invoke:
python3 tests/tests-httpd/scorecard.py --help
for usage.
Improvements on gathering connect statistics and socket access.
- new CF_CTRL_CONN_REPORT_STATS cfilter control for having cfilters
report connection statistics. This is triggered when the connection
has completely connected.
- new void Curl_pgrsTimeWas(..) method to report a timer update with
a timestamp of when it happend. This allows for updating timers
"later", e.g. a connect statistic after full connectivity has been
reached.
- in case of HTTP eyeballing, the previous changes will update
statistics only from the filter chain that "won" the eyeballing.
- new cfilter query CF_QUERY_SOCKET for retrieving the socket used
by a filter chain.
Added methods Curl_conn_cf_get_socket() and Curl_conn_get_socket()
for convenient use of this query.
- Change VTLS backend to query their sub-filters for the socket when
checks during the handshake are made.
HTTP/3 documentation on how https eyeballing works.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
Scorecard with Caddy.
- configure can be run with `--with-test-caddy=path` to specify which caddy to use for testing
- tests/tests-httpd/scorecard.py now measures download speeds with caddy
pytest improvements
- adding Makfile to clean gen dir
- adding nghttpx rundir creation on start
- checking httpd version 2.4.55 for test_05 cases where it is needed. Skipping with message if too old.
- catch exception when checking for caddy existance on system.
Closes #10349
2023-02-02 00:13:12 +08:00
|
|
|
/**
|
|
|
|
* Return the socket used on data's connection for the index.
|
|
|
|
* Returns CURL_SOCKET_BAD if not available.
|
|
|
|
*/
|
|
|
|
curl_socket_t Curl_conn_get_socket(struct Curl_easy *data, int sockindex);
|
2023-10-26 23:02:45 +08:00
|
|
|
|
|
|
|
/**
|
2023-11-23 16:51:14 +08:00
|
|
|
* Tell filters to forget about the socket at sockindex.
|
2023-10-26 23:02:45 +08:00
|
|
|
*/
|
|
|
|
void Curl_conn_forget_socket(struct Curl_easy *data, int sockindex);
|
connections: introduce http/3 happy eyeballs
New cfilter HTTP-CONNECT for h3/h2/http1.1 eyeballing.
- filter is installed when `--http3` in the tool is used (or
the equivalent CURLOPT_ done in the library)
- starts a QUIC/HTTP/3 connect right away. Should that not
succeed after 100ms (subject to change), a parallel attempt
is started for HTTP/2 and HTTP/1.1 via TCP
- both attempts are subject to IPv6/IPv4 eyeballing, same
as happens for other connections
- tie timeout to the ip-version HAPPY_EYEBALLS_TIMEOUT
- use a `soft` timeout at half the value. When the soft timeout
expires, the HTTPS-CONNECT filter checks if the QUIC filter
has received any data from the server. If not, it will start
the HTTP/2 attempt.
HTTP/3(ngtcp2) improvements.
- setting call_data in all cfilter calls similar to http/2 and vtls filters
for use in callback where no stream data is available.
- returning CURLE_PARTIAL_FILE for prematurely terminated transfers
- enabling pytest test_05 for h3
- shifting functionality to "connect" UDP sockets from ngtcp2
implementation into the udp socket cfilter. Because unconnected
UDP sockets are weird. For example they error when adding to a
pollset.
HTTP/3(quiche) improvements.
- fixed upload bug in quiche implementation, now passes 251 and pytest
- error codes on stream RESET
- improved debug logs
- handling of DRAIN during connect
- limiting pending event queue
HTTP/2 cfilter improvements.
- use LOG_CF macros for dynamic logging in debug build
- fix CURLcode on RST streams to be CURLE_PARTIAL_FILE
- enable pytest test_05 for h2
- fix upload pytests and improve parallel transfer performance.
GOAWAY handling for ngtcp2/quiche
- during connect, when the remote server refuses to accept new connections
and closes immediately (so the local conn goes into DRAIN phase), the
connection is torn down and a another attempt is made after a short grace
period.
This is the behaviour observed with nghttpx when we tell it to shut
down gracefully. Tested in pytest test_03_02.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
- new tests/tests-httpd/scorecard.py for testing h3/h2 protocol implementation.
Invoke:
python3 tests/tests-httpd/scorecard.py --help
for usage.
Improvements on gathering connect statistics and socket access.
- new CF_CTRL_CONN_REPORT_STATS cfilter control for having cfilters
report connection statistics. This is triggered when the connection
has completely connected.
- new void Curl_pgrsTimeWas(..) method to report a timer update with
a timestamp of when it happend. This allows for updating timers
"later", e.g. a connect statistic after full connectivity has been
reached.
- in case of HTTP eyeballing, the previous changes will update
statistics only from the filter chain that "won" the eyeballing.
- new cfilter query CF_QUERY_SOCKET for retrieving the socket used
by a filter chain.
Added methods Curl_conn_cf_get_socket() and Curl_conn_get_socket()
for convenient use of this query.
- Change VTLS backend to query their sub-filters for the socket when
checks during the handshake are made.
HTTP/3 documentation on how https eyeballing works.
TLS improvements
- ALPN selection for SSL/SSL-PROXY filters in one vtls set of functions, replaces
copy of logic in all tls backends.
- standardized the infof logging of offered ALPNs
- ALPN negotiated: have common function for all backends that sets alpn proprty
and connection related things based on the negotiated protocol (or lack thereof).
Scorecard with Caddy.
- configure can be run with `--with-test-caddy=path` to specify which caddy to use for testing
- tests/tests-httpd/scorecard.py now measures download speeds with caddy
pytest improvements
- adding Makfile to clean gen dir
- adding nghttpx rundir creation on start
- checking httpd version 2.4.55 for test_05 cases where it is needed. Skipping with message if too old.
- catch exception when checking for caddy existance on system.
Closes #10349
2023-02-02 00:13:12 +08:00
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/**
|
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.
Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.
This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.
Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.
After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.
Example:
* transfer wants to send, adds POLLOUT
* http/2 filter has a flow control block, removes POLLOUT and adds
POLLIN (it is waiting on a WINDOW_UPDATE from the server)
* TLS filter is connected and changes nothing
* h2-proxy filter also has a flow control block on its tunnel stream,
removes POLLOUT and adds POLLIN also.
* socket filter is connected and changes nothing
* The resulting pollset is then mixed together with all other transfers
and their pollsets, just as before.
Use of `SEND_HOLD` is no longer necessary in the filters.
All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.
The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.
No noticeable difference in performance was detected in local scorecard
runs.
Closes #11833
2023-09-04 18:06:07 +08:00
|
|
|
* Adjust the pollset for the filter chain startgin at `cf`.
|
2022-11-22 16:55:41 +08:00
|
|
|
*/
|
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.
Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.
This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.
Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.
After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.
Example:
* transfer wants to send, adds POLLOUT
* http/2 filter has a flow control block, removes POLLOUT and adds
POLLIN (it is waiting on a WINDOW_UPDATE from the server)
* TLS filter is connected and changes nothing
* h2-proxy filter also has a flow control block on its tunnel stream,
removes POLLOUT and adds POLLIN also.
* socket filter is connected and changes nothing
* The resulting pollset is then mixed together with all other transfers
and their pollsets, just as before.
Use of `SEND_HOLD` is no longer necessary in the filters.
All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.
The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.
No noticeable difference in performance was detected in local scorecard
runs.
Closes #11833
2023-09-04 18:06:07 +08:00
|
|
|
void Curl_conn_cf_adjust_pollset(struct Curl_cfilter *cf,
|
|
|
|
struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust pollset from filters installed at transfer's connection.
|
|
|
|
*/
|
|
|
|
void Curl_conn_adjust_pollset(struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
|
|
|
/**
|
2022-11-22 16:55:41 +08:00
|
|
|
* Receive data through the filter chain at `sockindex` for connection
|
|
|
|
* `data->conn`. Copy at most `len` bytes into `buf`. Return the
|
|
|
|
* actuel number of bytes copied or a negative value on error.
|
|
|
|
* The error code is placed into `*code`.
|
2022-11-11 18:45:34 +08:00
|
|
|
*/
|
2022-11-22 16:55:41 +08:00
|
|
|
ssize_t Curl_conn_recv(struct Curl_easy *data, int sockindex, char *buf,
|
|
|
|
size_t len, CURLcode *code);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2022-11-22 16:55:41 +08:00
|
|
|
/**
|
|
|
|
* Send `len` bytes of data from `buf` through the filter chain `sockindex`
|
|
|
|
* at connection `data->conn`. Return the actual number of bytes written
|
|
|
|
* or a negative value on error.
|
|
|
|
* The error code is placed into `*code`.
|
|
|
|
*/
|
|
|
|
ssize_t Curl_conn_send(struct Curl_easy *data, int sockindex,
|
|
|
|
const void *buf, size_t len, CURLcode *code);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
|
|
|
/**
|
2022-12-30 16:14:55 +08:00
|
|
|
* The easy handle `data` is being attached to `conn`. This does
|
|
|
|
* not mean that data will actually do a transfer. Attachment is
|
|
|
|
* also used for temporary actions on the connection.
|
2022-11-11 18:45:34 +08:00
|
|
|
*/
|
2022-12-30 16:14:55 +08:00
|
|
|
void Curl_conn_ev_data_attach(struct connectdata *conn,
|
|
|
|
struct Curl_easy *data);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The easy handle `data` is being detached (no longer served)
|
|
|
|
* by connection `conn`. All filters are informed to release any resources
|
|
|
|
* related to `data`.
|
|
|
|
* Note: there may be several `data` attached to a connection at the same
|
|
|
|
* time.
|
|
|
|
*/
|
2022-12-30 16:14:55 +08:00
|
|
|
void Curl_conn_ev_data_detach(struct connectdata *conn,
|
|
|
|
struct Curl_easy *data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify connection filters that they need to setup data for
|
|
|
|
* a transfer.
|
|
|
|
*/
|
|
|
|
CURLcode Curl_conn_ev_data_setup(struct Curl_easy *data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify connection filters that now would be a good time to
|
|
|
|
* perform any idle, e.g. time related, actions.
|
|
|
|
*/
|
|
|
|
CURLcode Curl_conn_ev_data_idle(struct Curl_easy *data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify connection filters that the transfer represented by `data`
|
|
|
|
* is donw with sending data (e.g. has uploaded everything).
|
|
|
|
*/
|
|
|
|
void Curl_conn_ev_data_done_send(struct Curl_easy *data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify connection filters that the transfer represented by `data`
|
|
|
|
* is finished - eventually premature, e.g. before being complete.
|
|
|
|
*/
|
|
|
|
void Curl_conn_ev_data_done(struct Curl_easy *data, bool premature);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify connection filters that the transfer of data is paused/unpaused.
|
|
|
|
*/
|
|
|
|
CURLcode Curl_conn_ev_data_pause(struct Curl_easy *data, bool do_pause);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inform connection filters to update their info in `conn`.
|
|
|
|
*/
|
|
|
|
void Curl_conn_ev_update_info(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if FIRSTSOCKET's cfilter chain deems connection alive.
|
|
|
|
*/
|
2023-03-06 19:44:45 +08:00
|
|
|
bool Curl_conn_is_alive(struct Curl_easy *data, struct connectdata *conn,
|
|
|
|
bool *input_pending);
|
2022-12-30 16:14:55 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to upkeep the connection filters at sockindex.
|
|
|
|
*/
|
|
|
|
CURLcode Curl_conn_keep_alive(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn,
|
|
|
|
int sockindex);
|
2022-11-22 16:55:41 +08:00
|
|
|
|
2023-05-22 15:00:16 +08:00
|
|
|
void Curl_cf_def_close(struct Curl_cfilter *cf, struct Curl_easy *data);
|
2022-11-22 16:55:41 +08:00
|
|
|
void Curl_conn_get_host(struct Curl_easy *data, int sockindex,
|
|
|
|
const char **phost, const char **pdisplay_host,
|
|
|
|
int *pport);
|
|
|
|
|
2022-12-30 16:14:55 +08:00
|
|
|
/**
|
|
|
|
* Get the maximum number of parallel transfers the connection
|
|
|
|
* expects to be able to handle at `sockindex`.
|
|
|
|
*/
|
|
|
|
size_t Curl_conn_get_max_concurrent(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn,
|
|
|
|
int sockindex);
|
2022-11-11 18:45:34 +08:00
|
|
|
|
2023-01-23 18:41:23 +08:00
|
|
|
|
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.
Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.
This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.
Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.
After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.
Example:
* transfer wants to send, adds POLLOUT
* http/2 filter has a flow control block, removes POLLOUT and adds
POLLIN (it is waiting on a WINDOW_UPDATE from the server)
* TLS filter is connected and changes nothing
* h2-proxy filter also has a flow control block on its tunnel stream,
removes POLLOUT and adds POLLIN also.
* socket filter is connected and changes nothing
* The resulting pollset is then mixed together with all other transfers
and their pollsets, just as before.
Use of `SEND_HOLD` is no longer necessary in the filters.
All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.
The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.
No noticeable difference in performance was detected in local scorecard
runs.
Closes #11833
2023-09-04 18:06:07 +08:00
|
|
|
void Curl_pollset_reset(struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps);
|
|
|
|
|
|
|
|
/* Change the poll flags (CURL_POLL_IN/CURL_POLL_OUT) to the poll set for
|
|
|
|
* socket `sock`. If the socket is not already part of the poll set, it
|
|
|
|
* will be added.
|
|
|
|
* If the socket is present and all poll flags are cleared, it will be removed.
|
|
|
|
*/
|
|
|
|
void Curl_pollset_change(struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps, curl_socket_t sock,
|
|
|
|
int add_flags, int remove_flags);
|
|
|
|
|
|
|
|
void Curl_pollset_set(struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps, curl_socket_t sock,
|
|
|
|
bool do_in, bool do_out);
|
|
|
|
|
|
|
|
#define Curl_pollset_add_in(data, ps, sock) \
|
|
|
|
Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0)
|
|
|
|
#define Curl_pollset_add_out(data, ps, sock) \
|
|
|
|
Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0)
|
|
|
|
#define Curl_pollset_add_inout(data, ps, sock) \
|
|
|
|
Curl_pollset_change((data), (ps), (sock), \
|
|
|
|
CURL_POLL_IN|CURL_POLL_OUT, 0)
|
|
|
|
#define Curl_pollset_set_in_only(data, ps, sock) \
|
|
|
|
Curl_pollset_change((data), (ps), (sock), \
|
|
|
|
CURL_POLL_IN, CURL_POLL_OUT)
|
|
|
|
#define Curl_pollset_set_out_only(data, ps, sock) \
|
|
|
|
Curl_pollset_change((data), (ps), (sock), \
|
|
|
|
CURL_POLL_OUT, CURL_POLL_IN)
|
|
|
|
|
|
|
|
void Curl_pollset_add_socks(struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps,
|
|
|
|
int (*get_socks_cb)(struct Curl_easy *data,
|
|
|
|
curl_socket_t *socks));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the pollset, as is, wants to read and/or write regarding
|
|
|
|
* the given socket.
|
|
|
|
*/
|
|
|
|
void Curl_pollset_check(struct Curl_easy *data,
|
|
|
|
struct easy_pollset *ps, curl_socket_t sock,
|
|
|
|
bool *pwant_read, bool *pwant_write);
|
|
|
|
|
2023-01-23 18:41:23 +08:00
|
|
|
/**
|
|
|
|
* Types and macros used to keep the current easy handle in filter calls,
|
|
|
|
* allowing for nested invocations. See #10336.
|
|
|
|
*
|
|
|
|
* `cf_call_data` is intended to be a member of the cfilter's `ctx` type.
|
|
|
|
* A filter defines the macro `CF_CTX_CALL_DATA` to give access to that.
|
|
|
|
*
|
|
|
|
* With all values 0, the default, this indicates that there is no cfilter
|
|
|
|
* call with `data` ongoing.
|
|
|
|
* Macro `CF_DATA_SAVE` preserves the current `cf_call_data` in a local
|
|
|
|
* variable and sets the `data` given, incrementing the `depth` counter.
|
|
|
|
*
|
|
|
|
* Macro `CF_DATA_RESTORE` restores the old values from the local variable,
|
|
|
|
* while checking that `depth` values are as expected (debug build), catching
|
|
|
|
* cases where a "lower" RESTORE was not called.
|
|
|
|
*
|
|
|
|
* Finally, macro `CF_DATA_CURRENT` gives the easy handle of the current
|
|
|
|
* invocation.
|
|
|
|
*/
|
|
|
|
struct cf_call_data {
|
|
|
|
struct Curl_easy *data;
|
|
|
|
#ifdef DEBUGBUILD
|
|
|
|
int depth;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* define to access the `struct cf_call_data for a cfilter. Normally
|
|
|
|
* a member in the cfilter's `ctx`.
|
|
|
|
*
|
|
|
|
* #define CF_CTX_CALL_DATA(cf) -> struct cf_call_data instance
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef DEBUGBUILD
|
|
|
|
|
|
|
|
#define CF_DATA_SAVE(save, cf, data) \
|
|
|
|
do { \
|
|
|
|
(save) = CF_CTX_CALL_DATA(cf); \
|
|
|
|
DEBUGASSERT((save).data == NULL || (save).depth > 0); \
|
|
|
|
CF_CTX_CALL_DATA(cf).depth++; \
|
|
|
|
CF_CTX_CALL_DATA(cf).data = (struct Curl_easy *)data; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define CF_DATA_RESTORE(cf, save) \
|
|
|
|
do { \
|
|
|
|
DEBUGASSERT(CF_CTX_CALL_DATA(cf).depth == (save).depth + 1); \
|
|
|
|
DEBUGASSERT((save).data == NULL || (save).depth > 0); \
|
|
|
|
CF_CTX_CALL_DATA(cf) = (save); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#else /* DEBUGBUILD */
|
|
|
|
|
|
|
|
#define CF_DATA_SAVE(save, cf, data) \
|
|
|
|
do { \
|
|
|
|
(save) = CF_CTX_CALL_DATA(cf); \
|
|
|
|
CF_CTX_CALL_DATA(cf).data = (struct Curl_easy *)data; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define CF_DATA_RESTORE(cf, save) \
|
|
|
|
do { \
|
|
|
|
CF_CTX_CALL_DATA(cf) = (save); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#endif /* !DEBUGBUILD */
|
|
|
|
|
|
|
|
#define CF_DATA_CURRENT(cf) \
|
|
|
|
((cf)? (CF_CTX_CALL_DATA(cf).data) : NULL)
|
|
|
|
|
2022-11-11 18:45:34 +08:00
|
|
|
#endif /* HEADER_CURL_CFILTERS_H */
|