Hello,

When using table_* converters ref_cnt was incremented
and never decremented causing entries to not expire.

The root cause appears to be that stktable_lookup_key()
was called within all sample_conv_table_* functions which was
incrementing ref_cnt and not decrementing after completion.

Added stktable_release() to the end of each sample_conv_table_*
function.

This should be backported to 1.8.


Thanks,
-- Daniel

>From 28530921746e62bb229880774a311bfebfcf7579 Mon Sep 17 00:00:00 2001
From: Daniel Corbett <dcorb...@haproxy.com>
Date: Thu, 17 May 2018 13:17:54 -0400
Subject: [PATCH] BUG/MEDIUM: stick-tables: Decrement ref_cnt in table_*
 converters

When using table_* converters ref_cnt was incremented
and never decremented causing entries to not expire.

The root cause appears to be that stktable_lookup_key()
was called within all sample_conv_table_* functions which was
incrementing ref_cnt and not decrementing after completion.

Added stktable_release() to the end of each sample_conv_table_*
function.

This should be backported to 1.8
---
 src/stick_table.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/stick_table.c b/src/stick_table.c
index 3e44747..f1ad347 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -912,6 +912,7 @@ static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sampl
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
 					       t->data_arg[STKTABLE_DT_BYTES_IN_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -948,6 +949,7 @@ static int sample_conv_table_conn_cnt(const struct arg *arg_p, struct sample *sm
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, conn_cnt);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -984,6 +986,7 @@ static int sample_conv_table_conn_cur(const struct arg *arg_p, struct sample *sm
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, conn_cur);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1021,6 +1024,7 @@ static int sample_conv_table_conn_rate(const struct arg *arg_p, struct sample *s
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
 					       t->data_arg[STKTABLE_DT_CONN_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1058,6 +1062,7 @@ static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct samp
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
 					       t->data_arg[STKTABLE_DT_BYTES_OUT_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1094,6 +1099,7 @@ static int sample_conv_table_gpt0(const struct arg *arg_p, struct sample *smp, v
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, gpt0);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1130,6 +1136,7 @@ static int sample_conv_table_gpc0(const struct arg *arg_p, struct sample *smp, v
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, gpc0);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1167,6 +1174,7 @@ static int sample_conv_table_gpc0_rate(const struct arg *arg_p, struct sample *s
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate),
 	                                      t->data_arg[STKTABLE_DT_GPC0_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1203,6 +1211,7 @@ static int sample_conv_table_gpc1(const struct arg *arg_p, struct sample *smp, v
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, gpc1);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1240,6 +1249,7 @@ static int sample_conv_table_gpc1_rate(const struct arg *arg_p, struct sample *s
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc1_rate),
 	                                      t->data_arg[STKTABLE_DT_GPC1_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1276,6 +1286,7 @@ static int sample_conv_table_http_err_cnt(const struct arg *arg_p, struct sample
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, http_err_cnt);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1313,6 +1324,7 @@ static int sample_conv_table_http_err_rate(const struct arg *arg_p, struct sampl
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
 					       t->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1349,6 +1361,7 @@ static int sample_conv_table_http_req_cnt(const struct arg *arg_p, struct sample
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, http_req_cnt);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1386,6 +1399,7 @@ static int sample_conv_table_http_req_rate(const struct arg *arg_p, struct sampl
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
 					       t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1422,6 +1436,7 @@ static int sample_conv_table_kbytes_in(const struct arg *arg_p, struct sample *s
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1458,6 +1473,7 @@ static int sample_conv_table_kbytes_out(const struct arg *arg_p, struct sample *
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1494,6 +1510,7 @@ static int sample_conv_table_server_id(const struct arg *arg_p, struct sample *s
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, server_id);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1530,6 +1547,7 @@ static int sample_conv_table_sess_cnt(const struct arg *arg_p, struct sample *sm
 		return 0; /* parameter not stored */
 
 	smp->data.u.sint = stktable_data_cast(ptr, sess_cnt);
+	stktable_release(t, ts);
 	return 1;
 }
 
@@ -1567,6 +1585,7 @@ static int sample_conv_table_sess_rate(const struct arg *arg_p, struct sample *s
 
 	smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
 					       t->data_arg[STKTABLE_DT_SESS_RATE].u);
+	stktable_release(t, ts);
 	return 1;
 }
 
-- 
2.7.4

Reply via email to