]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
quic: rename vquic implementations, fix for quiche build.
authorStefan Eissing <stefan@eissing.org>
Thu, 5 Jan 2023 18:23:21 +0000 (19:23 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 5 Jan 2023 22:39:49 +0000 (23:39 +0100)
- 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

lib/Makefile.inc
lib/vquic/curl_msh3.c [moved from lib/vquic/msh3.c with 99% similarity]
lib/vquic/curl_msh3.h [moved from lib/vquic/msh3.h with 92% similarity]
lib/vquic/curl_ngtcp2.c [moved from lib/vquic/ngtcp2.c with 99% similarity]
lib/vquic/curl_ngtcp2.h [moved from lib/vquic/ngtcp2.h with 93% similarity]
lib/vquic/curl_quiche.c [moved from lib/vquic/quiche.c with 96% similarity]
lib/vquic/curl_quiche.h [moved from lib/vquic/quiche.h with 92% similarity]
lib/vquic/vquic.c

index 3a3ace0f1626b378d605b8d5df4cca752691084d..c9fc37a58a29d37f83f40779cc664f029581b393 100644 (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
 
similarity index 99%
rename from lib/vquic/msh3.c
rename to lib/vquic/curl_msh3.c
index 513b8e3623ce07d1db8caac33c697bb9a919d3ae..15d0bab5b4643cb2407e18204a19632fb1c96380 100644 (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"
similarity index 92%
rename from lib/vquic/msh3.h
rename to lib/vquic/curl_msh3.h
index c1e9b65cdd53ca96501ee36108969d6337715de1..33931f59bbcfd2a85b76e2ba7b6911a3ae6f30da 100644 (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 */
similarity index 99%
rename from lib/vquic/ngtcp2.c
rename to lib/vquic/curl_ngtcp2.c
index 6c8696d8429c8b2028427d7cd6e6d5183dba88ac..09cae498ed74e2f2c2d9ce7a8d7c7ae9ab202c14 100644 (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"
similarity index 93%
rename from lib/vquic/ngtcp2.h
rename to lib/vquic/curl_ngtcp2.h
index 8d1e997b55c93bbd95913e6d3d2fa08994249feb..8813ec9a77da7b22637d33f933082edb685bc07e 100644 (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 */
similarity index 96%
rename from lib/vquic/quiche.c
rename to lib/vquic/curl_quiche.c
index 232333b2643d6b16cb90c6a9988e2efdbb67be40..5a9feb997728fb50422bb0cf4a528b5703d6bfbf 100644 (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;
   }
similarity index 92%
rename from lib/vquic/quiche.h
rename to lib/vquic/curl_quiche.h
index dcce280f12c459280bc40712ca9b90f54179c925..bce781c1bccc0f1e019524305e50317f0528d1d4 100644 (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 */
index 056be044e8316040a04bcdc391af386c1f80f838..67f010b24c35d37b852c60d7c8f113ad1bf270cf 100644 (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