From 88bdb6c8b59485bd60b5f48a8d875b4195b0db50 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Fri, 8 May 2020 09:17:20 +0000 Subject: [PATCH] mptcp: make sure timer is inited/started once data is pending for transmission The mptcp_connect self-tests with additional '-m mmap' argument triggers a (harmless) WARN_ON_ONCE splat in mptcp_reset_timer() as the mptcp timer is not initialized yet. This is because the timer is only set up after the transmit loop, but consecutive iterations can trigger the splat. Make sure the timer is set as soon as we pass the first chunk of data. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/3 Signed-off-by: Florian Westphal --- net/mptcp/protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index c8f1d91bc67ed..4a6101f220618 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -785,6 +785,11 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } copied += ret; + mptcp_set_timeout(sk, ssk); + /* start the timer, if it's not pending */ + if (!mptcp_timer_pending(sk)) + mptcp_reset_timer(sk); + tx_ok = msg_data_left(msg); if (!tx_ok) break; @@ -796,12 +801,10 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } } - mptcp_set_timeout(sk, ssk); if (copied) { ret = copied; tcp_push(ssk, msg->msg_flags, mss_now, tcp_sk(ssk)->nonagle, size_goal); - /* start the timer, if it's not pending */ if (!mptcp_timer_pending(sk)) mptcp_reset_timer(sk);