]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: define retry_source_connection_id TP
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 11 Jan 2022 11:03:09 +0000 (12:03 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 12 Jan 2022 10:08:48 +0000 (11:08 +0100)
Define a new QUIC transport parameter retry_source_connection_id. This
parameter is set only by server, after issuing a Retry packet.

include/haproxy/xprt_quic-t.h
include/haproxy/xprt_quic.h
src/xprt_quic.c

index 78ced5160cca4cff32faaf208b539c88d70249f9..98a0ea709319fc315b685a216dff171d20388a32 100644 (file)
@@ -306,6 +306,7 @@ struct preferred_address {
 #define QUIC_TP_PREFERRED_ADDRESS                   13
 #define QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT          14
 #define QUIC_TP_INITIAL_SOURCE_CONNECTION_ID        15
+#define QUIC_TP_RETRY_SOURCE_CONNECTION_ID          16
 
 /*
  * These defines are not for transport parameter type, but the maximum accepted value for
@@ -346,6 +347,10 @@ struct quic_transport_params {
         * When received by clients, must be set to 1 if present.
         */
        struct quic_cid original_destination_connection_id;            /* Forbidden for clients */
+       /*
+        * MUST be sent by servers after Retry.
+        */
+       struct quic_cid retry_source_connection_id;                    /* Forbidden for clients */
        /* MUST be present both for servers and clients. */
        struct quic_cid initial_source_connection_id;
        struct preferred_address preferred_address;                    /* Forbidden for clients */
index 2c41355ba6728cb6a4655fcaeb3fef56bc6f98ff..9e76c75948eab20dc3ddfa361b198907537e3214 100644 (file)
@@ -488,6 +488,8 @@ static inline void quic_transport_params_init(struct quic_transport_params *p,
                p->with_stateless_reset_token      = 1;
        p->active_connection_id_limit          = 8;
 
+       p->retry_source_connection_id.len = 0;
+
 }
 
 /* Encode <addr> preferred address transport parameter in <buf> without its
@@ -779,6 +781,15 @@ static inline int quic_transport_params_encode(unsigned char *buf,
                                                  p->original_destination_connection_id.data,
                                                  p->original_destination_connection_id.len))
                        return 0;
+
+               if (p->retry_source_connection_id.len) {
+                       if (!quic_transport_param_enc_mem(&pos, end,
+                                                         QUIC_TP_RETRY_SOURCE_CONNECTION_ID,
+                                                         p->retry_source_connection_id.data,
+                                                         p->retry_source_connection_id.len))
+                               return 0;
+               }
+
                if (p->with_stateless_reset_token &&
                        !quic_transport_param_enc_mem(&pos, end, QUIC_TP_STATELESS_RESET_TOKEN,
                                                      p->stateless_reset_token,
index 6cf0d4bb7a21e3eda23cb0317dfa429df2351fb7..83379d0970e290bb84d9952fa92646fd25b10ed3 100644 (file)
@@ -4198,6 +4198,9 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end,
                                        TRACE_PROTO("Error during Initial token parsing", QUIC_EV_CONN_LPKT, qc);
                                        goto err;
                                }
+                               /* Copy retry_source_connection_id transport parameter. */
+                               quic_cid_cpy(&qc->rx.params.retry_source_connection_id,
+                                            &pkt->dcid);
                        }
                        else {
                                memcpy(odcid->data, &pkt->dcid.data, pkt->dcid.len);