From 6c9b315187c57986321fded0b5b77a1bf37fcc51 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 14 Jan 2025 10:11:54 +0100 Subject: [PATCH] MEDIUM: stktable: split sc_ and src_ fetch lookup logics While this patch actually adds more insertions than deletions, it actually tries to simplify the lookup logic for sc_ and src_ sticktable fetches. Indeed, smp_create_src_stkctr() and smp_fetch_sc_stkctr() combination was used everywhere the fetch supports sc_ and src_ form, and smp_fetch_sc_stkctr() even integrated some of the src-oriented fetch logic. Not only this was confusing, but it made the task of adding new generic fetches even more complex. Thus in this patch we completely dedicate smp_fetch_sc_stkctr() to sc_ oriented fetches, while smp_create_src_stkctr() is now renamed to smp_fetch_src_stkctr() and can now work on its own for src_ oriented fetches. It takes an additional paramater, "create" to tell the function if the entry should be created if it doesn't exist yet. Now it's up to the calling function to know if it should be using the sc_ oriented fetch or the src_ oriented one based on the input keyword. --- src/stick_table.c | 256 +++++++++++++++++++++++++++++----------------- 1 file changed, 164 insertions(+), 92 deletions(-) diff --git a/src/stick_table.c b/src/stick_table.c index 9d7af8eee..5530cc66d 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -3610,27 +3610,8 @@ smp_fetch_sc_stkctr(struct session *sess, struct stream *strm, const struct arg /* sc_* variant, args[0] = ctr# (mandatory) */ num = args[arg++].data.sint; } - else if (num > 9) { /* src_* variant, args[0] = table */ - struct stksess *entry; - struct connection *conn = objt_conn(sess->origin); - struct sample smp; - if (!conn) - return NULL; - - /* Fetch source address in a sample. */ - smp.px = NULL; - smp.sess = sess; - smp.strm = strm; - if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, &smp, "src", NULL)) - return NULL; - - entry = smp_fetch_stksess(args->data.t, &smp, 0); - - stkctr->table = args->data.t; - stkctr_set_entry(stkctr, entry); - return stkctr; - } + BUG_ON(num > 9, "unexpected value"); /* Here, contains the counter number from 0 to 9 for * the sc[0-9]_ form, or even higher using sc_(num) if needed. @@ -3672,20 +3653,16 @@ smp_fetch_sc_stkctr(struct session *sess, struct stream *strm, const struct arg } /* same as smp_fetch_sc_stkctr() but dedicated to src_* and can create - * the entry if it doesn't exist yet. This is needed for a few fetch - * functions which need to create an entry, such as src_inc_gpc* and - * src_clr_gpc*. + * the entry if it doesn't exist yet and is set to 1. */ struct stkctr * -smp_create_src_stkctr(struct session *sess, struct stream *strm, const struct arg *args, const char *kw, struct stkctr *stkctr) +smp_fetch_src_stkctr(struct session *sess, struct stream *strm, + const struct arg *args, struct stkctr *stkctr, int create) { struct stksess *entry; struct connection *conn = objt_conn(sess->origin); struct sample smp; - if (strncmp(kw, "src_", 4) != 0) - return NULL; - if (!conn) return NULL; @@ -3696,7 +3673,7 @@ smp_create_src_stkctr(struct session *sess, struct stream *strm, const struct ar if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, &smp, "src", NULL)) return NULL; - entry = smp_fetch_stksess(args->data.t, &smp, 1); + entry = smp_fetch_stksess(args->data.t, &smp, create); stkctr->table = args->data.t; stkctr_set_entry(stkctr, entry); @@ -3768,7 +3745,11 @@ smp_fetch_sc_get_gpt(const struct arg *args, struct sample *smp, const char *kw, idx = args[0].data.sint; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args + 1, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -3817,7 +3798,11 @@ smp_fetch_sc_get_gpt0(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -3867,7 +3852,11 @@ smp_fetch_sc_get_gpc(const struct arg *args, struct sample *smp, const char *kw, idx = args[0].data.sint; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args + 1, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -3918,7 +3907,11 @@ smp_fetch_sc_get_gpc0(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -3969,7 +3962,11 @@ smp_fetch_sc_get_gpc1(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4019,7 +4016,11 @@ smp_fetch_sc_gpc_rate(const struct arg *args, struct sample *smp, const char *kw idx = args[0].data.sint; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args + 1, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4076,7 +4077,11 @@ smp_fetch_sc_gpc0_rate(const struct arg *args, struct sample *smp, const char *k struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4133,7 +4138,11 @@ smp_fetch_sc_gpc1_rate(const struct arg *args, struct sample *smp, const char *k struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4192,13 +4201,14 @@ smp_fetch_sc_inc_gpc(const struct arg *args, struct sample *smp, const char *kw, idx = args[0].data.sint; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args + 1, &tmpstkctr, 1); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (!stkctr) return 0; - if (!stkctr_entry(stkctr)) - stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); - return smp_fetch_inc_gpc(stkctr, smp, idx, (stkctr == &tmpstkctr) ? 1 : 0); } @@ -4268,13 +4278,14 @@ smp_fetch_sc_inc_gpc0(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 1); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; - if (!stkctr_entry(stkctr)) - stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); - return smp_fetch_inc_gpc0(stkctr, smp, (stkctr == &tmpstkctr) ? 1 : 0); } @@ -4343,13 +4354,14 @@ smp_fetch_sc_inc_gpc1(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 1); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; - if (!stkctr_entry(stkctr)) - stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); - return smp_fetch_inc_gpc1(stkctr, smp, (stkctr == &tmpstkctr) ? 1 : 0); } @@ -4396,13 +4408,14 @@ smp_fetch_sc_clr_gpc(const struct arg *args, struct sample *smp, const char *kw, idx = args[0].data.sint; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args + 1, &tmpstkctr, 1); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args + 1, kw, &tmpstkctr); + if (!stkctr) return 0; - if (!stkctr_entry(stkctr)) - stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); - return smp_fetch_clr_gpc(stkctr, smp, idx, (stkctr == &tmpstkctr) ? 1 : 0); } @@ -4450,13 +4463,14 @@ smp_fetch_sc_clr_gpc0(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 1); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; - if (!stkctr_entry(stkctr)) - stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); - return smp_fetch_clr_gpc0(stkctr, smp, (stkctr == &tmpstkctr) ? 1 : 0); } @@ -4504,13 +4518,14 @@ smp_fetch_sc_clr_gpc1(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 1); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; - if (!stkctr_entry(stkctr)) - stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); - return smp_fetch_clr_gpc1(stkctr, smp, (stkctr == &tmpstkctr) ? 1 : 0); } @@ -4553,7 +4568,11 @@ smp_fetch_sc_conn_cnt(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4598,7 +4617,11 @@ smp_fetch_sc_conn_rate(const struct arg *args, struct sample *smp, const char *k struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4640,26 +4663,15 @@ static int smp_fetch_updt_conn_cnt(struct stkctr *stkctr, struct sample *smp) static int smp_fetch_src_updt_conn_cnt(const struct arg *args, struct sample *smp, const char *kw, void *private) { - struct connection *conn = objt_conn(smp->sess->origin); - struct stksess *ts; struct stkctr tmpstkctr; + struct stkctr *stkctr; - if (!conn) - return 0; - - /* Fetch source address in a sample. */ - if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, smp, "src", NULL)) - return 0; - - tmpstkctr.table = args->data.t; + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 1); - if ((ts = smp_fetch_stksess(args->data.t, smp, 1)) == NULL) - /* entry does not exist and could not be created */ + if (!stkctr) return 0; - stkctr_set_entry(&tmpstkctr, ts); - - return smp_fetch_updt_conn_cnt(&tmpstkctr, smp); + return smp_fetch_updt_conn_cnt(stkctr, smp); } static int smp_fetch_conn_cur(struct stkctr *stkctr, struct sample *smp, int decrefcnt) @@ -4699,7 +4711,11 @@ smp_fetch_sc_conn_cur(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4743,7 +4759,11 @@ smp_fetch_sc_glitch_cnt(const struct arg *args, struct sample *smp, const char * struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4788,7 +4808,11 @@ smp_fetch_sc_glitch_rate(const struct arg *args, struct sample *smp, const char struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4832,7 +4856,11 @@ smp_fetch_sc_sess_cnt(const struct arg *args, struct sample *smp, const char *kw struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4876,7 +4904,11 @@ smp_fetch_sc_sess_rate(const struct arg *args, struct sample *smp, const char *k struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4920,7 +4952,11 @@ smp_fetch_sc_http_req_cnt(const struct arg *args, struct sample *smp, const char struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -4965,7 +5001,11 @@ smp_fetch_sc_http_req_rate(const struct arg *args, struct sample *smp, const cha struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5009,7 +5049,11 @@ smp_fetch_sc_http_err_cnt(const struct arg *args, struct sample *smp, const char struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5054,7 +5098,11 @@ smp_fetch_sc_http_err_rate(const struct arg *args, struct sample *smp, const cha struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5098,7 +5146,11 @@ smp_fetch_sc_http_fail_cnt(const struct arg *args, struct sample *smp, const cha struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5144,7 +5196,11 @@ smp_fetch_sc_http_fail_rate(const struct arg *args, struct sample *smp, const ch struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5188,7 +5244,11 @@ smp_fetch_sc_kbytes_in(const struct arg *args, struct sample *smp, const char *k struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5233,7 +5293,11 @@ smp_fetch_sc_bytes_in_rate(const struct arg *args, struct sample *smp, const cha struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5277,7 +5341,11 @@ smp_fetch_sc_kbytes_out(const struct arg *args, struct sample *smp, const char * struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; @@ -5348,7 +5416,11 @@ smp_fetch_sc_bytes_out_rate(const struct arg *args, struct sample *smp, const ch struct stkctr tmpstkctr; struct stkctr *stkctr; - stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (strncmp(kw, "src_", 4) == 0) + stkctr = smp_fetch_src_stkctr(smp->sess, smp->strm, args, &tmpstkctr, 0); + else + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) return 0; -- 2.39.5