From nobody Tue Apr 30 14:38:29 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp951038uad; Fri, 1 Jul 2022 03:05:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uYVStU0ol7I2Qao+Er8s/L+wVYBweFFyslF+eHLm9lIyXnLIGo3MpEayPjhSdACfpjvbYl X-Received: by 2002:a05:6870:170c:b0:102:4a:a9df with SMTP id h12-20020a056870170c00b00102004aa9dfmr7628132oae.31.1656669945585; Fri, 01 Jul 2022 03:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656669945; cv=none; d=google.com; s=arc-20160816; b=SBEAAAvQFbJRxLZnjsa4VTDwtZkE8vWompLmrZRg0jsFYe0izRsvb3wlv7KhYmhK3P 7sOcWGn7x6v5r+Mt0EvnY11mud5Kx+yC13ldTw4gKr/sP91Bc+jdzbLKg5PD0kgNvF6u FRb9vQLoX2SAw9A97ZR8e8s7sjgFYmJoLh5w8R4TfbG0BhNqsEGUzK+WsljwRszv2QUB iUmfqmE01ojPhNIwNCmswSFJmmMv0ED8TXhj63zDIy+Ld8EjD3jsyW2q9CCfj2Lg8jk/ rx6pGxEaYnkgm8YPtHQEdPws3ibWIXKi/Ju9sJ8gpCZfECIzF4qOY+lM+fmrotdRIEPD rXrg== 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=Q7OC7siZlgh2V8GE/bIeQ5XSN0QjjB/wMmgjUbAS9Z0=; b=CJx6cU06u1c9nZzcNJ1+m8PguMUNA7IAq1q+qJdzFlJIPpOF3AlLKsIlYa9cFIs8i5 cfTX9bhcCmz2M1JAPCfKohk2VrOUCoqrvjuUgPRovNrVG5nq8YUgnumMFD9JzbbgWKp+ +wtWeiCC2oQAhsSKd15H+Al49WbQgGlUeyjJQiLzkMMSFLljU4Rkf2OVCVgxJWp2xCCK tiItjDiLFerUY3q5uIXp28QmZsMloxamod0Vc6DYXW94WP1FeqZwRKMApDnil6HYUIIC pUKVWyVJoCxQcBdFb2exwHNZyft5BM8ckDsEldSB7W5zPKh5mnRaNW35vP8b7yNpSe6K wS3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CgrNQSEL; spf=pass (google.com: domain of mptcp+bounces-5926-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-5926-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from da.mirrors.kernel.org (da.mirrors.kernel.org. [139.178.84.19]) by mx.google.com with ESMTPS id z23-20020a056808065700b003357bef2a00si13693247oih.131.2022.07.01.03.05.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2022 03:05:45 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5926-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) client-ip=139.178.84.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CgrNQSEL; spf=pass (google.com: domain of mptcp+bounces-5926-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-5926-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by da.mirrors.kernel.org (Postfix) with ESMTPS id 27A3A2E0A90 for ; Fri, 1 Jul 2022 10:05:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95A00186D; Fri, 1 Jul 2022 10:05:43 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 506D81869 for ; Fri, 1 Jul 2022 10:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656669941; 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=Q7OC7siZlgh2V8GE/bIeQ5XSN0QjjB/wMmgjUbAS9Z0=; b=CgrNQSELwIHzfypl+osoUvbA+Z1X26H4FiZU5vIBAG7/UePKdJgzKHsE+kX8CMwq3vkyoL RjtFx6wXmwrJymCGYx9xqh2PUfqGBjGxuwlqMF3qyM3Y6u8k8Q8Ue4bsK4sKRCywTPXaTa hmm8iKYa+DLGsCP5kQPhCKgaNbCF2mM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-543-HIsuwN5GOyuRO_5QSPO_jg-1; Fri, 01 Jul 2022 06:05:40 -0400 X-MC-Unique: HIsuwN5GOyuRO_5QSPO_jg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C43821C06EDD for ; Fri, 1 Jul 2022 10:05:39 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53F9C400DFD0 for ; Fri, 1 Jul 2022 10:05:39 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 1/6] mptcp: fix local endpoint acconting. Date: Fri, 1 Jul 2022 12:05:21 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" In mptcp_pm_nl_rm_addr_or_subflow() we always mark as availble the id corresponding to the just removed address. The used bitmap actually tracks only the local IDs: we must restrict the operation when a (local) subflow is removed. Fixes: a88c9e496937 ("mptcp: do not block subflows creation on errors") Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau --- net/mptcp/pm_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 0a295acf99b8..f1909006a859 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -800,7 +800,8 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp= _sock *msk, removed =3D true; __MPTCP_INC_STATS(sock_net(sk), rm_type); } - __set_bit(rm_list->ids[i], msk->pm.id_avail_bitmap); + if (rm_type =3D=3D MPTCP_MIB_RMSUBFLOW) + __set_bit(rm_list->ids[i], msk->pm.id_avail_bitmap); if (!removed) continue; =20 --=20 2.35.3 From nobody Tue Apr 30 14:38:29 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp951055uad; Fri, 1 Jul 2022 03:05:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uUAxJTKZ2kUEo2B87sgTO0YaSgRLstM8MFYHgaS1EYFV/Ny2CG9ywB9e7FlOe8KvQruJOH X-Received: by 2002:a17:903:2350:b0:16b:8ff9:6ab with SMTP id c16-20020a170903235000b0016b8ff906abmr18416710plh.89.1656669946439; Fri, 01 Jul 2022 03:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656669946; cv=none; d=google.com; s=arc-20160816; b=Jl4n6ASbWhetsOpuYgmxAEO30lWCw91QODsrNaRLCh51WfIgulXENEsGzE2NZcu8oM TRkEWolMzrVlbAxIR1RjcaKNI/PUhN0Rtm1PmP4Fn1ogdqh/m4FJbPj8++pOZizNMO6E u/xUH2liLsynvhVra6ObRmIiwLpf0jGdwUDMDX6geHQVuznyEsXPcLg9VDV/QtGQ5tKe wpiIvnTnTlS/fhV9Wh7V21veVwXDPnWYPnd0X2L5umyFY31T4EpGZlxq91e6/TmkMdj3 gsr2Q6dzmRSyKj3pBhVo8hJ1Ti7uXRTd9QR6sNiji46h2o/y7vf+91RyrQxMjFEvmP6O pgUw== 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=ajOjvh9cevBNeFaEoFAdQs9ZvNpnwdFg2bunoUFettw=; b=VIjLNj94J81mTIYYRuqh1WzyYUNev8fqndqj4kZ4mGzwmbO/6kRLsaibmLLcQR7Uqh vq+KcEndVLbxl6Mx/VTOPpcSjnycE7DkWuOP+uPuOA3rilaS6CBi+HZhgmCuYa2AfZws YWRyp0ARtpVrnhg1pRd632s5/W5VYLXkhktx5+DUVP1sWqaNvfWNfEAvSs2+jxvH0u+A FPBlzhzGLP/ixTwDBxi/rhMRpEtlkNY/g5ML1e9+sZmBw1LdCOmxq3O0KPgdtsqCcHP1 wTc94cTDmXHLLMPAdOznaXh67sJ47U7CSrEVhm1w5++EljEo5NA5tLDisS7yOG/VRWl7 jrgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NrmETKv2; spf=pass (google.com: domain of mptcp+bounces-5927-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5927-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g24-20020a633758000000b0040d33f1a30fsi28803617pgn.290.2022.07.01.03.05.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2022 03:05:46 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5927-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NrmETKv2; spf=pass (google.com: domain of mptcp+bounces-5927-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5927-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0DF75280CAF for ; Fri, 1 Jul 2022 10:05:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A9C2186F; Fri, 1 Jul 2022 10:05:44 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D532D1855 for ; Fri, 1 Jul 2022 10:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656669941; 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=ajOjvh9cevBNeFaEoFAdQs9ZvNpnwdFg2bunoUFettw=; b=NrmETKv2r2cQjNqulpYgG/bxrrgVIrfkLJgv7GlNYrCBNE4rZ87Hw1utZ32i8o1sGxKDah 4Cn7c+djPFestpGRTeWza9mAcZ4D123aCmTjNVnoYDB2+ACG/++uZHT92/gjKyL8knxkku nUzVvty7ST6tbOUsCy2U2a9rfX6Yqic= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-kFf2HrQBMjSYJWPpUnyfUA-1; Fri, 01 Jul 2022 06:05:40 -0400 X-MC-Unique: kFf2HrQBMjSYJWPpUnyfUA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DD58801231 for ; Fri, 1 Jul 2022 10:05:40 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13612400DEFC for ; Fri, 1 Jul 2022 10:05:39 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 2/6] mptcp: introduce and use mptcp_pm_send_ack() Date: Fri, 1 Jul 2022 12:05:22 +0200 Message-Id: <6de116ad2229ddd1c557fca592b9c56fd2836823.1656669391.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.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" The in-kernel PM has a bit of duplicate code related to ack generation. Create a new helper factoring out the PM-specific needs and use it in a couple of places. As a bonus, mptcp_subflow_send_ack() is not used anymore outside its own compilation unit and can become static. Signed-off-by: Paolo Abeni --- net/mptcp/pm_netlink.c | 56 +++++++++++++++++++++++++----------------- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 1 - 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index f1909006a859..8dc7ff9953b9 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -463,6 +463,37 @@ static unsigned int fill_remote_addresses_vec(struct m= ptcp_sock *msk, bool fullm return i; } =20 +static void __mptcp_pm_send_ack(struct mptcp_sock *msk, struct mptcp_subfl= ow_context *subflow, + bool prio, bool backup) +{ + struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); + bool slow; + + pr_debug("send ack for %s", + prio ? "mp_prio" : (mptcp_pm_should_add_signal(msk) ? "add_addr" : "rm_= addr")); + + slow =3D lock_sock_fast(ssk); + if (prio) { + if (subflow->backup !=3D backup) + msk->last_snd =3D NULL; + + subflow->send_mp_prio =3D 1; + subflow->backup =3D backup; + subflow->request_bkup =3D backup; + } + + __mptcp_subflow_send_ack(ssk); + unlock_sock_fast(ssk, slow); +} + +static void mptcp_pm_send_ack(struct mptcp_sock *msk, struct mptcp_subflow= _context *subflow, + bool prio, bool backup) +{ + spin_unlock_bh(&msk->pm.lock); + __mptcp_pm_send_ack(msk, subflow, prio, backup); + spin_lock_bh(&msk->pm.lock); +} + static struct mptcp_pm_addr_entry * __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id) { @@ -705,16 +736,8 @@ void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk) return; =20 subflow =3D list_first_entry_or_null(&msk->conn_list, typeof(*subflow), n= ode); - if (subflow) { - struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); - - spin_unlock_bh(&msk->pm.lock); - pr_debug("send ack for %s", - mptcp_pm_should_add_signal(msk) ? "add_addr" : "rm_addr"); - - mptcp_subflow_send_ack(ssk); - spin_lock_bh(&msk->pm.lock); - } + if (subflow) + mptcp_pm_send_ack(msk, subflow, false, false); } =20 static int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, @@ -728,23 +751,12 @@ static int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_= sock *msk, mptcp_for_each_subflow(msk, subflow) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); struct mptcp_addr_info local; - bool slow; =20 local_address((struct sock_common *)ssk, &local); if (!mptcp_addresses_equal(&local, addr, addr->port)) continue; =20 - slow =3D lock_sock_fast(ssk); - if (subflow->backup !=3D bkup) - msk->last_snd =3D NULL; - subflow->backup =3D bkup; - subflow->send_mp_prio =3D 1; - subflow->request_bkup =3D bkup; - - pr_debug("send ack for mp_prio"); - __mptcp_subflow_send_ack(ssk); - unlock_sock_fast(ssk, slow); - + __mptcp_pm_send_ack(msk, subflow, true, bkup); return 0; } =20 diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 10bfa2b78206..874344f7e0fa 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -508,7 +508,7 @@ void __mptcp_subflow_send_ack(struct sock *ssk) tcp_send_ack(ssk); } =20 -void mptcp_subflow_send_ack(struct sock *ssk) +static void mptcp_subflow_send_ack(struct sock *ssk) { bool slow; =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 9a7ec7773e8c..a92b6276a03c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -610,7 +610,6 @@ void mptcp_subflow_shutdown(struct sock *sk, struct soc= k *ssk, int how); void mptcp_close_ssk(struct sock *sk, struct sock *ssk, struct mptcp_subflow_context *subflow); void __mptcp_subflow_send_ack(struct sock *ssk); -void mptcp_subflow_send_ack(struct sock *ssk); void mptcp_subflow_reset(struct sock *ssk); void mptcp_subflow_queue_clean(struct sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); --=20 2.35.3 From nobody Tue Apr 30 14:38:29 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp951064uad; Fri, 1 Jul 2022 03:05:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1saQtZwqi9VT4r22xR1QCJlQqC9ShR7NpoAVOWWvWGStwT5TZPPOROfBvoOEYfeNwg7wc2I X-Received: by 2002:a63:6888:0:b0:3fe:49fc:3be3 with SMTP id d130-20020a636888000000b003fe49fc3be3mr11342843pgc.182.1656669947663; Fri, 01 Jul 2022 03:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656669947; cv=none; d=google.com; s=arc-20160816; b=w6nVFED6Y0n4UKFwjlmduEygARgLN2KQbI8zKu3uvP//OxalH+NpqgnF2N4SvZap+g bBkvKysEIhn6kNDR6dMdYmM87+oGZSDk2wwIJi94xhMaOcWDvDdgrVDUAkpc8WPONO/i Zrh8AuAcfioYK/UdHe6BU/8qFhIRsRBaiMvTCPHlmUTOak/HR4uP1Efrc4jC1d8Pm39b vyj+FDRpsEYhQ9FaIGpy+1d5N5KZym569uElYZaWbfPdK/95X0CwOjWBmd5uc7PHAC/Y kY7qCedGMeXebG6VVxjilVDP2lAU8xmqzITYrk9IeQZeBmyjjzPdIyKvcYIopLl+gPXt KyIQ== 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=xzXC6+q0xBZj4f+7N9q0nm16YAyDGWcwUnsmOjuFUQc=; b=xdvNJF9o/2VtCzhSkEULGa2Rah6KOGSixFE6IAC82VMzQU7Yo5ND+cjDlwKWW848Iz zLGBGtQVe7BmjBfhO3qiJsXBX2UXQ7PSVn7/Zao/pjaeOqCjA2Rfkw/Jm4JA9bFcXmGT A2CojAH05xtXIVCyeHlRij2Q4BpzTHQJrdLphixMnQBL77RB6GYTGnEgC4ugY9bC5dzY dl/ng2M5bwiRRnFO0Qk5zoUzqVkaWnkc/u9h7gkoeOkkZejdxGdVO4/7ZrJbOF8kdxW1 wJscUSH2+zOghDqTQXOmvq/JwvsshaVyv/oBcHM4aua9PTFHjZQgB08+7IOJEg5/OG5B jR3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VW4B+6dh; spf=pass (google.com: domain of mptcp+bounces-5928-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5928-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f18-20020a63de12000000b003fe34775ab6si29332814pgg.286.2022.07.01.03.05.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2022 03:05:47 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5928-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VW4B+6dh; spf=pass (google.com: domain of mptcp+bounces-5928-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5928-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 48890280CC5 for ; Fri, 1 Jul 2022 10:05:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB48B1855; Fri, 1 Jul 2022 10:05:44 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA6BF1869 for ; Fri, 1 Jul 2022 10:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656669942; 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=xzXC6+q0xBZj4f+7N9q0nm16YAyDGWcwUnsmOjuFUQc=; b=VW4B+6dhxqPmu9/a9uGTkCxQuw+vsJC4VubDpJyh+Gl/i+PbmH1BANSJmq+7N6w7t6U+vt TQaiw2GCcl3Q034xQUk7iyzBqdoBDvMOWLE9TKMEC+ny8F9ouTw1G//jcF7Pq+q9WuvHC/ DhylJj92AjfNpD69g27rHSCXaJUgm1g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-202-jHb127gFPF-7L_DK-aqpgw-1; Fri, 01 Jul 2022 06:05:41 -0400 X-MC-Unique: jHb127gFPF-7L_DK-aqpgw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 504EF802D1C for ; Fri, 1 Jul 2022 10:05:41 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id D40A7400DFD0 for ; Fri, 1 Jul 2022 10:05:40 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 3/6] mptcp: address lookup improvements Date: Fri, 1 Jul 2022 12:05:23 +0200 Message-Id: <6439c41c08c91be16239b686ddb6ea3f2c871d16.1656669391.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.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" When looking-up a socket address in the endpoint list, we must prefer port-based matches over address only match. Ensure that port-based endpoints are listed first, using head insertion for them. Additionally be sure that only port-based endpoints carry a non zero port number. Signed-off-by: Paolo Abeni --- net/mptcp/pm_netlink.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 8dc7ff9953b9..d6180b34a2c9 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -413,7 +413,7 @@ static bool lookup_address_in_vec(const struct mptcp_ad= dr_info *addrs, unsigned int i; =20 for (i =3D 0; i < nr; i++) { - if (mptcp_addresses_equal(&addrs[i], addr, addr->port)) + if (addrs[i].id =3D=3D addr->id) return true; } =20 @@ -449,7 +449,8 @@ static unsigned int fill_remote_addresses_vec(struct mp= tcp_sock *msk, bool fullm mptcp_for_each_subflow(msk, subflow) { ssk =3D mptcp_subflow_tcp_sock(subflow); remote_address((struct sock_common *)ssk, &addrs[i]); - if (deny_id0 && mptcp_addresses_equal(&addrs[i], &remote, false)) + addrs[i].id =3D subflow->remote_id; + if (deny_id0 && !addrs[i].id) continue; =20 if (!lookup_address_in_vec(addrs, i, &addrs[i]) && @@ -912,10 +913,11 @@ static int mptcp_pm_nl_append_new_local_addr(struct p= m_nl_pernet *pernet, /* do not insert duplicate address, differentiate on port only * singled addresses */ + if (!address_use_port(entry)) + entry->addr.port =3D 0; list_for_each_entry(cur, &pernet->local_addr_list, list) { if (mptcp_addresses_equal(&cur->addr, &entry->addr, - address_use_port(entry) && - address_use_port(cur))) { + cur->addr.port || entry->addr.port)) { /* allow replacing the exiting endpoint only if such * endpoint is an implicit one and the user-space * did not provide an endpoint id @@ -961,7 +963,10 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm= _nl_pernet *pernet, } =20 pernet->addrs++; - list_add_tail_rcu(&entry->list, &pernet->local_addr_list); + if (!entry->addr.port) + list_add_tail_rcu(&entry->list, &pernet->local_addr_list); + else + list_add_rcu(&entry->list, &pernet->local_addr_list); ret =3D entry->addr.id; =20 out: --=20 2.35.3 From nobody Tue Apr 30 14:38:29 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp951144uad; Fri, 1 Jul 2022 03:05:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sKLurkls2DSDGjMudp22C74Lp1WiPXx8UiM7E2C/vAprE/yfo7XDJnBHOoWzKRm+gyrX+o X-Received: by 2002:a05:6808:130c:b0:337:917d:7dad with SMTP id y12-20020a056808130c00b00337917d7dadmr1191935oiv.179.1656669953021; Fri, 01 Jul 2022 03:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656669953; cv=none; d=google.com; s=arc-20160816; b=qPRhYpLLSVHk9kquJtY8whK+tOokmPCN6k5qiJf0XActfgt2VogEKhL5jBM/CAR+6u 6nuE0WshTKV2ILYEWPUBPpcRS9DkKCqPUBInax5+j36bWi+hCjvbTCUoLImk2qC8vkfT +J3U79fiyHS/MDClWZUHEX90VRqBeCIntn7h1Bz2QlF190f8XuDJQE+A/udS3CkdShyt zoypTsxROFA+zeQ9VYYhciSWxlt/kyvxT8RdweovX0zqiW4qSxfy9mnQtO5/HV+/lTtC Bd7juEqjhXXACtYb/T1UTqcbSlb9SUWdfxjtM0kpP3tFzOsklNlp/4H3XbOZgUTjGkWJ pS5g== 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=Vc4FXkpz2q5liVNY8feAVGT09eyRqTZZ5C9SLhxKAow=; b=E1wuLDcs/AvVZQI+GIFhOtvxoOQhuX4Ix1c2am/vGRHS4xYdOiUsbTv09EtPkSBiDn xUYSWw4JoZp/RhXLn19uBtzIVyCG2maUpAFiVZL+IbneoOudLXg+GDDIFeJh7/p30xNU I+SLPVvIlTZZf/5iPmzZJn+TzRNq3ih0pqfsIoQTHrlO2l7GQt5TaLGO/Fwq2hj72HBM gRCeXeYXu0z1376m4XC0uuKFR73QuSKj4Z7gkY8oTOmMfzTXvSZJLFLXYKADF3sEs6aU 8zoYB9w/GcKxp/Y0qjX77eskjwQitiWAj67ztcm7bbu8ut9gqkOmmukNdjnOq1/KskgZ Hm8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZPJkAbCb; spf=pass (google.com: domain of mptcp+bounces-5931-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-5931-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from da.mirrors.kernel.org (da.mirrors.kernel.org. [139.178.84.19]) by mx.google.com with ESMTPS id gk13-20020a0568703c0d00b000f1d06f6677si9474948oab.213.2022.07.01.03.05.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2022 03:05:53 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5931-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) client-ip=139.178.84.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZPJkAbCb; spf=pass (google.com: domain of mptcp+bounces-5931-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-5931-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by da.mirrors.kernel.org (Postfix) with ESMTPS id CD75E2E0BEA for ; Fri, 1 Jul 2022 10:05:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F1501855; Fri, 1 Jul 2022 10:05:51 +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 CACFF1869 for ; Fri, 1 Jul 2022 10:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656669946; 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=Vc4FXkpz2q5liVNY8feAVGT09eyRqTZZ5C9SLhxKAow=; b=ZPJkAbCbvOFqWaZtq4Pu0WYyFzXiw7tMlksAilV4temnc5Pe+mK+pI4Sxn+jk9lElI6ktD bfOq599jsRMLYKoXnEoaEIm9R2OueM9qNiixy+uYO9WnmLabZXq02gtCB7tPu9RqbD9vA0 pOpx20roOz4+cXR37bhs3ZED5aePcj4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-3fOJcKRuMkqNsHgGTaVuqw-1; Fri, 01 Jul 2022 06:05:45 -0400 X-MC-Unique: 3fOJcKRuMkqNsHgGTaVuqw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11E431C06EC7 for ; Fri, 1 Jul 2022 10:05:42 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 965B1400DEFC for ; Fri, 1 Jul 2022 10:05:41 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 4/6] mptcp: allow the in kernel PM to set MPC subflow priority Date: Fri, 1 Jul 2022 12:05:24 +0200 Message-Id: <00ff72e657916fc8c5e5a1cfca68d7e08b33097c.1656669391.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.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Any local endpoints configured on the address matching the MPC subflow are currently ignored. Specifically, setting a backup flag on them has no effect on the first subflow, as the MPC handshake can't carry such info. This change refactors the MPC endpoint id accounting to additionally fetch the priority info from the relevant endpoint and eventually trigger the MP_PRIO handshake as needed. As a result, the MPC subflow now switches to backup priority after that the MPTCP socket is fully established, according to the local endpoint configuration. Signed-off-by: Paolo Abeni --- net/mptcp/pm_netlink.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d6180b34a2c9..46950ccac07d 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -514,30 +514,14 @@ __lookup_addr(struct pm_nl_pernet *pernet, const stru= ct mptcp_addr_info *info, struct mptcp_pm_addr_entry *entry; =20 list_for_each_entry(entry, &pernet->local_addr_list, list) { - if ((!lookup_by_id && mptcp_addresses_equal(&entry->addr, info, true)) || + if ((!lookup_by_id && + mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) || (lookup_by_id && entry->addr.id =3D=3D info->id)) return entry; } return NULL; } =20 -static int -lookup_id_by_addr(const struct pm_nl_pernet *pernet, const struct mptcp_ad= dr_info *addr) -{ - const struct mptcp_pm_addr_entry *entry; - int ret =3D -1; - - rcu_read_lock(); - list_for_each_entry(entry, &pernet->local_addr_list, list) { - if (mptcp_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; @@ -555,13 +539,22 @@ 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_subflow_context *subflow =3D mptcp_subflow_ctx(msk->first); + struct mptcp_pm_addr_entry *entry; struct mptcp_addr_info mpc_addr; - int mpc_id; + bool backup =3D false; =20 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); + rcu_read_lock(); + entry =3D __lookup_addr(pernet, &mpc_addr, false); + if (entry) { + __clear_bit(entry->addr.id, msk->pm.id_avail_bitmap); + backup =3D !!(entry->flags & MPTCP_PM_ADDR_FLAG_BACKUP); + } + rcu_read_unlock(); + + if (backup) + mptcp_pm_send_ack(msk, subflow, true, backup); =20 msk->pm.status |=3D BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED); } --=20 2.35.3 From nobody Tue Apr 30 14:38:29 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp951083uad; Fri, 1 Jul 2022 03:05:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sz+3LciAEfROO4LcYqOh78WbHjMBtKVDtcABSckxHzSp8P0+1KqYS0old7n4jEIX0OC4IC X-Received: by 2002:a17:902:ac90:b0:16a:1c0d:b586 with SMTP id h16-20020a170902ac9000b0016a1c0db586mr20371656plr.155.1656669948793; Fri, 01 Jul 2022 03:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656669948; cv=none; d=google.com; s=arc-20160816; b=fQT1kAO2QpgYTN4zvtW9FCm+uckpJCj/NK0wTTjGT5jAovUkMmlx87nCZtUkOSTrCv 7Ej7YS2uf9tJhLIbXyE7XUftu690psooLwrpzCEQuTQGbRZvPvmy84QYGo1lbzqxH4vR cXQwTUt+tSv0p3fREq42G/lnPiuRHwWY6cfnkIEqAzyPqRSv4n6yjWr9eff3kzCg5y4L UmQnrST0ZnBl7fw8aXibyCZILBfELxgtZcuaXaOG05ZRy9TVAE+d0824Uqe2J0sABRVj QP7/VydunXsVNE3qa0CKiunXl6ixIiSbsgwEsey2JfL/bGjBMeUvyZupTQCBWi5n8Ocg fUeQ== 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=8reQNlWVKXoq2m6YLHpdClytQxlaRIkaX32r8jaOapo=; b=cPWpyVeEi86kn/zh+iMG/xLuEs+xBgV38G+kQm7UtLqSpd6p1OmLTS7UvhnQqi59+S tqfVKA4M9dLbfOSnZ/RYRHuu2WOja9rSsNXd+/nsxQW2Pex0K9joLm6em9j34FZQJLEu moHz8wC+UTsIVBmdBmGY+TEcWRMV09+McjUgQ2C2h4hHWKfGPBtk3v2bNXvK5mHQxxag FDDsVY1vjE/0X8Ga1+I+Gl+EwLFuvqsYQ7YUVKGhL+8ySsvV4+IoxIkLJNc9lW5WPjRC Q31UUIcKXNgDDEDEEd6PlAweub3a9U4B7CcrHnVAWylbCYBcC1YW/T0Mp4+PtivEieP4 NLcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eDpqK5Vo; spf=pass (google.com: domain of mptcp+bounces-5929-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5929-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v15-20020a056a00148f00b0051c6152700asi8373411pfu.136.2022.07.01.03.05.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2022 03:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5929-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eDpqK5Vo; spf=pass (google.com: domain of mptcp+bounces-5929-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5929-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 870E8280CC9 for ; Fri, 1 Jul 2022 10:05:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63841186C; Fri, 1 Jul 2022 10:05:46 +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 0ECE21869 for ; Fri, 1 Jul 2022 10:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656669944; 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=8reQNlWVKXoq2m6YLHpdClytQxlaRIkaX32r8jaOapo=; b=eDpqK5Vov5FfjTJstzez7DsN6vZuk/WKY0WPuywTmJfk8/5U0PNZJ96Yg7rlS5IZnVFy1z MNkFMDDwwF5DILfYCQDUuN7BR+034CMN+OymTophKyVLLVJAy5YuJiH0iDQrxhAitEN5gM LGWEdCXSK7CVI1GVdy9JlfZqbcb+w3A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-482-If2maUYSNwe0leY4oJjQjw-1; Fri, 01 Jul 2022 06:05:43 -0400 X-MC-Unique: If2maUYSNwe0leY4oJjQjw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5EE7800882 for ; Fri, 1 Jul 2022 10:05:42 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 566F0400DEFC for ; Fri, 1 Jul 2022 10:05:42 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 5/6] mptcp: more accurate MPC endpoint tracking Date: Fri, 1 Jul 2022 12:05:25 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Currently the id accounting for the ID 0 subflow is not correct: at creation time we mark (correctly) as unavailable the endpoint id corresponding the MPC subflow source address, while at subflow removal time set as available the id 0. With this change we track explicitly the endpoint id corresponding to the MPC subflow so that we can mark it as available at removal time. Additionally this allow deleting the initial subflow via the NL PM specifying the corresponding endpoint id. Signed-off-by: Paolo Abeni --- net/mptcp/pm_netlink.c | 20 +++++++++++++------- net/mptcp/protocol.h | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 46950ccac07d..d3001484f0d6 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -549,6 +549,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(stru= ct mptcp_sock *msk) entry =3D __lookup_addr(pernet, &mpc_addr, false); if (entry) { __clear_bit(entry->addr.id, msk->pm.id_avail_bitmap); + msk->mpc_endpoint_id =3D entry->addr.id; backup =3D !!(entry->flags & MPTCP_PM_ADDR_FLAG_BACKUP); } rcu_read_unlock(); @@ -757,6 +758,11 @@ static int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_s= ock *msk, return -EINVAL; } =20 +static bool mptcp_local_id_match(const struct mptcp_sock *msk, u8 local_id= , u8 id) +{ + return local_id =3D=3D id || (!local_id && msk->mpc_endpoint_id =3D=3D id= ); +} + static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list, enum linux_mptcp_mib_field rm_type) @@ -780,6 +786,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp= _sock *msk, return; =20 for (i =3D 0; i < rm_list->nr; i++) { + u8 rm_id =3D rm_list->ids[i]; bool removed =3D false; =20 list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { @@ -787,15 +794,14 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mpt= cp_sock *msk, int how =3D RCV_SHUTDOWN | SEND_SHUTDOWN; u8 id =3D subflow->local_id; =20 - if (rm_type =3D=3D MPTCP_MIB_RMADDR) - id =3D subflow->remote_id; - - if (rm_list->ids[i] !=3D id) + if (rm_type =3D=3D MPTCP_MIB_RMADDR && subflow->remote_id !=3D rm_id) + continue; + if (rm_type =3D=3D MPTCP_MIB_RMSUBFLOW && !mptcp_local_id_match(msk, id= , rm_id)) continue; =20 - pr_debug(" -> %s rm_list_ids[%d]=3D%u local_id=3D%u remote_id=3D%u", + pr_debug(" -> %s rm_list_ids[%d]=3D%u local_id=3D%u remote_id=3D%u mpc_= id=3D%u", rm_type =3D=3D MPTCP_MIB_RMADDR ? "address" : "subflow", - i, rm_list->ids[i], subflow->local_id, subflow->remote_id); + i, rm_id, subflow->local_id, subflow->remote_id, msk->mpc_endpoint_id= ); spin_unlock_bh(&msk->pm.lock); mptcp_subflow_shutdown(sk, ssk, how); =20 @@ -807,7 +813,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp= _sock *msk, __MPTCP_INC_STATS(sock_net(sk), rm_type); } if (rm_type =3D=3D MPTCP_MIB_RMSUBFLOW) - __set_bit(rm_list->ids[i], msk->pm.id_avail_bitmap); + __set_bit(rm_id ? rm_id : msk->mpc_endpoint_id, msk->pm.id_avail_bitmap= ); if (!removed) continue; =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a92b6276a03c..ec91776f9b18 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -282,6 +282,7 @@ struct mptcp_sock { bool use_64bit_ack; /* Set when we received a 64-bit DSN */ bool csum_enabled; bool allow_infinite_fallback; + u8 mpc_endpoint_id; u8 recvmsg_inq:1, cork:1, nodelay:1; --=20 2.35.3 From nobody Tue Apr 30 14:38:29 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp951103uad; Fri, 1 Jul 2022 03:05:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tTjPCN+SLS3v29erh9aKpwxH/7hZ2a1tyvAQ2+Yatxi20yZfOpMWl6/urGXc5S6eiKaBsQ X-Received: by 2002:a05:6808:1247:b0:32c:2ba9:4fab with SMTP id o7-20020a056808124700b0032c2ba94fabmr8657588oiv.261.1656669950404; Fri, 01 Jul 2022 03:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656669950; cv=none; d=google.com; s=arc-20160816; b=w1w8o95UQw6KG7YIWnGfQMFs4bcLvqBBgOfvsyUD0iTGw6hrQLlSIiUCmaBeQH6kMU 7h6WESWOtCpOO187+vLl6XfFNc9vNaRgycg+n2S8uE7s176FyQwp/3fKjxs/3cK3j7UT mKGfmkcL9mhhdQeJ6JyJD1Vlg9ZwECr3qMLcZ1zYll1zzOAhPn6tjMVHFW8i8kURZnAY DKidIPPYxODYB/ePR9arxflUZX0KiBoGIO4AUMRoCZpDK10iRpuCRTE1wzk1pZHHUaoa 7LGf/ElR1oZydh+hm43uH1XAfN9mcDR/8j9OKasRy3n6fswCgALEueCNPjj4+yG+N9hy JUXw== 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=+DFKaN8QVS/mKAoW3OQy6u47fqbLFxD26tTV/pZD5xY=; b=dol6pX3491yTHuEhBeww0eg2UQDl9yOs+8zy1asyMNOYlchMZpeq+P9uyMsCvvKvvl GjlCezh9taB+Zf4t9rQOJstEzmvS/qXEHwULpDEpr+H509RtE0eeP0vkdqJKHuE0H9Wn avSn+xnrqufdxfDCBV0ajhXSGF+IXusCWPTMmHoKhwvOYkBIAsbwUeJzPQFrxfFHwdZq MblvP22IJ0CoMSiF9u+Wthg6LFsqhgNNEQPwo+uRY9hhk9Re44e/+aWxeZcJYy048p16 mBCPlR3pDny+s1S8P7jzrcVrwjxLKhILCJjzMYUBrL5DaThA6+ljm48mfk+HkSVF53/V LK3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="V/AaSLA1"; spf=pass (google.com: domain of mptcp+bounces-5930-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-5930-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from da.mirrors.kernel.org (da.mirrors.kernel.org. [139.178.84.19]) by mx.google.com with ESMTPS id q22-20020a056870e61600b000edb27edd25si24639386oag.64.2022.07.01.03.05.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2022 03:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5930-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) client-ip=139.178.84.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="V/AaSLA1"; spf=pass (google.com: domain of mptcp+bounces-5930-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.84.19 as permitted sender) smtp.mailfrom="mptcp+bounces-5930-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by da.mirrors.kernel.org (Postfix) with ESMTPS id 3FBD42E0C34 for ; Fri, 1 Jul 2022 10:05:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FF171855; Fri, 1 Jul 2022 10:05:49 +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 3E270186D for ; Fri, 1 Jul 2022 10:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656669947; 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=+DFKaN8QVS/mKAoW3OQy6u47fqbLFxD26tTV/pZD5xY=; b=V/AaSLA1rQ9Jg8urdXEAiHQ7BMHRspGQVYp4meFsH+yTOXvvQYi3ShDkp9pVhUHakxV6kz E5pvK5hQ6UGOoQ/X7CSYCCqPsa+2K1ULGe7rmMLlSM9CdEQ1+kMlwPDlM0ewhwnKF1YVaT G4d/sZB4RL050FEyk6mIooDfJsW7wtg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-637-WNawn-H0NzWzTbTg3fq65g-1; Fri, 01 Jul 2022 06:05:43 -0400 X-MC-Unique: WNawn-H0NzWzTbTg3fq65g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82A68101A586 for ; Fri, 1 Jul 2022 10:05:43 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12E4240E7F28 for ; Fri, 1 Jul 2022 10:05:42 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 6/6] selftests: mptcp: add MPC backup tests Date: Fri, 1 Jul 2022 12:05:26 +0200 Message-Id: <212a50ec33651131416e0bc7c0533343d8135dfb.1656669391.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.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Add a couple of test-cases covering the newly introduced features - priority update for the MPC subflow. Signed-off-by: Paolo Abeni --- .../testing/selftests/net/mptcp/mptcp_join.sh | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 55efe2aafb84..ff83ef426df5 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2428,6 +2428,36 @@ backup_tests() chk_add_nr 1 1 chk_prio_nr 1 1 fi + + if reset "mpc backup"; then + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr 0 0 0 + chk_prio_nr 0 1 + fi + + if reset "mpc backup both sides"; then + pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow,backup + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr 0 0 0 + chk_prio_nr 1 1 + fi + + if reset "mpc switch to backup"; then + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup + chk_join_nr 0 0 0 + chk_prio_nr 0 1 + fi + + if reset "mpc switch to backup both sides"; then + pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup + chk_join_nr 0 0 0 + chk_prio_nr 1 1 + fi } =20 add_addr_ports_tests() --=20 2.35.3