]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Define ->get_info() control layer callback for QUIC
authorFrederic Lecaille <flecaille@haproxy.com>
Tue, 30 Jul 2024 14:32:48 +0000 (16:32 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 31 Jul 2024 08:29:42 +0000 (10:29 +0200)
This low level callback may be called by several sample fetches for
frontend connections like "fc_rtt", "fc_rttvar" etc.
Define this callback for QUIC protocol as pointer to quic_get_info().
This latter supports these sample fetches:
   "fc_lost", "fc_reordering", "fc_rtt" and "fc_rttvar".

Update the documentation consequently.

doc/configuration.txt
src/proto_quic.c

index 529061bf271338d51332651ab9ca9b2e25d0b048..abca2245083f457d95304969920dab79b351525d 100644 (file)
@@ -22203,10 +22203,12 @@ fc_http_major : integer
   encoding and not on the version present in the request header.
 
 fc_lost : integer
-  Returns the lost counter measured by the kernel for the client
-  connection. If the server connection is not established, if the connection is
-  not TCP or if the operating system does not support TCP_INFO, for example
-  Linux kernels before 2.4, the sample fetch fails.
+  If the connection is not TCP, nor QUIC, the sample fetch fails.
+  For QUIC, returns the number of lost QUIC packets by the client connection.
+  For TCP, returns the lost counter measured by the kernel for the client
+  connection. If the server connection is not established, or if the operating
+  system does not support TCP_INFO, for example Linux kernels before 2.4, the
+  sample fetch fails.
 
 fc_nb_streams : integer
   Returns the number of streams opened on the frontend connection.
@@ -22247,10 +22249,12 @@ fc_rcvd_proxy : boolean
   header.
 
 fc_reordering : integer
-  Returns the reordering counter measured by the kernel for the client
-  connection. If the server connection is not established, if the connection is
-  not TCP or if the operating system does not support TCP_INFO, for example
-  Linux kernels before 2.4, the sample fetch fails.
+  If the connection is not TCP, nor QUIC, the sample fetch fails.
+  For QUIC, return the number of QUIC reordered packets for the client connection.
+  For TCP, returns the reordering counter measured by the kernel for the client
+  connection. If the server connection is not established, or if the operating
+  system does not support TCP_INFO, for example Linux kernels before 2.4, the
+  sample fetch fails.
 
 fc_retrans : integer
   Returns the retransmits counter measured by the kernel for the client
@@ -22259,20 +22263,22 @@ fc_retrans : integer
   Linux kernels before 2.4, the sample fetch fails.
 
 fc_rtt(<unit>) : integer
-  Returns the Round Trip Time (RTT) measured by the kernel for the client
+  If the connection is not TCP, nor QUIC, the sample fetch fails.
+  For QUIC, returns Smoothed Round Trip Time for the client connection.
+  For TCP, returns the Round Trip Time (RTT) measured by the kernel for the client
   connection. <unit> is facultative, by default the unit is milliseconds. <unit>
   can be set to "ms" for milliseconds or "us" for microseconds. If the server
-  connection is not established, if the connection is not TCP or if the
-  operating system does not support TCP_INFO, for example Linux kernels before
-  2.4, the sample fetch fails.
+  connection is not established, or if the operating system does not support
+  TCP_INFO, for example Linux kernels before 2.4, the sample fetch fails.
 
 fc_rttvar(<unit>) : integer
-  Returns the Round Trip Time (RTT) variance measured by the kernel for the
-  client connection. <unit> is facultative, by default the unit is milliseconds.
+  If the connection is not TCP, nor QUIC, the sample fetch fails.
+  For QUIC, returns Smoothed Round Trip Time variance for the client connection.
+  For TCP, returns the Round Trip Time (RTT) variance measured by the kernel for
+  the client connection. <unit> is facultative, by default the unit is milliseconds.
   <unit> can be set to "ms" for milliseconds or "us" for microseconds. If the
-  server connection is not established, if the connection is not TCP or if the
-  operating system does not support TCP_INFO, for example Linux kernels before
-  2.4, the sample fetch fails.
+  server connection is not established, or if the operating system does not
+  support TCP_INFO, for example Linux kernels before 2.4, the sample fetch fails.
 
 fc_sacked : integer
   Returns the sacked counter measured by the kernel for the client connection.
index 7456be62943b77b9aec25208c5e39d810e4df9ab..d16cbbb8a7745e38e83d74fe932adb3128f186be 100644 (file)
@@ -64,6 +64,7 @@ static void quic_disable_listener(struct listener *listener);
 static int quic_bind_tid_prep(struct connection *conn, int new_tid);
 static void quic_bind_tid_commit(struct connection *conn);
 static void quic_bind_tid_reset(struct connection *conn);
+static int quic_get_info(struct connection *conn, long long int *info, int info_num);
 
 /* Note: must not be declared <const> as its list will be overwritten */
 struct protocol proto_quic4 = {
@@ -82,6 +83,7 @@ struct protocol proto_quic4 = {
        .get_src        = quic_sock_get_src,
        .get_dst        = quic_sock_get_dst,
        .connect        = quic_connect_server,
+       .get_info       = quic_get_info,
        .bind_tid_prep   = quic_bind_tid_prep,
        .bind_tid_commit = quic_bind_tid_commit,
        .bind_tid_reset  = quic_bind_tid_reset,
@@ -128,6 +130,7 @@ struct protocol proto_quic6 = {
        .get_src        = quic_sock_get_src,
        .get_dst        = quic_sock_get_dst,
        .connect        = quic_connect_server,
+       .get_info       = quic_get_info,
        .bind_tid_prep   = quic_bind_tid_prep,
        .bind_tid_commit = quic_bind_tid_commit,
        .bind_tid_reset  = quic_bind_tid_reset,
@@ -694,6 +697,21 @@ static void quic_disable_listener(struct listener *l)
                fd_stop_recv(l->rx.fd);
 }
 
+static int quic_get_info(struct connection *conn, long long int *info, int info_num)
+{
+       struct quic_conn *qc = conn->handle.qc;
+
+       switch (info_num) {
+       case 0:  *info = qc->path->loss.srtt;             break;
+       case 1:  *info = qc->path->loss.rtt_var;          break;
+       case 3:  *info = qc->path->loss.nb_lost_pkt;      break;
+       case 7:  *info = qc->path->loss.nb_reordered_pkt; break;
+       default: return 0;
+       }
+
+       return 1;
+}
+
 /* change the connection's thread to <new_tid>. For frontend connections, the
  * target is a listener, and the caller is responsible for guaranteeing that
  * the listener assigned to the connection is bound to the requested thread.