Skip to content

Commit e222399

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: use tcp_build_frag()
mptcp_push_pending() is called even on orphaned msk (and orphaned subflows), if there is outstanding data at close() time. To cope with the above MPTCP needs to handle explicitly the allocation failure on xmit. The newly introduced do_tcp_sendfrag() allows that, just plug it. We can additionally drop a couple of sanity checks, duplicate in the TCP code. Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b796d04 commit e222399

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

net/mptcp/protocol.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -992,17 +992,13 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
992992
psize = min_t(size_t, dfrag->data_len, avail_size);
993993
}
994994

995-
/* tell the TCP stack to delay the push so that we can safely
996-
* access the skb after the sendpages call
997-
*/
998-
ret = do_tcp_sendpages(ssk, page, offset, psize,
999-
msg->msg_flags | MSG_SENDPAGE_NOTLAST | MSG_DONTWAIT);
1000-
if (ret <= 0) {
1001-
if (!retransmission)
1002-
iov_iter_revert(&msg->msg_iter, psize);
1003-
return ret;
995+
tail = tcp_build_frag(ssk, psize, msg->msg_flags, page, offset, &psize);
996+
if (!tail) {
997+
tcp_remove_empty_skb(sk, tcp_write_queue_tail(ssk));
998+
return -ENOMEM;
1004999
}
10051000

1001+
ret = psize;
10061002
frag_truesize += ret;
10071003
if (!retransmission) {
10081004
if (unlikely(ret < psize))
@@ -1026,20 +1022,15 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
10261022
sk->sk_forward_alloc -= frag_truesize;
10271023
}
10281024

1029-
/* if the tail skb extension is still the cached one, collapsing
1030-
* really happened. Note: we can't check for 'same skb' as the sk_buff
1031-
* hdr on tail can be transmitted, freed and re-allocated by the
1032-
* do_tcp_sendpages() call
1025+
/* if the tail skb is still the cached one, collapsing really happened.
10331026
*/
1034-
tail = tcp_write_queue_tail(ssk);
1035-
if (mpext && tail && mpext == skb_ext_find(tail, SKB_EXT_MPTCP)) {
1027+
if (skb == tail) {
10361028
WARN_ON_ONCE(!can_collapse);
10371029
mpext->data_len += ret;
10381030
goto out;
10391031
}
10401032

1041-
skb = tcp_write_queue_tail(ssk);
1042-
mpext = __skb_ext_set(skb, SKB_EXT_MPTCP, msk->cached_ext);
1033+
mpext = __skb_ext_set(tail, SKB_EXT_MPTCP, msk->cached_ext);
10431034
msk->cached_ext = NULL;
10441035

10451036
memset(mpext, 0, sizeof(*mpext));

0 commit comments

Comments
 (0)