Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1ca04af
Implement new config option `client_mem`.
EvgeniiMekhanik Jun 14, 2025
38ca553
Codestyle fixes
EvgeniiMekhanik Jun 21, 2025
352bcbd
Adjust frame size during `snd_wnd` calculation
EvgeniiMekhanik Apr 28, 2026
bbe69f9
Change API of some functions.
EvgeniiMekhanik Jun 24, 2025
694b98b
Adjust memory used by Tempesta FW.
EvgeniiMekhanik Jun 29, 2025
bdc2989
Adjust memory used by Tempesta FW.
EvgeniiMekhanik Jul 1, 2025
40d2bb9
Drop connetion with TCP RST if client mem is exceeded
EvgeniiMekhanik Jul 8, 2025
aa6bf4a
Inplement TfwClient refcounting for memory adjustment
EvgeniiMekhanik Jul 9, 2025
2690d99
Adjust tcp send window for all sending data.
EvgeniiMekhanik Oct 28, 2025
a99aa75
Fix accroding review and after rebase
EvgeniiMekhanik Nov 19, 2025
12750ef
Fix according review
EvgeniiMekhanik Jan 14, 2026
6f69c6f
Remove extra connections callbacks
EvgeniiMekhanik Jan 26, 2026
2cf38e9
Adjust http level memory.
EvgeniiMekhanik Jan 28, 2026
85bc711
Use per cpu counter instead of atomic
EvgeniiMekhanik Feb 4, 2026
b58139a
Fix removing still used clients.
EvgeniiMekhanik Mar 4, 2026
9d59d32
Improve performance and make fixes
EvgeniiMekhanik Mar 18, 2026
6f59e49
Fix according review
EvgeniiMekhanik Apr 15, 2026
b29c89e
Implement client mem allocation optimization
EvgeniiMekhanik Apr 10, 2026
6bc6875
Fix BUG in case of allocation fail.
EvgeniiMekhanik Apr 13, 2026
5674a34
Rework error code library.
EvgeniiMekhanik Apr 16, 2026
c07d573
Improve performance during checking client memory
EvgeniiMekhanik Apr 16, 2026
d6a3271
Update copyright years
EvgeniiMekhanik Apr 16, 2026
1273899
Adjust coding style and add a minor comment
krizhanovsky Apr 25, 2026
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
12 changes: 9 additions & 3 deletions db/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,17 @@ tdb_rec_get_alloc(TDB *db, unsigned long key, TdbGetAllocCtx *ctx)
}
ctx->is_new = true;
r = tdb_entry_alloc(db, key, &ctx->len);
if (!r) {
if (unlikely(!r)) {
spin_unlock(&db->ga_lock);
return r;
return NULL;
}
if (unlikely(ctx->init_rec(r, ctx->ctx))) {
tdb_rec_put(db, r);
tdb_entry_remove(db, key, NULL, NULL, true);
spin_unlock(&db->ga_lock);
return NULL;
}
ctx->init_rec(r, ctx->ctx);

tdb_entry_mark_complete(r);

spin_unlock(&db->ga_lock);
Expand Down
2 changes: 1 addition & 1 deletion db/core/tdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ typedef struct {
typedef struct {
bool (*eq_rec)(TdbRec *rec, void *ctx);
int (*precreate_rec)(void *ctx);
void (*init_rec)(TdbRec *rec, void *ctx);
int (*init_rec)(TdbRec *rec, void *ctx);
void *ctx;
size_t len;
bool is_new;
Expand Down
6 changes: 3 additions & 3 deletions fw/apm.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Tempesta FW
*
* Copyright (C) 2016-2025 Tempesta Technologies, Inc.
* Copyright (C) 2016-2026 Tempesta Technologies, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1659,8 +1659,8 @@ tfw_cfgop_apm_add_hm_req(const char *req_cstr, TfwApmHM *hm_entry)
unsigned long size;

size = strlen(req_cstr);
hm_entry->req = (char *)__get_free_pages(GFP_KERNEL,
get_order(size));
hm_entry->req = (char *)tfw__get_free_pages(GFP_KERNEL,
get_order(size));
if (!hm_entry->req) {
T_ERR_NL("Can't allocate memory for health monitoring request"
"\n");
Expand Down
45 changes: 26 additions & 19 deletions fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* HTTP cache (RFC 7234).
*
* Copyright (C) 2014 NatSys Lab. (info@natsys-lab.com).
* Copyright (C) 2015-2025 Tempesta Technologies, Inc.
* Copyright (C) 2015-2026 Tempesta Technologies, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -812,14 +812,14 @@ tfw_cache_h2_write(TDB *db, TdbVRec **trec, TfwHttpResp *resp, char **data,
TfwStr c = { 0 };
TdbVRec *tr = *trec;
TfwHttpTransIter *mit = &resp->mit;
TfwMsgIter *it = &resp->iter;
int r = 0, copied = 0;

while (1) {
c.data = *data;
c.len = min(tr->data + tr->len - *data, (long)(len - copied));
if (!dc_iter->skip) {
r = tfw_http_msg_expand_data(it, &resp->msg.skb_head,
r = tfw_http_msg_expand_data((TfwHttpMsg *)resp,
&resp->msg.skb_head,
&c, &mit->start_off);
if (unlikely(r))
break;
Expand Down Expand Up @@ -887,11 +887,10 @@ static int
tfw_cache_set_status(TDB *db, TfwCacheEntry *ce, TfwHttpResp *resp,
TdbVRec **trec, char **p, unsigned long *acc_len)
{
int r;
TfwMsgIter *it = &resp->iter;
struct sk_buff **skb_head = &resp->msg.skb_head;
bool h2_mode = TFW_MSG_H2(resp->req);
TfwDecodeCacheIter dc_iter = {};
int r;

if (h2_mode)
resp->mit.start_off = FRAME_HEADER_SIZE;
Expand Down Expand Up @@ -920,7 +919,8 @@ tfw_cache_set_status(TDB *db, TfwCacheEntry *ce, TfwHttpResp *resp,
H2_STAT_VAL_LEN))
return -E2BIG;

r = tfw_http_msg_expand_data(it, skb_head, &s_line, NULL);
r = tfw_http_msg_expand_data((TfwHttpMsg *)resp, skb_head,
&s_line, NULL);
if (unlikely(r))
return r;

Expand All @@ -936,7 +936,8 @@ tfw_cache_set_status(TDB *db, TfwCacheEntry *ce, TfwHttpResp *resp,
*acc_len += dc_iter.acc_len;

if (!h2_mode) {
r = tfw_http_msg_expand_data(it, skb_head, &g_crlf, NULL);
r = tfw_http_msg_expand_data((TfwHttpMsg *)resp, skb_head,
&g_crlf, NULL);
if (unlikely(r))
return r;

Expand Down Expand Up @@ -1095,6 +1096,7 @@ tfw_cache_send_304(TfwHttpReq *req, TfwCacheEntry *ce)
int r, i;
TfwMsgIter *it;
TfwHttpResp *resp;
TfwHttpMsg *hm;
struct sk_buff **skb_head;
unsigned long h_len = 0;
TdbVRec *trec = &ce->trec;
Expand All @@ -1106,11 +1108,12 @@ tfw_cache_send_304(TfwHttpReq *req, TfwCacheEntry *ce)
if (!(resp = tfw_http_msg_alloc_resp_light(req)))
goto err_create;

hm = (TfwHttpMsg *)resp;
it = &resp->iter;
skb_head = &resp->msg.skb_head;

if (!TFW_MSG_H2(req)) {
r = tfw_http_prep_304(req, skb_head, it);
r = tfw_http_prep_304(req, skb_head, hm);
if (unlikely(r))
goto err_setup;
} else {
Expand Down Expand Up @@ -1149,7 +1152,7 @@ tfw_cache_send_304(TfwHttpReq *req, TfwCacheEntry *ce)
}

if (!TFW_MSG_H2(req)) {
if (tfw_http_msg_expand_data(it, skb_head, &g_crlf, NULL))
if (tfw_http_msg_expand_data(hm, skb_head, &g_crlf, NULL))
goto err_setup;

tfw_http_resp_fwd(resp);
Expand All @@ -1166,7 +1169,7 @@ tfw_cache_send_304(TfwHttpReq *req, TfwCacheEntry *ce)
return;
err_setup:
T_WARN("Can't build 304 response, key=%lx\n", ce->key);
tfw_http_msg_free((TfwHttpMsg *)resp);
tfw_http_msg_free(hm);
err_create:
tfw_http_resp_build_error(req);
}
Expand Down Expand Up @@ -2817,6 +2820,8 @@ tfw_cache_add_body_page(TfwMsgIter *it, char *p, int sz, bool h2)
if (!h2)
skb_frag_ref(it->skb, it->frag);
ss_skb_adjust_data_len(it->skb, sz);
if (!h2)
ss_skb_adjust_client_mem(it->skb, -sz);

return 0;
}
Expand Down Expand Up @@ -2901,7 +2906,7 @@ tfw_cache_build_resp_body(TDB *db, TdbVRec *trec, TfwHttpResp *resp, char *p,
|| (sh_frag && tfw_cache_should_append_body_skb(it, body_sz,
chunked_body)))
{
if ((r = tfw_msg_iter_append_skb(it)))
if ((r = tfw_http_msg_append_skb((TfwHttpMsg *)resp)))
return r;
}
if (sh_frag)
Expand Down Expand Up @@ -2935,7 +2940,7 @@ tfw_cache_build_resp_body(TDB *db, TdbVRec *trec, TfwHttpResp *resp, char *p,
__TFW_STR_CH(&b_len, 0)->len = digs;
b_len.len += digs;

r = tfw_http_msg_expand_data(it, &it->skb_head,
r = tfw_http_msg_expand_data((TfwHttpMsg *)resp, &it->skb_head,
&b_len, NULL);
if (unlikely(r))
return r;
Expand Down Expand Up @@ -2965,7 +2970,7 @@ tfw_cache_build_resp_body(TDB *db, TdbVRec *trec, TfwHttpResp *resp, char *p,
p = trec->data;

if (it->frag + 1 == MAX_SKB_FRAGS
&& (r = tfw_msg_iter_append_skb(it)))
&& (r = tfw_http_msg_append_skb((TfwHttpMsg *)resp)))
{
return r;
}
Expand All @@ -2977,13 +2982,13 @@ tfw_cache_build_resp_body(TDB *db, TdbVRec *trec, TfwHttpResp *resp, char *p,
.len = SLEN(S_ZERO S_CRLF)
};

r = tfw_http_msg_expand_data(it, &it->skb_head,
r = tfw_http_msg_expand_data((TfwHttpMsg *)resp, &it->skb_head,
&g_crlf, NULL);
if (unlikely(r))
return r;

add_zero_chunk:
r = tfw_http_msg_expand_data(it, &it->skb_head,
r = tfw_http_msg_expand_data((TfwHttpMsg *)resp, &it->skb_head,
&b_len, NULL);
if (unlikely(r))
return r;
Expand Down Expand Up @@ -3027,11 +3032,11 @@ tfw_cache_set_hdr_age(TfwHttpResp *resp, TfwCacheEntry *ce, long age)
if ((r = tfw_hpack_encode(resp, &h_age, false, false)))
goto err;
} else {
if ((r = tfw_http_msg_expand_data(&resp->iter, skb_head,
if ((r = tfw_http_msg_expand_data((TfwHttpMsg *)resp, skb_head,
&h_age, NULL)))
goto err;

if ((r = tfw_http_msg_expand_data(&resp->iter, skb_head,
if ((r = tfw_http_msg_expand_data((TfwHttpMsg *)resp, skb_head,
&g_crlf, NULL)))
goto err;
}
Expand Down Expand Up @@ -3160,7 +3165,8 @@ tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long age)
&& tfw_http_expand_stale_warn(resp))
|| (!test_bit(TFW_HTTP_B_HDR_DATE, resp->flags)
&& tfw_http_expand_hdr_date(resp))
|| tfw_http_msg_expand_data(it, skb_head, &g_crlf, NULL))
|| tfw_http_msg_expand_data((TfwHttpMsg *)resp, skb_head,
&g_crlf, NULL))
{
goto free;
}
Expand Down Expand Up @@ -3238,7 +3244,8 @@ tfw_cache_build_resp(TfwHttpReq *req, TfwCacheEntry *ce, long age)
* trailer or chunked body.
*/
if (chunked_body && req->method != TFW_HTTP_METH_HEAD
&& tfw_http_msg_expand_data(it, skb_head, &g_crlf, NULL))
&& tfw_http_msg_expand_data((TfwHttpMsg *)resp, skb_head,
&g_crlf, NULL))
goto free;

return resp;
Expand Down
Loading