MAJOR: sample: pass a pointer to the session to each sample fetch function
Many such function need a session, and till now they used to dereference
the stream. Once we remove the stream from the embryonic session, this
will not be possible anymore.
So as of now, sample fetch functions will be called with this :
- sess = NULL, strm = NULL : never
- sess = valid, strm = NULL : tcp-req connection
- sess = valid, strm = valid, strm->txn = NULL : tcp-req content
- sess = valid, strm = valid, strm->txn = valid : http-req / http-res
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index b7904e0..b49eddd 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1134,7 +1134,7 @@
enum acl_test_res ret = ACL_TEST_PASS;
if (rule->cond) {
- ret = acl_exec_cond(rule->cond, s->be, s, SMP_OPT_DIR_REQ | partial);
+ ret = acl_exec_cond(rule->cond, s->be, sess, s, SMP_OPT_DIR_REQ | partial);
if (ret == ACL_TEST_MISS)
goto missing_data;
@@ -1175,7 +1175,7 @@
continue;
t = rule->act_prm.trk_ctr.table.t;
- key = stktable_fetch_key(t, s->be, s, SMP_OPT_DIR_REQ | partial, rule->act_prm.trk_ctr.expr, &smp);
+ key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->act_prm.trk_ctr.expr, &smp);
if ((smp.flags & SMP_F_MAY_CHANGE) && !(partial & SMP_OPT_FINAL))
goto missing_data; /* key might appear later */
@@ -1193,7 +1193,7 @@
char **cap = s->req_cap;
int len;
- key = sample_fetch_string(s->be, s, SMP_OPT_DIR_REQ | partial, rule->act_prm.cap.expr);
+ key = sample_fetch_string(s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->act_prm.cap.expr);
if (!key)
continue;
@@ -1292,7 +1292,7 @@
enum acl_test_res ret = ACL_TEST_PASS;
if (rule->cond) {
- ret = acl_exec_cond(rule->cond, s->be, s, SMP_OPT_DIR_RES | partial);
+ ret = acl_exec_cond(rule->cond, s->be, sess, s, SMP_OPT_DIR_RES | partial);
if (ret == ACL_TEST_MISS) {
/* just set the analyser timeout once at the beginning of the response */
if (!tick_isset(rep->analyse_exp) && s->be->tcp_rep.inspect_delay)
@@ -1377,7 +1377,7 @@
ret = ACL_TEST_PASS;
if (rule->cond) {
- ret = acl_exec_cond(rule->cond, sess->fe, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
+ ret = acl_exec_cond(rule->cond, sess->fe, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
ret = acl_pass(ret);
if (rule->cond->pol == ACL_COND_UNLESS)
ret = !ret;
@@ -1407,7 +1407,7 @@
continue;
t = rule->act_prm.trk_ctr.table.t;
- key = stktable_fetch_key(t, s->be, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
+ key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
if (key && (ts = stktable_get_entry(t, key)))
stream_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);
@@ -1965,10 +1965,9 @@
/* fetch the connection's source IPv4/IPv6 address */
static int
-smp_fetch_src(struct proxy *px, struct stream *strm, unsigned int opt,
+smp_fetch_src(struct proxy *px, struct session *sess, struct stream *strm, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
- struct session *sess = strm_sess(strm);
struct connection *cli_conn = objt_conn(sess->origin);
if (!cli_conn)
@@ -1993,10 +1992,9 @@
/* set temp integer to the connection's source port */
static int
-smp_fetch_sport(struct proxy *px, struct stream *strm, unsigned int opt,
+smp_fetch_sport(struct proxy *px, struct session *sess, struct stream *strm, unsigned int opt,
const struct arg *args, struct sample *smp, const char *k, void *private)
{
- struct session *sess = strm_sess(strm);
struct connection *cli_conn = objt_conn(sess->origin);
if (!cli_conn)
@@ -2012,10 +2010,9 @@
/* fetch the connection's destination IPv4/IPv6 address */
static int
-smp_fetch_dst(struct proxy *px, struct stream *strm, unsigned int opt,
+smp_fetch_dst(struct proxy *px, struct session *sess, struct stream *strm, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
- struct session *sess = strm_sess(strm);
struct connection *cli_conn = objt_conn(sess->origin);
if (!cli_conn)
@@ -2042,10 +2039,9 @@
/* set temp integer to the frontend connexion's destination port */
static int
-smp_fetch_dport(struct proxy *px, struct stream *strm, unsigned int opt,
+smp_fetch_dport(struct proxy *px, struct session *sess, struct stream *strm, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
- struct session *sess = strm_sess(strm);
struct connection *cli_conn = objt_conn(sess->origin);
if (!cli_conn)