From nobody Sun Feb 8 14:22:36 2026 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