Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mekhanik evgenii/1196 itog 2 #1973

Merged
merged 25 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e272f97
Update linux kernel patch
EvgeniiMekhanik Jan 5, 2024
720b460
Rework HTTP2 framing for further streams priority support
EvgeniiMekhanik Aug 9, 2023
f19b609
Rework RST STREAM sending and stream processing
EvgeniiMekhanik May 9, 2024
e79b8cb
Remove hpack table spin lock and guard
EvgeniiMekhanik Jan 8, 2024
5c2c799
Implement handling of HTTP2_PRIORITY frames for idle streams
EvgeniiMekhanik Jan 5, 2024
40561b8
Port ebtree to tempesta
EvgeniiMekhanik Sep 26, 2023
698c67d
Implement stream prioritization according RFC 7540
EvgeniiMekhanik Jan 8, 2024
8d1d28c
Implement "latency_optimized_write" option
EvgeniiMekhanik Aug 29, 2023
66acc7d
Several fixes.
EvgeniiMekhanik May 22, 2024
0e87fca
Fixes according review.
EvgeniiMekhanik May 24, 2024
8c07d7b
Codestyle fixes according review
EvgeniiMekhanik May 27, 2024
6cc37ed
Remove latency_optimized_write option
EvgeniiMekhanik May 27, 2024
29ed953
Rework applying new settings according review
EvgeniiMekhanik May 28, 2024
52030fa
Rework sending error response
EvgeniiMekhanik May 29, 2024
5217ce1
Add comments about our scheduler algorithm
EvgeniiMekhanik May 29, 2024
3ec643f
Rework send window calculation for making frames
EvgeniiMekhanik Jun 3, 2024
028567f
Move some http2 related logic to separate files
EvgeniiMekhanik Jun 3, 2024
5bb8bda
Add comments and codestyle fixes
EvgeniiMekhanik Jun 4, 2024
6d66631
Fix enomem in tls encryption
EvgeniiMekhanik Jun 4, 2024
36d4bc5
Rework and fix sending error response and TCP shutdown
EvgeniiMekhanik Jun 5, 2024
b84bf4b
Do not terminate connection in case of STREAM_FSM_RES_TERM_STREAM
EvgeniiMekhanik Jun 5, 2024
fd8769f
Fix according review
EvgeniiMekhanik Jun 17, 2024
10f01b9
Fix several perfomance issues in new framing
EvgeniiMekhanik Jun 18, 2024
d6b3e51
Fix after rebasing on master
EvgeniiMekhanik Jun 25, 2024
f355a6f
Fix `__extend_pgfrags` function.
EvgeniiMekhanik Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ DBG_WS ?= 0
DBG_APM ?= 0
DBG_GFSM ?= 0
DBG_HTTP ?= 0
DBG_HTTP2 ?= 0
DBG_HTTP_FRAME ?= 0
DBG_HTTP_SESS ?= 0
DBG_HTTP_STREAM ?= 0
Expand All @@ -89,6 +90,7 @@ TFW_CFLAGS += -DDBG_HTTP_SESS=$(DBG_HTTP_SESS)
TFW_CFLAGS += -DDBG_HTTP_STREAM=$(DBG_HTTP_STREAM)
TFW_CFLAGS += -DDBG_HPACK=$(DBG_HPACK) -DDBG_CACHE=$(DBG_CACHE)
TFW_CFLAGS += -DDBG_SRV=$(DBG_SRV) -DDBG_VHOST=$(DBG_VHOST) -DDBG_TEST=$(DBG_TEST)
TFW_CFLAGS += -DDBG_HTTP2=$(DBG_HTTP2)

# By default Tempesta TLS randomizes elliptic curve points using RDRAND
# instruction, which provides a high speed random numbers generator.
Expand Down
37 changes: 14 additions & 23 deletions fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,7 @@ tfw_cache_send_304(TfwHttpReq *req, TfwCacheEntry *ce)

resp->mit.start_off = FRAME_HEADER_SIZE;

r = tfw_h2_resp_status_write(resp, 304, false, true,
stream_id);
r = tfw_h2_resp_status_write(resp, 304, false, true);
if (unlikely(r))
goto err_setup;
/* account for :status field itself */
Expand Down Expand Up @@ -1060,7 +1059,7 @@ tfw_cache_send_304(TfwHttpReq *req, TfwCacheEntry *ce)
return;
}

if (tfw_h2_frame_local_resp(resp, stream_id, h_len, NULL))
if (tfw_h2_frame_local_resp(resp, h_len, NULL))
goto err_setup;

tfw_h2_req_unlink_stream(req);
Expand Down Expand Up @@ -2666,7 +2665,7 @@ tfw_cache_add_body_page(TfwMsgIter *it, char *p, int sz, bool h2,
*/
static int
tfw_cache_build_resp_body(TDB *db, TdbVRec *trec, TfwMsgIter *it, char *p,
unsigned long body_sz, bool h2, unsigned int stream_id)
unsigned long body_sz, bool h2)
{
int r;
bool sh_frag = h2 ? false : true;
Expand Down Expand Up @@ -2702,10 +2701,6 @@ tfw_cache_build_resp_body(TDB *db, TdbVRec *trec, TfwMsgIter *it, char *p,
!body_sz);
if (r)
return r;
if (stream_id) {
skb_set_tfw_flags(it->skb, SS_F_HTTT2_FRAME_DATA);
skb_set_tfw_cb(it->skb, stream_id);
}
}
if (!body_sz || !(trec = tdb_next_rec_chunk(db, trec)))
break;
Expand All @@ -2728,8 +2723,7 @@ tfw_cache_build_resp_body(TDB *db, TdbVRec *trec, TfwMsgIter *it, char *p,
}

