return (struct session *)t->context;
}
+/* sets the stick counter's entry pointer */
+static inline void stkctr_set_entry(struct stkctr *stkctr, struct stksess *entry)
+{
+ stkctr->entry = caddr_from_ptr(entry, 0);
+}
+
+/* returns the entry pointer from a stick counter */
+static inline struct stksess *stkctr_entry(struct stkctr *stkctr)
+{
+ return caddr_to_ptr(stkctr->entry);
+}
+
+/* returns the two flags from a stick counter */
+static inline unsigned int stkctr_flags(struct stkctr *stkctr)
+{
+ return caddr_to_data(stkctr->entry);
+}
+
+/* sets up to two flags at a time on a composite address */
+static inline void stkctr_set_flags(struct stkctr *stkctr, unsigned int flags)
+{
+ stkctr->entry = caddr_set_flags(stkctr->entry, flags);
+}
+
+/* returns the two flags from a stick counter */
+static inline void stkctr_clr_flags(struct stkctr *stkctr, unsigned int flags)
+{
+ stkctr->entry = caddr_clr_flags(stkctr->entry, flags);
+}
+
/* Remove the refcount from the session to the tracked counters, and clear the
* pointer to ensure this is only performed once. The caller is responsible for
* ensuring that the pointer is valid first.
int i;
for (i = 0; i < MAX_SESS_STKCTR; i++) {
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_CONN_CUR);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_CONN_CUR);
if (ptr)
stktable_data_cast(ptr, conn_cur)--;
- s->stkctr[i].entry->ref_cnt--;
- stksess_kill_if_expired(s->stkctr[i].table, s->stkctr[i].entry);
- s->stkctr[i].entry = NULL;
+ stkctr_entry(&s->stkctr[i])->ref_cnt--;
+ stksess_kill_if_expired(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]));
+ stkctr_set_entry(&s->stkctr[i], NULL);
}
}
void *ptr;
int i;
- if (likely(!(s->flags & SN_CT_TRACK_ANY)))
- return;
-
for (i = 0; i < MAX_SESS_STKCTR; i++) {
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
- if (!(s->flags & (SN_CT_TRACK_SC0 << i)))
+ if (!(stkctr_flags(&s->stkctr[i]) & STKCTR_TRACK_CONTENT))
continue;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_CONN_CUR);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_CONN_CUR);
if (ptr)
stktable_data_cast(ptr, conn_cur)--;
- s->stkctr[i].entry->ref_cnt--;
- stksess_kill_if_expired(s->stkctr[i].table, s->stkctr[i].entry);
- s->stkctr[i].entry = NULL;
+ stkctr_entry(&s->stkctr[i])->ref_cnt--;
+ stksess_kill_if_expired(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]));
+ stkctr_set_entry(&s->stkctr[i], NULL);
}
- s->flags &= ~SN_CT_TRACK_ANY;
}
/* Increase total and concurrent connection count for stick entry <ts> of table
*/
static inline void session_track_stkctr(struct stkctr *ctr, struct stktable *t, struct stksess *ts)
{
- if (ctr->entry)
+ if (stkctr_entry(ctr))
return;
ts->ref_cnt++;
ctr->table = t;
- ctr->entry = ts;
+ stkctr_set_entry(ctr, ts);
session_start_counters(t, ts);
}
int i;
for (i = 0; i < MAX_SESS_STKCTR; i++) {
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_HTTP_REQ_CNT);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_CNT);
if (ptr)
stktable_data_cast(ptr, http_req_cnt)++;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_HTTP_REQ_RATE);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_RATE);
if (ptr)
update_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
s->stkctr[i].table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1);
void *ptr;
int i;
- if (likely(!(s->flags & SN_BE_TRACK_ANY)))
- return;
-
for (i = 0; i < MAX_SESS_STKCTR; i++) {
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
- if (!(s->flags & (SN_BE_TRACK_SC0 << i)))
+ if (!(stkctr_flags(&s->stkctr[i]) & STKCTR_TRACK_BACKEND))
continue;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_HTTP_REQ_CNT);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_CNT);
if (ptr)
stktable_data_cast(ptr, http_req_cnt)++;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_HTTP_REQ_RATE);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_RATE);
if (ptr)
update_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
s->stkctr[i].table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1);
int i;
for (i = 0; i < MAX_SESS_STKCTR; i++) {
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_HTTP_ERR_CNT);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_ERR_CNT);
if (ptr)
stktable_data_cast(ptr, http_err_cnt)++;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_HTTP_ERR_RATE);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_ERR_RATE);
if (ptr)
update_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
s->stkctr[i].table->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u, 1);
for (i = 0; i < MAX_SESS_STKCTR; i++) {
void *ptr;
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_SESS_CNT);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_SESS_CNT);
if (ptr)
stktable_data_cast(ptr, sess_cnt)++;
- ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_SESS_RATE);
+ ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_SESS_RATE);
if (ptr)
update_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
s->stkctr[i].table->data_arg[STKTABLE_DT_SESS_RATE].u, 1);
s->listener->counters->bytes_in += bytes;
for (i = 0; i < MAX_SESS_STKCTR; i++) {
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
ptr = stktable_data_ptr(s->stkctr[i].table,
- s->stkctr[i].entry,
+ stkctr_entry(&s->stkctr[i]),
STKTABLE_DT_BYTES_IN_CNT);
if (ptr)
stktable_data_cast(ptr, bytes_in_cnt) += bytes;
ptr = stktable_data_ptr(s->stkctr[i].table,
- s->stkctr[i].entry,
+ stkctr_entry(&s->stkctr[i]),
STKTABLE_DT_BYTES_IN_RATE);
if (ptr)
update_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
s->listener->counters->bytes_out += bytes;
for (i = 0; i < MAX_SESS_STKCTR; i++) {
- if (!s->stkctr[i].entry)
+ if (!stkctr_entry(&s->stkctr[i]))
continue;
ptr = stktable_data_ptr(s->stkctr[i].table,
- s->stkctr[i].entry,
+ stkctr_entry(&s->stkctr[i]),
STKTABLE_DT_BYTES_OUT_CNT);
if (ptr)
stktable_data_cast(ptr, bytes_out_cnt) += bytes;
ptr = stktable_data_ptr(s->stkctr[i].table,
- s->stkctr[i].entry,
+ stkctr_entry(&s->stkctr[i]),
STKTABLE_DT_BYTES_OUT_RATE);
if (ptr)
update_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
return NULL;
stkctr.table = &args->data.prx->table;
- stkctr.entry = stktable_lookup_key(stkctr.table, key);
+ stkctr_set_entry(&stkctr, stktable_lookup_key(stkctr.table, key));
return &stkctr;
}
if (unlikely(args[arg].type == ARGT_TAB)) {
/* an alternate table was specified, let's look up the same key there */
stkctr.table = &args[arg].data.prx->table;
- stkctr.entry = stktable_lookup(stkctr.table, l4->stkctr[num].entry);
+ stkctr_set_entry(&stkctr, stktable_lookup(stkctr.table, stkctr_entry(&l4->stkctr[num])));
return &stkctr;
}
- return l4->stkctr[num].entry ? &l4->stkctr[num] : NULL;
+ return stkctr_entry(&l4->stkctr[num]) ? &l4->stkctr[num] : NULL;
}
/* set return a boolean indicating if the requested session counter is
{
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_BOOL;
- smp->data.uint = !!l4->stkctr[kw[2] - '0'].entry;
+ smp->data.uint = !!stkctr_entry(&l4->stkctr[kw[2] - '0']);
return 1;
}
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_GPC0);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, gpc0);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_GPC0_RATE);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0_RATE);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate),
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
+ if (stkctr_entry(stkctr) != NULL) {
void *ptr;
/* First, update gpc0_rate if it's tracked. Second, update its
* gpc0 if tracked. Returns gpc0's value otherwise the curr_ctr.
*/
- ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_GPC0_RATE);
+ ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0_RATE);
if (ptr) {
update_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate),
stkctr->table->data_arg[STKTABLE_DT_GPC0_RATE].u, 1);
smp->data.uint = (&stktable_data_cast(ptr, gpc0_rate))->curr_ctr;
}
- ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_GPC0);
+ ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0);
if (ptr)
smp->data.uint = ++stktable_data_cast(ptr, gpc0);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_GPC0);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, gpc0);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_CONN_CNT);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_CONN_CNT);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, conn_cnt);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_CONN_RATE);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_CONN_RATE);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_CONN_CUR);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_CONN_CUR);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, conn_cur);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_SESS_CNT);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_SESS_CNT);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, sess_cnt);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_SESS_RATE);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_SESS_RATE);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_HTTP_REQ_CNT);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_REQ_CNT);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, http_req_cnt);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_HTTP_REQ_RATE);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_REQ_RATE);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_HTTP_ERR_CNT);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_ERR_CNT);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, http_err_cnt);
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_HTTP_ERR_RATE);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_ERR_RATE);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_BYTES_IN_CNT);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_IN_CNT);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_BYTES_IN_RATE);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_IN_RATE);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_BYTES_OUT_CNT);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_OUT_CNT);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
smp->data.uint = 0;
- if (stkctr->entry != NULL) {
- void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_BYTES_OUT_RATE);
+ if (stkctr_entry(stkctr) != NULL) {
+ void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_OUT_RATE);
if (!ptr)
return 0; /* parameter not stored */
smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
smp->flags = SMP_F_VOL_TEST;
smp->type = SMP_T_UINT;
- smp->data.uint = stkctr->entry->ref_cnt;
+ smp->data.uint = stkctr_entry(stkctr)->ref_cnt;
return 1;
}