Skip to content

Commit

Permalink
fix(1902): correct the skb len
Browse files Browse the repository at this point in the history
Fix #1902

When we contruct frames for HTTP/2 response and
reuse the same skbs from the backend (HTTP/1), we forget to adjust
the skb size according to the trailer headers (if exist) size, then it
comes with extra partial HTTP/1 response to the client. Then, the client
will send a `GOAWAY` to temepesta due to wrong frame size, and tempesta
sends back the `TCP RESET`.
  • Loading branch information
kingluo committed May 6, 2024
1 parent 6b29d18 commit 073c050
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fw/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ typedef struct {
TfwConn *conn; \
void (*destructor)(void *msg); \
TfwStr crlf; \
TfwStr body;
TfwStr body; \
int trailers_len;


static inline void
Expand Down
8 changes: 7 additions & 1 deletion fw/http_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ tfw_http_msg_hdr_close(TfwHttpMsg *hm)
/* Close just parsed header. */
parser->hdr.flags |= TFW_STR_COMPLETE;

/* Cumulate the trailer headers length */
if (parser->hdr.flags & TFW_STR_TRAILER)
hm->trailers_len += parser->hdr.len +
tfw_str_eolen(&parser->hdr);

/*
* We make this frang check here, because it is the earliest
* place where we can determine that new added header is violating
Expand Down Expand Up @@ -1050,7 +1055,8 @@ tfw_http_msg_cutoff_body_chunks(TfwHttpResp *resp)
int r;

r = ss_skb_cutoff_data(resp->body.skb, &resp->cut, 0,
tfw_str_eolen(&resp->body));
tfw_str_eolen(&resp->body) +
((TfwHttpMsg*)resp)->trailers_len);
if (unlikely(r))
return r;

Expand Down

0 comments on commit 073c050

Please sign in to comment.