Aleks,
On 5/31/21 9:35 PM, Aleksandar Lazic wrote:
While I try to get the stream id from spoa I recognized that there is
no fetch method for the streamID.
Attached a patch which adds the fetch sample for the stream id.
I assume it could be back ported up to version 2.0
The backporting information should be part of the commit message. But I
don't think it's going to be backported that far.
Further comments inline.
From 15a2026c495e64d8165a13a3c8a4e5e19ad7e8d6 Mon Sep 17 00:00:00 2001
From: Alexandar Lazic <[email protected]>
Date: Mon, 31 May 2021 21:28:56 +0200
Subject: [PATCH] MINOR: sample: fetch stream_uniq_id
This fetch sample allows to get the current Stream ID for the
current session.
---
doc/configuration.txt | 13 ++++++----
reg-tests/sample_fetches/stream_id.vtc | 33 ++++++++++++++++++++++++++
src/sample.c | 14 +++++++++++
3 files changed, 55 insertions(+), 5 deletions(-)
create mode 100644 reg-tests/sample_fetches/stream_id.vtc
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 11c38945c..7eb7e29cd 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -17433,11 +17433,6 @@ rand([<range>]) : integer
needed to take some routing decisions for example, or just for debugging
purposes. This random must not be used for security purposes.
-uuid([<version>]) : string
- Returns a UUID following the RFC4122 standard. If the version is not
- specified, a UUID version 4 (fully random) is returned.
- Currently, only version 4 is supported.
-
Good catch, but please split moving this around into a dedicated patch
(DOC).
srv_conn([<backend>/]<server>) : integer
Returns an integer value corresponding to the number of currently established
connections on the designated server, possibly including the connection being
@@ -17514,6 +17509,9 @@ stopping : boolean
str(<string>) : string
Returns a string.
+stream_uniq_id : integer
+ Returns the uniq stream id.
+
This explanation is not useful to the reader (even I don't understand it).
table_avl([<table>]) : integer
Returns the total number of available entries in the current proxy's
stick-table or in the designated stick-table. See also table_cnt.
@@ -17528,6 +17526,11 @@ thread : integer
the function, between 0 and (global.nbthread-1). This is useful for logging
and debugging purposes.
+uuid([<version>]) : string
+ Returns a UUID following the RFC4122 standard. If the version is not
+ specified, a UUID version 4 (fully random) is returned.
+ Currently, only version 4 is supported.
+
var(<var-name>) : undefined
Returns a variable with the stored type. If the variable is not set, the
sample fetch fails. The name of the variable starts with an indication
diff --git a/src/sample.c b/src/sample.c
index 09c272c48..5d3b06b10 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -4210,6 +4210,18 @@ static int smp_fetch_uuid(const struct arg *args, struct
sample *smp, const char
return 0;
}
+/* returns the stream uniq_id */
+static int
+smp_fetch_stream_uniq_id(const struct arg *args, struct sample *smp, const
char *kw, void *private)
I believe the 'static int' should go on the same line.
+{
+ if (!smp->strm)
+ return 0;
+
+ smp->data.type = SMP_T_SINT;
+ smp->data.u.sint = smp->strm->uniq_id;
+ return 1;
+}
+
/* Note: must not be declared <const> as its list will be overwritten.
* Note: fetches that may return multiple types must be declared as the lowest
* common denominator, the type that can be casted into all other ones. For
@@ -4243,6 +4255,8 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
{ "bin", smp_fetch_const_bin, ARG1(1,STR), smp_check_const_bin ,
SMP_T_BIN, SMP_USE_CONST },
{ "meth", smp_fetch_const_meth, ARG1(1,STR), smp_check_const_meth,
SMP_T_METH, SMP_USE_CONST },
+ { "stream_uniq_id", smp_fetch_stream_uniq_id, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
+
I believe 'SMP_USE_INTRN' is not correct. I believe you need
'SMP_SRC_L4CLI', but don't quote me on that.
{ /* END */ },
}};
--
2.25.1
Best regards
Tim Düsterhus