Skip to content

Commit

Permalink
strparser: Remove early eaten to fix full tcp receive buffer stall
Browse files Browse the repository at this point in the history
On receving an incomplete message, the existing code stores the
remaining length of the cloned skb in the early_eaten field instead of
incrementing the value returned by __strp_recv. This defers invocation
of sock_rfree for the current skb until the next invocation of
__strp_recv, which returns early_eaten if early_eaten is non-zero.

This behavior causes a stall when the current message occupies the very
tail end of a massive skb, and strp_peek/need_bytes indicates that the
remainder of the current message has yet to arrive on the socket. The
TCP receive buffer is totally full, causing the TCP window to go to
zero, so the remainder of the message will never arrive.

Incrementing the value returned by __strp_recv by the amount otherwise
stored in early_eaten prevents stalls of this nature.

Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Doron Roberts-Kedes authored and davem330 committed Jun 28, 2018
1 parent 04c6faa commit 977c711
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions net/strparser/strparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct _strp_msg {
*/
struct strp_msg strp;
int accum_len;
int early_eaten;
};

static inline struct _strp_msg *_strp_msg(struct sk_buff *skb)
Expand Down Expand Up @@ -115,20 +114,6 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
head = strp->skb_head;
if (head) {
/* Message already in progress */

stm = _strp_msg(head);
if (unlikely(stm->early_eaten)) {
/* Already some number of bytes on the receive sock
* data saved in skb_head, just indicate they
* are consumed.
*/
eaten = orig_len <= stm->early_eaten ?
orig_len : stm->early_eaten;
stm->early_eaten -= eaten;

return eaten;
}

if (unlikely(orig_offset)) {
/* Getting data with a non-zero offset when a message is
* in progress is not expected. If it does happen, we
Expand Down Expand Up @@ -297,9 +282,9 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
}

stm->accum_len += cand_len;
eaten += cand_len;
strp->need_bytes = stm->strp.full_len -
stm->accum_len;
stm->early_eaten = cand_len;
STRP_STATS_ADD(strp->stats.bytes, cand_len);
desc->count = 0; /* Stop reading socket */
break;
Expand Down

0 comments on commit 977c711

Please sign in to comment.