Skip to content

Commit

Permalink
MINOR: quic: Define ->get_info() control layer callback for QUIC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
haproxyFred committed Jul 30, 2024
1 parent bb6a9b7 commit 55d1e4a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
40 changes: 23 additions & 17 deletions doc/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/proto_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -85,6 +86,7 @@ struct protocol proto_quic4 = {
.bind_tid_prep = quic_bind_tid_prep,
.bind_tid_commit = quic_bind_tid_commit,
.bind_tid_reset = quic_bind_tid_reset,
.get_info = quic_get_info,

/* binding layer */
.rx_suspend = udp_suspend_receiver,
Expand Down Expand Up @@ -131,6 +133,7 @@ struct protocol proto_quic6 = {
.bind_tid_prep = quic_bind_tid_prep,
.bind_tid_commit = quic_bind_tid_commit,
.bind_tid_reset = quic_bind_tid_reset,
.get_info = quic_get_info,

/* binding layer */
.rx_suspend = udp_suspend_receiver,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 55d1e4a

Please sign in to comment.