Skip to content

Commit

Permalink
Merge pull request #1449 from tempesta-tech/avb-1441
Browse files Browse the repository at this point in the history
Handling the return code of tfw_gfsm_move()
  • Loading branch information
avbelov23 authored Sep 11, 2020
2 parents a833215 + e3296bf commit 4069f60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 10 additions & 5 deletions tempesta_fw/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -5542,8 +5542,8 @@ tfw_http_resp_gfsm(TfwHttpMsg *hmresp, TfwFsmData *data)

error:
tfw_http_popreq(hmresp, false);
tfw_http_conn_msg_free(hmresp);
tfw_http_req_block(req, 502, "response blocked: filtered out");
/* The response is freed by tfw_http_req_block(). */
tfw_http_req_block(req, 403, "response blocked: filtered out");
TFW_INC_STAT_BH(serv.msgs_filtout);
return r;
}
Expand Down Expand Up @@ -5603,7 +5603,12 @@ tfw_http_resp_cache(TfwHttpMsg *hmresp)
data.skb = NULL;
data.req = (TfwMsg *)req;
data.resp = (TfwMsg *)hmresp;
tfw_gfsm_move(&hmresp->conn->state, TFW_HTTP_FSM_RESP_MSG_FWD, &data);
if (tfw_gfsm_move(&hmresp->conn->state, TFW_HTTP_FSM_RESP_MSG_FWD, &data)) {
/* The response is freed by tfw_http_req_block(). */
tfw_http_req_block(req, 403, "response blocked: filtered out");
TFW_INC_STAT_BH(serv.msgs_filtout);
return;
}

/*
* Complete HTTP message has been collected and processed
Expand Down Expand Up @@ -5648,7 +5653,7 @@ tfw_http_resp_terminate(TfwHttpMsg *hm)
TfwHttpReq *req = hm->req;

tfw_http_popreq(hm, false);
tfw_http_conn_msg_free(hm);
/* The response is freed by tfw_http_req_block(). */
tfw_http_req_block(req, 502, "response blocked: filtered out");
TFW_INC_STAT_BH(serv.msgs_filtout);
return;
Expand Down Expand Up @@ -5885,7 +5890,7 @@ tfw_http_resp_process(TfwConn *conn, TfwStream *stream, const TfwFsmData *data)
*/
bad_req = hmresp->req;
tfw_http_popreq(hmresp, false);
tfw_http_conn_msg_free(hmresp);
/* The response is freed by tfw_http_req_block/drop(). */
if (filtout)
tfw_http_req_block(bad_req, 502,
"response blocked: filtered out");
Expand Down
3 changes: 1 addition & 2 deletions tempesta_fw/http_limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,12 +1270,11 @@ frang_resp_fwd_process(TfwHttpResp *resp)
FrangGlobCfg *fg_cfg = req->vhost->vhost_dflt
? req->vhost->vhost_dflt->frang_gconf
: req->vhost->frang_gconf;
tfw_cli_conn_close_all_sync((TfwClient *)req->conn->peer);
if (fg_cfg->ip_block)
tfw_filter_block_ip(&FRANG_ACC2CLI(ra)->addr);
}

return TFW_PASS;
return r;
}

static int
Expand Down

0 comments on commit 4069f60

Please sign in to comment.