Skip to content

Commit 026f948

Browse files
committed
Deleted unsed functions and structures
1 parent 6b339b8 commit 026f948

File tree

6 files changed

+4
-440
lines changed

6 files changed

+4
-440
lines changed

fw/hpack.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,25 +3470,6 @@ tfw_huffman_encode_string(TfwStr *str, TfwPool *pool)
34703470
return r ? ERR_PTR(r) : encoded;
34713471
}
34723472

3473-
static int
3474-
tfw_hpack_str_add_raw(TfwHttpTransIter *mit, TfwStr *str, bool in_huffman)
3475-
{
3476-
int r = 0;
3477-
TfwHPackInt len;
3478-
TfwStr len_str = { 0 };
3479-
unsigned short mask = in_huffman ? 0x80 : 0x0;
3480-
3481-
write_int(str->len, 0x7F, mask, &len);
3482-
len_str.data = len.buf;
3483-
len_str.len = len.sz;
3484-
3485-
r = tfw_h2_msg_rewrite_data(mit, &len_str, mit->bnd);
3486-
if (unlikely(r))
3487-
return r;
3488-
3489-
return tfw_h2_msg_rewrite_data(mit, str, mit->bnd);
3490-
}
3491-
34923473
static int
34933474
tfw_hpack_str_expand_raw(TfwHttpTransIter *mit, TfwMsgIter *it,
34943475
struct sk_buff **skb_head, TfwStr *str,
@@ -3537,22 +3518,6 @@ tfw_hpack_str_expand_raw(TfwHttpTransIter *mit, TfwMsgIter *it,
35373518
* headers (e.g. in cases of HTTP/1.1=>HTTP/2 or HTTP/2=>HTTP/2 response proxy),
35383519
* thus avoiding Huffman encodings is completely RFC-compliant behaviour.
35393520
*/
3540-
static inline int
3541-
tfw_hpack_str_add(TfwHttpTransIter *mit, TfwStr *str, TfwPool *pool)
3542-
{
3543-
bool in_huffman = false;
3544-
3545-
if (0) {
3546-
str = tfw_huffman_encode_string(str, pool);
3547-
3548-
if (IS_ERR(str))
3549-
return PTR_ERR(str);
3550-
in_huffman = true;
3551-
}
3552-
3553-
return tfw_hpack_str_add_raw(mit, str, in_huffman);
3554-
}
3555-
35563521
static inline int
35573522
tfw_hpack_str_expand(TfwHttpTransIter *mit, TfwMsgIter *it,
35583523
struct sk_buff **skb_head, TfwStr *str,

fw/hpack.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ typedef struct {
107107
TFW_HPACK_ETBL_COMMON;
108108
} TfwHPackETblIter;
109109

110-
typedef enum {
111-
TFW_H2_TRANS_INPLACE = 0,
112-
TFW_H2_TRANS_ADD,
113-
TFW_H2_TRANS_EXPAND,
114-
} TfwH2TransOp;
115-
116110
typedef enum {
117111
TFW_TAG_HDR_H2_STATUS,
118112
TFW_TAG_HDR_H2_METHOD,

fw/http.c

Lines changed: 4 additions & 164 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
}
@@ -4699,162 +4698,6 @@ tfw_h2_hpack_encode_headers(TfwHttpResp *resp, const TfwHdrMods *h_mods)
46994698
return 0;
47004699
}
47014700

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

55025345
tfw_h2_msg_cutoff_headers(resp, &cleanup);
@@ -5507,14 +5350,11 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
55075350
*/
55085351
r = tfw_http_msg_setup_transform_pool(mit, resp->pool);
55095352
if (unlikely(r))
5510-
goto clean;
5353+
goto clean;
55115354

55125355
r = tfw_h2_resp_status_write(resp, resp->status, true, false);
55135356
if (unlikely(r))
5514-
goto clean;
5515-
5516-
if (0)
5517-
r = tfw_h2_resp_next_hdr(resp, h_mods);
5357+
goto clean;
55185358

55195359
r = tfw_h2_hpack_encode_headers(resp, h_mods);
55205360
if (unlikely(r))

fw/http.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -487,22 +487,6 @@ struct tfw_http_req_t {
487487
#define TFW_IDX_BITS 12
488488
#define TFW_D_IDX_BITS 4
489489

490-
/**
491-
* Representation of operation with the next header (in order of headers in the
492-
* message) during HTTP/1.1=>HTTP/2 transformation process.
493-
*
494-
* @s_hdr - source header for transformation;
495-
* @off - offset of not copied data from last processed @chunk;
496-
* @chunk - last chunk to be processed from @s_hdr;
497-
* @op - transformation operation which should be executed.
498-
*/
499-
typedef struct {
500-
TfwStr s_hdr;
501-
unsigned long off;
502-
unsigned int chunk;
503-
TfwH2TransOp op;
504-
} TfwNextHdrOp;
505-
506490
/**
507491
* The indirection map entry.
508492
*
@@ -552,11 +536,8 @@ typedef struct {
552536
typedef struct {
553537
TfwHttpHdrMap *map;
554538
unsigned int start_off;
555-
unsigned int curr;
556-
TfwNextHdrOp next;
557539
DECLARE_BITMAP (found, TFW_USRHDRS_ARRAY_SZ);
558540
char *curr_ptr;
559-
char *bnd;
560541
char *frame_head;
561542
TfwMsgIter iter;
562543
unsigned long acc_len;

0 commit comments

Comments
 (0)