Skip to content

Commit

Permalink
HTTP/2: corrections according additional review comments (#309).
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksostapenko committed Mar 4, 2020
1 parent 4f43032 commit 6164968
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tempesta_fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ tfw_cache_h2_copy_hdr(TfwCacheEntry *ce, char **p, TdbVRec **trec, TfwStr *hdr,
st_index = hdr->hpack_idx;
h_len = tfw_h2_hdr_size(s_nm.len, s_val.len, st_index);

/* Don't split short stprings. */
/* Don't split short strings. */
if (sizeof(TfwCStr) + h_len <= L1_CACHE_BYTES)
n += h_len;
}
Expand Down
2 changes: 1 addition & 1 deletion tempesta_fw/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -3106,7 +3106,7 @@ __h2_req_hdrs(TfwHttpReq *req, const TfwStr *hdr, unsigned int hid, bool append)
}
}
else {
hid = __h2_hdr_lookup(hm, hdr);
hid = __http_hdr_lookup(hm, hdr);
if (hid == ht->off && !s_val)
/*
* The raw header not found, and there is nothing
Expand Down
26 changes: 20 additions & 6 deletions tempesta_fw/http_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ tfw_http_msg_req_spec_hid(const TfwStr *hdr)
}

/**
* Fills @val with second part of special HTTP header containing the header
* value.
* Fills @val with second part of special HTTP/1.1 header containing the
* header value.
*
* TODO: with the current HTTP-parser implementation (parsing header name,
* colon, LWS and value into different chunks) this procedure can be
* simplified to avoid the usage of predefined header arrays.
*/
void
__http_msg_hdr_val(TfwStr *hdr, unsigned id, TfwStr *val, bool client)
Expand Down Expand Up @@ -338,9 +342,19 @@ tfw_http_msg_hdr_lookup(TfwHttpMsg *hm, const TfwStr *hdr)
* Certain header fields are strictly singular and may not be repeated in
* an HTTP message. Duplicate of a singular header fields is a bug worth
* blocking the whole HTTP message.
*
* TODO: with the current HTTP-parser implementation (parsing header name,
* colon, LWS and value into different chunks) we can avoid slow string
* matcher, which is used in @tfw_http_msg_hdr_lookup(), and can compare
* strings just by chunks (including searching the stop character) for both
* HTTP/2 and HTTP/1.1 formatted headers (see @__hdr_name_cmp() below).
* Thus, @__h1_hdr_lookup() and @tfw_http_msg_hdr_lookup() procedures should
* be unified to @__hdr_name_cmp() and @__http_hdr_lookup() in order to
* substitute current mess of multiple partially duplicated procedures with
* one simple interface.
*/
static inline unsigned int
__hdr_lookup(TfwHttpMsg *hm, const TfwStr *hdr)
__h1_hdr_lookup(TfwHttpMsg *hm, const TfwStr *hdr)
{
unsigned int id = tfw_http_msg_hdr_lookup(hm, hdr);

Expand Down Expand Up @@ -439,7 +453,7 @@ __hdr_name_cmp(const TfwStr *hdr, const TfwStr *cmp_hdr)
* headers in HTTP/2 or HTTP/1.1 format.
*/
int
__h2_hdr_lookup(TfwHttpMsg *hm, const TfwStr *hdr)
__http_hdr_lookup(TfwHttpMsg *hm, const TfwStr *hdr)
{
unsigned int id;
TfwHttpHdrTbl *ht = hm->h_tbl;
Expand Down Expand Up @@ -530,7 +544,7 @@ tfw_http_msg_hdr_close(TfwHttpMsg *hm)
* Both the headers, the new one and existing one, can already be
* compound.
*/
id = __h2_hdr_lookup(hm, &parser->hdr);
id = __http_hdr_lookup(hm, &parser->hdr);

/* Allocate some more room if not enough to store the header. */
if (unlikely(id == ht->size)) {
Expand Down Expand Up @@ -827,7 +841,7 @@ tfw_http_msg_hdr_xfrm_str(TfwHttpMsg *hm, const TfwStr *hdr, unsigned int hid,
/* Not found, nothing to delete. */
return 0;
} else {
hid = __hdr_lookup(hm, hdr);
hid = __h1_hdr_lookup(hm, hdr);
if (hid == ht->off && !s_val)
/* Not found, nothing to delete. */
return 0;
Expand Down
2 changes: 1 addition & 1 deletion tempesta_fw/http_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void tfw_http_msg_free(TfwHttpMsg *m);
int tfw_http_msg_expand_data(TfwMsgIter *it, struct sk_buff **skb_head,
const TfwStr *src, unsigned int *start_off);
int __hdr_name_cmp(const TfwStr *hdr, const TfwStr *cmp_hdr);
int __h2_hdr_lookup(TfwHttpMsg *hm, const TfwStr *hdr);
int __http_hdr_lookup(TfwHttpMsg *hm, const TfwStr *hdr);
int tfw_h2_msg_rewrite_data(TfwHttpTransIter *mit, const TfwStr *str,
const char *stop);

Expand Down

0 comments on commit 6164968

Please sign in to comment.