Skip to content

Commit 6468634

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

File tree

6 files changed

+1
-436
lines changed

6 files changed

+1
-436
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: 1 addition & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -4699,162 +4699,6 @@ tfw_h2_hpack_encode_headers(TfwHttpResp *resp, const TfwHdrMods *h_mods)
46994699
return 0;
47004700
}
47014701

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-
48584702
static int
48594703
__tfw_h2_make_frames(unsigned long len, char *data, u8 buf_sz,
48604704
TfwMsgIter *iter, unsigned long skew,
@@ -5496,7 +5340,7 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
54965340
* Transform HTTP/1.1 headers into HTTP/2 form, in parallel with
54975341
* adjusting of particular headers.
54985342
*/
5499-
WARN_ON_ONCE(mit->acc_len || mit->curr);
5343+
WARN_ON_ONCE(mit->acc_len);
55005344
tfw_h2_msg_transform_setup(mit, resp->msg.skb_head, true);
55015345

55025346
tfw_h2_msg_cutoff_headers(resp, &cleanup);
@@ -5513,9 +5357,6 @@ tfw_h2_resp_adjust_fwd(TfwHttpResp *resp)
55135357
if (unlikely(r))
55145358
goto clean;
55155359

5516-
if (0)
5517-
r = tfw_h2_resp_next_hdr(resp, h_mods);
5518-
55195360
r = tfw_h2_hpack_encode_headers(resp, h_mods);
55205361
if (unlikely(r))
55215362
goto clean;

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;

fw/http_msg.c

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,118 +1573,6 @@ tfw_h2_msg_cutoff_headers(TfwHttpResp *resp, TfwHttpRespCleanup* cleanup)
15731573
it->frag = -1;
15741574
}
15751575

1576-
static int
1577-
tfw_h2_msg_rewrite_data_common(TfwHttpTransIter *mit, const TfwStr *str,
1578-
const char *stop,
1579-
void cpy(void *dest, const void *src, size_t n))
1580-
{
1581-
const TfwStr *c, *end;
1582-
TfwMsgIter *it = &mit->iter;
1583-
TfwNextHdrOp *next = &mit->next;
1584-
1585-
BUG_ON(!stop);
1586-
BUG_ON(TFW_STR_DUP(str));
1587-
1588-
TFW_STR_FOR_EACH_CHUNK(c, str, end) {
1589-
const char *addr, *next_ptr;
1590-
long offset, stop_offset;
1591-
unsigned int c_off = 0, f_size, c_size, f_room, n_copy;
1592-
this_chunk:
1593-
c_size = c->len - c_off;
1594-
if (it->frag >= 0) {
1595-
skb_frag_t *frag = &skb_shinfo(it->skb)->frags[it->frag];
1596-
1597-
f_size = skb_frag_size(frag);
1598-
addr = skb_frag_address(frag);
1599-
} else {
1600-
f_size = skb_headlen(it->skb);
1601-
addr = it->skb->data;
1602-
}
1603-
1604-
offset = mit->curr_ptr - addr;
1605-
if (WARN_ON_ONCE(offset < 0 || offset >= f_size))
1606-
return -EINVAL;
1607-
1608-
f_room = f_size - offset;
1609-
n_copy = min(c_size, f_room);
1610-
next_ptr = mit->curr_ptr + n_copy;
1611-
1612-
/*
1613-
* If the stop mark is met, we should verify that all the data
1614-
* will be copied from @str; if not, save offsets for not copied
1615-
* data from current @str (for subsequent copying after more
1616-
* space allocation) and exit with corresponding error code.
1617-
*/
1618-
stop_offset = stop - addr;
1619-
if (stop_offset >= 0 && stop_offset < f_size
1620-
&& (next_ptr > stop
1621-
|| (next_ptr == stop
1622-
&& (c_size > f_room || c + 1 < end))))
1623-
{
1624-
WARN_ON_ONCE(next->chunk || next->off);
1625-
next->chunk = TFW_STR_PLAIN(str) ? 0 : c - str->chunks;
1626-
next->off = c_off;
1627-
1628-
T_WARN("Unable to transform HTTP/1.1 data into HTTP/2"
1629-
" format: free space exhausted (accumulated"
1630-
" length: %lu\n", mit->acc_len);
1631-
1632-
return -ENOSPC;
1633-
}
1634-
cpy(mit->curr_ptr, c->data + c_off, n_copy);
1635-
1636-
T_DBG3("%s: acc_len=%lu, n_copy=%u, mit->curr_ptr='%.*s',"
1637-
" ptr_diff=%ld\n", __func__, mit->acc_len, n_copy,
1638-
n_copy, mit->curr_ptr, stop - mit->curr_ptr);
1639-
1640-
mit->curr_ptr += n_copy;
1641-
mit->acc_len += n_copy;
1642-
1643-
/*
1644-
* The fragment is exhausted. Move to the next fragment (or skb)
1645-
* and reset the @mit->curr_ptr pointer.
1646-
*/
1647-
if (c_size >= f_room) {
1648-
if (skb_shinfo(it->skb)->nr_frags > it->frag + 1) {
1649-
skb_frag_t *frag;
1650-
1651-
++it->frag;
1652-
frag = &skb_shinfo(it->skb)->frags[it->frag];
1653-
mit->curr_ptr = skb_frag_address(frag);
1654-
}
1655-
else {
1656-
if (it->skb_head == it->skb->next
1657-
&& (c_size != f_room || c + 1 < end))
1658-
return -ENOSPC;
1659-
1660-
tfw_h2_msg_transform_setup(mit, it->skb->next,
1661-
false);
1662-
}
1663-
1664-
if (c_size != f_room) {
1665-
c_off += n_copy;
1666-
goto this_chunk;
1667-
}
1668-
}
1669-
}
1670-
1671-
return 0;
1672-
}
1673-
1674-
int
1675-
tfw_h2_msg_rewrite_data(TfwHttpTransIter *mit, const TfwStr *str,
1676-
const char *stop)
1677-
{
1678-
return tfw_h2_msg_rewrite_data_common(mit, str, stop, memcpy_fast);
1679-
}
1680-
1681-
int
1682-
tfw_h2_msg_rewrite_data_lc(TfwHttpTransIter *mit, const TfwStr *str,
1683-
const char *stop)
1684-
{
1685-
return tfw_h2_msg_rewrite_data_common(mit, str, stop, tfw_cstrtolower);
1686-
}
1687-
16881576
/**
16891577
* Insert data from string @data to message at offset defined by message
16901578
* iterator @it and @off. This function doesn't maintain message structure.

0 commit comments

Comments
 (0)