static int
tfw_cache_set_hdr_age(TfwHttpResp *resp, TfwCacheEntry *ce,
unsigned int stream_id)
tfw_cache_set_hdr_age(TfwHttpResp *resp, TfwCacheEntry *ce)
{
int r;
size_t digs;
Expand Down Expand Up @@ -2760,8 +2754,7 @@ tfw_cache_set_hdr_age(TfwHttpResp *resp, TfwCacheEntry *ce,

if (to_h2) {
h_age.hpack_idx = 21;
if ((r = tfw_hpack_encode(resp, &h_age, false, false,
stream_id)))
if ((r = tfw_hpack_encode(resp, &h_age, false, false)))
goto err;
} else {
if ((r = tfw_http_msg_expand_data(&mit->iter, skb_head,
Expand Down Expand Up @@ -2803,8 +2796,7 @@ tfw_cache_set_hdr_age(TfwHttpResp *resp, TfwCacheEntry *ce,
* TODO use iterator and passed skbs to be called from net_tx_action.
*/
static TfwHttpResp *
tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long lifetime,
unsigned int stream_id)
tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long lifetime)
{
int h;
TfwStr dummy_body = { 0 };
Expand Down Expand Up @@ -2863,14 +2855,14 @@ tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long lifetime,
* Set 'set-cookie' header if needed, for HTTP/2 or HTTP/1.1
* response.
*/
if (tfw_http_sess_resp_process(resp, true, stream_id))
if (tfw_http_sess_resp_process(resp, true))
goto free;
/*
* RFC 7234 p.4 Constructing Responses from Caches:
* When a stored response is used to satisfy a request without
* validation, a cache MUST generate an Age header field.
*/
if (tfw_cache_set_hdr_age(resp, ce, stream_id))
if (tfw_cache_set_hdr_age(resp, ce))
goto free;

if (!TFW_MSG_H2(req)) {
Expand Down Expand Up @@ -2898,11 +2890,11 @@ tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long lifetime,
}

/* Set additional headers for HTTP/2 response. */
if (tfw_h2_resp_add_loc_hdrs(resp, h_mods, true, stream_id)
if (tfw_h2_resp_add_loc_hdrs(resp, h_mods, true)
|| (lifetime > ce->lifetime
&& tfw_h2_set_stale_warn(resp, stream_id))
&& tfw_h2_set_stale_warn(resp))
|| (!test_bit(TFW_HTTP_B_HDR_DATE, resp->flags)
&& tfw_h2_add_hdr_date(resp, true, stream_id)))
&& tfw_h2_add_hdr_date(resp, true)))
goto free;

h_len += mit->acc_len;
Expand All @@ -2923,7 +2915,7 @@ tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long lifetime,
* send content in the response.
*/
dummy_body.len = req->method != TFW_HTTP_METH_HEAD ? ce->body_len : 0;
if (tfw_h2_frame_local_resp(resp, stream_id, h_len, &dummy_body))
if (tfw_h2_frame_local_resp(resp, h_len, &dummy_body))
goto free;
it->skb = ss_skb_peek_tail(&it->skb_head);
it->frag = skb_shinfo(it->skb)->nr_frags - 1;
Expand All @@ -2933,7 +2925,7 @@ tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long lifetime,
BUG_ON(p != TDB_PTR(db->hdr, ce->body));
if (ce->body_len && req->method != TFW_HTTP_METH_HEAD) {
if (tfw_cache_build_resp_body(db, trec, it, p, ce->body_len,
TFW_MSG_H2(req), stream_id))
TFW_MSG_H2(req)))
goto free;
}
resp->content_length = ce->body_len;
Expand Down Expand Up @@ -2994,8 +2986,7 @@ cache_req_process_node(TfwHttpReq *req, tfw_http_cache_cb_t action)
}
}

resp = tfw_cache_build_resp(req, ce, lifetime, id);

resp = tfw_cache_build_resp(req, ce, lifetime);
/*
* The stream of HTTP/2-request should be closed here since we have
* successfully created the resulting response from cache and will
Expand Down
6 changes: 3 additions & 3 deletions fw/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "gfsm.h"
#include "peer.h"
#include "sync_socket.h"
#include "http_frame.h"
#include "http2.h"
#include "tls.h"

/* We account users with FRANG_FREQ frequency per second. */
Expand Down Expand Up @@ -292,7 +292,7 @@ typedef struct {
*/
#define tfw_h2_context_unsafe(conn) ((TfwH2Ctx *)(&((TfwH2Conn *)conn)->h2))
#define tfw_h2_context_safe(conn) \
ttls_hs_done(tfw_tls_context(conn)) ? tfw_h2_context_unsafe(conn) : NULL;
ttls_hs_done(tfw_tls_context(conn)) ? tfw_h2_context_unsafe(conn) : NULL


/* Callbacks used by l5-l7 protocols to operate on connection level. */
Expand Down Expand Up @@ -548,8 +548,8 @@ tfw_connection_unlink_from_sk(struct sock *sk)

sk->sk_data_ready = NULL;
sk->sk_state_change = NULL;
sk->sk_prepare_xmit = NULL;
sk->sk_write_xmit = NULL;
sk->sk_fill_write_queue = NULL;
sk->sk_destroy_cb = NULL;

sk->sk_user_data = NULL;
Expand Down
Loading