Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8deb2ff
Implement new config option `client_mem`.
EvgeniiMekhanik Jun 14, 2025
2c8adfb
Codestyle fixes
EvgeniiMekhanik Jun 21, 2025
da9ac44
Change API of some functions.
EvgeniiMekhanik Jun 24, 2025
862ae93
Adjust memory used by Tempesta FW.
EvgeniiMekhanik Jun 29, 2025
c7e0f33
Adjust memory used by Tempesta FW.
EvgeniiMekhanik Jul 1, 2025
69b7d3d
Drop connetion with TCP RST if client mem is exceeded
EvgeniiMekhanik Jul 8, 2025
3c0bbd9
Inplement TfwClient refcounting for memory adjustment
EvgeniiMekhanik Jul 9, 2025
81393fb
Adjust tcp send window for all sending data.
EvgeniiMekhanik Oct 28, 2025
a28fba4
Fix accroding review and after rebase
EvgeniiMekhanik Nov 19, 2025
f1b3673
TMP (need merge)
EvgeniiMekhanik Nov 20, 2025
b167937
Fix according review
EvgeniiMekhanik Dec 11, 2025
e55cb39
TMP (NEED MERGE)
EvgeniiMekhanik Dec 22, 2025
18f5ba2
Fix accroding review
EvgeniiMekhanik Jan 13, 2026
af5951c
Fix according review
EvgeniiMekhanik Jan 14, 2026
63f6e79
Remove extra connections callbacks
EvgeniiMekhanik Jan 26, 2026
33732de
Adjust http level memory.
EvgeniiMekhanik Jan 28, 2026
e6ebe87
Use per cpu counter instead of atomic
EvgeniiMekhanik Feb 4, 2026
22ce552
Change using `skb_shift` to `skb_try_coalesce` back.
EvgeniiMekhanik Feb 4, 2026
a3ad176
Fix removing still used clients.
EvgeniiMekhanik Mar 4, 2026
efd5c1a
Improve performance and make fixes
EvgeniiMekhanik Mar 18, 2026
3073ec4
Last fixes.
EvgeniiMekhanik Apr 2, 2026
176f020
Fix aacording review
EvgeniiMekhanik Apr 4, 2026
2ef5e01
Fix according review
EvgeniiMekhanik Apr 15, 2026
916df02
Implement client mem allocation optimization
EvgeniiMekhanik Apr 10, 2026
ca2049a
Fix BUG in case of allocation fail.
EvgeniiMekhanik Apr 13, 2026
b6e5da2
Rework error code library.
EvgeniiMekhanik Apr 16, 2026
1a3bfb2
Improve performance during checking client memory
EvgeniiMekhanik Apr 16, 2026
0ff3939
Update copyright years
EvgeniiMekhanik Apr 16, 2026
349cbaf
Last fixed
EvgeniiMekhanik Apr 16, 2026
4c6d0e0
Fix according review
EvgeniiMekhanik Apr 22, 2026
49417b4
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