From: Anil Kaushik <anilkaushikwireless@gmail.com>
To: mptcp@lists.linux.dev
Cc: anilkaushikwireless@gmail.com
Subject: [PATCH mptcp-next v16 2/7] mptcp: pm: in-kernel: check the limits with the netlink policy
Date: Sun, 22 Nov 2026 00:47:49 +0000 [thread overview]
Message-ID: <20261122004754.2276802-3-anilkaushikwireless@gmail.com> (raw)
In-Reply-To: <20261122004754.2276802-1-anilkaushikwireless@gmail.com>
The maximum of the rcv-add-addrs and subflows limits is checked by
parse_limit(). The netlink policy can do that: add the maximum to the
spec, and drop this helper. The next limit will do the same.
The maximum is unchanged, but a value above it now gets ERANGE from the
policy, instead of EINVAL.
The uapi header is not changed. The generated files are updated with
ynl-regen.
Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
---
Documentation/netlink/specs/mptcp_pm.yaml | 4 +++
net/mptcp/mptcp_pm_gen.c | 8 ++---
net/mptcp/pm_kernel.c | 39 +++++------------------
3 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/Documentation/netlink/specs/mptcp_pm.yaml b/Documentation/netlink/specs/mptcp_pm.yaml
index 39f3facc38e5..f25f00759ffa 100644
--- a/Documentation/netlink/specs/mptcp_pm.yaml
+++ b/Documentation/netlink/specs/mptcp_pm.yaml
@@ -183,9 +183,13 @@ attribute-sets:
-
name: rcv-add-addrs
type: u32
+ checks:
+ max: 64
-
name: subflows
type: u32
+ checks:
+ max: 64
-
name: token
type: u32
diff --git a/net/mptcp/mptcp_pm_gen.c b/net/mptcp/mptcp_pm_gen.c
index c180930a8e0e..59d57aebf968 100644
--- a/net/mptcp/mptcp_pm_gen.c
+++ b/net/mptcp/mptcp_pm_gen.c
@@ -45,14 +45,14 @@ const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR +
/* MPTCP_PM_CMD_SET_LIMITS - do */
const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = {
- [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, },
- [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, },
+ [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = NLA_POLICY_MAX(NLA_U32, 64),
+ [MPTCP_PM_ATTR_SUBFLOWS] = NLA_POLICY_MAX(NLA_U32, 64),
};
/* MPTCP_PM_CMD_GET_LIMITS - do */
const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = {
- [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, },
- [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, },
+ [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = NLA_POLICY_MAX(NLA_U32, 64),
+ [MPTCP_PM_ATTR_SUBFLOWS] = NLA_POLICY_MAX(NLA_U32, 64),
};
/* MPTCP_PM_CMD_SET_FLAGS - do */
diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index 2680d4672d58..eb66e0c1c797 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -30,7 +30,6 @@ struct pm_nl_pernet {
};
#define MPTCP_PM_ADDR_MAX 8
-#define MPTCP_PM_SUBFLOWS_MAX 64
static struct pm_nl_pernet *pm_nl_get_pernet(const struct net *net)
{
@@ -1402,46 +1401,24 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
return msg->len;
}
-static int parse_limit(struct genl_info *info, int id, unsigned int *limit)
-{
- struct nlattr *attr = info->attrs[id];
-
- if (!attr)
- return 0;
-
- *limit = nla_get_u32(attr);
- if (*limit > MPTCP_PM_SUBFLOWS_MAX) {
- NL_SET_ERR_MSG_ATTR_FMT(info->extack, attr,
- "limit greater than maximum (%u)",
- MPTCP_PM_SUBFLOWS_MAX);
- return -EINVAL;
- }
- return 0;
-}
-
int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info)
{
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
+ struct nlattr **attrs = info->attrs;
unsigned int rcv_addrs, subflows;
- int ret;
+ /* the maximums are checked by the policy */
spin_lock_bh(&pernet->lock);
- rcv_addrs = pernet->limit_add_addr_accepted;
- ret = parse_limit(info, MPTCP_PM_ATTR_RCV_ADD_ADDRS, &rcv_addrs);
- if (ret)
- goto unlock;
-
- subflows = pernet->limit_extra_subflows;
- ret = parse_limit(info, MPTCP_PM_ATTR_SUBFLOWS, &subflows);
- if (ret)
- goto unlock;
+ rcv_addrs = nla_get_u32_default(attrs[MPTCP_PM_ATTR_RCV_ADD_ADDRS],
+ pernet->limit_add_addr_accepted);
+ subflows = nla_get_u32_default(attrs[MPTCP_PM_ATTR_SUBFLOWS],
+ pernet->limit_extra_subflows);
WRITE_ONCE(pernet->limit_add_addr_accepted, rcv_addrs);
WRITE_ONCE(pernet->limit_extra_subflows, subflows);
-
-unlock:
spin_unlock_bh(&pernet->lock);
- return ret;
+
+ return 0;
}
int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info)
--
2.25.1
next prev parent reply other threads:[~2026-11-22 0:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 0:47 [PATCH mptcp-next v16 0/7] mptcp: pm: in-kernel: retry subflows closed after an error Anil Kaushik
2026-11-22 0:47 ` [PATCH mptcp-next v16 1/7] selftests: mptcp: connect: retry write() on EAGAIN Anil Kaushik
2026-11-22 0:47 ` Anil Kaushik [this message]
2026-11-22 0:47 ` [PATCH mptcp-next v16 3/7] netlink: specs: mptcp: add the subflow-retries attribute Anil Kaushik
2026-11-22 0:47 ` [PATCH mptcp-next v16 4/7] mptcp: pm: in-kernel: add the subflow-retries limit Anil Kaushik
2026-11-22 0:47 ` [PATCH mptcp-next v16 5/7] mptcp: pm: in-kernel: retry subflows closed after an error Anil Kaushik
2026-11-22 0:47 ` [PATCH mptcp-next v16 6/7] selftests: mptcp: pm_nl_ctl: support the subflow-retries limit Anil Kaushik
2026-11-22 0:47 ` [PATCH mptcp-next v16 7/7] selftests: mptcp: join: validate subflow retry after link failure Anil Kaushik
2026-11-22 3:28 ` [PATCH mptcp-next v16 0/7] mptcp: pm: in-kernel: retry subflows closed after an error MPTCP CI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122004754.2276802-3-anilkaushikwireless@gmail.com \
--to=anilkaushikwireless@gmail.com \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.