quic: rename vquic implementations, fix for quiche build.

- quiche in debug mode did not build, fixed.
- moved all vquic implementation files to prefix curl_* to avoid
  the potential mixups between provided .h files and our own.
- quich passes test 2500 and 2502. 2501, the POST, fail with
  the body being rejected. Quich bug?

Closes #10242
This commit is contained in:
Stefan Eissing 2023-01-05 19:23:21 +01:00 committed by Daniel Stenberg
parent 16bb32e104
commit 446267c555
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
8 changed files with 52 additions and 58 deletions

View File

@ -79,15 +79,15 @@ LIB_VTLS_HFILES = \
vtls/x509asn1.h
LIB_VQUIC_CFILES = \
vquic/msh3.c \
vquic/ngtcp2.c \
vquic/quiche.c \
vquic/curl_msh3.c \
vquic/curl_ngtcp2.c \
vquic/curl_quiche.c \
vquic/vquic.c
LIB_VQUIC_HFILES = \
vquic/msh3.h \
vquic/ngtcp2.h \
vquic/quiche.h \
vquic/curl_msh3.h \
vquic/curl_ngtcp2.h \
vquic/curl_quiche.h \
vquic/vquic.h \
vquic/vquic_int.h

View File

@ -33,7 +33,7 @@
#include "cfilters.h"
#include "connect.h"
#include "h2h3.h"
#include "msh3.h"
#include "curl_msh3.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"

View File

@ -1,5 +1,5 @@
#ifndef HEADER_CURL_VQUIC_MSH3_H
#define HEADER_CURL_VQUIC_MSH3_H
#ifndef HEADER_CURL_VQUIC_CURL_MSH3_H
#define HEADER_CURL_VQUIC_CURL_MSH3_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -43,4 +43,4 @@ bool Curl_conn_is_msh3(const struct Curl_easy *data,
#endif /* USE_MSQUIC */
#endif /* HEADER_CURL_VQUIC_MSH3_H */
#endif /* HEADER_CURL_VQUIC_CURL_MSH3_H */

View File

@ -48,7 +48,6 @@
#include "sendf.h"
#include "strdup.h"
#include "rand.h"
#include "ngtcp2.h"
#include "multiif.h"
#include "strcase.h"
#include "cfilters.h"
@ -60,6 +59,7 @@
#include "h2h3.h"
#include "vtls/keylog.h"
#include "vtls/vtls.h"
#include "curl_ngtcp2.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"

View File

@ -1,5 +1,5 @@
#ifndef HEADER_CURL_VQUIC_NGTCP2_H
#define HEADER_CURL_VQUIC_NGTCP2_H
#ifndef HEADER_CURL_VQUIC_CURL_NGTCP2_H
#define HEADER_CURL_VQUIC_CURL_NGTCP2_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -58,4 +58,4 @@ bool Curl_conn_is_ngtcp2(const struct Curl_easy *data,
int sockindex);
#endif
#endif /* HEADER_CURL_VQUIC_NGTCP2_H */
#endif /* HEADER_CURL_VQUIC_CURL_NGTCP2_H */

View File

