MINOR: tcp-rules: check that the listener exists before updating its counters

The tcp rules may be applied to a TCP stream initiated by applets (spoe,
lua, peers, later H2). These ones do not necessarily have a valid listener
so we must verify the field is not null before updating the stats. For now
there's no way to trigger this bug because lua and peers don't have analysers,
h2 is not implemented and spoe has a dummy listener. But this threatens to
break at any instant.
This commit is contained in:
Willy Tarreau 2016-12-22 18:14:41 +01:00
parent 0ff98a4758
commit a12dde04e0

View File

@ -168,7 +168,7 @@ resume_execution:
s->be->be_counters.denied_req++; s->be->be_counters.denied_req++;
sess->fe->fe_counters.denied_req++; sess->fe->fe_counters.denied_req++;
if (sess->listener->counters) if (sess->listener && sess->listener->counters)
sess->listener->counters->denied_req++; sess->listener->counters->denied_req++;
if (!(s->flags & SF_ERR_MASK)) if (!(s->flags & SF_ERR_MASK))
@ -346,7 +346,7 @@ resume_execution:
s->be->be_counters.denied_resp++; s->be->be_counters.denied_resp++;
sess->fe->fe_counters.denied_resp++; sess->fe->fe_counters.denied_resp++;
if (sess->listener->counters) if (sess->listener && sess->listener->counters)
sess->listener->counters->denied_resp++; sess->listener->counters->denied_resp++;
if (!(s->flags & SF_ERR_MASK)) if (!(s->flags & SF_ERR_MASK))
@ -428,7 +428,7 @@ int tcp_exec_l4_rules(struct session *sess)
} }
else if (rule->action == ACT_ACTION_DENY) { else if (rule->action == ACT_ACTION_DENY) {
sess->fe->fe_counters.denied_conn++; sess->fe->fe_counters.denied_conn++;
if (sess->listener->counters) if (sess->listener && sess->listener->counters)
sess->listener->counters->denied_conn++; sess->listener->counters->denied_conn++;
result = 0; result = 0;
@ -515,7 +515,7 @@ int tcp_exec_l5_rules(struct session *sess)
} }
else if (rule->action == ACT_ACTION_DENY) { else if (rule->action == ACT_ACTION_DENY) {
sess->fe->fe_counters.denied_sess++; sess->fe->fe_counters.denied_sess++;
if (sess->listener->counters) if (sess->listener && sess->listener->counters)
sess->listener->counters->denied_sess++; sess->listener->counters->denied_sess++;
result = 0; result = 0;