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.
This commit is contained in:
Frederic Lecaille 2024-07-30 16:32:48 +02:00
parent 1733dff42a
commit f7f76b8b0d
2 changed files with 41 additions and 17 deletions

View File

@ -22203,10 +22203,12 @@ fc_http_major : integer
encoding and not on the version present in the request header. encoding and not on the version present in the request header.
fc_lost : integer fc_lost : integer
Returns the lost counter measured by the kernel for the client If the connection is not TCP, nor QUIC, the sample fetch fails.
connection. If the server connection is not established, if the connection is For QUIC, returns the number of lost QUIC packets by the client connection.
not TCP or if the operating system does not support TCP_INFO, for example For TCP, returns the lost counter measured by the kernel for the client
Linux kernels before 2.4, the sample fetch fails. 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 fc_nb_streams : integer
Returns the number of streams opened on the frontend connection. Returns the number of streams opened on the frontend connection.
@ -22247,10 +22249,12 @@ fc_rcvd_proxy : boolean
header. header.
fc_reordering : integer fc_reordering : integer
Returns the reordering counter measured by the kernel for the client If the connection is not TCP, nor QUIC, the sample fetch fails.
connection. If the server connection is not established, if the connection is For QUIC, return the number of QUIC reordered packets for the client connection.
not TCP or if the operating system does not support TCP_INFO, for example For TCP, returns the reordering counter measured by the kernel for the client
Linux kernels before 2.4, the sample fetch fails. 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 fc_retrans : integer
Returns the retransmits counter measured by the kernel for the client 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. Linux kernels before 2.4, the sample fetch fails.
fc_rtt(<unit>) : integer 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> 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 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 connection is not established, or if the operating system does not support
operating system does not support TCP_INFO, for example Linux kernels before TCP_INFO, for example Linux kernels before 2.4, the sample fetch fails.
2.4, the sample fetch fails.
fc_rttvar(<unit>) : integer fc_rttvar(<unit>) : integer
Returns the Round Trip Time (RTT) variance measured by the kernel for the If the connection is not TCP, nor QUIC, the sample fetch fails.
client connection. <unit> is facultative, by default the unit is milliseconds. 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 <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 server connection is not established, or if the operating system does not
operating system does not support TCP_INFO, for example Linux kernels before support TCP_INFO, for example Linux kernels before 2.4, the sample fetch fails.
2.4, the sample fetch fails.
fc_sacked : integer fc_sacked : integer
Returns the sacked counter measured by the kernel for the client connection. Returns the sacked counter measured by the kernel for the client connection.

View 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 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_commit(struct connection *conn);
static void quic_bind_tid_reset(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 */ /* Note: must not be declared <const> as its list will be overwritten */
struct protocol proto_quic4 = { struct protocol proto_quic4 = {
@ -82,6 +83,7 @@ struct protocol proto_quic4 = {
.get_src = quic_sock_get_src, .get_src = quic_sock_get_src,
.get_dst = quic_sock_get_dst, .get_dst = quic_sock_get_dst,
.connect = quic_connect_server, .connect = quic_connect_server,
.get_info = quic_get_info,
.bind_tid_prep = quic_bind_tid_prep, .bind_tid_prep = quic_bind_tid_prep,
.bind_tid_commit = quic_bind_tid_commit, .bind_tid_commit = quic_bind_tid_commit,
.bind_tid_reset = quic_bind_tid_reset, .bind_tid_reset = quic_bind_tid_reset,
@ -128,6 +130,7 @@ struct protocol proto_quic6 = {
.get_src = quic_sock_get_src, .get_src = quic_sock_get_src,
.get_dst = quic_sock_get_dst, .get_dst = quic_sock_get_dst,
.connect = quic_connect_server, .connect = quic_connect_server,
.get_info = quic_get_info,
.bind_tid_prep = quic_bind_tid_prep, .bind_tid_prep = quic_bind_tid_prep,
.bind_tid_commit = quic_bind_tid_commit, .bind_tid_commit = quic_bind_tid_commit,
.bind_tid_reset = quic_bind_tid_reset, .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); 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 /* change the connection's thread to <new_tid>. For frontend connections, the
* target is a listener, and the caller is responsible for guaranteeing that * target is a listener, and the caller is responsible for guaranteeing that
* the listener assigned to the connection is bound to the requested thread. * the listener assigned to the connection is bound to the requested thread.