]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: quic: use the listener for Retry and Version Negotiation emission
authorYeonggi Kim <yg.kim@navercorp.com>
Thu, 15 Oct 2026 23:45:52 +0000 (08:45 +0900)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 16 Oct 2026 07:31:06 +0000 (09:31 +0200)
send_retry() and send_version_negotiation() take the listener socket FD
as first argument, while send_stateless_reset() takes the listener
instance. Make the first two also take the listener instance. Also
rename their <addr> argument to <dst> to remove any ambiguity, as it is
the destination of the emitted datagram, and fix send_stateless_reset()
comment which still mentioned a FD.

This patch does not introduce any functional change. It is a
prerequisite for the following fixes on Retry, Stateless Reset and
Version Negotiation emission. As such, it should be backported with
them up to 2.8. Prior to 2.9, these functions are static functions
defined in quic_conn.c.

include/haproxy/quic_tx.h
src/quic_rx.c
src/quic_tx.c

index 60d567a723c77f3674be06c8f203f964d6d98e87..f68fbc26bbe622cd843e57ecc0c7127ca7d43c2c 100644 (file)
@@ -47,11 +47,11 @@ int qc_send(struct quic_conn *qc, int old_data, struct list *send_list,
 int qc_dgrams_retransmit(struct quic_conn *qc);
 void qc_prep_hdshk_fast_retrans(struct quic_conn *qc,
                                 struct list *ifrms, struct list *hfrms);
-int send_retry(int fd, struct sockaddr_storage *addr,
+int send_retry(struct listener *l, struct sockaddr_storage *dst,
                struct quic_rx_packet *pkt, const struct quic_version *qv);
 int send_stateless_reset(struct listener *l, struct sockaddr_storage *dstaddr,
                          struct quic_rx_packet *rxpkt);
-int send_version_negotiation(int fd, struct sockaddr_storage *addr,
+int send_version_negotiation(struct listener *l, struct sockaddr_storage *dst,
                              struct quic_rx_packet *pkt);
 
 /* The TX packets sent in the same datagram are linked to each others in
index c4411c9cd318c85d56eaf7303fa56aa217d902e4..fbefac5883ac4c9aa01a660d375762c00be37224 100644 (file)
@@ -1845,7 +1845,7 @@ static struct quic_conn *quic_rx_pkt_retrieve_conn(struct quic_rx_packet *pkt,
                                /* Validate the token, retry or not only when connection is unknown. */
                                if (!quic_token_validate(pkt, dgram, l, qc, &token_odcid)) {
                                        if (dgram->flags & QUIC_DGRAM_FL_SEND_RETRY) {
-                                               if (send_retry(l->rx.fd, (struct sockaddr_storage *)&dgram->saddr, pkt, pkt->version)) {
+                                               if (send_retry(l, (struct sockaddr_storage *)&dgram->saddr, pkt, pkt->version)) {
                                                        TRACE_ERROR("Error during Retry generation",
                                                                    QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
                                                }
@@ -1875,7 +1875,7 @@ static struct quic_conn *quic_rx_pkt_retrieve_conn(struct quic_rx_packet *pkt,
 
                                        TRACE_PROTO("Initial without token, sending retry",
                                                    QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
-                                       if (send_retry(l->rx.fd, (struct sockaddr_storage *)&dgram->saddr, pkt, pkt->version)) {
+                                       if (send_retry(l, (struct sockaddr_storage *)&dgram->saddr, pkt, pkt->version)) {
                                                TRACE_ERROR("Error during Retry generation",
                                                            QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
                                                goto out;
@@ -2054,7 +2054,7 @@ static int quic_rx_pkt_parse(struct quic_conn *qc, struct quic_rx_packet *pkt,
                 */
                if (l && !pkt->version) {
                         /* unsupported version, send Negotiation packet */
-                       if (send_version_negotiation(l->rx.fd, (struct sockaddr_storage *)&dgram->saddr, pkt)) {
+                       if (send_version_negotiation(l, (struct sockaddr_storage *)&dgram->saddr, pkt)) {
                                TRACE_ERROR("VN packet not sent", QUIC_EV_CONN_LPKT);
                                goto drop_silent;
                        }
index 43ce8fc57e861f6f1ee5a431c96721a5b8c68917..7339c0a8372c2b55bc182659db2a5817be1dc1f2 100644 (file)
@@ -1136,21 +1136,21 @@ int qc_dgrams_retransmit(struct quic_conn *qc)
 }
 
 /*
- * Send a Version Negotiation packet on response to <pkt> on socket <fd> to
- * address <addr>.
+ * Send a Version Negotiation packet on response to <pkt> on <l> listener
+ * socket to <dst> address.
  * Implementation of RFC9000 6. Version Negotiation
  *
  * TODO implement a rate-limiting sending of Version Negotiation packets
  *
  * Returns 0 on success else non-zero
  */
-int send_version_negotiation(int fd, struct sockaddr_storage *addr,
+int send_version_negotiation(struct listener *l, struct sockaddr_storage *dst,
                              struct quic_rx_packet *pkt)
 {
        char buf[256];
        int ret = 0, i = 0, j;
        uint32_t version;
-       const socklen_t addrlen = get_addr_len(addr);
+       const socklen_t addrlen = get_addr_len(dst);
 
        TRACE_ENTER(QUIC_EV_CONN_TXPKT);
        /*
@@ -1187,7 +1187,7 @@ int send_version_negotiation(int fd, struct sockaddr_storage *addr,
                i += sizeof(version);
        }
 
-       if (sendto(fd, buf, i, 0, (struct sockaddr *)addr, addrlen) < 0)
+       if (sendto(l->rx.fd, buf, i, 0, (struct sockaddr *)dst, addrlen) < 0)
                goto out;
 
        ret = 1;
@@ -1203,8 +1203,8 @@ int send_version_negotiation(int fd, struct sockaddr_storage *addr,
 static THREAD_LOCAL struct freq_ctr quic_stateless_reset_freq_ctr;
 static THREAD_LOCAL uint quic_stateless_reset_rate;
 
-/* Send a stateless reset packet depending on <pkt> RX packet information
- * from <fd> UDP socket to <dst>
+/* Send a stateless reset packet depending on <rxpkt> RX packet information
+ * from <l> listener socket to <dstaddr>
  * Return 1 if succeeded, 0 if not.
  */
 int send_stateless_reset(struct listener *l, struct sockaddr_storage *dstaddr,
@@ -1305,18 +1305,18 @@ static inline int quic_pkt_type(int type, uint32_t version)
 }
 
 
-/* Generate a Retry packet and send it on <fd> socket to <addr> in response to
- * the Initial <pkt> packet.
+/* Generate a Retry packet and send it on <l> listener socket to <dst> in
+ * response to the Initial <pkt> packet.
  *
  * Returns 0 on success else non-zero.
  */
-int send_retry(int fd, struct sockaddr_storage *addr,
+int send_retry(struct listener *l, struct sockaddr_storage *dst,
                struct quic_rx_packet *pkt, const struct quic_version *qv)
 {
        int ret = 0;
        unsigned char buf[128];
        int i = 0, token_len;
-       const socklen_t addrlen = get_addr_len(addr);
+       const socklen_t addrlen = get_addr_len(dst);
        struct quic_cid scid;
 
        TRACE_ENTER(QUIC_EV_CONN_TXPKT);
@@ -1348,7 +1348,7 @@ int send_retry(int fd, struct sockaddr_storage *addr,
 
        /* token */
        if (!(token_len = quic_generate_retry_token(&buf[i], sizeof(buf) - i, qv->num,
-                                                   &pkt->dcid, &pkt->scid, addr))) {
+                                                   &pkt->dcid, &pkt->scid, dst))) {
                TRACE_ERROR("quic_generate_retry_token() failed", QUIC_EV_CONN_TXPKT);
                goto out;
        }
@@ -1365,7 +1365,7 @@ int send_retry(int fd, struct sockaddr_storage *addr,
 
        i += QUIC_TLS_TAG_LEN;
 
-       if (sendto(fd, buf, i, 0, (struct sockaddr *)addr, addrlen) < 0) {
+       if (sendto(l->rx.fd, buf, i, 0, (struct sockaddr *)dst, addrlen) < 0) {
                TRACE_ERROR("quic_tls_generate_retry_integrity_tag() failed", QUIC_EV_CONN_TXPKT);
                goto out;
        }