This patch adds a new helper mptcp_pm_parse_needs_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 <geliang.tang@linux.dev>
---
net/mptcp/pm.c | 17 +++++++++++++++++
net/mptcp/protocol.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 4ae19113b8eb..e16312fde6fb 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -533,6 +533,23 @@ 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_parse_needs_id(const struct nlattr *attr,
+ struct genl_info *info)
+{
+ struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1];
+ int err;
+
+ if (attr) {
+ /* no validation needed - was already done via nested policy */
+ err = nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
+ mptcp_pm_address_nl_policy, info->extack);
+ if (!err && tb[MPTCP_PM_ADDR_ATTR_ID])
+ return false;
+ }
+
+ return true;
+}
+
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..63c6e6dbc867 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_parse_needs_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