@ -39,6 +39,7 @@
#include "connect.h"
#include "strerror.h"
#include "vquic.h"
#include "curl_quiche.h"
#include "transfer.h"
#include "h2h3.h"
#include "vtls/openssl.h"
@ -133,7 +134,7 @@ struct quic_handshake {
struct h3_event_node {
struct h3_event_node *next;
uint64_t stream3_id;
int64_t stream3_id;
quiche_h3_event *ev;
};
@ -175,28 +176,9 @@ static void h3_clear_pending(struct cf_quiche_ctx *ctx)
}
}
static bool h3_has_pending(struct Curl_cfilter *cf,
struct Curl_easy *data)
{
struct cf_quiche_ctx *ctx = cf->ctx;
struct HTTP *stream = data->req.p.http;
struct h3_event_node *node;
for(node = ctx->pending; node; node = node->next) {
if(node->stream3_id == stream->stream3_id) {
CF_DEBUGF(infof(data, CFMSG(cf, "h3[%u] has data pending"),
stream->stream3_id));
return TRUE;
}
}
CF_DEBUGF(infof(data, CFMSG(cf, "h3[%u] no data pending"),
stream->stream3_id));
return FALSE;
}
static CURLcode h3_add_event(struct Curl_cfilter *cf,
struct Curl_easy *data,
uint64_t stream3_id, quiche_h3_event *ev)
int64_t stream3_id, quiche_h3_event *ev)
{
struct cf_quiche_ctx *ctx = cf->ctx;
struct Curl_easy *mdata;
@ -270,7 +252,7 @@ static int cb_each_header(uint8_t *name, size_t name_len,
static ssize_t h3_process_event(struct Curl_cfilter *cf,
struct Curl_easy *data,
char *buf, size_t len,
uint64_t stream3_id,
int64_t stream3_id,
quiche_h3_event *ev,
CURLcode *err)
{
@ -387,7 +369,7 @@ static CURLcode cf_process_ingress(struct Curl_cfilter *cf,
socklen_t from_len;
quiche_recv_info recv_info;
DEBUGASSERT(qs->conn);
DEBUGASSERT(ctx->qconn);
/* in case the timeout expired */
quiche_conn_on_timeout(ctx->qconn);
@ -482,7 +464,6 @@ static ssize_t cf_quiche_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
ssize_t recvd = -1;
ssize_t rcode;
quiche_h3_event *ev;
int rc;
struct h3h1header headers;
struct HTTP *stream = data->req.p.http;
headers.dest = buf;
@ -614,6 +595,8 @@ static CURLcode cf_http_request(struct Curl_cfilter *cf,
stream3_id = quiche_h3_send_request(ctx->h3c, ctx->qconn, nva, nheader,
stream->upload_left ? FALSE: TRUE);
CF_DEBUGF(infof(data, CFMSG(cf, "send_request(with_body=%d) -> %zd"),
!!stream->upload_left, stream3_id));
if((stream3_id >= 0) && data->set.postfields) {
ssize_t sent = quiche_h3_send_body(ctx->h3c, ctx->qconn, stream3_id,
(uint8_t *)data->set.postfields,
@ -655,7 +638,7 @@ fail:
static ssize_t cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data,
const void *buf, size_t len, CURLcode *err)
{
struct cf_quiche_ctx *ctx = ctx;
struct cf_quiche_ctx *ctx = cf->ctx;
struct HTTP *stream = data->req.p.http;
ssize_t sent;
@ -673,7 +656,14 @@ static ssize_t cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data,
if(sent == QUICHE_H3_ERR_DONE) {
sent = 0;
}
else if(sent == QUICHE_H3_TRANSPORT_ERR_FINAL_SIZE) {
DEBUGF(infof(data, CFMSG(cf, "send_body(len=%zu) -> exceeds size"),
len));
*err = CURLE_SEND_ERROR;
return -1;
}
else if(sent < 0) {
DEBUGF(infof(data, CFMSG(cf, "send_body(len=%zu) -> %zd"), len, sent));
*err = CURLE_SEND_ERROR;
return -1;
}
@ -695,7 +685,6 @@ static int cf_quiche_get_select_socks(struct Curl_cfilter *cf,
struct cf_quiche_ctx *ctx = cf->ctx;
struct SingleRequest *k = &data->req;
int rv = GETSOCK_BLANK;
struct HTTP *stream = data->req.p.http;
socks[0] = ctx->sockfd;
@ -718,8 +707,19 @@ static bool cf_quiche_data_pending(struct Curl_cfilter *cf,
const struct Curl_easy *data)
{
struct cf_quiche_ctx *ctx = cf->ctx;
struct HTTP *stream = data->req.p.http;
struct h3_event_node *node;
return h3_has_pending(cf, (struct Curl_easy *)data);
for(node = ctx->pending; node; node = node->next) {
if(node->stream3_id == stream->stream3_id) {
CF_DEBUGF(infof((struct Curl_easy *)data,
CFMSG(cf, "h3[%u] has data pending"), stream->stream3_id));
return TRUE;
}
}
CF_DEBUGF(infof((struct Curl_easy *)data,
CFMSG(cf, "h3[%u] no data pending"), stream->stream3_id));
return FALSE;
}
static CURLcode cf_quiche_data_event(struct Curl_cfilter *cf,
@ -815,7 +815,6 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf,
const struct Curl_sockaddr_ex *sockaddr;
const char *r_ip;
int r_port;
int qfd;
result = Curl_cf_socket_peek(cf->next, &ctx->sockfd,
&sockaddr, &r_ip, &r_port);
@ -1045,6 +1044,7 @@ static void cf_quiche_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
{
struct cf_quiche_ctx *ctx = cf->ctx;
(void)data;
cf_quiche_ctx_clear(ctx);
free(ctx);
cf->ctx = NULL;
@ -1058,17 +1058,11 @@ static CURLcode cf_quiche_query(struct Curl_cfilter *cf,
switch(query) {
case CF_QUERY_MAX_CONCURRENT: {
uint64_t in_use = CONN_INUSE(cf->conn);
if(ctx->goaway) {
*pres1 = in_use;
}
else {
uint64_t bidi_left = quiche_conn_peer_streams_left_bidi(ctx->qconn);
if(bidi_left >= (INT_MAX - in_use))
*pres1 = INT_MAX;
else
*pres1 = (long)(bidi_left + in_use);
uint64_t max_streams = CONN_INUSE(cf->conn);
if(!ctx->goaway) {
max_streams += quiche_conn_peer_streams_left_bidi(ctx->qconn);
}
*pres1 = (max_streams > INT_MAX)? INT_MAX : (int)max_streams;
CF_DEBUGF(infof(data, CFMSG(cf, "query: MAX_CONCURRENT -> %ld"), *pres1));
return CURLE_OK;
}

View File

@ -1,5 +1,5 @@
#ifndef HEADER_CURL_VQUIC_QUICHE_H
#define HEADER_CURL_VQUIC_QUICHE_H
#ifndef HEADER_CURL_VQUIC_CURL_QUICHE_H
#define HEADER_CURL_VQUIC_CURL_QUICHE_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -47,4 +47,4 @@ bool Curl_conn_is_quiche(const struct Curl_easy *data,
#endif
#endif /* HEADER_CURL_VQUIC_QUICHE_H */
#endif /* HEADER_CURL_VQUIC_CURL_QUICHE_H */

View File

@ -32,9 +32,9 @@
#include "urldata.h"
#include "dynbuf.h"
#include "curl_printf.h"
#include "msh3.h"
#include "ngtcp2.h"
#include "quiche.h"
#include "curl_msh3.h"
#include "curl_ngtcp2.h"
#include "curl_quiche.h"
#include "vquic.h"
#ifdef O_BINARY