Artifactspublic-v0

curl

master
ply4 git calls26 ms290 KiB3 cachedprotocol v2
258 lines11 KiBRaw
1#ifndef HEADER_CURL_VQUIC_CF_NGTCP2_CMN_H
2#define HEADER_CURL_VQUIC_CF_NGTCP2_CMN_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#if !defined(CURL_DISABLE_HTTP) && defined(USE_NGTCP2) && defined(USE_NGHTTP3)
30#include <ngtcp2/ngtcp2.h>
31#include <ngtcp2/ngtcp2_crypto.h>
33#ifdef USE_OPENSSL
34#include <openssl/err.h>
35#if defined(OPENSSL_IS_AWSLC) || defined(OPENSSL_IS_BORINGSSL)
36#include <ngtcp2/ngtcp2_crypto_boringssl.h>
37#elif defined(OPENSSL_QUIC_API2)
38#include <ngtcp2/ngtcp2_crypto_ossl.h>
39#else
40#include <ngtcp2/ngtcp2_crypto_quictls.h>
41#endif
42#include "vtls/openssl.h"
43#elif defined(USE_GNUTLS)
44#include <ngtcp2/ngtcp2_crypto_gnutls.h>
45#include "vtls/gtls.h"
46#elif defined(USE_WOLFSSL)
47#include <wolfssl/options.h>
48#include <wolfssl/ssl.h>
49#include <wolfssl/quic.h>
50#include <ngtcp2/ngtcp2_crypto_wolfssl.h>
51#include "vtls/wolfssl.h"
52#endif
54#ifdef HAVE_NETINET_UDP_H
55#include <netinet/udp.h>
56#endif
58#include <nghttp3/nghttp3.h>
60#include "http1.h"
61#include "u32_ptrset.h"
62#include "vtls/vtls.h"
63#include "vquic/vquic_int.h"
64#include "vquic/vquic-tls.h"
66struct Curl_cfilter;
67struct Curl_easy;
68struct cf_ngtcp2_ctx;
69struct cf_quic_ctx;
71#define QUIC_MAX_STREAMS (256 * 1024)
72#define QUIC_HANDSHAKE_TIMEOUT (10 * NGTCP2_SECONDS)
73#define QUIC_TUNNEL_INBUF_SIZE (64 * 1024)
75/* We announce a small window size in transport param to the server,
76 * and grow that immediately to max when no rate limit is in place.
77 * We need to start small as we are not able to decrease it. */
78#define H3_STREAM_WINDOW_SIZE_INITIAL (32 * 1024)
79#define H3_STREAM_WINDOW_SIZE_MAX (10 * 1024 * 1024)
80#define H3_CONN_WINDOW_SIZE_MAX (100 * H3_STREAM_WINDOW_SIZE_MAX)
82#define H3_STREAM_CHUNK_SIZE (64 * 1024)
83#if H3_STREAM_CHUNK_SIZE < NGTCP2_MAX_UDP_PAYLOAD_SIZE
84#error H3_STREAM_CHUNK_SIZE smaller than NGTCP2_MAX_UDP_PAYLOAD_SIZE
85#endif
86/* The pool keeps spares around for all streams.
87 * The benefit of the pool is that stream buffers do not keep
88 * spares. Memory consumption goes down when streams run empty,
89 * have a large upload done, etc. */
90#define H3_STREAM_POOL_SPARES 5
91/* The max amount of un-acked upload data we keep around per stream */
92#define H3_STREAM_SEND_BUFFER_MAX (10 * H3_STREAM_CHUNK_SIZE)
93#define H3_STREAM_SEND_CHUNKS \
94 (H3_STREAM_SEND_BUFFER_MAX / H3_STREAM_CHUNK_SIZE)
95/* How much data we initially want to buffer un-acked */
96#define H3_STREAM_SEND_BUF_INITIAL (32 * 1024)
98#define QUIC_TUNNEL_INGRESS_PKT_LIMIT 1000
101void Curl_ngtcp2_ver(char *p, size_t len);
103typedef CURLcode cf_ngtcp2_init_h3_conn(struct Curl_cfilter *cf,
104 struct Curl_easy *data,
105 struct cf_ngtcp2_ctx *ctx);
107struct cf_ngtcp2_ctx {
108 struct cf_quic_ctx q;
109 struct ssl_peer ssl_peer;
110 struct curl_tls_ctx tls;
111#ifdef OPENSSL_QUIC_API2
112 ngtcp2_crypto_ossl_ctx *ossl_ctx;
113#endif
114 ngtcp2_path connected_path;
115 ngtcp2_conn *qconn;
116 ngtcp2_cid dcid;
117 ngtcp2_cid scid;
118 uint32_t version;
119 ngtcp2_settings settings;
120 ngtcp2_transport_params transport_params;
121 ngtcp2_ccerr last_error;
122 ngtcp2_crypto_conn_ref conn_ref;
123 struct cf_call_data call_data;
124 cf_ngtcp2_init_h3_conn *init_h3_conn_cb;
125 nghttp3_conn *h3conn;
126 nghttp3_settings h3settings;
127 struct curltime started_at; /* time the current attempt started */
128 struct curltime handshake_at; /* time connect handshake finished */
129 struct bufc_pool stream_bufcp; /* chunk pool for streams */
130 struct dynbuf scratch; /* temp buffer for header construction */
131 struct u32_ptrset streams; /* set of data->mid + h3_stream_ctx */
132 uint64_t used_bidi_streams; /* bidi streams we have opened */
133 uint64_t max_bidi_streams; /* max bidi streams we can open */
134 size_t earlydata_max; /* max amount of early data supported by
135 server on session reuse */
136 size_t earlydata_skip; /* sending bytes to skip when earlydata
137 is accepted by peer */
138 CURLcode tls_vrfy_result; /* result of TLS peer verification */
139 int qlogfd;
140 unsigned char *tunnel_inbuf; /* ingress buffer for tunneled packets */
141 size_t tunnel_inbuf_len;
142 BIT(initialized);
143 BIT(tls_handshake_complete); /* TLS handshake is done */
144 BIT(use_earlydata); /* Using 0RTT data */
145 BIT(earlydata_accepted); /* 0RTT was accepted by server */
146 BIT(shutdown_started); /* queued shutdown packets */
147 BIT(stats_reported); /* connect statistics reported */
148};
150/* How to access `call_data` from a cf_ngtcp2 filter */
151#undef CF_CTX_CALL_DATA
152#define CF_CTX_CALL_DATA(cf) ((struct cf_ngtcp2_ctx *)(cf)->ctx)->call_data
154CURLcode Curl_cf_ngtcp2_ctx_init(struct cf_ngtcp2_ctx *ctx,
155 struct Curl_peer *origin,
156 struct Curl_peer *peer,
157 struct ssl_filter_config *sslc,
158 cf_ngtcp2_init_h3_conn *init_h3_conn_cb);
159void Curl_cf_ngtcp2_ctx_cleanup(struct cf_ngtcp2_ctx *ctx);
160void Curl_cf_ngtcp2_cmn_err_set(struct Curl_cfilter *cf,
161 struct Curl_easy *data, int code);
163/**
164 * All about the H3 internals of a stream
165 */
166struct h3_stream_ctx {
167 int64_t id; /* HTTP/3 stream identifier */
168 curl_off_t xfer_id; /* `id` of transfer owning this stream */
169 struct bufq sendbuf; /* h3 request body */
170 struct h1_req_parser h1; /* h1 request parsing */
171 uint64_t error3; /* HTTP/3 stream error code */
172 curl_off_t upload_left; /* number of request bytes left to upload */
173 curl_off_t rx_total; /* total number of bytes received */
174 uint64_t rx_offset; /* current receive offset */
175 uint64_t rx_offset_max; /* allowed receive offset */
176 size_t tx_in_flight_size; /* sendbuf data "in flight" */
177 size_t tx_in_flight_ideal; /* ideal amount of un-acked send data */
178 uint32_t mid; /* `mid` of transfer owning this stream */
179 int32_t status_code; /* HTTP status code */
180 CURLcode xfer_result; /* result from xfer_resp_write(_hd) */
181 BIT(resp_hds_complete); /* we have a complete, final response */
182 BIT(closed); /* TRUE on stream close */
183 BIT(reset); /* TRUE on stream reset */
184 BIT(send_closed); /* stream is local closed */
185 BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */
186};
188void Curl_cf_ngtcp2_h3_stream_ctx_free(struct h3_stream_ctx *stream);
189void Curl_cf_ngtcp2_h3_err_set(struct Curl_cfilter *cf,
190 struct Curl_easy *data, int code);
192CURLcode Curl_cf_ngtcp2_h3_init_ctrls(struct cf_ngtcp2_ctx *ctx,
193 struct Curl_easy *data);
195CURLcode Curl_cf_ngtcp2_cmn_connect(struct Curl_cfilter *cf,
196 struct Curl_easy *data,
197 bool *done);
199CURLcode Curl_cf_ngtcp2_cmn_shutdown(struct Curl_cfilter *cf,
200 struct Curl_easy *data, bool *done);
201void Curl_cf_ngtcp2_cmn_conn_close(struct Curl_cfilter *cf,
202 struct Curl_easy *data);
204struct cf_ngtcp2_io_ctx {
205 struct Curl_cfilter *cf;
206 struct Curl_easy *data;
207 struct curltime now;
208 ngtcp2_tstamp ts;
209 ngtcp2_path_storage ps;
210};
212void Curl_cf_ngtcp2_io_ctx_init(struct cf_ngtcp2_io_ctx *io_ctx,
213 struct Curl_cfilter *cf,
214 struct Curl_easy *data);
215void Curl_cf_ngtcp2_io_ctx_update_time(struct Curl_easy *data,
216 struct cf_ngtcp2_io_ctx *io_ctx,
217 struct Curl_cfilter *cf);
219CURLcode Curl_cf_ngtcp2_progress_egress(struct Curl_cfilter *cf,
220 struct Curl_easy *data,
221 struct cf_ngtcp2_io_ctx *pktx);
223CURLcode Curl_cf_ngtcp2_progress_ingress(struct Curl_cfilter *cf,
224 struct Curl_easy *data,
225 struct cf_ngtcp2_io_ctx *pktx);
227CURLcode Curl_cf_ngtcp2_cmn_set_expiry(struct Curl_cfilter *cf,
228 struct Curl_easy *data,
229 struct cf_ngtcp2_io_ctx *pktx);
231CURLcode Curl_cf_ngtcp2_h3_stream_setup(struct Curl_cfilter *cf,
232 struct Curl_easy *data,
233 struct h3_stream_ctx **pstream);
234void Curl_cf_ngtcp2_h3_stream_close(struct Curl_cfilter *cf,
235 struct Curl_easy *data,
236 struct h3_stream_ctx *stream);
237void Curl_cf_ngtcp2_h3_stream_done(struct Curl_cfilter *cf,
238 struct Curl_easy *data);
240bool Curl_cf_ngtcp2_cmn_conn_is_alive(struct Curl_cfilter *cf,
241 struct Curl_easy *data,
242 bool *input_pending);
244CURLcode Curl_cf_ngtcp2_cmn_query(struct Curl_cfilter *cf,
245 struct Curl_easy *data,
246 int query, int *pres1, void *pres2);
248CURLcode Curl_cf_ngtcp2_cmn_cntrl(struct Curl_cfilter *cf,
249 struct Curl_easy *data,
250 int event, int arg1, void *arg2);
252struct Curl_easy *Curl_cf_ngtcp2_get_xfer(struct Curl_cfilter *cf,
253 void *stream_user_data,
254 struct h3_stream_ctx **pstream);
256#endif /* !CURL_DISABLE_HTTP && USE_NGTCP2 && USE_NGHTTP3 */
258#endif /* HEADER_CURL_VQUIC_CF_NGTCP2_CMN_H */
Diagnostics4 git calls · 26 ms
CallStatusSizeTime026 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=22
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2003.3 KiB · hit22 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3397
git.response.cache=HIT
git.response.duration_ms=22
git.fetch.wants=2ead50ea152656b457d0327ee69ed1da6563b5dc
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=3397
git.pkt.payload.max=3376
git.sideband.band1.bytes=3375
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e395a54af06019
Request
4fe40cea…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format