diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 27f6672589ce2..7832b20baac2e 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -758,11 +758,17 @@ static bool mptcp_skb_can_collapse_to(u64 write_seq, return mpext && mpext->data_seq + mpext->data_len == write_seq; } +/* we can append data to the given data frag if: + * - there is space available in the backing page_frag + * - the data frag tail matches the current page_frag free offset + * - the data frag end sequence number matches the current write seq + */ static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk, const struct page_frag *pfrag, const struct mptcp_data_frag *df) { return df && pfrag->page == df->page && + pfrag->offset == (df->offset + df->data_len) && df->data_seq + df->data_len == msk->write_seq; }