From nobody Sat May 4 16:20:47 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:9f92:0:0:0:0:0 with SMTP id a18csp3280121jam; Thu, 10 Feb 2022 10:49:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzP+exIgnqhJRapAL3R1IIHGAWwYhQiGEUu23NvZEL6zi97o6LJHp+cKOC3meamwQUXaKOb X-Received: by 2002:a17:90b:4a8e:: with SMTP id lp14mr4252877pjb.75.1644518974625; Thu, 10 Feb 2022 10:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644518974; cv=none; d=google.com; s=arc-20160816; b=QnY+S57OBOQkEBujNIUdqC3VxImgcNWxbvMxoZs2aZLOHT1CGhddRv9pwRnpCGB2n4 ZK/vrJ0IzZVaKvYmfUu7Q19Mk+bmoWTtDc2Dg8KnqCNVR38ueHfJmYaWTrCAfejBucO7 m/7iO+gRNlBiFV+q4TueIdgE/KaCCfN2dSvq1hjYhbCkYK/YLRY8i4jtpE8ooqR309ww 4mxn3gYKmaddYbkyflAXGDxg9pkifLb5scL+gRdj+3GICeNYbEKFkKmbCw1lr8admmGW 08B3beFXMVZtSgAkXmoo9pPjKVMBkFQz06VjeZrsVr8uLWs+EnKbjlWvsIeh9er3caSF AC0w== 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=3UBJflAZ80wm6ItZgAyOxnQGEwFP1voeDFnm8/KOqyg=; b=lwNn1/+KR75ryrEdXo5rfNLihnyvbOWcZM9QllraLpm3qS/fove+ftuOjVGzVTXrmU xljtcMwtSbCRgVwl+BQ0RmUTz102cWzxwka44gsl/tHqciFg1U60qko0sN3B60DLjHJR ohonuHdEAOCUjpVgOK6TSU0BV1u3dO6plQndkTde7rrQSYu6Vwrxs0l0kG7WYtdStyri 84iPfMpUlLlu5b8P3k7kqz0mQyxV/1bqF3OOhrnUdhmat0w/wR0JXaoKSesJY0dN34Je Hxenl8l3KIY7JLtnWkP/QBfFgXJcHDZW8Pyxao/W0KAsSowUhw5++cBsZnGbDN/ogbQB gCQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jUThGW0y; spf=pass (google.com: domain of mptcp+bounces-3650-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-3650-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 kb17si2298150pjb.76.2022.02.10.10.49.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Feb 2022 10:49:34 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-3650-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=jUThGW0y; spf=pass (google.com: domain of mptcp+bounces-3650-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-3650-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 4A77E3E1089 for ; Thu, 10 Feb 2022 18:49:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB4FD2C9C; Thu, 10 Feb 2022 18:49:32 +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 3006F2C9D for ; Thu, 10 Feb 2022 18:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644518970; 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=3UBJflAZ80wm6ItZgAyOxnQGEwFP1voeDFnm8/KOqyg=; b=jUThGW0y/22X4hZ137ieN2lBc4hlsWgn2/Lhf3+JAH5g4ZpvAXF2ZYCXDN9IRkLrBLTjKD zQzS7Zz7XlkkPUrue2ouaR6IO1pnjsCNzvzRVKP0MPgjbCLf+QPGyNLxi7Zdl2eU6Ux9na FFq9/d2o2RMrt17qu70KDXyaMBDmzmI= 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-390-ecHu_qElN5eVG4wPu0twwg-1; Thu, 10 Feb 2022 13:49:29 -0500 X-MC-Unique: ecHu_qElN5eVG4wPu0twwg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40D92802B7A for ; Thu, 10 Feb 2022 18:49:28 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5510106C0D2 for ; Thu, 10 Feb 2022 18:49:27 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v3 mptcp-next 1/3] Squash-to: "mptcp: constify a bunch of of helpers" Date: Thu, 10 Feb 2022 19:49:15 +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.22 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" There are a few more helpers that can be const-ified and I missed in the previous patch, just squash these change into there. Signed-off-by: Paolo Abeni --- net/mptcp/pm_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 46346f009485..56f5603c10f2 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1289,7 +1289,7 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct net *= net, unsigned int id, } =20 static bool remove_anno_list_by_saddr(struct mptcp_sock *msk, - struct mptcp_addr_info *addr) + const struct mptcp_addr_info *addr) { struct mptcp_pm_add_entry *entry; =20 @@ -1304,7 +1304,7 @@ static bool remove_anno_list_by_saddr(struct mptcp_so= ck *msk, } =20 static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, - struct mptcp_addr_info *addr, + const struct mptcp_addr_info *addr, bool force) { struct mptcp_rm_list list =3D { .nr =3D 0 }; --=20 2.34.1 From nobody Sat May 4 16:20:47 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:9f92:0:0:0:0:0 with SMTP id a18csp3280155jam; Thu, 10 Feb 2022 10:49:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwS3ilTdkYrMSM+buRgrYQsLC8D2GmxfCGHOXqQMPFzc3Drztj1gnpOEJySb8WxvUcHKlz2 X-Received: by 2002:a05:6a00:198a:: with SMTP id d10mr8976808pfl.2.1644518977756; Thu, 10 Feb 2022 10:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644518977; cv=none; d=google.com; s=arc-20160816; b=wBlzFOLCoYxDrUVupLi+/awjmff8aRtunKOltnlqHqtDtCXNwj4Qzhe2iENuZ4R6or dkgeqhu33j8y167X97eswpG2ho+6UTC3Xk0OuJ/OyWJnLA8kTea/aB9nOS3j97HqLRAT aBzmdl5NBMV8+GRuTn2WXHHHemO4WGllEW83hvw74JbUy4dvmSVKvu+BxXmb5g79Xmz7 /gvwf0238I5I5PKH0x5N/EjoKjEmzz+02EEN3vwcND8zXFzBNdEVJt/u65fPxIDk43Fg XxFJ0aXh6rXHKyKRcjCSVKpvH8ZPl8jZXyBRo4HQVVBnKO9Aw+M/v0VzRqwwpPefMgrD NC4w== 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=6Y25qPVEtZdEWPZPhZ8Fu9k9PFMIJUGonmkwYLBriCs=; b=JwW6gkRU0LF1kMRKo3WQFqrllaTFoQhmrlojwaTjiNRzFJ7K2pUorwHHQINR3WbzZq BxQakSSn9GaKQtOs0pqDbFuDjTBtrF5Ri+Iwb0YB/Cra6AQX3KBzCKpvwaxAcKhuQqE2 CJaRC/Fe+XT2oF0cu+q9O8rgaQ1A1LlVm6anyrHrOLjX4w6casaVnjsu28iqEM1gu/Oa lUAfbr3c1EL2alqLPJDR+XJFHt3ADBPtUPoalLsjHr/KLGEjlevhaeXH5dvtUWA4mIRG ATj17QjooxiaK2znHb9hZfLktfQ2wmCMKb7A3eqqilphskfoSphBT0Co8n0TZbj6QiBa zV8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IBojfdVK; spf=pass (google.com: domain of mptcp+bounces-3652-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-3652-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 u21si2926013plq.325.2022.02.10.10.49.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Feb 2022 10:49:37 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-3652-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=IBojfdVK; spf=pass (google.com: domain of mptcp+bounces-3652-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-3652-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 7E8FB3E108C for ; Thu, 10 Feb 2022 18:49:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61AA22C9D; Thu, 10 Feb 2022 18:49:36 +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 034F72C9E for ; Thu, 10 Feb 2022 18:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644518974; 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=6Y25qPVEtZdEWPZPhZ8Fu9k9PFMIJUGonmkwYLBriCs=; b=IBojfdVK39NratIw1SF8FqiXohvMwsJe6a4MTyeY9ExNhqz0h0CekCkM82EqjfgsziIG/b /u3wFOV63w2lh0eo2sKVYsC/skgXQeyzR0/lT4tpkECC/80/LMJoq19YHpum/9XoMDzMMT q68qB6toNuWoCOH78kLQ2YwW3E+VAGA= 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-82-FKbHNahNMFCBBY_6tGi0LQ-1; Thu, 10 Feb 2022 13:49:30 -0500 X-MC-Unique: FKbHNahNMFCBBY_6tGi0LQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 363A01091DA5 for ; Thu, 10 Feb 2022 18:49:29 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A631106C0D5 for ; Thu, 10 Feb 2022 18:49:28 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v3 mptcp-next 2/3] mptcp: more careful RM_ADDR generation Date: Thu, 10 Feb 2022 19:49:16 +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.22 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" In some edge scenarios, an MPTCP subflows can use a local address mapped by a "dummy" endpoint created by the in kernel path manager. When such endpoint is deleted, the in kernel PM sends a RM_ADDR MPTCP suboption. That is somewhat unexpected, as an MPTCP listener will keep accepting incoming subflows targeting such address and the unexpected options can confuse some self-tests. Be more conservative about RM_ADDR generation: do it only if the relevant endpoint has either the SIGNAL or SUBFLOW flag - it's not a dummy one. Signed-off-by: Paolo Abeni --- include/uapi/linux/mptcp.h | 1 + net/mptcp/pm_netlink.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index f106a3941cdf..34ca8c04f64e 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -81,6 +81,7 @@ enum { #define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) #define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) #define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3) +#define MPTCP_PM_ADDR_FLAG_DUMMY (1 << 4) =20 enum { MPTCP_PM_CMD_UNSPEC, diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 56f5603c10f2..928ebe4949e9 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1036,7 +1036,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, = struct sock_common *skc) entry->addr.id =3D 0; entry->addr.port =3D 0; entry->ifindex =3D 0; - entry->flags =3D 0; + entry->flags =3D MPTCP_PM_ADDR_FLAG_DUMMY; entry->lsk =3D NULL; ret =3D mptcp_pm_nl_append_new_local_addr(pernet, entry); if (ret < 0) @@ -1238,6 +1238,11 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb= , struct genl_info *info) return -EINVAL; } =20 + if (addr.flags & MPTCP_PM_ADDR_FLAG_DUMMY) { + GENL_SET_ERR_MSG(info, "can't create DUMMY endpoint"); + return -EINVAL; + } + entry =3D kmalloc(sizeof(*entry), GFP_KERNEL); if (!entry) { GENL_SET_ERR_MSG(info, "can't allocate addr"); @@ -1322,11 +1327,12 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_= sock *msk, } =20 static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, - struct mptcp_addr_info *addr) + const struct mptcp_pm_addr_entry *entry) { - struct mptcp_sock *msk; - long s_slot =3D 0, s_num =3D 0; + const struct mptcp_addr_info *addr =3D &entry->addr; struct mptcp_rm_list list =3D { .nr =3D 0 }; + long s_slot =3D 0, s_num =3D 0; + struct mptcp_sock *msk; =20 pr_debug("remove_id=3D%d", addr->id); =20 @@ -1346,7 +1352,8 @@ static int mptcp_nl_remove_subflow_and_signal_addr(st= ruct net *net, =20 lock_sock(sk); remove_subflow =3D lookup_subflow_by_saddr(&msk->conn_list, addr); - mptcp_pm_remove_anno_addr(msk, addr, remove_subflow); + mptcp_pm_remove_anno_addr(msk, addr, remove_subflow && + !(entry->flags & MPTCP_PM_ADDR_FLAG_DUMMY)); if (remove_subflow) mptcp_pm_remove_subflow(msk, &list); release_sock(sk); @@ -1443,7 +1450,7 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb,= struct genl_info *info) __clear_bit(entry->addr.id, pernet->id_bitmap); spin_unlock_bh(&pernet->lock); =20 - mptcp_nl_remove_subflow_and_signal_addr(sock_net(skb->sk), &entry->addr); + mptcp_nl_remove_subflow_and_signal_addr(sock_net(skb->sk), entry); synchronize_rcu(); __mptcp_pm_release_addr_entry(entry); =20 @@ -1458,9 +1465,11 @@ static void mptcp_pm_remove_addrs_and_subflows(struc= t mptcp_sock *msk, =20 list_for_each_entry(entry, rm_list, list) { if (lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) && - alist.nr < MPTCP_RM_IDS_MAX && slist.nr < MPTCP_RM_IDS_MAX) { - alist.ids[alist.nr++] =3D entry->addr.id; + /* skip RM_ADDR for dummy endpoints */ + if (!(entry->flags & MPTCP_PM_ADDR_FLAG_DUMMY) && + alist.nr < MPTCP_RM_IDS_MAX) + alist.ids[alist.nr++] =3D entry->addr.id; slist.ids[slist.nr++] =3D entry->addr.id; } else if (remove_anno_list_by_saddr(msk, &entry->addr) && alist.nr < MPTCP_RM_IDS_MAX) { --=20 2.34.1 From nobody Sat May 4 16:20:47 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:9f92:0:0:0:0:0 with SMTP id a18csp3280146jam; Thu, 10 Feb 2022 10:49:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGDcYic0OGhrwlMOcSDblH+dY8HqFgYXjvs9AEFajinEpohAAHWJViFLr3ZzHyz/Febxli X-Received: by 2002:a05:620a:430e:: with SMTP id u14mr4555215qko.561.1644518976939; Thu, 10 Feb 2022 10:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644518976; cv=none; d=google.com; s=arc-20160816; b=VBSNcod2UqoYtQDUNmlSuZBWNZvImN0Al8awFD4WNwnmunTrs0ruCYcnlzitnos4qB 3+F8VqPjxDYNV1Yb2VNArBQ1ipILnCfT0uR1CligKS9tP6gMqf6vNs36/ChQABoUz297 TvfVA0zEctmWV43trGDzItNatvC7vQ0YRHEv9G8I5wr0gcoqVjwBOh9gUYBwDNKHsaio juDONU7rV5Y6L9YJky0dpNQgFrkPu4C1+4u56UHQQGFIfkPOhY4xwBT7zSsnRyG8Z5Mv ySn1dhLdCBZ/Uq01awKiWfRx+2KRkm+y1uXtKNBybX5vpWRETd9IeJeU1KZ0Kt/idzZf 1RHQ== 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=8xn2GOTfCO1VgoVzcOS8H29hbmSMw/yzMtcFHNbP9FE=; b=MUWEDjQHSviy4Q3cYl5IY4l6UPDsadruYGs8LllYVfgM0Q+KYmrruI5Up0X1HF98j/ 52NR3Eib31uWwteingZrIsoLgK8QZJjhEORPPXQvfELes/jcCI4PhDChLHmKLxxY3ewh yWlbG0jDndbMX/QUk5AS/8i8TLkC2YclyoPxPcAWZNINwo5ERXzl9+ubxbK83GfNH1nE SlvropBt39xyeGVx4DHded9AWRxoM1xphHxBd4IlbRR+cigUaY8u2i4OHfWTHbY39ITa m9js7FhDMmSZ0uq+eW34CSVLGn8wfpgzUDXePt1JypnWXtX5AjrSXriH6pU587xr5zt5 pwSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZSxCsoIw; spf=pass (google.com: domain of mptcp+bounces-3651-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-3651-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 bl26si4781436qkb.576.2022.02.10.10.49.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Feb 2022 10:49:36 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-3651-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=ZSxCsoIw; spf=pass (google.com: domain of mptcp+bounces-3651-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-3651-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 986FF1C0F15 for ; Thu, 10 Feb 2022 18:49:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8727C2C9C; Thu, 10 Feb 2022 18:49:35 +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 17A342C9D for ; Thu, 10 Feb 2022 18:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644518973; 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=8xn2GOTfCO1VgoVzcOS8H29hbmSMw/yzMtcFHNbP9FE=; b=ZSxCsoIwaEPzw7mslV+SY6ZVhmWh99xZYzaHhklOD0YEJAB6po9PN5ksDgHXIWF3HgLC4G AhtTwBcq0LeGULaM91IoqNlLf3nuF58nI5GVvJUHpBoXFTiG5G3FSkAt6lOD8bIWmnBs3W RXLsQItEJwFJKEI+SbqZigfVjjwpJFU= 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-619-F2n8bCXdOHq1QeZSxxTxxw-1; Thu, 10 Feb 2022 13:49:31 -0500 X-MC-Unique: F2n8bCXdOHq1QeZSxxTxxw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C39C1932482 for ; Thu, 10 Feb 2022 18:49:30 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 903B3106C0D2 for ; Thu, 10 Feb 2022 18:49:29 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v3 mptcp-next 3/3] mptcp: strict local address ID selection. Date: Thu, 10 Feb 2022 19:49:17 +0100 Message-Id: <246389435f6d9660fee8f8c01a6544e4089f8708.1644518737.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.22 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" The address ID selection for MPJ subflows created in response to incoming ADD_ADDR option is currently unreliable: it happens at MPJ socket creation time, when the local address could be unknown. Additionally, if the no local endpoint is available for the local address, a new dummy endpoint is created, confusing the user-land. This change refactor the code to move the address ID seleciton inside the rebuild_header() helper, when the local address eventually selected by the route lookup is finally known. If the address used is not mapped by any endpoint - and thus can't be advertised/removed pick the id 0 instead of allocate a new endpoint. Signed-off-by: Paolo Abeni --- v2 -> v3: - keep creating dummy endpoint v1 -> v2: - hopefully fix build issue with ipv6 disabled - avoid looking-up multiple times the local_id for req sockets - factor-out an helper for local_id initialization RFC -> v1: - don't bail if ID lookup fails, use 0 instead --- net/mptcp/pm_netlink.c | 15 +--------- net/mptcp/protocol.c | 3 ++ net/mptcp/protocol.h | 3 +- net/mptcp/subflow.c | 67 ++++++++++++++++++++++++++++++++++++------ 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 928ebe4949e9..ca0fb2ab1204 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -83,16 +83,6 @@ static bool addresses_equal(const struct mptcp_addr_info= *a, return a->port =3D=3D b->port; } =20 -static bool address_zero(const struct mptcp_addr_info *addr) -{ - struct mptcp_addr_info zero; - - memset(&zero, 0, sizeof(zero)); - zero.family =3D addr->family; - - return addresses_equal(addr, &zero, true); -} - static void local_address(const struct sock_common *skc, struct mptcp_addr_info *addr) { @@ -998,7 +988,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, st= ruct sock_common *skc) struct mptcp_addr_info skc_local; struct mptcp_addr_info msk_local; struct pm_nl_pernet *pernet; - int ret =3D -1; + int ret =3D 0; =20 if (WARN_ON_ONCE(!msk)) return -1; @@ -1011,9 +1001,6 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, = struct sock_common *skc) if (addresses_equal(&msk_local, &skc_local, false)) return 0; =20 - if (address_zero(&skc_local)) - return 0; - pernet =3D net_generic(sock_net((struct sock *)msk), pm_nl_pernet_id); =20 rcu_read_lock(); diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 3324e1c61576..57caf470e500 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -117,6 +117,9 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) list_add(&subflow->node, &msk->conn_list); sock_hold(ssock->sk); subflow->request_mptcp =3D 1; + + /* This is the first subflow, always with id 0 */ + subflow->local_id_valid =3D 1; mptcp_sock_graft(msk->first, sk->sk_socket); =20 return 0; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a1ce1fd005ab..663b8d83154e 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -453,7 +453,8 @@ struct mptcp_subflow_context { rx_eof : 1, can_ack : 1, /* only after processing the remote a key */ disposable : 1, /* ctx can be free at ulp release time */ - stale : 1; /* unable to snd/rcv data, do not use for xmit */ + stale : 1, /* unable to snd/rcv data, do not use for xmit */ + local_id_valid : 1; /* local_id is correctly initialized */ enum mptcp_data_avail data_avail; u32 remote_nonce; u64 thmac; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index b53b392dd280..283e5d57e003 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -481,6 +481,51 @@ static void subflow_finish_connect(struct sock *sk, co= nst struct sk_buff *skb) mptcp_subflow_reset(sk); } =20 +static void subflow_set_local_id(struct mptcp_subflow_context *subflow, in= t local_id) +{ + subflow->local_id =3D local_id; + subflow->local_id_valid =3D 1; +} + +static int subflow_chk_local_id(struct sock *sk) +{ + struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(sk); + struct mptcp_sock *msk =3D mptcp_sk(subflow->conn); + int err; + + if (likely(subflow->local_id_valid)) + return 0; + + err =3D mptcp_pm_get_local_id(msk, (struct sock_common *)sk); + if (err < 0) + return err; + + subflow_set_local_id(subflow, err); + return 0; +} + +static int subflow_rebuild_header(struct sock *sk) +{ + int err =3D subflow_chk_local_id(sk); + + if (unlikely(err < 0)) + return err; + + return inet_sk_rebuild_header(sk); +} + +#if IS_ENABLED(CONFIG_MPTCP_IPV6) +static int subflow_v6_rebuild_header(struct sock *sk) +{ + int err =3D subflow_chk_local_id(sk); + + if (unlikely(err < 0)) + return err; + + return inet6_sk_rebuild_header(sk); +} +#endif + struct request_sock_ops mptcp_subflow_request_sock_ops; static struct tcp_request_sock_ops subflow_request_sock_ipv4_ops __ro_afte= r_init; =20 @@ -1403,13 +1448,8 @@ int __mptcp_subflow_connect(struct sock *sk, const s= truct mptcp_addr_info *loc, get_random_bytes(&subflow->local_nonce, sizeof(u32)); } while (!subflow->local_nonce); =20 - if (!local_id) { - err =3D mptcp_pm_get_local_id(msk, (struct sock_common *)ssk); - if (err < 0) - goto failed; - - local_id =3D err; - } + if (local_id) + subflow_set_local_id(subflow, local_id); =20 mptcp_pm_get_flags_and_ifindex_by_id(sock_net(sk), local_id, &flags, &ifindex); @@ -1434,7 +1474,6 @@ int __mptcp_subflow_connect(struct sock *sk, const st= ruct mptcp_addr_info *loc, pr_debug("msk=3D%p remote_token=3D%u local_id=3D%d remote_id=3D%d", msk, remote_token, local_id, remote_id); subflow->remote_token =3D remote_token; - subflow->local_id =3D local_id; subflow->remote_id =3D remote_id; subflow->request_join =3D 1; subflow->request_bkup =3D !!(flags & MPTCP_PM_ADDR_FLAG_BACKUP); @@ -1734,15 +1773,22 @@ static void subflow_ulp_clone(const struct request_= sock *req, new_ctx->token =3D subflow_req->token; new_ctx->ssn_offset =3D subflow_req->ssn_offset; new_ctx->idsn =3D subflow_req->idsn; + + /* this is the first subflow, id is always 0 */ + new_ctx->local_id_valid =3D 1; } else if (subflow_req->mp_join) { new_ctx->ssn_offset =3D subflow_req->ssn_offset; new_ctx->mp_join =3D 1; new_ctx->fully_established =3D 1; new_ctx->backup =3D subflow_req->backup; - new_ctx->local_id =3D subflow_req->local_id; new_ctx->remote_id =3D subflow_req->remote_id; new_ctx->token =3D subflow_req->token; new_ctx->thmac =3D subflow_req->thmac; + + /* the subflow req id is valid, fetched via subflow_check_req() + * and subflow_token_join_request() + */ + subflow_set_local_id(new_ctx, subflow_req->local_id); } } =20 @@ -1795,6 +1841,7 @@ void __init mptcp_subflow_init(void) subflow_specific.conn_request =3D subflow_v4_conn_request; subflow_specific.syn_recv_sock =3D subflow_syn_recv_sock; subflow_specific.sk_rx_dst_set =3D subflow_finish_connect; + subflow_specific.rebuild_header =3D subflow_rebuild_header; =20 tcp_prot_override =3D tcp_prot; tcp_prot_override.release_cb =3D tcp_release_cb_override; @@ -1807,6 +1854,7 @@ void __init mptcp_subflow_init(void) subflow_v6_specific.conn_request =3D subflow_v6_conn_request; subflow_v6_specific.syn_recv_sock =3D subflow_syn_recv_sock; subflow_v6_specific.sk_rx_dst_set =3D subflow_finish_connect; + subflow_v6_specific.rebuild_header =3D subflow_v6_rebuild_header; =20 subflow_v6m_specific =3D subflow_v6_specific; subflow_v6m_specific.queue_xmit =3D ipv4_specific.queue_xmit; @@ -1814,6 +1862,7 @@ void __init mptcp_subflow_init(void) subflow_v6m_specific.net_header_len =3D ipv4_specific.net_header_len; subflow_v6m_specific.mtu_reduced =3D ipv4_specific.mtu_reduced; subflow_v6m_specific.net_frag_header_len =3D 0; + subflow_v6m_specific.rebuild_header =3D subflow_rebuild_header; =20 tcpv6_prot_override =3D tcpv6_prot; tcpv6_prot_override.release_cb =3D tcp_release_cb_override; --=20 2.34.1