From nobody Wed May 8 13:05:34 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ac4:a898:0:b0:4b1:af33:c52d with SMTP id z24csp282578pid; Thu, 21 Apr 2022 07:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykLpP7vyjnn5vAsUP5vl5X5vyesdft/93L37CNfP2scO97M3zK2LpCOX7tulMVw6JQL4M5 X-Received: by 2002:a05:6870:e245:b0:de:9321:9ea3 with SMTP id d5-20020a056870e24500b000de93219ea3mr3930784oac.79.1650550844819; Thu, 21 Apr 2022 07:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650550844; cv=none; d=google.com; s=arc-20160816; b=ZVXoNJqCZ1kOUR9PhBBPKIMabq342bgNoxuv2xoCvvFd3Bk7CjDCPevzJb8yhnFfOf nl4MenggrGDpjNUDoyV9aNu9J6ERr+W4AiioWDrHGdJ1ATaf9YG79cLzRbWnuQRWT5uX 0pj+Z9RG8nQEtreX4hSJBP0ce9xVziEO2HrPE2QpAVtd7BHGlkISW8ARFoSiw2dDlIiL w7/5zl2UzhYsor70NcF/F8lO/5WgTc2CGG5uJSmryi6Vp6oawWrj7ep3uMxJ2X9E+Q87 7RMw2ZkvmE9O8mLnB3IxCdzl0C6coBD0a0Ji45Q+EqXvp+PO8KeMfUU2Krwf9RP9MrlD 0qJQ== 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=/+PlDzX3BInqcc0tHCS3Q4FtxV2bsrUdYWwDuwua/Og=; b=uUKxL6AYScmue1xl3y86VOMEU1q5Jrd1yRVfjUQATzEOy0EQu03l37VgK1rY8/n3vu yA3dZBMfYUGOBprP9Nt+GbR0PZj/suooUS6EIs44Li2XSHKQ5z44d0aUF+FZ1HWTd1WF D+f+cjJm9zxH2yNz3gzExHqGw6aaxJi0n/e0XHP8lHmgpZdJ4PdJKHoragaa5gmj9MP3 JUTL9ioDp7MxidjLRipXMmwPULg6jQRaq+QQuNuX/RhmtYgOJPtibvMCaH4ZNJJZMaBd LOhoCneCC2MVXrsqhlpvSAeGN5szs1kuQhvl9mHEk3BfO4FntMh1Iv5Tg3ku6QVAqts5 v9YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=glhxFKRB; spf=pass (google.com: domain of mptcp+bounces-4836-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-4836-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [147.75.69.165]) by mx.google.com with ESMTPS id l10-20020a056871068a00b000e5aa7f2ca5si1444654oao.35.2022.04.21.07.20.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Apr 2022 07:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-4836-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) client-ip=147.75.69.165; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=glhxFKRB; spf=pass (google.com: domain of mptcp+bounces-4836-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-4836-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 sjc.edge.kernel.org (Postfix) with ESMTPS id 4916B3E0EAC for ; Thu, 21 Apr 2022 14:20:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 975E61FC1; Thu, 21 Apr 2022 14:20:42 +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.133.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 5071F1FBE for ; Thu, 21 Apr 2022 14:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650550840; 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=/+PlDzX3BInqcc0tHCS3Q4FtxV2bsrUdYWwDuwua/Og=; b=glhxFKRBEBpWxUneEbZtPs25TRWCQ3NiiowHIEE8Q5fyswdKUROJi24Zw3FTxG10W4iTRX /6dt7h592Nq/Yq2hGGVB3J76t0xWbBY3YPqfUbZ//n3kvfzpqEdesQJAkjRJz6g2UPA8b6 lQjzdl/oyQv+fX3HopWs0WvqwIOnAgY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-5leVGC77Mq6sKL-37v4_aQ-1; Thu, 21 Apr 2022 10:20:38 -0400 X-MC-Unique: 5leVGC77Mq6sKL-37v4_aQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 930802822A25 for ; Thu, 21 Apr 2022 14:20:38 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.32.181.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4487514A4F80 for ; Thu, 21 Apr 2022 14:20:38 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 1/5] mptcp: really share subflow snd_wnd Date: Thu, 21 Apr 2022 16:20:15 +0200 Message-Id: <4d20fad8c4fbc23b033045c4a333408f4802afe7.1650550242.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.85 on 10.11.54.7 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"; x-default="true" As per RFC, mptcp subflows use a "shared" snd_wnd: the effective window is the maximum among the current values received on all subflows. Without such feature a data transfer using multiple subflows could block. Window sharing is currently implemented in the RX side: __tcp_select_window uses the mptcp-level receive buffer to compute the announced window. That is not enough: the TCP stack will stick to the window size received on the given subflow; we need to propagate the msk window value on each subflow at xmit time. Change the packet scheduler to ignore the subflow level window and use instead the msk level one Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau --- net/mptcp/protocol.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 6d59bfdd6bbd..0223a44d6b29 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1141,19 +1141,20 @@ struct mptcp_sendmsg_info { bool data_lock_held; }; =20 -static int mptcp_check_allowed_size(struct mptcp_sock *msk, u64 data_seq, - int avail_size) +static int mptcp_check_allowed_size(const struct mptcp_sock *msk, struct s= ock *ssk, + u64 data_seq, int avail_size) { u64 window_end =3D mptcp_wnd_end(msk); + u64 mptcp_snd_wnd; =20 if (__mptcp_check_fallback(msk)) return avail_size; =20 - if (!before64(data_seq + avail_size, window_end)) { - u64 allowed_size =3D window_end - data_seq; + mptcp_snd_wnd =3D window_end - data_seq; + avail_size =3D min_t(unsigned int, mptcp_snd_wnd, avail_size); =20 - return min_t(unsigned int, allowed_size, avail_size); - } + if (unlikely(tcp_sk(ssk)->snd_wnd < mptcp_snd_wnd)) + tcp_sk(ssk)->snd_wnd =3D min_t(u64, U32_MAX, mptcp_snd_wnd); =20 return avail_size; } @@ -1305,7 +1306,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct= sock *ssk, } =20 /* Zero window and all data acked? Probe. */ - copy =3D mptcp_check_allowed_size(msk, data_seq, copy); + copy =3D mptcp_check_allowed_size(msk, ssk, data_seq, copy); if (copy =3D=3D 0) { u64 snd_una =3D READ_ONCE(msk->snd_una); =20 @@ -1498,11 +1499,16 @@ static struct sock *mptcp_subflow_get_send(struct m= ptcp_sock *msk) * to check that subflow has a non empty cwin. */ ssk =3D send_info[SSK_MODE_ACTIVE].ssk; - if (!ssk || !sk_stream_memory_free(ssk) || !tcp_sk(ssk)->snd_wnd) + if (!ssk || !sk_stream_memory_free(ssk)) return NULL; =20 - burst =3D min_t(int, MPTCP_SEND_BURST_SIZE, tcp_sk(ssk)->snd_wnd); + burst =3D min_t(int, MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd= _nxt); wmem =3D READ_ONCE(ssk->sk_wmem_queued); + if (!burst) { + msk->last_snd =3D NULL; + return ssk; + } + subflow =3D mptcp_subflow_ctx(ssk); subflow->avg_pacing_rate =3D div_u64((u64)subflow->avg_pacing_rate * wmem= + READ_ONCE(ssk->sk_pacing_rate) * burst, --=20 2.35.1 From nobody Wed May 8 13:05:34 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ac4:a898:0:b0:4b1:af33:c52d with SMTP id z24csp282624pid; Thu, 21 Apr 2022 07:20:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwilbE75B3O2M6FUE/cuGt0fsAPNr6JehYd/8aWXo++1battupNKFGMxKPnCGpLby/wloCV X-Received: by 2002:a2e:2281:0:b0:24e:4cd3:7f0d with SMTP id i123-20020a2e2281000000b0024e4cd37f0dmr4597684lji.281.1650550848350; Thu, 21 Apr 2022 07:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650550848; cv=none; d=google.com; s=arc-20160816; b=VQXEc4MJaklIYjlVMF+2dvaa37IfEjNf1a0brq8bYjU+gzan3KoFpK26jQ9w0HQzex tEXYsi76GewvdTeJ+TQr2oDpDAiOM9+AfU/QrBqLPVbYUUAROOIZMjz8axROgokhehLR /uL13kNXf+PfkBZ6e2nssOc0t6l8QWQtLDE4qGfs9ntykcUOi7qcEcOQ5udnC6Amcb2c H3UaTt7RnERNgNNh8oezNPDM80HRiQaNW9BSzBJ+qf5516UQ/9F9wm8C6u1Kxd+iq2oF zeF0i/qKfZK8lZPVdCS4Xsc82WRLAuV84F3DMPSECO1MTl3U8c5YoHMY3hr5MfxFs9js zUUA== 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=4lwxSQtYs3DtTz8QQ9eyhgcYER6AqBrJiuFnazSgJUc=; b=Zxioc0nLWiC+QlRdS5g9Vn6LBcHc6nSOGzm0PQn6SGw3MsGHt2QeLxcLX78RNByUy1 XHS333C4ZoGD9fN/xPNb/kCTk+8RTiGqvyl7OD0q6cErnKA+wlVMRghi6Rk4MHNTTQQJ 8YDXwKehp6PQeApK7k4/825BrhhZ2P8WdR0d7eRa/JouvljW/bB+VJBglzPv/UFAYkSv 6aSIOwJ+07W1MbYGwnbQOwbL4CWqFh3uJsfo9X448HHoqBqzGS2Iie4Ym3uZmgII2x+s AiC5QkcYFMFh4oD1b+n6dOBy67L6gCtIsLmHP/DZtUlAMrTTu9Pvcm4/AyHdjmAh4Tkq DMIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RrjLv5if; spf=pass (google.com: domain of mptcp+bounces-4837-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-4837-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from da.mirrors.kernel.org (da.mirrors.kernel.org. [139.178.84.19]) by mx.google.com with ESMTPS id z7-20020a2e9b87000000b0024c8f54c66dsi4604771lji.291.2022.04.21.07.20.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Apr 2022 07:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-4837-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) client-ip=139.178.84.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RrjLv5if; spf=pass (google.com: domain of mptcp+bounces-4837-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-4837-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 da.mirrors.kernel.org (Postfix) with ESMTPS id E824F2E051C for ; Thu, 21 Apr 2022 14:20:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4AAD11FC3; Thu, 21 Apr 2022 14:20:43 +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 B49EE1FBF for ; Thu, 21 Apr 2022 14:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650550840; 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=4lwxSQtYs3DtTz8QQ9eyhgcYER6AqBrJiuFnazSgJUc=; b=RrjLv5ifFxjmB3y9dRzAfd9y1xmweGfVXpYo506TI7CYVLXWOccfeDwa5tQnvXsGZtr/IX a53DrLY3dFyZL0EK/PiUaLwdvIVEL10QzLXbyHwjU8pySzvPVDTmrhxh5j17HZpNmfcN60 ejIUQkWtn7jWCyL6RYQxzB1BtyCim3Y= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-4ZtpBCRQP5mtJegCQQVD-w-1; Thu, 21 Apr 2022 10:20:39 -0400 X-MC-Unique: 4ZtpBCRQP5mtJegCQQVD-w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CC8F1C07386 for ; Thu, 21 Apr 2022 14:20:39 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.32.181.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id C317D14A4F80 for ; Thu, 21 Apr 2022 14:20:38 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 2/5] mptcp: add mib for xmit window sharing Date: Thu, 21 Apr 2022 16:20:16 +0200 Message-Id: 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.85 on 10.11.54.7 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"; x-default="true" Bump a counter for counter when snd_wnd is shared among subflow, for observability's sake. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau --- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/protocol.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index d93a8c9996fd..6a6f8151375a 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -56,6 +56,7 @@ static const struct snmp_mib mptcp_snmp_list[] =3D { SNMP_MIB_ITEM("RcvPruned", MPTCP_MIB_RCVPRUNED), SNMP_MIB_ITEM("SubflowStale", MPTCP_MIB_SUBFLOWSTALE), SNMP_MIB_ITEM("SubflowRecover", MPTCP_MIB_SUBFLOWRECOVER), + SNMP_MIB_ITEM("SndWndShared", MPTCP_MIB_SNDWNDSHARED), SNMP_MIB_SENTINEL }; =20 diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index 529d07af9e14..2411510bef66 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -49,6 +49,7 @@ enum linux_mptcp_mib_field { MPTCP_MIB_RCVPRUNED, /* Incoming packet dropped due to memory limit */ MPTCP_MIB_SUBFLOWSTALE, /* Subflows entered 'stale' status */ MPTCP_MIB_SUBFLOWRECOVER, /* Subflows returned to active status after bei= ng stale */ + MPTCP_MIB_SNDWNDSHARED, /* Subflow snd wnd is overridden by msk's one */ __MPTCP_MIB_MAX }; =20 diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 0223a44d6b29..098f8f7d6366 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1153,8 +1153,10 @@ static int mptcp_check_allowed_size(const struct mpt= cp_sock *msk, struct sock *s mptcp_snd_wnd =3D window_end - data_seq; avail_size =3D min_t(unsigned int, mptcp_snd_wnd, avail_size); =20 - if (unlikely(tcp_sk(ssk)->snd_wnd < mptcp_snd_wnd)) + if (unlikely(tcp_sk(ssk)->snd_wnd < mptcp_snd_wnd)) { tcp_sk(ssk)->snd_wnd =3D min_t(u64, U32_MAX, mptcp_snd_wnd); + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_SNDWNDSHARED); + } =20 return avail_size; } --=20 2.35.1 From nobody Wed May 8 13:05:34 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ac4:a898:0:b0:4b1:af33:c52d with SMTP id z24csp282602pid; Thu, 21 Apr 2022 07:20:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvnSHyh+83doTrXAIhHNYpm3ogDT7gUTpcWeaa593ixd0we88IFerGOglOAebbxOATKRiX X-Received: by 2002:a63:f217:0:b0:39d:a9ed:2160 with SMTP id v23-20020a63f217000000b0039da9ed2160mr24350489pgh.111.1650550846735; Thu, 21 Apr 2022 07:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650550846; cv=none; d=google.com; s=arc-20160816; b=CQi/6In7+WxbZEg75T1VnLqG2pSdDs3KO3uNe8KqTfQU92IWDMBzC40Px9ODG0N2bM gm5i96KjM+edGKtZ7Dr5lxYPb5USE7nBuGTl3nqP2dQTts/oTFfsxwMnpRBUnFuxaec+ 4UUpj5LT3LRy0h8Gm51ODZQN8cmz3OHcaXQZUyJLb+twg0qCGK+5enY/i4l87cxId3zN 7PQ5bANPV7s+HY/bxY2u1hnGg0X/mLSOhCFXCeM8hKXT/wnkF2jtEnGzAE+YIjivYugh VbG6jG7rOWzGN+TgDOQrzdVUnfLraz7BJGO34Q41NBenIsuNtj4OpggjsE28OUlcehyq LZTw== 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=YnjGadD6ccpqBfveBes2YRSiqHUFgLrxA78oJ6O23Ng=; b=t+Dk4EU/7qBM6cvqGRSwakxIKAERoBTGXvEqrvyEZJv9cTPf6yTFKr4Zj3v+tQyoMW lM1peXfJq8jJisWXfaCrIw2ppVa9vKj8G+K4i+3zf18WhSh1txm5KhVzZXm4bFf7hqJF bJjVwV+G7d+CN/m6pOkic+3QgqkDQr56XpYQpCx14bP4pmJRlCuUPf96L9CJsSUNbFVx 9NlCjn+gEsqVKG+H3VvxMNECm65EzQSMpQe3YwgMNCdhmErvLmhyp8vsFcN+5pm08h7Q JA6WAn6fMYycYawBWcFLvD/wCsZRY5iy9q8b1fDwD8gz1tNIcZpNiaezqRDKeLqvdpvV cPwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WZ6dBOzj; spf=pass (google.com: domain of mptcp+bounces-4838-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-4838-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k6-20020a170902ce0600b0015833d93f52si1980192plg.66.2022.04.21.07.20.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Apr 2022 07:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-4838-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WZ6dBOzj; spf=pass (google.com: domain of mptcp+bounces-4838-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-4838-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 85092280ABB for ; Thu, 21 Apr 2022 14:20:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA6041FBF; Thu, 21 Apr 2022 14:20:43 +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 680167A for ; Thu, 21 Apr 2022 14:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650550841; 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=YnjGadD6ccpqBfveBes2YRSiqHUFgLrxA78oJ6O23Ng=; b=WZ6dBOzjj13hNnsb+1ervq4aTreRmLQAVXXTN8eFGtNKKa84CxEZSqE5CI58U+53Z+f4Kz NGsO7iod8prsFFMnuvw/yv5QFbrX9P1EP6TOOUwjyXHh3KxwO/W0aPzligNR7uMQ23a4Th D11+ya0Wq+tIcXOVG1C39qj02pW+cBo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-471-8s3NTryAMOq96tQ9aHWBMg-1; Thu, 21 Apr 2022 10:20:39 -0400 X-MC-Unique: 8s3NTryAMOq96tQ9aHWBMg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9AFEF3834C05 for ; Thu, 21 Apr 2022 14:20:39 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.32.181.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CD5614A4F80 for ; Thu, 21 Apr 2022 14:20:39 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 3/5] tcp: allow MPTCP to update the announced window. Date: Thu, 21 Apr 2022 16:20:17 +0200 Message-Id: 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.85 on 10.11.54.7 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"; x-default="true" The MPTCP RFC requires that the MPTCP-level receive window's right edge never moves backward. Currently the MPTCP code enforces such constraint while tracking the right edge, but it does not reflects it on the wire, as MPTCP lacks a suitable hook to update accordingly the TCP header. This change modifies the existing mptcp_write_options() hook, providing the current packet's TCP header to the MPTCP protocol, so that the next patch could implement the above mentioned constraint. No functional changes intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau --- v1 -> v2: - Use a single hdr/opt argument (Mat) --- include/net/mptcp.h | 2 +- net/ipv4/tcp_output.c | 14 ++++++++------ net/mptcp/options.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 877077b53200..6b07011c060d 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -125,7 +125,7 @@ bool mptcp_established_options(struct sock *sk, struct = sk_buff *skb, struct mptcp_out_options *opts); bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb); =20 -void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, +void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *= tp, struct mptcp_out_options *opts); =20 void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index c221f3bce975..7d64c3fc5d40 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -444,12 +444,13 @@ struct tcp_out_options { struct mptcp_out_options mptcp; }; =20 -static void mptcp_options_write(__be32 *ptr, const struct tcp_sock *tp, +static void mptcp_options_write(struct tcphdr *th, __be32 *ptr, + struct tcp_sock *tp, struct tcp_out_options *opts) { #if IS_ENABLED(CONFIG_MPTCP) if (unlikely(OPTION_MPTCP & opts->options)) - mptcp_write_options(ptr, tp, &opts->mptcp); + mptcp_write_options(th, ptr, tp, &opts->mptcp); #endif } =20 @@ -605,9 +606,10 @@ static void bpf_skops_write_hdr_opt(struct sock *sk, s= truct sk_buff *skb, * At least SACK_PERM as the first option is known to lead to a disaster * (but it may well be that other scenarios fail similarly). */ -static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp, +static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, struct tcp_out_options *opts) { + __be32 *ptr =3D (__be32 *)(th + 1); u16 options =3D opts->options; /* mungable copy */ =20 if (unlikely(OPTION_MD5 & options)) { @@ -701,7 +703,7 @@ static void tcp_options_write(__be32 *ptr, struct tcp_s= ock *tp, =20 smc_options_write(ptr, &options); =20 - mptcp_options_write(ptr, tp, opts); + mptcp_options_write(th, ptr, tp, opts); } =20 static void smc_set_option(const struct tcp_sock *tp, @@ -1354,7 +1356,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct= sk_buff *skb, th->window =3D htons(min(tp->rcv_wnd, 65535U)); } =20 - tcp_options_write((__be32 *)(th + 1), tp, &opts); + tcp_options_write(th, tp, &opts); =20 #ifdef CONFIG_TCP_MD5SIG /* Calculate the MD5 hash, as we have all we need now */ @@ -3590,7 +3592,7 @@ struct sk_buff *tcp_make_synack(const struct sock *sk= , struct dst_entry *dst, =20 /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */ th->window =3D htons(min(req->rsk_rcv_wnd, 65535U)); - tcp_options_write((__be32 *)(th + 1), NULL, &opts); + tcp_options_write(th, NULL, &opts); th->doff =3D (tcp_header_size >> 2); __TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTSEGS); =20 diff --git a/net/mptcp/options.c b/net/mptcp/options.c index e05d9458a025..2570911735ab 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1265,7 +1265,7 @@ static u16 mptcp_make_csum(const struct mptcp_ext *mp= ext) ~csum_unfold(mpext->csum)); } =20 -void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, +void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *= tp, struct mptcp_out_options *opts) { const struct sock *ssk =3D (const struct sock *)tp; --=20 2.35.1 From nobody Wed May 8 13:05:34 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ac4:a898:0:b0:4b1:af33:c52d with SMTP id z24csp282618pid; Thu, 21 Apr 2022 07:20:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKteqAWHiJiAQdBm71TUwDgkW2lgQaJyXrosu1Z7VyXnRlH+M9QpXbTpjb3KBvLOJvUbrB X-Received: by 2002:a05:6808:1788:b0:322:eae3:5d3c with SMTP id bg8-20020a056808178800b00322eae35d3cmr3588755oib.222.1650550848154; Thu, 21 Apr 2022 07:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650550848; cv=none; d=google.com; s=arc-20160816; b=agj2Eih48c33zntLdnF3Kg4WMyv+ZnjFTL66GJVVda7fDHEuufM1MiIgZFl/1fLT/Z PE23bFjaeatG01YPi1jjegLq1MKYrjVYZfTu7dchnbDq8PtUwnHpos+AjiwUWOORmzQ3 hYI+H2qj8hfUyAyvPhTPv1AmzQYtHtX7eRZIUAew8p7wllAY88Mucmgjpy/505+g8yWq V7nCtNei/6d1kUCjHpMVDNgG2HX+DmpJbtbTg4NGS51wrJVW+uHdfHw96xYcY0IBwYx1 izu4K74eogMAu/ytH0a9fuidSt1DHl7ZBRw40sJs3dMZ0kUlELKDvEn01zhOnfAi5meh U3Gw== 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=HysrGFLfwusrd53mt5VTm/xDXivI7TUWaCPA66/u1M4=; b=S5p3xKjXtfyOR/0Mv4tHHw9fo5L9h6umcjIaRzgLVmLyEDhFlPR36XH9vn9MZAQRk8 ykdCBnPIrLwvzg/DzVaXRmHLAyKqQTWyBolNJXxeNWIPuty3yaUNiROeMSRZ6bZBVJTo BMQidOKtKCWsaly02SjvgzkbMFQNEXeJFcxll/MzX0leqyPeq5mg+hb9VwLTwGZCFXgO FRcbQQih+PiyIclQMKSimHvTiwDp/woasBFXXX3BSUcrZmpllCamMBwwhRh9c6yoAvUg C27RQ3OI9+xFkbIdtBdTkxQT1BYA7xLrfpqLSBev6p6KCIqPZidPNiHBiyHpdflpwsu5 8PHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S0rFywG8; spf=pass (google.com: domain of mptcp+bounces-4839-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-4839-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h16-20020a056830165000b006054fabb41fsi2698287otr.99.2022.04.21.07.20.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Apr 2022 07:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-4839-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S0rFywG8; spf=pass (google.com: domain of mptcp+bounces-4839-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-4839-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AA6CD280A94 for ; Thu, 21 Apr 2022 14:20:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 345157A; Thu, 21 Apr 2022 14:20:44 +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.133.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 B95C31FBE for ; Thu, 21 Apr 2022 14:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650550841; 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=HysrGFLfwusrd53mt5VTm/xDXivI7TUWaCPA66/u1M4=; b=S0rFywG8+/WyU4vw8uVpplFK540nPlePW5J+RYJDQZs1su01KDbE6+4hO95s8/sZTNMaHE cZfNOt8wXn5BiEaygE9nXairemEkiwORYxQ1ndilK2Dr1HDcTdPvt//rOJoiCfK7xPYAsj SGue8WF8nnSJo6j9qOFfInAbv8ZPz3U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-166-F8vCFtOjOAWqihLSbPMMMg-1; Thu, 21 Apr 2022 10:20:40 -0400 X-MC-Unique: F8vCFtOjOAWqihLSbPMMMg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 25BDE18A6581 for ; Thu, 21 Apr 2022 14:20:40 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.32.181.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB89414A4F86 for ; Thu, 21 Apr 2022 14:20:39 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 4/5] mptcp: never shrink offered window Date: Thu, 21 Apr 2022 16:20:18 +0200 Message-Id: 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.85 on 10.11.54.7 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"; x-default="true" As per RFC, the offered MPTCP-level window should never shrink. While we currently track the right edge, we don't enforce the above constraint on the wire. Additionally, concurrent xmit on different subflows can end-up in erroneous right edge update. Address the above explicitly updating the announced window and protecting the update with an additional atomic operation (sic) Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau --- v1 -> v2: - convert rcv_wnd_sent to atomic64: cmpxchg64 is not supported by every arch, while atomic64_t has no such issue RFC -> v1: - rebased on previous patch --- net/mptcp/options.c | 52 ++++++++++++++++++++++++++++++++++++++------ net/mptcp/protocol.c | 8 +++---- net/mptcp/protocol.h | 2 +- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 2570911735ab..df58130da4dc 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1224,20 +1224,58 @@ bool mptcp_incoming_options(struct sock *sk, struct= sk_buff *skb) return true; } =20 -static void mptcp_set_rwin(const struct tcp_sock *tp) +static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th) { const struct sock *ssk =3D (const struct sock *)tp; - const struct mptcp_subflow_context *subflow; + struct mptcp_subflow_context *subflow; + u64 ack_seq, rcv_wnd_old, rcv_wnd_new; struct mptcp_sock *msk; - u64 ack_seq; + u32 new_win; + u64 win; =20 subflow =3D mptcp_subflow_ctx(ssk); msk =3D mptcp_sk(subflow->conn); =20 - ack_seq =3D READ_ONCE(msk->ack_seq) + tp->rcv_wnd; + ack_seq =3D READ_ONCE(msk->ack_seq); + rcv_wnd_new =3D ack_seq + tp->rcv_wnd; + + rcv_wnd_old =3D atomic64_read(&msk->rcv_wnd_sent); + if (after64(rcv_wnd_new, rcv_wnd_old)) { + u64 rcv_wnd; + + for (;;) { + rcv_wnd =3D atomic64_cmpxchg(&msk->rcv_wnd_sent, rcv_wnd_old, rcv_wnd_n= ew); + + if (rcv_wnd =3D=3D rcv_wnd_old) + break; + if (before64(rcv_wnd_new, rcv_wnd)) + goto raise_win; + rcv_wnd_old =3D rcv_wnd; + }; + return; + } + + if (rcv_wnd_new !=3D rcv_wnd_old) { +raise_win: + win =3D rcv_wnd_old - ack_seq; + tp->rcv_wnd =3D min_t(u64, win, U32_MAX); + new_win =3D tp->rcv_wnd; =20 - if (after64(ack_seq, READ_ONCE(msk->rcv_wnd_sent))) - WRITE_ONCE(msk->rcv_wnd_sent, ack_seq); + /* Make sure we do not exceed the maximum possible + * scaled window. + */ + if (unlikely(th->syn)) + new_win =3D min(new_win, 65535U) << tp->rx_opt.rcv_wscale; + if (!tp->rx_opt.rcv_wscale && + sock_net(ssk)->ipv4.sysctl_tcp_workaround_signed_windows) + new_win =3D min(new_win, MAX_TCP_WINDOW); + else + new_win =3D min(new_win, (65535U << tp->rx_opt.rcv_wscale)); + + /* RFC1323 scaling applied */ + new_win >>=3D tp->rx_opt.rcv_wscale; + th->window =3D htons(new_win); + } } =20 u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum = sum) @@ -1554,7 +1592,7 @@ void mptcp_write_options(struct tcphdr *th, __be32 *p= tr, struct tcp_sock *tp, } =20 if (tp) - mptcp_set_rwin(tp); + mptcp_set_rwin(tp, th); } =20 __be32 mptcp_get_reset_option(const struct sk_buff *skb) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 098f8f7d6366..653757ea0aca 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -216,7 +216,7 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk= , struct sk_buff *skb) =20 seq =3D MPTCP_SKB_CB(skb)->map_seq; end_seq =3D MPTCP_SKB_CB(skb)->end_seq; - max_seq =3D READ_ONCE(msk->rcv_wnd_sent); + max_seq =3D atomic64_read(&msk->rcv_wnd_sent); =20 pr_debug("msk=3D%p seq=3D%llx limit=3D%llx empty=3D%d", msk, seq, max_seq, RB_EMPTY_ROOT(&msk->out_of_order_queue)); @@ -225,7 +225,7 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk= , struct sk_buff *skb) mptcp_drop(sk, skb); pr_debug("oow by %lld, rcv_wnd_sent %llu\n", (unsigned long long)end_seq - (unsigned long)max_seq, - (unsigned long long)msk->rcv_wnd_sent); + (unsigned long long)atomic64_read(&msk->rcv_wnd_sent)); MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_NODSSWINDOW); return; } @@ -3008,7 +3008,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, mptcp_crypto_key_sha(msk->remote_key, NULL, &ack_seq); ack_seq++; WRITE_ONCE(msk->ack_seq, ack_seq); - WRITE_ONCE(msk->rcv_wnd_sent, ack_seq); + atomic64_set(&msk->rcv_wnd_sent, ack_seq); } =20 #if !IS_ENABLED(CONFIG_KASAN) @@ -3303,9 +3303,9 @@ void mptcp_finish_connect(struct sock *ssk) WRITE_ONCE(msk->write_seq, subflow->idsn + 1); WRITE_ONCE(msk->snd_nxt, msk->write_seq); WRITE_ONCE(msk->ack_seq, ack_seq); - WRITE_ONCE(msk->rcv_wnd_sent, ack_seq); WRITE_ONCE(msk->can_ack, 1); WRITE_ONCE(msk->snd_una, msk->write_seq); + atomic64_set(&msk->rcv_wnd_sent, ack_seq); =20 mptcp_pm_new_connection(msk, ssk, 0); =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f542aeaa5b09..4672901d0dfe 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -257,7 +257,7 @@ struct mptcp_sock { u64 write_seq; u64 snd_nxt; u64 ack_seq; - u64 rcv_wnd_sent; + atomic64_t rcv_wnd_sent; u64 rcv_data_fin_seq; int rmem_fwd_alloc; struct sock *last_snd; --=20 2.35.1 From nobody Wed May 8 13:05:34 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ac4:a898:0:b0:4b1:af33:c52d with SMTP id z24csp282629pid; Thu, 21 Apr 2022 07:20:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYsH8GQbYl8nDP76M9X8JTjUKLDIN4kgINfkO7waux8tNqLRq8khywYp+8MnfIASUhNKKJ X-Received: by 2002:a05:6870:a707:b0:e2:cc85:d98 with SMTP id g7-20020a056870a70700b000e2cc850d98mr3978590oam.131.1650550849581; Thu, 21 Apr 2022 07:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650550849; cv=none; d=google.com; s=arc-20160816; b=tOsyOsRIMhE5l1399x0CjbLAKS2/S55uQuFggtI5iHO34YBvbPBdXdpQiEHCR3+uZm 2/HmGHXl3iBYiQEfGMjJuxgQJLYuR4v/wOIBeYtL9OBDo+h6ijjiSLSWbFhdvjS1Az+b mqKceakgMb7pf14JEGAYN8WdB8rafBvI9719PhRs5cs7GuWTjGA69KxXiahgek+QsNK4 1manqTT0lQ+WcK06gRelNbbY5jlVXier7f3zTKk95DlHii/+ylEMudm47w5f7+Wt2Keq 0y0wkaZfY1Wb68MvLbrp6wTd2LPbLus3AL+xclbWpv8NF4SHFdUAuNi8SyDMZ+L9Svi7 A4uQ== 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=+F1M2HKHxxNfS8VnfTINrDi/c85wS0LH/iyLHYKGnnE=; b=B7yDTOplhW7WHCr58+1v+iHZh56oPXa4xf07936YxzJhvguvcAnF651RqxjofBrO/Y mfaW7dvqcznyyEVDOiypvO24oobTCJZYQQt/2c8oRUBViVkyXNP0Nr/bcukjyMgaCEv3 okg3Y5CuHAuZ2SAZ7g4sGn3C9ODhp9kmmuxI/+QMtLEzbzMtgiK7YLmTjyIvgGBrqa4l FsfqdIgEQko5wY3KhKpdhp1Kw3XhFsy0CfBsZ4ipDX4Uqceb5dyur0POQs4uTuHHoIId LbAYLId4wc0tKHfL2QdeH5Q3Ky8Z3JwHwPMzhXJ8gilm/P1S/lRgnrCMQSnZ6BFEROub OyIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f5ngB7NL; spf=pass (google.com: domain of mptcp+bounces-4840-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-4840-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v4-20020a9d69c4000000b0060414324b81si2813139oto.333.2022.04.21.07.20.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Apr 2022 07:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-4840-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f5ngB7NL; spf=pass (google.com: domain of mptcp+bounces-4840-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-4840-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C0798280BD7 for ; Thu, 21 Apr 2022 14:20:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FDDF1FBE; Thu, 21 Apr 2022 14:20:44 +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 2A29A1FC2 for ; Thu, 21 Apr 2022 14:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650550842; 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=+F1M2HKHxxNfS8VnfTINrDi/c85wS0LH/iyLHYKGnnE=; b=f5ngB7NLwdtZMOpN80djzMGNKC1dw7xkbQpxaEENqAoxvdHd1cuAQNBA2+RnGdqJVni453 /Y7yDPoOxzhnzt9Rz/E3tGn03c9TW5I6cnb0jSckj+qAZkgr2OoGOvFG9UI45HzJIJJrAl quZ68qJJd9eRJAGiPfFbmZDdvgQrVQ8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-223-YJrj1FPlMyC3Q2A5v_-CIw-1; Thu, 21 Apr 2022 10:20:41 -0400 X-MC-Unique: YJrj1FPlMyC3Q2A5v_-CIw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A408618A6585 for ; Thu, 21 Apr 2022 14:20:40 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.32.181.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55B1D14A4F80 for ; Thu, 21 Apr 2022 14:20:40 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 5/5] mptcp: add more offered MIBs counter. Date: Thu, 21 Apr 2022 16:20:19 +0200 Message-Id: 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.85 on 10.11.54.7 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"; x-default="true" Track the exceptional handling of MPTCP-level offered window with a few more counters for observability. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau --- net/mptcp/mib.c | 3 +++ net/mptcp/mib.h | 5 +++++ net/mptcp/options.c | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index 6a6f8151375a..0dac2863c6e1 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -57,6 +57,9 @@ static const struct snmp_mib mptcp_snmp_list[] =3D { SNMP_MIB_ITEM("SubflowStale", MPTCP_MIB_SUBFLOWSTALE), SNMP_MIB_ITEM("SubflowRecover", MPTCP_MIB_SUBFLOWRECOVER), SNMP_MIB_ITEM("SndWndShared", MPTCP_MIB_SNDWNDSHARED), + SNMP_MIB_ITEM("RcvWndShared", MPTCP_MIB_RCVWNDSHARED), + SNMP_MIB_ITEM("RcvWndConflictUpdate", MPTCP_MIB_RCVWNDCONFLICTUPDATE), + SNMP_MIB_ITEM("RcvWndConflict", MPTCP_MIB_RCVWNDCONFLICT), SNMP_MIB_SENTINEL }; =20 diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index 2411510bef66..2be3596374f4 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -50,6 +50,11 @@ enum linux_mptcp_mib_field { MPTCP_MIB_SUBFLOWSTALE, /* Subflows entered 'stale' status */ MPTCP_MIB_SUBFLOWRECOVER, /* Subflows returned to active status after bei= ng stale */ MPTCP_MIB_SNDWNDSHARED, /* Subflow snd wnd is overridden by msk's one */ + MPTCP_MIB_RCVWNDSHARED, /* Subflow rcv wnd is overridden by msk's one */ + MPTCP_MIB_RCVWNDCONFLICTUPDATE, /* subflow rcv wnd is overridden by msk's= one due to + * conflict with another subflow while updating msk rcv wnd + */ + MPTCP_MIB_RCVWNDCONFLICT, /* Conflict with while updating msk rcv wnd */ __MPTCP_MIB_MAX }; =20 diff --git a/net/mptcp/options.c b/net/mptcp/options.c index df58130da4dc..5e337f5303cc 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1248,8 +1248,11 @@ static void mptcp_set_rwin(struct tcp_sock *tp, stru= ct tcphdr *th) =20 if (rcv_wnd =3D=3D rcv_wnd_old) break; - if (before64(rcv_wnd_new, rcv_wnd)) + if (before64(rcv_wnd_new, rcv_wnd)) { + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICTUPDATE); goto raise_win; + } + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICT); rcv_wnd_old =3D rcv_wnd; }; return; @@ -1275,6 +1278,7 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struc= t tcphdr *th) /* RFC1323 scaling applied */ new_win >>=3D tp->rx_opt.rcv_wscale; th->window =3D htons(new_win); + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDSHARED); } } =20 --=20 2.35.1