Skip to content

Commit

Permalink
mptcp: accurate SIOCOUTQ for fallback socket
Browse files Browse the repository at this point in the history
The MPTCP SIOCOUTQ implementation is not very accurate in
case of fallback: it only measures the data in the MPTCP-level
write queue, but it does not take in account the subflow
write queue utilization. In case of fallback the first can be
empty, while the latter is not.

The above produces sporadic self-tests issues and can foul
legit user-space application.

Fix the issue additionally querying the subflow in case of fallback.

Fixes: 644807e ("mptcp: add SIOCINQ, OUTQ and OUTQNSD ioctls")
Closes: #260
Reported-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Paolo Abeni authored and matttbe committed Feb 25, 2022
1 parent 9e46c60 commit 1e036b8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -3294,6 +3294,17 @@ static int mptcp_ioctl_outq(const struct mptcp_sock *msk, u64 v)
return 0;

delta = msk->write_seq - v;
if (__mptcp_check_fallback(msk) && msk->first) {
struct tcp_sock *tp = tcp_sk(msk->first);

/* the first subflow is disconnected after close - see
* __mptcp_close_ssk(). tcp_disconnect() moves the write_seq
* so ignore that status, too.
*/
if (!((1 << msk->first->sk_state) &
(TCPF_SYN_SENT | TCPF_SYN_RECV | TCPF_CLOSE)))
delta += READ_ONCE(tp->write_seq) - tp->snd_una;
}
if (delta > INT_MAX)
delta = INT_MAX;

Expand Down

0 comments on commit 1e036b8

Please sign in to comment.