[PATCH mptcp-next v9 01/23] mptcp: add pm_has_addr_attr_id helper

Geliang Tang posted 23 patches 7 months, 3 weeks ago
There is a newer version of this series
[PATCH mptcp-next v9 01/23] mptcp: add pm_has_addr_attr_id helper
Posted by Geliang Tang 7 months, 3 weeks ago
From: Geliang Tang <tanggeliang@kylinos.cn>

This patch adds a new helper mptcp_pm_has_addr_attr_id() to check whether
an address ID is set from PM or not. It will be used in the next two
commits.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 net/mptcp/pm.c       | 12 ++++++++++++
 net/mptcp/protocol.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 4ae19113b8eb..6856d10368be 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -533,6 +533,18 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)
 	bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
 }
 
+bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,
+			       struct genl_info *info)
+{
+	struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1];
+
+	if (!nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
+					 mptcp_pm_address_nl_policy, info->extack) &&
+	    tb[MPTCP_PM_ADDR_ATTR_ID])
+		return true;
+	return false;
+}
+
 void mptcp_pm_data_init(struct mptcp_sock *msk)
 {
 	spin_lock_init(&msk->pm.lock);
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index f7b9c1b995df..def791ce751b 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -886,6 +886,8 @@ int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
 int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info,
 			 bool require_family,
 			 struct mptcp_pm_addr_entry *entry);
+bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,
+			       struct genl_info *info);
 bool mptcp_pm_addr_families_match(const struct sock *sk,
 				  const struct mptcp_addr_info *loc,
 				  const struct mptcp_addr_info *rem);
-- 
2.40.1