MINOR: sample: define bc_reused fetch

Define a new layer4 sample fetch "bc_reused". It is used as a boolean,
set to true if backend connection was reused for the request.
This commit is contained in:
Amaury Denoyelle 2025-03-28 16:54:12 +01:00
parent 5fda64e87e
commit ec76d52cea
2 changed files with 16 additions and 0 deletions

View File

@ -23083,6 +23083,7 @@ bc_err_str string
bc_glitches integer
bc_http_major integer
bc_nb_streams integer
bc_reused boolean
bc_src ip
bc_src_port integer
bc_srv_queue integer
@ -23375,6 +23376,9 @@ bc_http_major : integer
bc_nb_streams : integer
Returns the number of streams opened on the backend connection.
bc_reused : boolean
Returns true if the transfer was performed via a reused backend connection.
bc_src : ip
This is the source ip address of the connection on the server side, which is
the server address HAProxy connected from. It is of type IP and works on both

View File

@ -116,6 +116,17 @@ smp_fetch_sport(const struct arg *args, struct sample *smp, const char *kw, void
return 1;
}
/* return a valid test if the current request was performed using connection reuse */
static int smp_fetch_reused(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
if (!smp->strm)
return 0;
smp->data.type = SMP_T_BOOL;
smp->data.u.sint = !!(smp->strm->flags & SF_SRV_REUSED);
return 1;
}
/* fetch the connection's destination IPv4/IPv6 address. Depending on the
* keyword, it may be the frontend or the backend connection.
*/
@ -551,6 +562,7 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
{ "bc_dst_port", smp_fetch_dport, 0, NULL, SMP_T_SINT, SMP_USE_L4SRV },
{ "bc_src", smp_fetch_src, 0, NULL, SMP_T_ADDR, SMP_USE_L4SRV },
{ "bc_src_port", smp_fetch_sport, 0, NULL, SMP_T_SINT, SMP_USE_L4SRV },
{ "bc_reused", smp_fetch_reused, 0, NULL, SMP_T_BOOL, SMP_USE_L4SRV },
{ "dst", smp_fetch_dst, 0, NULL, SMP_T_ADDR, SMP_USE_L4CLI },
{ "dst_is_local", smp_fetch_dst_is_local, 0, NULL, SMP_T_BOOL, SMP_USE_L4CLI },