From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0C6AE1BD50A; Wed, 20 Nov 2024 13:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732107690; cv=none; b=Hm2+clYFZ4rrrfj0EHBBRUCo/YdzE43E+6tDsYQ46M6IlGzqJVi7lSYmg9jPrEsmXKD8oAbG5ywXiokzXsBnos9whGnaDeELwgfL21V1xCUiyL3eKsg2HXA65xFVL/TGBVDlZ0ylRVoQjL24fkdfIxOdws9xfx9Q0iD/GGHcDu0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732107690; c=relaxed/simple; bh=TZx7xhJKsQa3LSoXx8kkSUXUzcJLXIKNwYlA5eCQTpE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RP8wILTpC+LkQeNLChxo6z74expYxv8kUsysYlqOx9fp2hIVAKu/p9mzeN+nofai7bn61poh/Cicbzf8S+/PewnZRWuLbpC4Wrb4PaIxqFYPo7aV2DK7urmD0W0vyu7aaxbKSwP2snIwkkX/J/V/+7gMXXp1O3Yzeneo2TBAxLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=S0rSbjM6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="S0rSbjM6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5F12C4CECD; Wed, 20 Nov 2024 13:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1732107689; bh=TZx7xhJKsQa3LSoXx8kkSUXUzcJLXIKNwYlA5eCQTpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0rSbjM6vfPPzn79XkDWVUP9KDiaZrAIGBDfCrcXYQlNtX3zwBXgrdc58+rRCdS71 8nUx3OxONgNTBzmh1S7b1iEVXklc6GAZxz6iHnVbrG3JdW5oTXWO5qa55DGFQ/E4bp 6D9Wvpzcih2nCepNt0itPxdj8e2wGEowmv1yIqT8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Geliang Tang , "Matthieu Baerts (NGI0)" , Mat Martineau , "David S. Miller" Subject: [PATCH 6.1 48/73] mptcp: add userspace_pm_lookup_addr_by_id helper Date: Wed, 20 Nov 2024 13:58:34 +0100 Message-ID: <20241120125810.764904769@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241120125809.623237564@linuxfoundation.org> References: <20241120125809.623237564@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Geliang Tang commit 06afe09091ee69dc7ab058b4be9917ae59cc81e5 upstream. Corresponding __lookup_addr_by_id() helper in the in-kernel netlink PM, this patch adds a new helper mptcp_userspace_pm_lookup_addr_by_id() to lookup the address entry with the given id on the userspace pm local address list. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: David S. Miller Stable-dep-of: f642c5c4d528 ("mptcp: hold pm lock when deleting entry") Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: Greg Kroah-Hartman --- net/mptcp/pm_userspace.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -106,22 +106,29 @@ static int mptcp_userspace_pm_delete_loc return -EINVAL; } +static struct mptcp_pm_addr_entry * +mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (entry->addr.id == id) + return entry; + } + return NULL; +} + int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex) { - struct mptcp_pm_addr_entry *entry, *match = NULL; + struct mptcp_pm_addr_entry *match; *flags = 0; *ifindex = 0; spin_lock_bh(&msk->pm.lock); - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (id == entry->addr.id) { - match = entry; - break; - } - } + match = mptcp_userspace_pm_lookup_addr_by_id(msk, id); spin_unlock_bh(&msk->pm.lock); if (match) { *flags = match->flags; @@ -282,7 +289,7 @@ int mptcp_nl_cmd_remove(struct sk_buff * { struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID]; - struct mptcp_pm_addr_entry *match = NULL; + struct mptcp_pm_addr_entry *match; struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; LIST_HEAD(free_list); @@ -319,13 +326,7 @@ int mptcp_nl_cmd_remove(struct sk_buff * lock_sock(sk); - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (entry->addr.id == id_val) { - match = entry; - break; - } - } - + match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val); if (!match) { GENL_SET_ERR_MSG(info, "address with specified id not found"); release_sock(sk);