From nobody Fri May 3 10:51:09 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp613265jap; Thu, 9 Dec 2021 09:30:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpdspbEL4KArb1kqZJA61FKWLKPqYZm0qq4vq4HMbDE/CLK8nYiDrrzB1pq6jOcRLlyN35 X-Received: by 2002:a05:622a:95:: with SMTP id o21mr19449973qtw.386.1639071056609; Thu, 09 Dec 2021 09:30:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639071056; cv=none; d=google.com; s=arc-20160816; b=z7/yzGTq1sTKkdT9RbPTXHvNYHW0CYSQuVMSn2Oq5eYV00LdxDrrSlF/NTiyKs2DBQ HJTsHhsNnIeufBIKTjv9RZXbNHQmTr13Z5sD6h9uiUcnDT9T9ME6pkTe8jRwbpJj3vfZ UXP5eAUtp++WJufnM0/Q1qLMGNYDwqrsjhISmOvHIdvigy9iQvgVxN8ff/Wf8iebqtob ut2NZYgpSZLpQ7H4vbVykCEZoE/BLnVsKo0F7UsSRVPP/84JxCOCJ79qFatW3XaS4Zve x5T2eo1sgnx5NmrKWYt0BUXxvJ870589wZfcWU7PkgKbXHgM5Hy1tJucEc7oI+7H+Zuj r0EA== 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=aMR1hYkvoUwefVKooQD8Jdkgq7b6DI69kqlt/t+9Rd8=; b=YTenyHAyrWl7muhqEbMeh1qf1AAX+isJg+xYpjm/756Zu5VEBuDs0bi/ntokOlfiYu wu3W1xckOPDV+C4cRkxot2wKCN65RobU/Q3yXhFXoVCOJhPZyahnYXY00CNtiglM2/uq OAwLh8mGvOgf/PpMt7vULtGXM9J8Xxji1921tcY13Wslw2V/r3cTV8mZe0Iz3BdpEWjp ivMGYNn5AuinDmIEEyzBorHqb3IMzOITq9IzzJ/NVy8vXj0OnThqDfIz3i1pbZUGWY+e QgB9ndjY2Hp+jzk10AZXovqolADI+LGE+G8PM3QTeR7k1BKetuT3ygTcZTrOPbsUMBXT U+iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Yd1/537a"; spf=pass (google.com: domain of mptcp+bounces-2701-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2701-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. [2604:1380:1000:8100::1]) by mx.google.com with ESMTPS id c13si389757qtb.778.2021.12.09.09.30.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 09:30:56 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2701-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) client-ip=2604:1380:1000:8100::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Yd1/537a"; spf=pass (google.com: domain of mptcp+bounces-2701-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2701-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 EC4093E0F00 for ; Thu, 9 Dec 2021 17:30:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADB332C9E; Thu, 9 Dec 2021 17:30:53 +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 EB4A02C80 for ; Thu, 9 Dec 2021 17:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639071051; 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=aMR1hYkvoUwefVKooQD8Jdkgq7b6DI69kqlt/t+9Rd8=; b=Yd1/537aMtV3zeoUKWuLRkiiXv4tnyeMn8Etwi0Q8/FcAVW7R4l16OLirSIRP6Ag93DsVt faBISMaYmpU86UJ3FVAP+i6FeTn5wUqMyDtz5S+XzwHbGfymB2ne1EqtPhEkiYLK5vobu0 7ra212NNP14UJWR0P7iyviE5lYNWfKg= 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-27-ZGjfGL4BPIKO4tAb-OWM5Q-1; Thu, 09 Dec 2021 12:30:49 -0500 X-MC-Unique: ZGjfGL4BPIKO4tAb-OWM5Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE04014754 for ; Thu, 9 Dec 2021 17:30:48 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B92D5ED2C for ; Thu, 9 Dec 2021 17:30:48 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next v5 1/5] mptcp: fix per socket endpoint accounting. Date: Thu, 9 Dec 2021 18:30:38 +0100 Message-Id: <48503581612e8e8c39ab21b56d069a1170093fc1.1639070864.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.14 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" Since full-mesh endpoint support, the reception of a single ADD_ADDR option can cause multiple subflows creation. When such option is accepted we increment 'add_addr_accepted' by one. When we received a paired RM_ADDR option, we deleted all the relevant subflows, decrementing 'add_addr_accepted' by one for each of them. We have a similar issue for 'local_addr_used' Fix them moving the pm endpoint accounting outside the subflow traversal. Fixes: 1a0d6136c5f0 ("mptcp: local addresses fullmesh") Signed-off-by: Paolo Abeni --- net/mptcp/pm_netlink.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 3186d33b5208..d18b13e3e74c 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -710,6 +710,8 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp= _sock *msk, return; =20 for (i =3D 0; i < rm_list->nr; i++) { + bool removed =3D false; + list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); int how =3D RCV_SHUTDOWN | SEND_SHUTDOWN; @@ -729,15 +731,19 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mpt= cp_sock *msk, mptcp_close_ssk(sk, ssk, subflow); spin_lock_bh(&msk->pm.lock); =20 - if (rm_type =3D=3D MPTCP_MIB_RMADDR) { - msk->pm.add_addr_accepted--; - WRITE_ONCE(msk->pm.accept_addr, true); - } else if (rm_type =3D=3D MPTCP_MIB_RMSUBFLOW) { - msk->pm.local_addr_used--; - } + removed =3D true; msk->pm.subflows--; __MPTCP_INC_STATS(sock_net(sk), rm_type); } + if (!removed) + continue; + + if (rm_type =3D=3D MPTCP_MIB_RMADDR) { + msk->pm.add_addr_accepted--; + WRITE_ONCE(msk->pm.accept_addr, true); + } else if (rm_type =3D=3D MPTCP_MIB_RMSUBFLOW) { + msk->pm.local_addr_used--; + } } } =20 --=20 2.33.1 From nobody Fri May 3 10:51:09 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp613298jap; Thu, 9 Dec 2021 09:30:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbT/i+CY4+WD3YYTFAVQQShtCox+g4h+ozniF0g0KJXH3u/9xVbO3jkrszlor2iiZUksz5 X-Received: by 2002:a05:620a:1991:: with SMTP id bm17mr14889709qkb.459.1639071057815; Thu, 09 Dec 2021 09:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639071057; cv=none; d=google.com; s=arc-20160816; b=oz/WzsfewltbjH9/WOiUcECHSvch+lNKa5qrBC/HLuba4aILfHuDuCRtZJTiQf//zA 9Yvm9dFlUwW9qwt0rXqTv09Lu9Emu3CAlgIMRw2xdsSog+sNwz04+dVrs/BND7elfulQ N2x/hyDIsYPCz6SL6oNRf1l7jynSfw/a8fOu3g+jRfl6iOFBfaNkDdUTIQv/NbTsDuWB x3Fx48AQIYK0V7VbsNSR/JV8gM0dtkAbK+psdy9SCcVbbNSZ3yorz5flfBe8i4NCoyXU j12x9WtwIHuhwYN5k6ZdQi4yfo364CabzWI5qJ/CLmRBlwyxh+VTvYLZuE4pnA0PZWLI yuUQ== 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=R1mY7UFdQVRSDeafvZWZ10zEPnX1i9Jjr2qNMeJH7g8=; b=atBmqAlze/PQ/iy8Ae3M4Z6QHSxPx/OVb5qDHi7E43+NPeE8m7zGXz9Rrc3YP0bZkF 7Wt5sr/2IYN7PqTNF0EPB204gfgsJ8Ib9IMYxKVBJ9pucbeUMIP3gudTCzyyZxulQU/9 F8yvNkHJXzoXyOHAK3Hp/+NZwGEddqF2Lz543NXeZOyf1rmzEtlMr2DWmgF4DaIKPLf3 Y1xRbAD5lmOboYk6paxrZiYex4fssLirostRPParAndWPyM2iHn4C45NyOz6nfVGdMFk vfFsW2CbeW03/4czKQJthI+N8vbgZKlUU2QdoQG14tt0YUvu1zWR6O9qs4VCaWT/Yx+k jVVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qp5r+Rc1; spf=pass (google.com: domain of mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2702-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. [2604:1380:1000:8100::1]) by mx.google.com with ESMTPS id 14si584850qvf.171.2021.12.09.09.30.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 09:30:57 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) client-ip=2604:1380:1000:8100::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qp5r+Rc1; spf=pass (google.com: domain of mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2702-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 394293E0F1C for ; Thu, 9 Dec 2021 17:30:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AAD32C80; Thu, 9 Dec 2021 17:30:54 +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 D29122CB2 for ; Thu, 9 Dec 2021 17:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639071052; 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=R1mY7UFdQVRSDeafvZWZ10zEPnX1i9Jjr2qNMeJH7g8=; b=Qp5r+Rc1godnRkVgehz/J8pKxv1rKqZG+clJEx3GPsoY6FKmgNjQWjg0IK/M/nQLsVmcQW uEgdGe8ELMx4nzu2Exldr1aag3TmSrxc0xHbgj2JEMfG889UIF/KSbx0KzBlgbnzTvxu6S EL0C3j24hr5Yx25j15UFAkBnENKrpAo= 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-493-gcwnJYkSOqefW-P4erij-w-1; Thu, 09 Dec 2021 12:30:50 -0500 X-MC-Unique: gcwnJYkSOqefW-P4erij-w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3B9481EE61 for ; Thu, 9 Dec 2021 17:30:49 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53B355ED27 for ; Thu, 9 Dec 2021 17:30:49 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next v5 2/5] mptcp: clean-up MPJ option writing. Date: Thu, 9 Dec 2021 18:30:39 +0100 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.79 on 10.5.11.14 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" Check for all MPJ variant at once, this reduces the number of conditionals traversed on average and will simplify the next patch. No functional change intended. Signed-off-by: Paolo Abeni --- net/mptcp/options.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 8a1020e4285c..7a6a39b71633 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1381,27 +1381,29 @@ void mptcp_write_options(__be32 *ptr, const struct = tcp_sock *tp, =20 /* MPC is additionally mutually exclusive with MP_PRIO */ goto mp_capable_done; - } else if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { - *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, - TCPOLEN_MPTCP_MPJ_SYN, - opts->backup, opts->join_id); - put_unaligned_be32(opts->token, ptr); - ptr +=3D 1; - put_unaligned_be32(opts->nonce, ptr); - ptr +=3D 1; - } else if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) { - *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, - TCPOLEN_MPTCP_MPJ_SYNACK, - opts->backup, opts->join_id); - put_unaligned_be64(opts->thmac, ptr); - ptr +=3D 2; - put_unaligned_be32(opts->nonce, ptr); - ptr +=3D 1; - } else if (OPTION_MPTCP_MPJ_ACK & opts->suboptions) { - *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, - TCPOLEN_MPTCP_MPJ_ACK, 0, 0); - memcpy(ptr, opts->hmac, MPTCPOPT_HMAC_LEN); - ptr +=3D 5; + } else if (OPTIONS_MPTCP_MPJ & opts->suboptions) { + if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { + *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, + TCPOLEN_MPTCP_MPJ_SYN, + opts->backup, opts->join_id); + put_unaligned_be32(opts->token, ptr); + ptr +=3D 1; + put_unaligned_be32(opts->nonce, ptr); + ptr +=3D 1; + } else if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) { + *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, + TCPOLEN_MPTCP_MPJ_SYNACK, + opts->backup, opts->join_id); + put_unaligned_be64(opts->thmac, ptr); + ptr +=3D 2; + put_unaligned_be32(opts->nonce, ptr); + ptr +=3D 1; + } else { + *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, + TCPOLEN_MPTCP_MPJ_ACK, 0, 0); + memcpy(ptr, opts->hmac, MPTCPOPT_HMAC_LEN); + ptr +=3D 5; + } } else if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) { u8 len =3D TCPOLEN_MPTCP_ADD_ADDR_BASE; u8 echo =3D MPTCP_ADDR_ECHO; --=20 2.33.1 From nobody Fri May 3 10:51:09 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp613352jap; Thu, 9 Dec 2021 09:31:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYf/VQuoQHb4ApyjisS3fRRdUTiWYod0GYoTPfgQNGHnFDXTS9rOdLFxCHKv04jBCBWpti X-Received: by 2002:a05:6214:240c:: with SMTP id fv12mr18140767qvb.58.1639071060408; Thu, 09 Dec 2021 09:31:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639071060; cv=none; d=google.com; s=arc-20160816; b=I8p8I41vHQax2nVLCFi7LY7mSj7xFm00vSq3UmQneEnA/IXSSk4RyYa2VEG8XvsCb/ zU7kAVLs+6wsqW+oKIu/xdPxbV3dj2+I/knYoGZwowjRdfVF0OO6KkBfDERtSnxlzcbi FnDqQqCB4YeieMT8yBsUJn7Vqokp7XrSqtJ3YBlxJX3GnB0AC3n5Et/r7HHVYXc1b0ne CpU8/LYwIMIM9znhRQ+SgeHOk97Ph6is86Qq0qVX3LoaZjOTPLOVn3/i9I8PXt0xof+d ILcyFXjwupHGrHgmjM+rc82Fq0BPtsREDvJ8RIgZ4JB9r8oHlwpGFAASF5imv4WBeMGW 0Dtg== 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=Ohl5zYsWNwYXRSsrQGQXr/HuIfGyhAAwQj0p4h6+CCo=; b=oYm8r9iccvljBwflj1fPGjSAC7wf8dpaMJ6yQg++8KSFKgrQuPuxJtQqLW/aNH9oaZ BrR5i+Y8jl9iKzomfeRxbG4YwYB3rGnDji1r4LNAGUOk5dAtBAU+/JGIWWHtzYWhY0aT JgcPLc5Go9BuICR2A0KWwH9bkEBjol1EpbJrjMNPW2aLMi4onQHzCgljvWCCi9EwMEUO Z/M39rGrz4Lztb2g2kCu7SFr4lpTueLiJA7ZSH7PhQxEW9oEh6N6NB+Q85WpmWiNxGyP KruzFtu6OSk+eAgjohMLxlftLa8wcnsb4PxORYN+/2vizP5JqVBbgcGg/i/9UV20iNVU uplQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CJ69ztbc; spf=pass (google.com: domain of mptcp+bounces-2704-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) smtp.mailfrom="mptcp+bounces-2704-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. [147.75.197.195]) by mx.google.com with ESMTPS id z3si496336qtj.557.2021.12.09.09.31.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 09:31:00 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2704-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) client-ip=147.75.197.195; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CJ69ztbc; spf=pass (google.com: domain of mptcp+bounces-2704-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) smtp.mailfrom="mptcp+bounces-2704-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 2058D1C0652 for ; Thu, 9 Dec 2021 17:31:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 535C22C9E; Thu, 9 Dec 2021 17:30:57 +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 B75D32CB6 for ; Thu, 9 Dec 2021 17:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639071054; 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=Ohl5zYsWNwYXRSsrQGQXr/HuIfGyhAAwQj0p4h6+CCo=; b=CJ69ztbcy8x6T/fhjyDKcthox9xfMR65ZG5bJLHKrLTkMbv9W/yuzwiDAJYnGkZX+B2Dgt RSCBz8l0PmE0LTj+qATHTSzlzzReTmgr1/TwiWZslk48n5VzNPAby12MLxjXnGIWGFZhO+ ba5otADuKioYfU0LobpxFUnv3BBPYRs= 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-517-qeha2MslM06uI9NpLgZU_g-1; Thu, 09 Dec 2021 12:30:51 -0500 X-MC-Unique: qeha2MslM06uI9NpLgZU_g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D922C190A7A0 for ; Thu, 9 Dec 2021 17:30:50 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C2CF5ED27 for ; Thu, 9 Dec 2021 17:30:50 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next v5 3/5] mptcp: keep track of local endpoint still available for each msk Date: Thu, 9 Dec 2021 18:30:40 +0100 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.79 on 10.5.11.14 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" Include into the path manager status a bitmap tracking the list of local endpoints still available - not yet used - for the relavant mptcp socket. Keep such map updated at endpoint creation/deleteion time, so that we can easily skip already used endpoint at local address selection time. The endpoint used by the initial subflow is lazyly accounted at subflow creation time: the usage bitmap is be up2date before endpoint selection and we avoid such unneeded task in some relevant scenarions - e.g. busy servers accepting incoming subflows but not creating any additional ones nor annuncing additional addresses. Overall this allows for fair local endpoints usage in case of subflow failure. As a side effect, this patch also enforces that each endpoint is used at most once for each mptcp connection. Signed-off-by: Paolo Abeni --- v4 -> v5: - track MPC subflow, too - update self-tests accordingly v3 -> v4: - track the available (not yet used) id instead of the used ones - track both - cleanup duplication with id_bitmap --- net/mptcp/pm.c | 1 + net/mptcp/pm_netlink.c | 116 +++++++++++------- net/mptcp/protocol.c | 3 +- net/mptcp/protocol.h | 11 +- .../testing/selftests/net/mptcp/mptcp_join.sh | 5 +- 5 files changed, 86 insertions(+), 50 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 761995a34124..d6d22f18c418 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -376,6 +376,7 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) WRITE_ONCE(msk->pm.accept_subflow, false); WRITE_ONCE(msk->pm.remote_deny_join_id0, false); msk->pm.status =3D 0; + bitmap_fill(msk->pm.id_avail_bitmap, MAX_ADDR_ID + 1); =20 mptcp_pm_nl_data_init(msk); } diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d18b13e3e74c..1be7f92e9fc8 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -38,9 +38,6 @@ struct mptcp_pm_add_entry { u8 retrans_times; }; =20 -#define MAX_ADDR_ID 255 -#define BITMAP_SZ DIV_ROUND_UP(MAX_ADDR_ID + 1, BITS_PER_LONG) - struct pm_nl_pernet { /* protects pernet updates */ spinlock_t lock; @@ -52,14 +49,14 @@ struct pm_nl_pernet { unsigned int local_addr_max; unsigned int subflows_max; unsigned int next_id; - unsigned long id_bitmap[BITMAP_SZ]; + DECLARE_BITMAP(id_bitmap, MAX_ADDR_ID + 1); }; =20 #define MPTCP_PM_ADDR_MAX 8 #define ADD_ADDR_RETRANS_MAX 3 =20 static bool addresses_equal(const struct mptcp_addr_info *a, - struct mptcp_addr_info *b, bool use_port) + const struct mptcp_addr_info *b, bool use_port) { bool addr_equals =3D false; =20 @@ -173,6 +170,9 @@ select_local_address(const struct pm_nl_pernet *pernet, if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) continue; =20 + if (!test_bit(entry->addr.id, msk->pm.id_avail_bitmap)) + continue; + if (entry->addr.family !=3D sk->sk_family) { #if IS_ENABLED(CONFIG_MPTCP_IPV6) if ((entry->addr.family =3D=3D AF_INET && @@ -183,23 +183,17 @@ select_local_address(const struct pm_nl_pernet *perne= t, continue; } =20 - /* avoid any address already in use by subflows and - * pending join - */ - if (!lookup_subflow_by_saddr(&msk->conn_list, &entry->addr)) { - ret =3D entry; - break; - } + ret =3D entry; + break; } rcu_read_unlock(); return ret; } =20 static struct mptcp_pm_addr_entry * -select_signal_address(struct pm_nl_pernet *pernet, unsigned int pos) +select_signal_address(struct pm_nl_pernet *pernet, struct mptcp_sock *msk) { struct mptcp_pm_addr_entry *entry, *ret =3D NULL; - int i =3D 0; =20 rcu_read_lock(); /* do not keep any additional per socket state, just signal @@ -208,12 +202,14 @@ select_signal_address(struct pm_nl_pernet *pernet, un= signed int pos) * can lead to additional addresses not being announced. */ list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { + if (!test_bit(entry->addr.id, msk->pm.id_avail_bitmap)) + continue; + if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) continue; - if (i++ =3D=3D pos) { - ret =3D entry; - break; - } + + ret =3D entry; + break; } rcu_read_unlock(); return ret; @@ -257,9 +253,11 @@ EXPORT_SYMBOL_GPL(mptcp_pm_get_local_addr_max); =20 static void check_work_pending(struct mptcp_sock *msk) { - if (msk->pm.add_addr_signaled =3D=3D mptcp_pm_get_add_addr_signal_max(msk= ) && - (msk->pm.local_addr_used =3D=3D mptcp_pm_get_local_addr_max(msk) || - msk->pm.subflows =3D=3D mptcp_pm_get_subflows_max(msk))) + struct pm_nl_pernet *pernet =3D net_generic(sock_net((struct sock *)msk),= pm_nl_pernet_id); + + if (msk->pm.subflows =3D=3D mptcp_pm_get_subflows_max(msk) || + (find_next_and_bit(pernet->id_bitmap, msk->pm.id_avail_bitmap, MAX_AD= DR_ID + 1, 0) =3D=3D + MAX_ADDR_ID + 1)) WRITE_ONCE(msk->pm.work_pending, false); } =20 @@ -459,6 +457,35 @@ static unsigned int fill_remote_addresses_vec(struct m= ptcp_sock *msk, bool fullm return i; } =20 +static struct mptcp_pm_addr_entry * +__lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &pernet->local_addr_list, list) { + if (entry->addr.id =3D=3D id) + return entry; + } + return NULL; +} + +static int +lookup_id_by_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_inf= o *addr) +{ + struct mptcp_pm_addr_entry *entry; + int ret =3D -1; + + rcu_read_lock(); + list_for_each_entry(entry, &pernet->local_addr_list, list) { + if (addresses_equal(&entry->addr, addr, entry->addr.port)) { + ret =3D entry->addr.id; + break; + } + } + rcu_read_unlock(); + return ret; +} + static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) { struct sock *sk =3D (struct sock *)msk; @@ -474,6 +501,19 @@ static void mptcp_pm_create_subflow_or_signal_addr(str= uct mptcp_sock *msk) local_addr_max =3D mptcp_pm_get_local_addr_max(msk); subflows_max =3D mptcp_pm_get_subflows_max(msk); =20 + /* do lazy endpoint usage accounting for the MPC subflows */ + if (unlikely(!(msk->pm.status & BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED))) &&= msk->first) { + struct mptcp_addr_info local; + int mpc_id; + + local_address((struct sock_common *)msk->first, &local); + mpc_id =3D lookup_id_by_addr(pernet, &local); + if (mpc_id < 0) + __clear_bit(mpc_id, msk->pm.id_avail_bitmap); + + msk->pm.status |=3D BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED); + } + pr_debug("local %d:%d signal %d:%d subflows %d:%d\n", msk->pm.local_addr_used, local_addr_max, msk->pm.add_addr_signaled, add_addr_signal_max, @@ -481,21 +521,16 @@ static void mptcp_pm_create_subflow_or_signal_addr(st= ruct mptcp_sock *msk) =20 /* check first for announce */ if (msk->pm.add_addr_signaled < add_addr_signal_max) { - local =3D select_signal_address(pernet, - msk->pm.add_addr_signaled); + local =3D select_signal_address(pernet, msk); =20 if (local) { if (mptcp_pm_alloc_anno_list(msk, local)) { + __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); msk->pm.add_addr_signaled++; mptcp_pm_announce_addr(msk, &local->addr, false); mptcp_pm_nl_addr_send_ack(msk); } - } else { - /* pick failed, avoid fourther attempts later */ - msk->pm.local_addr_used =3D add_addr_signal_max; } - - check_work_pending(msk); } =20 /* check if should create a new subflow */ @@ -509,19 +544,16 @@ static void mptcp_pm_create_subflow_or_signal_addr(st= ruct mptcp_sock *msk) int i, nr; =20 msk->pm.local_addr_used++; - check_work_pending(msk); nr =3D fill_remote_addresses_vec(msk, fullmesh, addrs); + if (nr) + __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); spin_unlock_bh(&msk->pm.lock); for (i =3D 0; i < nr; i++) __mptcp_subflow_connect(sk, &local->addr, &addrs[i]); spin_lock_bh(&msk->pm.lock); - return; } - - /* lookup failed, avoid fourther attempts later */ - msk->pm.local_addr_used =3D local_addr_max; - check_work_pending(msk); } + check_work_pending(msk); } =20 static void mptcp_pm_nl_fully_established(struct mptcp_sock *msk) @@ -735,6 +767,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp= _sock *msk, msk->pm.subflows--; __MPTCP_INC_STATS(sock_net(sk), rm_type); } + __set_bit(rm_list->ids[1], msk->pm.id_avail_bitmap); if (!removed) continue; =20 @@ -764,6 +797,9 @@ void mptcp_pm_nl_work(struct mptcp_sock *msk) =20 msk_owned_by_me(msk); =20 + if (!(pm->status & MPTCP_PM_WORK_MASK)) + return; + spin_lock_bh(&msk->pm.lock); =20 pr_debug("msk=3D%p status=3D%x", msk, pm->status); @@ -1197,18 +1233,6 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb= , struct genl_info *info) return 0; } =20 -static struct mptcp_pm_addr_entry * -__lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id) -{ - struct mptcp_pm_addr_entry *entry; - - list_for_each_entry(entry, &pernet->local_addr_list, list) { - if (entry->addr.id =3D=3D id) - return entry; - } - return NULL; -} - int mptcp_pm_get_flags_and_ifindex_by_id(struct net *net, unsigned int id, u8 *flags, int *ifindex) { diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 4a8f2476cc75..63602c68f03d 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2508,8 +2508,7 @@ static void mptcp_worker(struct work_struct *work) =20 mptcp_check_fastclose(msk); =20 - if (msk->pm.status) - mptcp_pm_nl_work(msk); + mptcp_pm_nl_work(msk); =20 if (test_and_clear_bit(MPTCP_WORK_EOF, &msk->flags)) mptcp_check_for_eof(msk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 47d24478763c..e63fe60f70b8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -173,16 +173,24 @@ enum mptcp_pm_status { MPTCP_PM_ADD_ADDR_SEND_ACK, MPTCP_PM_RM_ADDR_RECEIVED, MPTCP_PM_ESTABLISHED, - MPTCP_PM_ALREADY_ESTABLISHED, /* persistent status, set after ESTABLISHED= event */ MPTCP_PM_SUBFLOW_ESTABLISHED, + MPTCP_PM_ALREADY_ESTABLISHED, /* persistent status, set after ESTABLISHED= event */ + MPTCP_PM_MPC_ENDPOINT_ACCOUNTED /* persistent status, set after MPC local= address is + * accounted int id_avail_bitmap + */ }; =20 +/* Status bits below MPTCP_PM_ALREADY_ESTABLISHED need pm worker actions */ +#define MPTCP_PM_WORK_MASK ((1 << MPTCP_PM_ALREADY_ESTABLISHED) - 1) + enum mptcp_addr_signal_status { MPTCP_ADD_ADDR_SIGNAL, MPTCP_ADD_ADDR_ECHO, MPTCP_RM_ADDR_SIGNAL, }; =20 +#define MAX_ADDR_ID 255 + struct mptcp_pm_data { struct mptcp_addr_info local; struct mptcp_addr_info remote; @@ -201,6 +209,7 @@ struct mptcp_pm_data { u8 local_addr_used; u8 subflows; u8 status; + DECLARE_BITMAP(id_avail_bitmap, MAX_ADDR_ID + 1); struct mptcp_rm_list rm_list_tx; struct mptcp_rm_list rm_list_rx; }; diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 2684ef9c0d42..526b05771d08 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -1109,7 +1109,10 @@ signal_address_tests() ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags signal ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags signal run_tests $ns1 $ns2 10.0.1.1 - chk_add_nr 4 4 + + # the server will not signal the address teminating + # the MPC subflow + chk_add_nr 3 3 } =20 link_failure_tests() --=20 2.33.1 From nobody Fri May 3 10:51:09 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp613331jap; Thu, 9 Dec 2021 09:30:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrDP3QbazAU/0Dm4k7j6gfdPl9Pwi/buYGR95ngd0J7CdUIuIGczZZYTgrxIUuiT9sAJQg X-Received: by 2002:ac8:5756:: with SMTP id 22mr19216082qtx.370.1639071059324; Thu, 09 Dec 2021 09:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639071059; cv=none; d=google.com; s=arc-20160816; b=kFLmOj21DWB+EZcCal1j8PPUQUN9AoPpGRjWzpuxKfHIbWeSCOtABoPEpk1M3caFmm 4NN+smIAGf5BRPnxmW66rTeFUngooGHoclBfFQSBVenQtPwSNICEdD2JDjJgdryPU8cn dYdBcx2iSZEcb7B7bfoiGj1mUdRQdtiyra1E5ecWiU/zdHp3+1Ack8kXD0DARmuGLMB2 ww0A8SWeqIW3DfUygYKIH9mz5/jMpDsgmHLw+pFjv0yGnahhHuFmZapVdux6KUbC2uBy hhH7F/1ABsBHB5Ly4jTjPW/gZWImhfU++H1KXhGt2GzqplYeGMUFU4238NxUzGw+oUxl VAwA== 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=bP+3KtDR0QxbzwJnnoMEg83kww9Zzm5gGT0L2smBgTI=; b=IJEfmYTxzfaEJ3ZtDN8kbru0xj3XE+ApnmT7Zw6TbmgqqODdqW+2qQK1MoUzdXztR6 zTy7a9xq3mkh3WOxA912kShxX5TtfNyjmNntl/s1g75Y3Nw1D+H4nuhDYBhPwdI5BuQ/ t0G6fv14VC7xiK5uDUeYhqliob+IS2dcxYDHpK4jjBWL3XenEHDf3d1fXWDnud5asfWv lVZy0MNjP+N3VRxduimJ8IdfLj9lAoXlPY7VHsinztJIJdrGbktU93GCuJvB/0qbsCdv YKyfkuK36ez6t7gJ+rtEu5xGRJPLoB/2ijEgI/6PiEdc8FdY/l6vsvi2eGaU7+wzfHFK T0Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R8QpnlL3; spf=pass (google.com: domain of mptcp+bounces-2703-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2703-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 t5si619635qkp.108.2021.12.09.09.30.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 09:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2703-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=R8QpnlL3; spf=pass (google.com: domain of mptcp+bounces-2703-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2703-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 C82721C0AF3 for ; Thu, 9 Dec 2021 17:30:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE46A2CB3; Thu, 9 Dec 2021 17:30:56 +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 ED8652CB2 for ; Thu, 9 Dec 2021 17:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639071054; 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=bP+3KtDR0QxbzwJnnoMEg83kww9Zzm5gGT0L2smBgTI=; b=R8QpnlL3opCvC4x8fmdPDfBms0cPdnz1ds+jBJG+hb5FE/EBWgQuyJgg/YkhgDaMFUUvH7 T8BuFMhG2YjGqgrFm1FJj3ExCLu1FtqZ5XWdR++Lu4MyJmkpmcclCKfjObDWcrCQzO6q9W Ws75tySWplg2T7kUuxJDp+Z5OTLyPWc= 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-274-YVW93C2hMnuSOPazGtxAuA-1; Thu, 09 Dec 2021 12:30:52 -0500 X-MC-Unique: YVW93C2hMnuSOPazGtxAuA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D439A14755 for ; Thu, 9 Dec 2021 17:30:51 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F4405E275 for ; Thu, 9 Dec 2021 17:30:51 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next v5 4/5] mptcp: do not block subflows creation on errors Date: Thu, 9 Dec 2021 18:30:41 +0100 Message-Id: <9b71adc2d81f4eff820862dfcd3ba32d31ac520b.1639070864.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.14 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" If the MPTCP configuration allows for multiple subflows creation, and the first additional subflows never reach the fully established status - e.g. due to packets drop or reset - the in kernel path manager do not move to the next subflow. This patch introduces a new PM helper to cope with MPJ subflow creation failure and delay and hook it where appropriate. Such helper triggers additional subflow creation, as needed and updates the PM subflow counter, if the current one is closing. Note that we don't need an additional timer to catch timeout and/or long delay in connection completion: we just need to measure the time elapsed since the subflow creation every time we emit an MPJ sub-option. Signed-off-by: Paolo Abeni --- v3 -> v4: - fix 'subflows' underflow v2 -> v3: - fix compile warning (CI) v1 -> v2: - explicitly hook on subflow close instead of error notification - fix checkpatch issue (Mat) - introduce and use a new pm helper to cope with subflow close - update pm subflow counters on close --- net/mptcp/options.c | 21 ++++++++++++++++++--- net/mptcp/pm.c | 23 +++++++++++++++++++++-- net/mptcp/pm_netlink.c | 20 ++++++++++++-------- net/mptcp/protocol.c | 6 ++++++ net/mptcp/protocol.h | 5 ++++- net/mptcp/subflow.c | 5 ++++- 6 files changed, 65 insertions(+), 15 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 7a6a39b71633..00a8697addcd 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1257,10 +1257,10 @@ static u16 mptcp_make_csum(const struct mptcp_ext *= mpext) void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, struct mptcp_out_options *opts) { - if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { - const struct sock *ssk =3D (const struct sock *)tp; - struct mptcp_subflow_context *subflow; + const struct sock *ssk =3D (const struct sock *)tp; + struct mptcp_subflow_context *subflow; =20 + if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { subflow =3D mptcp_subflow_ctx(ssk); subflow->send_mp_fail =3D 0; =20 @@ -1382,6 +1382,21 @@ void mptcp_write_options(__be32 *ptr, const struct t= cp_sock *tp, /* MPC is additionally mutually exclusive with MP_PRIO */ goto mp_capable_done; } else if (OPTIONS_MPTCP_MPJ & opts->suboptions) { + if (ssk) { + /* we are still in the MPJ handshake and "a lot" of time passed + * e.g. due to syn retranmissions. We can attempt next + * subflow creation + */ + subflow =3D mptcp_subflow_ctx(ssk); + if (subflow->start_stamp && + unlikely(after(tcp_jiffies32, subflow->start_stamp + HZ / 10))) { + mptcp_pm_subflow_check_next(mptcp_sk(subflow->conn), ssk, subflow); + + /* avoid triggering the PM multiple times due to timeout */ + subflow->start_stamp =3D 0; + } + } + if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, TCPOLEN_MPTCP_MPJ_SYN, diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index d6d22f18c418..7e2c76924492 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -172,9 +172,28 @@ void mptcp_pm_subflow_established(struct mptcp_sock *m= sk) spin_unlock_bh(&pm->lock); } =20 -void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id) +void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock= *ssk, + const struct mptcp_subflow_context *subflow) { - pr_debug("msk=3D%p", msk); + struct mptcp_pm_data *pm =3D &msk->pm; + bool update_subflows; + + update_subflows =3D (ssk->sk_state =3D=3D TCP_CLOSE) && + (subflow->request_join || subflow->mp_join); + if (!READ_ONCE(pm->work_pending) && !update_subflows) + return; + + spin_lock_bh(&pm->lock); + if (update_subflows) + pm->subflows--; + + /* Even if this subflow is not really established, tell the PM to try + * to pick the next one, if possible. + */ + if (mptcp_pm_nl_check_work_pending(msk)) + mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED); + + spin_unlock_bh(&pm->lock); } =20 void mptcp_pm_add_addr_received(struct mptcp_sock *msk, diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 1be7f92e9fc8..d908c0a0477b 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -251,14 +251,17 @@ unsigned int mptcp_pm_get_local_addr_max(struct mptcp= _sock *msk) } EXPORT_SYMBOL_GPL(mptcp_pm_get_local_addr_max); =20 -static void check_work_pending(struct mptcp_sock *msk) +bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk) { struct pm_nl_pernet *pernet =3D net_generic(sock_net((struct sock *)msk),= pm_nl_pernet_id); =20 if (msk->pm.subflows =3D=3D mptcp_pm_get_subflows_max(msk) || (find_next_and_bit(pernet->id_bitmap, msk->pm.id_avail_bitmap, MAX_AD= DR_ID + 1, 0) =3D=3D - MAX_ADDR_ID + 1)) + MAX_ADDR_ID + 1)) { WRITE_ONCE(msk->pm.work_pending, false); + return false; + } + return true; } =20 struct mptcp_pm_add_entry * @@ -503,12 +506,12 @@ static void mptcp_pm_create_subflow_or_signal_addr(st= ruct mptcp_sock *msk) =20 /* do lazy endpoint usage accounting for the MPC subflows */ if (unlikely(!(msk->pm.status & BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED))) &&= msk->first) { - struct mptcp_addr_info local; + struct mptcp_addr_info mpc_addr; int mpc_id; =20 - local_address((struct sock_common *)msk->first, &local); - mpc_id =3D lookup_id_by_addr(pernet, &local); - if (mpc_id < 0) + local_address((struct sock_common *)msk->first, &mpc_addr); + mpc_id =3D lookup_id_by_addr(pernet, &mpc_addr); + if (mpc_id >=3D 0) __clear_bit(mpc_id, msk->pm.id_avail_bitmap); =20 msk->pm.status |=3D BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED); @@ -553,7 +556,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(stru= ct mptcp_sock *msk) spin_lock_bh(&msk->pm.lock); } } - check_work_pending(msk); + mptcp_pm_nl_check_work_pending(msk); } =20 static void mptcp_pm_nl_fully_established(struct mptcp_sock *msk) @@ -760,11 +763,12 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mpt= cp_sock *msk, i, rm_list->ids[i], subflow->local_id, subflow->remote_id); spin_unlock_bh(&msk->pm.lock); mptcp_subflow_shutdown(sk, ssk, how); + + /* the following takes care of updating the subflows counter */ mptcp_close_ssk(sk, ssk, subflow); spin_lock_bh(&msk->pm.lock); =20 removed =3D true; - msk->pm.subflows--; __MPTCP_INC_STATS(sock_net(sk), rm_type); } __set_bit(rm_list->ids[1], msk->pm.id_avail_bitmap); diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 63602c68f03d..aa0a1fe749d9 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2351,6 +2351,12 @@ void mptcp_close_ssk(struct sock *sk, struct sock *s= sk, { if (sk->sk_state =3D=3D TCP_ESTABLISHED) mptcp_event(MPTCP_EVENT_SUB_CLOSED, mptcp_sk(sk), ssk, GFP_KERNEL); + + /* subflow aborted before reaching the fully_established status + * attempt the creation of the next subflow + */ + mptcp_pm_subflow_check_next(mptcp_sk(sk), ssk, subflow); + __mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_PUSH); } =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index e63fe60f70b8..bd1165189233 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -443,6 +443,7 @@ struct mptcp_subflow_context { stale : 1; /* unable to snd/rcv data, do not use for xmit */ enum mptcp_data_avail data_avail; u32 remote_nonce; + u32 start_stamp; u64 thmac; u32 local_nonce; u32 remote_token; @@ -744,7 +745,9 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk,= const struct sock *ssk, bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk); void mptcp_pm_connection_closed(struct mptcp_sock *msk); void mptcp_pm_subflow_established(struct mptcp_sock *msk); -void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id); +bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk); +void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock= *ssk, + const struct mptcp_subflow_context *subflow); void mptcp_pm_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 0f90bd61de01..76556743e952 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1273,7 +1273,8 @@ void __mptcp_error_report(struct sock *sk) =20 static void subflow_error_report(struct sock *ssk) { - struct sock *sk =3D mptcp_subflow_ctx(ssk)->conn; + struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); + struct sock *sk =3D subflow->conn; =20 mptcp_data_lock(sk); if (!sock_owned_by_user(sk)) @@ -1444,6 +1445,7 @@ int __mptcp_subflow_connect(struct sock *sk, const st= ruct mptcp_addr_info *loc, subflow->remote_id =3D remote_id; subflow->request_join =3D 1; subflow->request_bkup =3D !!(flags & MPTCP_PM_ADDR_FLAG_BACKUP); + subflow->start_stamp =3D tcp_jiffies32; mptcp_info2sockaddr(remote, &addr, ssk->sk_family); =20 mptcp_add_pending_subflow(msk, subflow); @@ -1461,6 +1463,7 @@ int __mptcp_subflow_connect(struct sock *sk, const st= ruct mptcp_addr_info *loc, spin_lock_bh(&msk->join_list_lock); list_del(&subflow->node); spin_unlock_bh(&msk->join_list_lock); + mptcp_pm_subflow_check_next(msk, ssk, subflow); sock_put(mptcp_subflow_tcp_sock(subflow)); =20 failed: --=20 2.33.1 From nobody Fri May 3 10:51:09 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp613370jap; Thu, 9 Dec 2021 09:31:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn4qoJyiEX6+ICNtDDgO8+nqHPVna6wXs+28Hd0NC0dwrXDc5Taz5JAo1cGCKHqBinOcpX X-Received: by 2002:ad4:594f:: with SMTP id eo15mr18057000qvb.102.1639071061370; Thu, 09 Dec 2021 09:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639071061; cv=none; d=google.com; s=arc-20160816; b=opa5joxVAvO1i5qoWAC16UjYstnKFMTy/GnHV1AOZRvbucSb4rvPECx76E7s0MwfsA N0sD8+6RqR30WowdeC5Yh7jI/C+TzFZS/OJj1e7dqXLr61v9wuSJP2xdU+FCaNklhbWy AIfHj8e2TdVuG8p8DVNaO2a8yr7v1MXxd2zbVTxYwp19W46S65zidp78gM04cPRxbKOm taUA7efn7CaDLG2rz72z8xveO87TeX+Rof5D9vR9s9w8GM1qHn8gMXwNfGiTdoI5U0Vz fD0XC1WDuzELm3CPl5M8PX+5wkNP7UK8uK+dzll3MWXrp1HfG38irSjjBBjOdDE2MV0e wlsQ== 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=JUbHfEkBVZFqyfcVCTKPBzllnLy+pacN825Gg+lW4E8=; b=v5KNXjHQH7l0qbPmCUNbnQPipFFWBd8zfCLEqQDbun2Bh1Yg+rDwoba3hAtuM9AjWa OnG+BO13lnDrSNVOcdJiB/RNIs0uxpglB0RuprJWTYgGutPVmFRmc5ZJCeAkuhMu5AZZ hqX2kNMFmBRaIp0zRrN39B1VCVh75VkevNe41nZUmUKr4irvKviunjy1lR69SgdtoPdX R07Yn5kp8eJgT707aus0e6S5vWgAXTLBczxYm4kA51u0SnAcKphkRXzpfoR2xUuhmEro WFHWHjoAWss4Eppen00OQintGCdrOPBHfhw9ITT22RoyPxXAiRKgItxO99+geN9nnmoU W4qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GJJaH4Vc; spf=pass (google.com: domain of mptcp+bounces-2705-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2705-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 u9si342828qtx.777.2021.12.09.09.31.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 09:31:01 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2705-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=GJJaH4Vc; spf=pass (google.com: domain of mptcp+bounces-2705-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2705-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 1E4BA1C0AD6 for ; Thu, 9 Dec 2021 17:31:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 530202C80; Thu, 9 Dec 2021 17:30:59 +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 D7C072CB2 for ; Thu, 9 Dec 2021 17:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639071057; 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=JUbHfEkBVZFqyfcVCTKPBzllnLy+pacN825Gg+lW4E8=; b=GJJaH4VcCbgtfjsJqH+XL9mwrkO3VOncEcsdWI+2b3IWy2U56o7XT7kZZaje0wleQ6wgGt Et6dokTuNNGyMPUj/ZtCEydTZY3uv5bAiLCZeHDbsOYgxIWI4uljl7aq3LbmyrRA0UJGRL EyhvhR0HRFGY55eWuPu32KOlRyRvR0E= 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-360-VeUaO0LTN4uK6IM-aMj3Zw-1; Thu, 09 Dec 2021 12:30:53 -0500 X-MC-Unique: VeUaO0LTN4uK6IM-aMj3Zw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C4A52190A7A0 for ; Thu, 9 Dec 2021 17:30:52 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 352A55E26C for ; Thu, 9 Dec 2021 17:30:52 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next v5 5/5] selftests: mptcp: add tests for subflow creation failure Date: Thu, 9 Dec 2021 18:30:42 +0100 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.79 on 10.5.11.14 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" Verify that, when multiple endpoints are available, subflows creation proceed even when the first additional subflow creation fails - due to packet drop on the relevant link Signed-off-by: Paolo Abeni --- v4 -> v5: - new test checking for wrong MPC reuse v3 -> v4: - use $() where applicable - Matt - fix typo in help() - Matt v1 -> v2: - add missing NF kconfig - add more test-cases (drop, later subflow creation) --- tools/testing/selftests/net/mptcp/config | 1 + .../testing/selftests/net/mptcp/mptcp_join.sh | 74 ++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/config b/tools/testing/selft= ests/net/mptcp/config index 419e71560fd1..41e94e004bdc 100644 --- a/tools/testing/selftests/net/mptcp/config +++ b/tools/testing/selftests/net/mptcp/config @@ -18,4 +18,5 @@ CONFIG_NFT_TPROXY=3Dm CONFIG_NFT_SOCKET=3Dm CONFIG_IP_ADVANCED_ROUTER=3Dy CONFIG_IP_MULTIPLE_TABLES=3Dy +CONFIG_IP_NF_TARGET_REJECT=3Dm CONFIG_IPV6_MULTIPLE_TABLES=3Dy diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 526b05771d08..8f49bbd4a201 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -975,6 +975,22 @@ chk_link_usage() fi } =20 +wait_for_tw() +{ + local timeout_ms=3D$((timeout_poll * 1000)) + local time=3D0 + local ns=3D$1 + + while [ $time -lt $timeout_ms ]; do + local cnt=3D$(ip netns exec $ns ss -t state time-wait |wc -l) + + [ "$cnt" =3D 1 ] && return 1 + time=3D$((time + 100)) + sleep 0.1 + done + return 1 +} + subflows_tests() { reset @@ -1032,6 +1048,57 @@ subflows_tests() chk_join_nr "single subflow, dev" 1 1 1 } =20 +subflows_error_tests() +{ + # If a single subflow is configured, and matches the MPC src + # address, no additional subflow should be created + reset + ip netns exec $ns1 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.1.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr "no MPC address reuse with single endpoint" 0 0 0 + + # multiple subflows, with subflow creation error + reset + ip netns exec $ns1 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow + ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr "multiple subflows, with failing subflow" 1 1 1 + + # multiple subflows, with subflow timeout on MPJ + reset + ip netns exec $ns1 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow + ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j DROP + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr "multiple subflows, with subflow timeout" 1 1 1 + + # multiple subflows, check that the endpoint corresponding to + # closed subflow (due to reset) is not reused if additional + # subflows are added later + reset + ip netns exec $ns1 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + ip netns exec $ns1 iptables -A INPUT -s 10.0.3.2 -p tcp -j REJECT + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & + + # mpj subflow will be in TW after the reset + wait_for_tw $ns2 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow + wait + + # additional subflow could be created only if the PM select + # the later endpoint, skipping the already used one + chk_join_nr "multiple subflows, fair usage on close" 1 1 1 +} + signal_address_tests() { # add_address, unused @@ -1843,6 +1910,7 @@ fullmesh_tests() all_tests() { subflows_tests + subflows_error_tests signal_address_tests link_failure_tests add_addr_timeout_tests @@ -1862,6 +1930,7 @@ usage() { echo "mptcp_join usage:" echo " -f subflows_tests" + echo " -e subflows_error_tests" echo " -s signal_address_tests" echo " -l link_failure_tests" echo " -t add_addr_timeout_tests" @@ -1910,11 +1979,14 @@ if [ $do_all_tests -eq 1 ]; then exit $ret fi =20 -while getopts 'fsltra64bpkdmchCS' opt; do +while getopts 'fesltra64bpkdmchCS' opt; do case $opt in f) subflows_tests ;; + e) + subflows_error_tests + ;; s) signal_address_tests ;; --=20 2.33.1