Message ID | 20191118214538.21931-14-fw@strlen.de |
---|---|
State | Accepted, archived |
Delegated to: | Matthieu Baerts |
Headers | show |
Series | [v2] mptcp: wmem accounting and nonblocking io support | expand |
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b36d1b89cb34..e158b30f9cab 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -483,6 +483,15 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) pr_debug("conn_list->subflow=%p", ssk); + if (unlikely(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) { + int limit = sk_stream_wspace(sk); + + if (WARN_ON_ONCE(limit <= 0)) + limit = 1; + + iov_iter_truncate(&msg->msg_iter, limit); + } + lock_sock(ssk); while (msg_data_left(msg)) { ret = mptcp_sendmsg_frag(sk, ssk, msg, NULL, &timeo, &mss_now,
If userspace uses SO_SNDBUF to set a value, then truncate the buffer according to remaining wmem. Otherwise, running selftest script with "-m mmap -b 4096" shows very large sucessful write() calls, as we're only limited by how much data the underlying tcp flow is willing to accept. NB: It might make sense to carry SO_SNDBUF down to the subflows, but thats left out for now. Signed-off-by: Florian Westphal <fw@strlen.de> --- net/mptcp/protocol.c | 9 +++++++++ 1 file changed, 9 insertions(+)