Skip to content

Commit 81c53ff

Browse files
committed
Deleted unsed functions and structures
1 parent e2828f2 commit 81c53ff

File tree

9 files changed

+19
-468
lines changed

9 files changed

+19
-468
lines changed

fw/hpack.c

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,25 +3538,6 @@ tfw_huffman_encode_string(TfwStr *str, TfwPool *pool)
35383538
return r ? ERR_PTR(r) : encoded;
35393539
}
35403540

3541-
static int
3542-
tfw_hpack_str_add_raw(TfwHttpTransIter *mit, TfwStr *str, bool in_huffman)
3543-
{
3544-
int r = 0;
3545-
TfwHPackInt len;
3546-
TfwStr len_str = { 0 };
3547-
unsigned short mask = in_huffman ? 0x80 : 0x0;
3548-
3549-
write_int(str->len, 0x7F, mask, &len);
3550-
len_str.data = len.buf;
3551-
len_str.len = len.sz;
3552-
3553-
r = tfw_h2_msg_rewrite_data(mit, &len_str, mit->bnd);
3554-
if (unlikely(r))
3555-
return r;
3556-
3557-
return tfw_h2_msg_rewrite_data(mit, str, mit->bnd);
3558-
}
3559-
35603541
static int
35613542
tfw_hpack_str_expand_raw(TfwHttpTransIter *mit, TfwMsgIter *it,
35623543
struct sk_buff **skb_head, TfwStr *str,
@@ -3605,22 +3586,6 @@ tfw_hpack_str_expand_raw(TfwHttpTransIter *mit, TfwMsgIter *it,
36053586
* headers (e.g. in cases of HTTP/1.1=>HTTP/2 or HTTP/2=>HTTP/2 response proxy),
36063587
* thus avoiding Huffman encodings is completely RFC-compliant behaviour.
36073588
*/
3608-
static inline int
3609-
tfw_hpack_str_add(TfwHttpTransIter *mit, TfwStr *str, TfwPool *pool)
3610-
{
3611-
bool in_huffman = false;
3612-
3613-
if (0) {
3614-
str = tfw_huffman_encode_string(str, pool);
3615-
3616-
if (IS_ERR(str))
3617-
return PTR_ERR(str);
3618-
in_huffman = true;
3619-
}
3620-
3621-
return tfw_hpack_str_add_raw(mit, str, in_huffman);
3622-
}
3623-
36243589
static inline int
36253590
tfw_hpack_str_expand(TfwHttpTransIter *mit, TfwMsgIter *it,
36263591
struct sk_buff **skb_head, TfwStr *str,
@@ -3685,7 +3650,8 @@ tfw_hpack_hdr_add(TfwHttpResp *__restrict resp, TfwStr *__restrict hdr,
36853650
if (WARN_ON_ONCE(TFW_STR_PLAIN(hdr) || TFW_STR_DUP(hdr)))
36863651
return -EINVAL;
36873652

3688-
tfw_http_hdr_split(hdr, &s_name, &s_val, trans);
3653+
if (!tfw_http_hdr_split(hdr, &s_name, &s_val, trans))
3654+
return -EINVAL;
36893655

36903656
if (unlikely(!name_indexed)) {
36913657
TfwHPackInt nlen;

fw/hpack.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ typedef struct {
115115
TFW_HPACK_ETBL_COMMON;
116116
} TfwHPackETblIter;
117117

118-
typedef enum {
119-
TFW_H2_TRANS_INPLACE = 0,
120-
TFW_H2_TRANS_ADD,
121-
TFW_H2_TRANS_EXPAND,
122-
} TfwH2TransOp;
123-
124118
typedef enum {
125119
TFW_TAG_HDR_H2_STATUS,
126120
TFW_TAG_HDR_H2_METHOD,

fw/http.c

Lines changed: 5 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ tfw_h2_prep_resp(TfwHttpResp *resp, unsigned short status, TfwStr *msg,
633633
__TFW_STR_CH(&hdr, 1)->len;
634634
hdr.hpack_idx = name->hpack_idx;
635635

636-
if ((r = tfw_hpack_encode(resp, &hdr,
637-
false, true)))
636+
if ((r = tfw_hpack_encode(resp, &hdr, false, true)))
638637
return r;
639638
}
640639
}
@@ -4700,162 +4699,6 @@ tfw_h2_hpack_encode_headers(TfwHttpResp *resp, const TfwHdrMods *h_mods)
47004699
return 0;
47014700
}
47024701

4703-
/*
4704-
* Get next header from the @mit->map. Procedure designed to be called from the
4705-
* outer cycle with changing of @mit iterator (including @mit->curr index of
4706-
* current header in the indirection map). Note, for optimization purposes, on
4707-
* each iteration function produces the boundary pointer @mit->bnd for current
4708-
* iteration and the operation instance @mit->next - for the next iteration
4709-
* (including source header @mit->next.s_hdr).
4710-
*
4711-
* TODO #1103: This function should be treated as a foundation for #1103 issue.
4712-
*/
4713-
static int
4714-
tfw_h2_resp_next_hdr(TfwHttpResp *resp, const TfwHdrMods *h_mods)
4715-
{
4716-
int r;
4717-
unsigned int i;
4718-
TfwHttpTransIter *mit = &resp->mit;
4719-
TfwHttpHdrMap *map = mit->map;
4720-
TfwNextHdrOp *next = &mit->next;
4721-
TfwHttpHdrTbl *ht = resp->h_tbl;
4722-
4723-
mit->bnd = NULL;
4724-
4725-
for (i = mit->curr; i < map->count; ++i) {
4726-
int k;
4727-
TfwStr *first;
4728-
unsigned short hid = map->index[i].idx;
4729-
unsigned short d_num = map->index[i].d_idx;
4730-
TfwStr *tgt = &ht->tbl[hid];
4731-
TfwHdrModsDesc *f_desc = NULL;
4732-
const TfwStr *val;
4733-
4734-
if (TFW_STR_DUP(tgt))
4735-
tgt = TFW_STR_CHUNK(tgt, d_num);
4736-
4737-
first = TFW_STR_CHUNK(tgt, 0);
4738-
4739-
if (WARN_ON_ONCE(!tgt
4740-
|| TFW_STR_EMPTY(tgt)
4741-
|| TFW_STR_DUP(tgt)))
4742-
return -EINVAL;
4743-
4744-
T_DBG3("%s: hid=%hu, d_num=%hu, nchunks=%u, h_mods->sz=%lu\n",
4745-
__func__, hid, d_num, ht->tbl[hid].nchunks,
4746-
h_mods ? h_mods->sz : 0);
4747-
4748-
if (!h_mods)
4749-
goto def;
4750-
4751-
for (k = 0; k < h_mods->sz; ++k) {
4752-
TfwHdrModsDesc *desc = &h_mods->hdrs[k];
4753-
4754-
if ((hid < TFW_HTTP_HDR_RAW && hid == desc->hid)
4755-
|| (hid >= TFW_HTTP_HDR_RAW
4756-
&& !__hdr_name_cmp(tgt, desc->hdr)))
4757-
{
4758-
f_desc = desc;
4759-
break;
4760-
}
4761-
}
4762-
if (!f_desc)
4763-
goto def;
4764-
4765-
val = TFW_STR_CHUNK(f_desc->hdr, 2);
4766-
/*
4767-
* If this is a duplicate of already processed header,
4768-
* leave this duplicate as is (for transformation
4769-
* in-place) in case of appending operation, and remove
4770-
* it (by skipping) in case of substitution or deletion
4771-
* operations.
4772-
*/
4773-
if (test_bit(k, mit->found)) {
4774-
if (!val || !f_desc->append)
4775-
continue;
4776-
4777-
mit->bnd = first->data;
4778-
next->s_hdr = *tgt;
4779-
next->op = TFW_H2_TRANS_INPLACE;
4780-
4781-
break;
4782-
}
4783-
4784-
__set_bit(k, mit->found);
4785-
4786-
/*
4787-
* If header configured with empty value, it should be
4788-
* removed from the response; so, just skip such header.
4789-
*/
4790-
if (!val)
4791-
continue;
4792-
4793-
mit->bnd = first->data;
4794-
4795-
/*
4796-
* If the header configured for value appending,
4797-
* concatenate it with the target header in skb for
4798-
* subsequent in-place rewriting.
4799-
*/
4800-
if (f_desc->append) {
4801-
TfwStr h_app = {
4802-
.chunks = (TfwStr []){
4803-
{ .data = ", ", .len = 2 },
4804-
{ .data = val->data,
4805-
.len = val->len }
4806-
},
4807-
.len = val->len + 2,
4808-
.nchunks = 2
4809-
};
4810-
4811-
r = tfw_strcat(resp->pool, tgt, &h_app);
4812-
if (unlikely(r))
4813-
return r;
4814-
4815-
next->s_hdr = *tgt;
4816-
next->op = TFW_H2_TRANS_INPLACE;
4817-
break;
4818-
}
4819-
4820-
next->s_hdr = *f_desc->hdr;
4821-
//next->op = TFW_H2_TRANS_SUB;
4822-
break;
4823-
4824-
def:
4825-
/*
4826-
* Remove 'Connection', 'Keep-Alive' headers and all hop-by-hop
4827-
* headers from the HTTP/2 response.
4828-
*/
4829-
if (hid == TFW_HTTP_HDR_KEEP_ALIVE
4830-
|| hid == TFW_HTTP_HDR_CONNECTION
4831-
|| tgt->flags & TFW_STR_HBH_HDR)
4832-
continue;
4833-
4834-
/*
4835-
* 'Server' header must be replaced; thus, remove the original
4836-
* header (and all its duplicates) skipping it here; the new
4837-
* header will be written later, during new headers' addition
4838-
* stage.
4839-
*/
4840-
if (hid == TFW_HTTP_HDR_SERVER)
4841-
continue;
4842-
4843-
/*
4844-
* In general case the header should be transformed in-place
4845-
* from its original HTTP/1.1-representation in skb.
4846-
*/
4847-
mit->bnd = first->data;
4848-
next->s_hdr = *tgt;
4849-
next->op = TFW_H2_TRANS_INPLACE;
4850-
4851-
break;
4852-
}
4853-
4854-
mit->curr = i + 1;
4855-
4856-
return 0;
4857-
}
4858-
48594702
static int
48604703
__tfw_h2_make_frames(unsigned long len, char *data, TfwMsgIter *iter,
48614704
unsigned long max_sz, const TfwStr* frame_hdr_str,
@@ -5449,7 +5292,7 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
54495292
TfwHttpReq *req = resp->req;
54505293
TfwH2Ctx *ctx = tfw_h2_context(req->conn);
54515294
TfwHttpTransIter *mit = &resp->mit;
5452-
TfwHttpRespCleanup cleanup;
5295+
TfwHttpRespCleanup cleanup = {};
54535296
TfwStr codings = {.data = *this_cpu_ptr(&g_te_buf), .len = 0};
54545297
const TfwHdrMods *h_mods = tfw_vhost_get_hdr_mods(req->location,
54555298
req->vhost,
@@ -5464,7 +5307,6 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
54645307
if (unlikely(!stream_id))
54655308
goto out;
54665309

5467-
memset(&cleanup, 0, sizeof(TfwHttpRespCleanup));
54685310
/*
54695311
* Accordingly to RFC 9113 8.2.2 connection-specific headers can't
54705312
* be used in HTTP/2.
@@ -5493,7 +5335,7 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
54935335
* Transform HTTP/1.1 headers into HTTP/2 form, in parallel with
54945336
* adjusting of particular headers.
54955337
*/
5496-
WARN_ON_ONCE(mit->acc_len || mit->curr);
5338+
WARN_ON_ONCE(mit->acc_len);
54975339
tfw_h2_msg_transform_setup(mit, resp->msg.skb_head, true);
54985340

54995341
tfw_h2_msg_cutoff_headers(resp, &cleanup);
@@ -5504,14 +5346,11 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
55045346
*/
55055347
r = tfw_http_msg_setup_transform_pool(mit, resp->pool);
55065348
if (unlikely(r))
5507-
goto clean;
5349+
goto clean;
55085350

55095351
r = tfw_h2_resp_status_write(resp, resp->status, true, false);
55105352
if (unlikely(r))
5511-
goto clean;
5512-
5513-
if (0)
5514-
r = tfw_h2_resp_next_hdr(resp, h_mods);
5353+
goto clean;
55155354

55165355
r = tfw_h2_hpack_encode_headers(resp, h_mods);
55175356
if (unlikely(r))

fw/http.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -494,22 +494,6 @@ struct tfw_http_req_t {
494494
#define TFW_IDX_BITS 12
495495
#define TFW_D_IDX_BITS 4
496496

497-
/**
498-
* Representation of operation with the next header (in order of headers in the
499-
* message) during HTTP/1.1=>HTTP/2 transformation process.
500-
*
501-
* @s_hdr - source header for transformation;
502-
* @off - offset of not copied data from last processed @chunk;
503-
* @chunk - last chunk to be processed from @s_hdr;
504-
* @op - transformation operation which should be executed.
505-
*/
506-
typedef struct {
507-
TfwStr s_hdr;
508-
unsigned long off;
509-
unsigned int chunk;
510-
TfwH2TransOp op;
511-
} TfwNextHdrOp;
512-
513497
/**
514498
* The indirection map entry.
515499
*
@@ -554,11 +538,8 @@ typedef struct {
554538
typedef struct {
555539
TfwHttpHdrMap *map;
556540
unsigned int start_off;
557-
unsigned int curr;
558-
TfwNextHdrOp next;
559541
DECLARE_BITMAP (found, TFW_USRHDRS_ARRAY_SZ);
560542
char *curr_ptr;
561-
char *bnd;
562543
char *frame_head;
563544
TfwMsgIter iter;
564545
unsigned long acc_len;

0 commit comments

Comments
 (0)