From nobody Sun May 5 07:59:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp1803419jap; Fri, 26 Nov 2021 04:19:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPH6pdB42GYIEMqQYwus30XNkgoduslvrNwRoXYiI7U4mL2G00sBUACFqS2uKNT7kW8FFa X-Received: by 2002:a37:a1c1:: with SMTP id k184mr21687663qke.383.1637929164571; Fri, 26 Nov 2021 04:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637929164; cv=none; d=google.com; s=arc-20160816; b=reXg8nkQj78cjw/SuiSk9eBPUVB90dVG/XNEaqfDuqCwpu8TlHRfTd4TUdi+S17GzC djtm//CDJQ6xDAo9X9+09ja5nTR2VLZsvCI52q7TyU1up5GkKkWkuoYB+/zIX7EcQdjd D7W0170q+Sjguc9WlIMPJHu3Ywj47hMgVsDZOi9q+bpKq1KsorsPJ/U0upJ66T8JUN0k YO45knNjPxpD+UDiWz3Vh8cKkCgsBjOmFrq59elp1v8XzE+N9JEGQ1UuG7iViDm+bfbf /C++PSAFFOGuqo4leDP28SgbL56T+0bSWUw4eKD/lDMjHh8VE8rBZb8CseZP19JFQF2P KpGQ== 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=dcyf93AGfyAaWdvrQtDodflQSv6ui3nybnWDu91YulS74R3s+9shMtSjeGzNJS+TQY u+Kx70GGjRMH2fo64X47ep7Iq5Vb2RPzOH5C/HnzbYL+QxhNvRqx35ww8ou2HbmYn+Mm BaoTJO+ujcp21PmqQP2GgIn+CBwDhFNeW7u8l4DclCKeAj+UL/5L84pD9mTIxjR1rYsw ukR+iZdrZSzPpUMC8vwJovUVT0HY6UTGOFiiOMpQSfy/iJp85+6Ni4q+vF5L/G/+iiEk RylYy/D/d83IyUbb2MSEhcZkA7y+f1TEaV5CbkZLsI02izar+KOKzXGkvJMD2X2fUSt5 JAvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GO7Ml9aH; spf=pass (google.com: domain of mptcp+bounces-2547-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2547-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 i15si9157516vsf.786.2021.11.26.04.19.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Nov 2021 04:19:24 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2547-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=GO7Ml9aH; spf=pass (google.com: domain of mptcp+bounces-2547-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2547-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 59D5F3E10F4 for ; Fri, 26 Nov 2021 12:19:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5547C29CA; Fri, 26 Nov 2021 12:19:22 +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 08B3968 for ; Fri, 26 Nov 2021 12:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637929159; 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=GO7Ml9aHj+ygx41N+xlXuBLeJ6ug+xlFZhNKVvKNISvaRvsBhSZQz+ONTmcuQTW6T99IdB fKieJysQxtGx6kogYMuuitpm3QO+Z40fIRNILrh30TOEpGGjHrWsw1EQAW+BKHgX2tSdzz cW1L20RG3AL2b8BDKArmaSn7MB+II84= 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-333-n9g8yoW8NmS5EXB1h1KpiQ-1; Fri, 26 Nov 2021 07:19:18 -0500 X-MC-Unique: n9g8yoW8NmS5EXB1h1KpiQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 02BBD1006AA0 for ; Fri, 26 Nov 2021 12:19:18 +0000 (UTC) Received: from gerbillo.fritz.box (unknown [10.39.194.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6600A19C46 for ; Fri, 26 Nov 2021 12:19:17 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 mptcp-next 1/4] mptcp: clean-up MPJ option writing. Date: Fri, 26 Nov 2021 13:19:06 +0100 Message-Id: <4c5e9cc2a8997673798166249b66fef891fe9938.1637929034.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.84 on 10.5.11.23 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 Sun May 5 07:59:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp1803440jap; Fri, 26 Nov 2021 04:19:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjw4TdfMX82ZHU2RDndfYnctGpIw7jQ17mV1HgH7YD8txmVfwMh61+ZitsIKtw6+Zq3aBm X-Received: by 2002:a0c:fb47:: with SMTP id b7mr24271980qvq.12.1637929166268; Fri, 26 Nov 2021 04:19:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637929166; cv=none; d=google.com; s=arc-20160816; b=Zu6FH94yWhoE1qUsRqRYOtc+9SGGxj9XsO7KKWkGOdCGf//4x+gZPNA1fpi5enet5u LnckcepHZR6XrbkuP3wDz1DgR7HE9aOwaMzD1LpgQr0Psdm8gHxmfS0xohvCxmLJd5vN c4D0a7RcdzG0U2hZVGsPr0CJvUNMRonvvwxCwNjcl7+1E/6cA/lkYjGVrMOguBSoq7FA mshBr96JJOIuwnaYxnz8X2A6VRCwLhbSSqd2G0Z2flcjrtPrCtV4y3xnE7wo6B14TwVD 6JwPRgaJbQBQZzJZL4dqQh/imT1OTygnaD3DPnLiEAEOweonLqhM1o+WSKdjMVjgajf2 KEnA== 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=jD308C1QiczBhX/LAxWPZcxwrxlTOMg31rQYGjXNCDY=; b=sPSLhwWtjhneuRhd+V14fphyUGJ2SJszsczrEso+FLIbDaThndltcIofEtlXtNJrN3 EbT4WnsGhlXoWmFyeRipmtxoLc9JLxok4CJry0xaJaZ/VOfqPkrAcAvb94Xv+5jB2fu+ KbUSRKA19X6a0jgwVWSmYGpw/XZRaLjoDwArdl/n3hH+Qqcx6xMYvyAjyFgORcn+129q G0zL3zFfkMUxct3yLPX08W4U6MLC3UFv7rTHOaqWvie8nNNIoMMjv/vDFWeWFCmrXYGG qH3dntoKvmXxG587TnxidcXWqBYPkndsiAZ2BUcs11LJRuPNMR7SL92q75aUqwFTK+sg KTXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q7veN72N; spf=pass (google.com: domain of mptcp+bounces-2549-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2549-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 7si7762552qtp.454.2021.11.26.04.19.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Nov 2021 04:19:26 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2549-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=Q7veN72N; spf=pass (google.com: domain of mptcp+bounces-2549-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2549-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 E18B21C0FBC for ; Fri, 26 Nov 2021 12:19:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 482642C89; Fri, 26 Nov 2021 12:19:24 +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 0B42168 for ; Fri, 26 Nov 2021 12:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637929162; 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=jD308C1QiczBhX/LAxWPZcxwrxlTOMg31rQYGjXNCDY=; b=Q7veN72NPXQZeQQUOWdUepk5hBMW/7dItP3V4Z2Cey14OSFdKEZk9NC7jRhwXu+VBcZZKt zzwvAi+HFIn9Bx8tZbzQD+M6jW/ywe6qhGmdrnAZQ8mPrT4Jm8G4zp3/ecwwBbXGOouoOj VuEMm5CrgdHZK09IICXjG3U/Tf0qcM4= 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-504-jCzBSTdANoOF6D3fbuypUQ-1; Fri, 26 Nov 2021 07:19:19 -0500 X-MC-Unique: jCzBSTdANoOF6D3fbuypUQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F3BCF190A7A0 for ; Fri, 26 Nov 2021 12:19:18 +0000 (UTC) Received: from gerbillo.fritz.box (unknown [10.39.194.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C03719C46 for ; Fri, 26 Nov 2021 12:19:18 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 mptcp-next 2/4] mptcp: keep track of used local endpoint Date: Fri, 26 Nov 2021 13:19:07 +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.84 on 10.5.11.23 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" So that we can skip already used endpoint at local address selection time. 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 Reviewed-by: Matthieu Baerts --- net/mptcp/pm.c | 1 + net/mptcp/pm_netlink.c | 8 +++++++- net/mptcp/protocol.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 761995a34124..1ff856dd92c4 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_zero(msk->pm.endpoint_usage_mask, 256); =20 mptcp_pm_nl_data_init(msk); } diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 3186d33b5208..78b68a8216b6 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -173,6 +173,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.endpoint_usage_mask)) + continue; + if (entry->addr.family !=3D sk->sk_family) { #if IS_ENABLED(CONFIG_MPTCP_IPV6) if ((entry->addr.family =3D=3D AF_INET && @@ -512,8 +515,10 @@ static void mptcp_pm_create_subflow_or_signal_addr(str= uct mptcp_sock *msk) check_work_pending(msk); nr =3D fill_remote_addresses_vec(msk, fullmesh, addrs); spin_unlock_bh(&msk->pm.lock); - for (i =3D 0; i < nr; i++) + for (i =3D 0; i < nr; i++) { + set_bit(local->addr.id, msk->pm.endpoint_usage_mask); __mptcp_subflow_connect(sk, &local->addr, &addrs[i]); + } spin_lock_bh(&msk->pm.lock); return; } @@ -1282,6 +1287,7 @@ static int mptcp_nl_remove_subflow_and_signal_addr(st= ruct net *net, mptcp_pm_remove_anno_addr(msk, addr, remove_subflow); if (remove_subflow) mptcp_pm_remove_subflow(msk, &list); + clear_bit(addr->id, msk->pm.endpoint_usage_mask); release_sock(sk); =20 next: diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a6a4bd7de5b4..d384f285b6c1 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -190,6 +190,7 @@ struct mptcp_pm_data { =20 spinlock_t lock; /*protects the whole PM data */ =20 + DECLARE_BITMAP(endpoint_usage_mask, 256); u8 addr_signal; bool server_side; bool work_pending; --=20 2.33.1 From nobody Sun May 5 07:59:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp1803471jap; Fri, 26 Nov 2021 04:19:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwesyUBmxb81oFsMAJsK6ufTcnKPmvJ8Zpa9k+BDtALH1Xtrwktj6nGabn1wrJbKrfpdATH X-Received: by 2002:a05:6122:2210:: with SMTP id bb16mr18716297vkb.28.1637929167838; Fri, 26 Nov 2021 04:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637929167; cv=none; d=google.com; s=arc-20160816; b=j/a5mnx6lo/4fmxGZcoSko4KbDYOmaba4Wcqo21XsH1+jiG9c3XxiNFYcm2Cn+NOa8 OAP9sakz+8Lz1QF0zihP0MqGlYnIv6NIu/oF5gu8iG5VFo56jsYyCkmk2rWI55AFLm1V AYTiqhQPvUAP6f4pIa/hxSRp8s0ElNCU1VB1U4ZzO/rcr5ZYfZ1F+n+fI4sTxj0FypIs bt7LBFzDhcOEzbqXx7PkLZ118fLT3Ckpw6xnF+Shm0gwaItdQffAsyUHKXoHvUerCaHF GjY/sqKexI20q39ez1kggSULRpKDiXqBBQr2dbiUcbhYNxCJW0gvamxvL0XhRO+6o8Hp Yg0w== 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=CcFuKKDteL0v8dMSWCZosRlT3CTedbLG4nJgSUOgpA8=; b=vUIJEklglfmWK3m8q4JGvknf/tv8GJYvvvWvS8cjKOaJv/wPeffIs4hNFzhr9yXwR1 YOU92Ir59Sh3SF35SV1qKXEECJmv05Ck+9Yg8V3d9VTUP3rOcgtrUHph7kDIG6uIeHQ9 sL51fZKcLhl9sd8hxZ+IfAOudePDM6TrWxPvJoeeg1F4mK3d0/OoyCIeI6sDuxBmT4M/ +G6lwGGrcHUUypXg1EF27cBdUKfb+m//5ArTd6Yav8dj/gGogR0PE6kKSGLt0NX7l4NH qAKHv+JtX8pzDkfn/9HK4pBDyCO/BLCtN0w+SS0J9qo6Udmdg5BIQfA0rwSVoUJlcDHK nNeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=egtJZBU+; spf=pass (google.com: domain of mptcp+bounces-2550-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2550-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 b1si56757vsf.647.2021.11.26.04.19.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Nov 2021 04:19:27 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2550-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=egtJZBU+; spf=pass (google.com: domain of mptcp+bounces-2550-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2550-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 BC3443E142A for ; Fri, 26 Nov 2021 12:19:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AF1C68; Fri, 26 Nov 2021 12:19:24 +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 1C3632C87 for ; Fri, 26 Nov 2021 12:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637929162; 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=CcFuKKDteL0v8dMSWCZosRlT3CTedbLG4nJgSUOgpA8=; b=egtJZBU+uCuGE8/NMh8mzS76xknIuzspG3G4HeHoEBg+BVS3rNRlKSDG7pWSkYYcxRu4s5 WZ9L+Nyr9aSPz2jDl+8wfrSfmju50YNNILUisbDLBU1vk7/i+b2T0IwtlqXYG/8l36stXx RpMXzXvtRPVxLh3qfTUXOu7a8daPjbw= 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-341-5hjWXBmoPtKR-rsezmebEw-1; Fri, 26 Nov 2021 07:19:20 -0500 X-MC-Unique: 5hjWXBmoPtKR-rsezmebEw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CD741F2DA for ; Fri, 26 Nov 2021 12:19:20 +0000 (UTC) Received: from gerbillo.fritz.box (unknown [10.39.194.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7172219C46 for ; Fri, 26 Nov 2021 12:19:19 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 mptcp-next 3/4] mptcp: do not block subflows creation on errors Date: Fri, 26 Nov 2021 13:19:08 +0100 Message-Id: <7eaa67c01eb780dacbbac368004d2306a7981e09.1637929034.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.84 on 10.5.11.23 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 --- 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 | 27 +++++++++++++++++++++++++-- net/mptcp/protocol.c | 6 ++++++ net/mptcp/protocol.h | 4 +++- net/mptcp/subflow.c | 5 ++++- 5 files changed, 56 insertions(+), 7 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 1ff856dd92c4..df8a596cd3ff 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -172,9 +172,32 @@ 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 closed; + + closed =3D ssk->sk_state =3D=3D TCP_CLOSE; + if (subflow->fully_established && !closed) + return; + + spin_lock_bh(&pm->lock); + if (closed) { + pm->local_addr_used--; + pm->subflows--; + /* do not enable the pm worker: we don't want to pick again + * the just closed subflow + */ + } + + /* Even if this subflow is not really established, tell the PM to try + * to pick the next one, if possible. + */ + if (pm->work_pending) + 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/protocol.c b/net/mptcp/protocol.c index ef2125798e64..2ee2fe97c553 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 d384f285b6c1..4da1ef964b88 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -433,6 +433,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; @@ -733,7 +734,8 @@ 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); +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 Sun May 5 07:59:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp1803486jap; Fri, 26 Nov 2021 04:19:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTYxFP2NZyqoDaCpZX8i8DfMgCnzyVOXs98gOhvkJarWY2P4DSdsXUCfhqIV8b0ncpLtfp X-Received: by 2002:ab0:71c3:: with SMTP id n3mr32964565uao.54.1637929168510; Fri, 26 Nov 2021 04:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637929168; cv=none; d=google.com; s=arc-20160816; b=RQFUSbRtWoaNZ5oon9MBsuLjON/gIUYeUwReswdpYhJL16CqfrpCkzHPsiZjDsQiiQ xCbyTloZQCkw6hOTLDJBFOheSQGlsjO//8sdaDuoYqBRAAgvpgdBD+8+WETZ3jObmN3c Upr2x3xczpRArnhHUS4snmtngmlgHHBM0QAALkM4M91PvigeBxdgUi+RpH+WAdzzkL1D vRHEFAfsVHwIjM4nY6TMPmPmat3JdpZ/2Q85aZw+J/NyPbbkNOsQSEs0r8GiWMijcF5M EehtcwkHwM1geQ0TUP9Y6kNleR+AAwH2SlWphmp9hMrw0m9EKzoKoRx46V0Fr+cGWooW ZGqg== 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=h4z8wCUS89CcyUEM+0LmMvqsYXS2sjkIU3n6Pg//daQ=; b=EjSV5UQdKVRsGnpyAR1VBSVtrcXzENkJ2sueRBagISuICeh9lXsT98fP8YYwOdvlS7 ItB3MXJeAQPPGsu1JJ+NSnBjmdU0+fIiskvbrNUJMFE921oSY/wBaJRZNTRvz6C5fqUz A77wyw6ZBJQivb3MstFSbEVpgoxwMQ1N3JIYCzO865N+dQP2Q+m0nhUseEOR2/K4b+bn tm1+IHBOV9R1+fr2Zh65PgJfuu39azDwjweRQ9OacScvlzRc+9C8YHQpypjs3q1fY6aw udNZGn+1TmsT9R0XnZbTISE0q3NHmDSGghpaTMbsruySwLlbbjQgW4tNLX04f9rxmkUS DJZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZwB6NVp2; spf=pass (google.com: domain of mptcp+bounces-2551-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-2551-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 33si9742292vkn.39.2021.11.26.04.19.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Nov 2021 04:19:28 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2551-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=ZwB6NVp2; spf=pass (google.com: domain of mptcp+bounces-2551-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-2551-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 DCA913E11B7 for ; Fri, 26 Nov 2021 12:19:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 207902C87; Fri, 26 Nov 2021 12:19:25 +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 E21EA2C86 for ; Fri, 26 Nov 2021 12:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637929163; 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=h4z8wCUS89CcyUEM+0LmMvqsYXS2sjkIU3n6Pg//daQ=; b=ZwB6NVp2pogZaaKgswcy/C7Y9voRiNAQzLYkJ68MeNJ+eXv5/FwTj3pCvMVBQNqVn2h+Sq +U3TzHysSeHrJPF2VbEwhjuK7yRUFbBQQRYthhD2pan4mwv/Y+d55OSKu1Q5PUBINsr03G ttxKoeNvcf6v85KEjZfYvcKGmBcFJ80= 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-232-MG2xo0KCP461sIPS0B5lZA-1; Fri, 26 Nov 2021 07:19:21 -0500 X-MC-Unique: MG2xo0KCP461sIPS0B5lZA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 099161F2DB for ; Fri, 26 Nov 2021 12:19:21 +0000 (UTC) Received: from gerbillo.fritz.box (unknown [10.39.194.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E60919C46 for ; Fri, 26 Nov 2021 12:19:20 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 mptcp-next 4/4] selftests: mptcp: add tests for subflow creation failure Date: Fri, 26 Nov 2021 13:19:09 +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.84 on 10.5.11.23 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 --- 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 | 65 ++++++++++++++++++- 2 files changed, 65 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 2684ef9c0d42..6d342f9985b8 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,48 @@ subflows_tests() chk_join_nr "single subflow, dev" 1 1 1 } =20 +subflows_error_tests() +{ + # 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 @@ -1840,6 +1898,7 @@ fullmesh_tests() all_tests() { subflows_tests + subflows_error_tests signal_address_tests link_failure_tests add_addr_timeout_tests @@ -1859,6 +1918,7 @@ usage() { echo "mptcp_join usage:" echo " -f subflows_tests" + echo " -f subflows_error_tests" echo " -s signal_address_tests" echo " -l link_failure_tests" echo " -t add_addr_timeout_tests" @@ -1907,11 +1967,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