From nobody Sun Feb 8 12:32:57 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6638:bd2:0:0:0:0 with SMTP id g18csp1560178jad; Fri, 18 Feb 2022 07:17:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3SH5QIdbmENCKuxbGyMNl2/517fjelOAWgbpYJuQJuE1gzjUdKgZgqB4ZAJL6aN8oqefF X-Received: by 2002:a65:4c4c:0:b0:35e:3c81:5b7f with SMTP id l12-20020a654c4c000000b0035e3c815b7fmr6909577pgr.162.1645197466068; Fri, 18 Feb 2022 07:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645197466; cv=none; d=google.com; s=arc-20160816; b=m08oFZ8xRXYOKclqBOGAibiAtkwwYq3tM9UDnTDSO8fL+saXb9oapwGaVp2P447I5p yomOm7Dwaw5PC1nHfV5jWt0i+TBza+1N6BKzxxIGjlkTMewHksU4YLb0uJ3vXJNft1Wn D7LXB2I1AKuAjb/WJfsOcxI4EOYoHaA20JKOVCNXt6hKm1ihf8KTPhInEzxmdKLZ4VOV UlvoQag06+yICeodcvnjPNzmPbniUqE1Gorzcn3kIA0+njaT13AxHmujzoYjaVEsl5wj bfiaoI4v24oR+znJvpRU5mGJf+AUZ7vtMJvgqAWTDwv9oy3yap2Vnz354HBF0h4uGgy7 Tjqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=gGABeR76OT7boktJeZcpdDVx6P1l3sl/4UkqnNBVzUg=; b=jOd7FETzeuciauVBuAj62ebWjDFUQCsdWeE0Ea4J0dybgZ8dllfil1enCJLzW/8mrI M1COmuAAljBqR62qUQZgfLsfKbF3sovqP608tBppr8xvXviLaCQXm8t+wNPNOYt31jFp 2kri2HsepIxcbRkYHgZa5m96ZItIVHxOAgsc025KsesMAxpJ8Dko78H+fSZMsw9q0Iji 1OVItTp7HOS/Oa0ILxZyn5ytDebjUASy01lYwvorHG6NdwC1mxym/if4W6vJe4ztnZzz I/b/AEhMHxf+WSNft48X2xGLim+kZ8/F8z6ywPhpR2dga21SDelrvt6UgawC+88xnXWp u0IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WeRxC2ci; spf=pass (google.com: domain of mptcp+bounces-3851-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-3851-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ewr.edge.kernel.org (ewr.edge.kernel.org. [2604:1380:1:3600::1]) by mx.google.com with ESMTPS id d132si11141050pgc.614.2022.02.18.07.17.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Feb 2022 07:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-3851-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) client-ip=2604:1380:1:3600::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WeRxC2ci; spf=pass (google.com: domain of mptcp+bounces-3851-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-3851-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ewr.edge.kernel.org (Postfix) with ESMTPS id 88EFE1C0EE9 for ; Fri, 18 Feb 2022 15:17:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F77E4A9B; Fri, 18 Feb 2022 15:17:38 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C4454A97 for ; Fri, 18 Feb 2022 15:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645197454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gGABeR76OT7boktJeZcpdDVx6P1l3sl/4UkqnNBVzUg=; b=WeRxC2ciD74ceBISIrjtfBxuFyHeS4yCJ+5/N1H63LiPcXXdkKpEbUGhN1xmELxwZIEFHw oej5/2Fo9fNjszZxfCKQavaLXROOhXlePtzwTIvNBFyVG/E2VLvcdvf/6Y6xRFNPQh0gah t3Z6Z3rkUTzymPJ88BMSxWY208iagCE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-281-cJ8IPFskM-qqBE4hqvGEOA-1; Fri, 18 Feb 2022 10:17:32 -0500 X-MC-Unique: cJ8IPFskM-qqBE4hqvGEOA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1BC11091DA0 for ; Fri, 18 Feb 2022 15:17:31 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.192.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1723F7CAD5 for ; Fri, 18 Feb 2022 15:17:30 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-net 1/2] mptcp: accurate SIOCOUTQ for fallback socket Date: Fri, 18 Feb 2022 16:17:20 +0100 Message-Id: <925c8780acf59dbcf647eeec18e5884e4cfc119b.1645196974.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: 644807e3e462 ("mptcp: add SIOCINQ, OUTQ and OUTQNSD ioctls") Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index bf5af6bf8756..a033ffa49fd7 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3325,6 +3325,17 @@ static int mptcp_ioctl_outq(const struct mptcp_sock = *msk, u64 v) return 0; =20 delta =3D msk->write_seq - v; + if (__mptcp_check_fallback(msk) && msk->first) { + struct tcp_sock *tp =3D 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 +=3D READ_ONCE(tp->write_seq) - tp->snd_una; + } if (delta > INT_MAX) delta =3D INT_MAX; =20 --=20 2.34.1