From f7f76b8b0db9d7dad6f8a6c5052bd54b6ded4da9 Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Tue, 30 Jul 2024 16:32:48 +0200 Subject: [PATCH] MINOR: quic: Define ->get_info() control layer callback for QUIC 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 | 40 +++++++++++++++++++++++----------------- src/proto_quic.c | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 529061bf2..abca22450 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -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() : 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. is facultative, by default the unit is milliseconds. 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() : integer - Returns the Round Trip Time (RTT) variance measured by the kernel for the - client connection. 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. is facultative, by default the unit is milliseconds. 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. diff --git a/src/proto_quic.c b/src/proto_quic.c index 7456be629..d16cbbb8a 100644 --- a/src/proto_quic.c +++ b/src/proto_quic.c @@ -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 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 . 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.