Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3701254pxb; Mon, 24 Jan 2022 15:46:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxTww4GTZBzPf0BxH4O+t9Qs/53FpXXIcxCu3DqS4oQbbVI0eZ+XIAiDmQlRfqQks01Dtn X-Received: by 2002:a17:902:7b87:b0:14a:bf7b:84da with SMTP id w7-20020a1709027b8700b0014abf7b84damr16409378pll.89.1643067979677; Mon, 24 Jan 2022 15:46:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067979; cv=none; d=google.com; s=arc-20160816; b=Chlb/+XmtFTCHYnKfS4GCDO4rYEPNfKzWwuEQDMVwnKLG29He5tL5xCoTumSfsiX4+ nfTD1rUWXhKDG3gxWLlGHxIdojMvjAaqG3xF+Nrn+CW6HwRUJyt0JcM5WFefMkAwsiic e06xylhA4Qh+DK7p2BmMkpghOmAQ2y0rFOOknydTQX0aNx+5EN9GoYHick+I6xv07RBT btxgP10yGjnM+akQL2TjD3Dk+tPBuUM078xs1eb05VMuDUgrn5kkTMwJt59poBOU0azI s/ux2Q9/Lxd4trDwNuRTV1EqcHuzdTkZInDxrjtPk105Fyqi4onkaq2sF9cFyGri52br nHrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CIw1ir1vncWBRYqfXOokyCT3T75ps2ZR71RXhfQQJAw=; b=E5frFnw5WqlUnZHwNA6552WkJDLOGQqEG7wbo97za86iqgsPMSt2nRDsjUcqHrJ/OT 0mGHAQ6mDiLTVYwLnaszq/6q2W+WtD82MyPNP+PRgiCbiEIgrRf36fVF1tbjmXTTCWRU /oM28Z5trUJMWMEurzRf7B7Y1wLfUyJr5xeISQX1pnbJaGfQpP3K01ZZekDzuHC0X2t4 6YLEHzSyZ8MVomotaeri07kc21GT+zlkkNmUJG/3kV/90gJ9o4m4HYwz0n2aesEM9QW5 J9kMSo1jcvnuLQscbuRwJuNXSLuXo/t2qG2Cdv5hCELpp9QpMDV6+vyoQOTTK2QTyqWx Ntsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GD7/bqbj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf20si8309880pgb.474.2022.01.24.15.46.06; Mon, 24 Jan 2022 15:46:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GD7/bqbj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2361264AbiAXXji (ORCPT + 99 others); Mon, 24 Jan 2022 18:39:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1842389AbiAXXBr (ORCPT ); Mon, 24 Jan 2022 18:01:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2DC6C0F0551; Mon, 24 Jan 2022 13:13:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83D646147D; Mon, 24 Jan 2022 21:13:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C436C340E5; Mon, 24 Jan 2022 21:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058834; bh=hu2038tPn5JoE1cXR2b9Gyfb0XVbNKodylO5hpbvfNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GD7/bqbj7wEFCekn2sjHrkoyoF8XSvWCbCN9hUCJJ6JZvS6qrHCS8n0tTpV7Kjabz 0g8A0tfPQpgxQmsiscU0sYDP+pvHghQVSryNBOJ5ocBr7ZjGLNbt/ZNjdygwEDfHJ/ B5j/dNhYyqVK/7ICSN0i2e7jmNBWAyraLoXD9CeU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Mat Martineau , "David S. Miller" , Sasha Levin Subject: [PATCH 5.16 0418/1039] mptcp: fix per socket endpoint accounting Date: Mon, 24 Jan 2022 19:36:47 +0100 Message-Id: <20220124184139.360599133@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit f7d6a237d7422809d458d754016de2844017cb4d ] Since full-mesh endpoint support, the reception of a single ADD_ADDR option can cause multiple subflows creation. When such option is accepted we increment 'add_addr_accepted' by one. When we received a paired RM_ADDR option, we deleted all the relevant subflows, decrementing 'add_addr_accepted' by one for each of them. We have a similar issue for 'local_addr_used' Fix them moving the pm endpoint accounting outside the subflow traversal. Fixes: 1a0d6136c5f0 ("mptcp: local addresses fullmesh") Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/mptcp/pm_netlink.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index f523051f5aef3..65764c8171b37 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -710,6 +710,8 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, return; for (i = 0; i < rm_list->nr; i++) { + bool removed = false; + list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { struct sock *ssk = mptcp_subflow_tcp_sock(subflow); int how = RCV_SHUTDOWN | SEND_SHUTDOWN; @@ -729,15 +731,19 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, mptcp_close_ssk(sk, ssk, subflow); spin_lock_bh(&msk->pm.lock); - if (rm_type == MPTCP_MIB_RMADDR) { - msk->pm.add_addr_accepted--; - WRITE_ONCE(msk->pm.accept_addr, true); - } else if (rm_type == MPTCP_MIB_RMSUBFLOW) { - msk->pm.local_addr_used--; - } + removed = true; msk->pm.subflows--; __MPTCP_INC_STATS(sock_net(sk), rm_type); } + if (!removed) + continue; + + if (rm_type == MPTCP_MIB_RMADDR) { + msk->pm.add_addr_accepted--; + WRITE_ONCE(msk->pm.accept_addr, true); + } else if (rm_type == MPTCP_MIB_RMSUBFLOW) { + msk->pm.local_addr_used--; + } } } -- 2.34.1