Skip to content

Commit

Permalink
Fixup after PR discussions
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksey Mikhaylov <aym@tempesta-tech.com>
  • Loading branch information
ttaym committed Apr 27, 2022
1 parent 406a052 commit 4057450
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
40 changes: 20 additions & 20 deletions fw/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,15 +1174,17 @@ tfw_http_conn_nip_adjust(TfwSrvConn *srv_conn)

/*
* Tell if the server connection's forwarding queue is on hold.
* It's on hold if the request that was sent last was non-idempotent.
* It's on hold if the request that was sent last was non-idempotent or
* if connection marked as unscheduled (in case of protocol upgrade).
*/
static inline bool
tfw_http_conn_on_hold(TfwSrvConn *srv_conn)
{
TfwHttpReq *req_sent = (TfwHttpReq *)srv_conn->msg_sent;

BUG_ON(!(TFW_CONN_TYPE(srv_conn) & Conn_Srv));
return (req_sent && tfw_http_req_is_nip(req_sent));
return ((req_sent && tfw_http_req_is_nip(req_sent))
|| test_bit(TFW_CONN_B_UNSCHED, &srv_conn->flags));
}

/*
Expand Down Expand Up @@ -5108,6 +5110,9 @@ tfw_http_req_mark_nip(TfwHttpReq *req)
goto nip_match;
}

if (test_bit(TFW_HTTP_B_UPGRADE_WEBSOCKET, req->flags))
goto nip_match;

if (safe_methods & (1 << req->method))
return;

Expand Down Expand Up @@ -5816,9 +5821,10 @@ tfw_http_resp_gfsm(TfwHttpMsg *hmresp, TfwFsmData *data)
* get the paired request, and then pass the response to cache
* for further processing.
*/
static void
static int
tfw_http_resp_cache(TfwHttpMsg *hmresp)
{
int r;
TfwHttpResp *resp = (TfwHttpResp *)hmresp;
TfwHttpReq *req = hmresp->req;
TfwFsmData data;
Expand Down Expand Up @@ -5857,7 +5863,7 @@ tfw_http_resp_cache(TfwHttpMsg *hmresp)
*/
if (test_bit(TFW_HTTP_B_HMONITOR, req->flags)) {
tfw_http_hm_drop_resp((TfwHttpResp *)hmresp);
return;
return TFW_BLOCK;
}
/*
* This hook isn't in tfw_http_resp_fwd() because responses from the
Expand All @@ -5870,7 +5876,7 @@ tfw_http_resp_cache(TfwHttpMsg *hmresp)
/* 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;
return TFW_BLOCK;
}

/*
Expand All @@ -5880,14 +5886,17 @@ tfw_http_resp_cache(TfwHttpMsg *hmresp)
* will be put in a new message.
*/
tfw_stream_unlink_msg(hmresp->stream);
if (tfw_cache_process(hmresp, tfw_http_resp_cache_cb))
if ((r = tfw_cache_process(hmresp, tfw_http_resp_cache_cb)))
{
tfw_http_conn_msg_free(hmresp);
tfw_http_send_resp(req, 500, "response dropped:"
" processing error");
TFW_INC_STAT_BH(serv.msgs_otherr);
/* Proceed with processing of the next response. */
return r;
}

return TFW_PASS;
}

/*
Expand Down Expand Up @@ -6175,7 +6184,9 @@ tfw_http_resp_process(TfwConn *conn, TfwStream *stream, struct sk_buff *skb)
* In the end, the response is sent on to the client.
* @hmsib is not attached to the connection yet.
*/
tfw_http_resp_cache(hmresp);
r = tfw_http_resp_cache(hmresp);
if (unlikely(r < TFW_PASS))
return TFW_BLOCK;

/* Do upgrade if correct websocket upgrade response detected earlier */
if (websocket) {
Expand Down Expand Up @@ -6235,7 +6246,6 @@ tfw_http_msg_process_generic(TfwConn *conn, TfwStream *stream,
{
int r;
TfwHttpMsg *req;
bool websocket = false;

if (WARN_ON_ONCE(!stream))
return -EINVAL;
Expand All @@ -6258,9 +6268,10 @@ tfw_http_msg_process_generic(TfwConn *conn, TfwStream *stream,

/* That is paired request, it may be freed after resp processing */
req = ((TfwHttpMsg *)stream->msg)->pair;
websocket = test_bit(TFW_HTTP_B_UPGRADE_WEBSOCKET, req->flags);
if ((r = tfw_http_resp_process(conn, stream, skb))) {
TfwSrvConn *srv_conn = (TfwSrvConn *)conn;
bool websocket = test_bit(TFW_HTTP_B_UPGRADE_WEBSOCKET,
req->flags);
/*
* We must clear TFW_CONN_B_UNSCHED to make server connection
* available for request scheduling further if websocket upgrade
Expand Down Expand Up @@ -7035,17 +7046,6 @@ TfwMod tfw_http_mod = {
.specs = tfw_http_specs,
};

// /*
// * We do not use http fsm for message processing any more, but only for
// * frang checks, so to clearly show our intention we BUG() here.
// */
// static int
// tfw_http_msg_process_fsm(TfwConn *conn, TfwFsmData *data)
// {
// BUG();
// return 0;
// }

/*
* ------------------------------------------------------------------------
* init/exit
Expand Down
14 changes: 7 additions & 7 deletions fw/http_sched_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,6 @@ tfw_sched_hash_add_grp(TfwSrvGroup *sg, void *data)
return 0;
}

static void
tfw_sched_hash_put_srv_data(struct rcu_head *rcu)
{
TfwHashConnList *cl = container_of(rcu, TfwHashConnList, rcu);
kfree(cl);
}

static int
tfw_sched_hash_add_srv(TfwServer *srv)
{
Expand All @@ -425,6 +418,13 @@ tfw_sched_hash_add_srv(TfwServer *srv)
return 0;
}

static void
tfw_sched_hash_put_srv_data(struct rcu_head *rcu)
{
TfwHashConnList *cl = container_of(rcu, TfwHashConnList, rcu);
kfree(cl);
}

static void
tfw_sched_hash_del_srv(TfwServer *srv)
{
Expand Down
4 changes: 2 additions & 2 deletions fw/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ tfw_ws_conn_alloc(void)
{
TfwConn *conn;

T_DBG2("%s: conn=[%p]\n", __func__, conn);

if (!(conn = kmem_cache_alloc(tfw_ws_conn_cache, GFP_ATOMIC)))
return NULL;

T_DBG2("%s: conn=[%p]\n", __func__, conn);

tfw_connection_init(conn);

ss_proto_init(&conn->proto, &tfw_ws_srv_ss_hooks, Conn_WsSrv);
Expand Down

0 comments on commit 4057450

Please sign in to comment.