From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: mptcp@lists.linux.dev
Cc: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Subject: [PATCH mptcp-next v6 3/7] mptcp: pm: improve error messages
Date: Mon, 30 Dec 2024 14:24:10 +0100 [thread overview]
Message-ID: <20241230-genl_req_attr_check-v6-3-3ec9103559e7@kernel.org> (raw)
In-Reply-To: <20241230-genl_req_attr_check-v6-0-3ec9103559e7@kernel.org>
Some error messages were:
- too generic: "missing input", "invalid request"
- not precise enough: "limit greater than maximum" but what's the max?
- missing: subflow not found, or connect error.
This can be easily improved by being more precise, or adding new error
messages.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_netlink.c | 7 ++++---
net/mptcp/pm_userspace.c | 9 ++++++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 49c34494e156ff6c3277b107c3840ee29dd3afbb..3bb213e2a967e87d4244dc0f1ba58d3ba21fb371 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1878,8 +1878,9 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit)
*limit = nla_get_u32(attr);
if (*limit > MPTCP_PM_ADDR_MAX) {
- NL_SET_ERR_MSG_ATTR(info->extack, attr,
- "limit greater than maximum");
+ NL_SET_ERR_MSG_ATTR_FMT(info->extack, attr,
+ "limit greater than maximum (%u)",
+ MPTCP_PM_ADDR_MAX);
return -EINVAL;
}
return 0;
@@ -2008,7 +2009,7 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info)
lookup_by_id = 1;
if (!addr.addr.id) {
NL_SET_ERR_MSG_ATTR(info->extack, attr,
- "missing required inputs");
+ "missing address ID");
return -EOPNOTSUPP;
}
}
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 9c0bec588c498e0aa78acf4018db509abe90cad2..a8f73b082460ba00f7fa998cf7646368f8201e2e 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -191,7 +191,7 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in
if (!mptcp_pm_is_userspace(msk)) {
NL_SET_ERR_MSG_ATTR(info->extack, token,
- "invalid request; userspace PM not selected");
+ "userspace PM not selected");
sock_put((struct sock *)msk);
return NULL;
}
@@ -433,6 +433,9 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
err = __mptcp_subflow_connect(sk, &local, &addr_r);
release_sock(sk);
+ if (err)
+ GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err);
+
spin_lock_bh(&msk->pm.lock);
if (err)
mptcp_userspace_pm_delete_local_addr(msk, &entry);
@@ -557,6 +560,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
lock_sock(sk);
ssk = mptcp_nl_find_ssk(msk, &addr_l.addr, &addr_r);
if (!ssk) {
+ GENL_SET_ERR_MSG(info, "subflow not found");
err = -ESRCH;
goto release_sock;
}
@@ -634,6 +638,9 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup);
release_sock(sk);
+ if (ret)
+ GENL_SET_ERR_MSG(info, "subflow not found");
+
set_flags_err:
sock_put(sk);
return ret;
--
2.47.1
next prev parent reply other threads:[~2024-12-30 13:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-30 13:24 [PATCH mptcp-next v6 0/7] mptcp: use GENL_REQ_ATTR_CHECK in userspace pm Matthieu Baerts (NGI0)
2024-12-30 13:24 ` [PATCH mptcp-next v6 1/7] mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible Matthieu Baerts (NGI0)
2025-01-06 8:27 ` Geliang Tang
2024-12-30 13:24 ` [PATCH mptcp-next v6 2/7] mptcp: pm: more precise error messages Matthieu Baerts (NGI0)
2025-01-06 8:38 ` Geliang Tang
2025-01-06 8:55 ` Matthieu Baerts
2024-12-30 13:24 ` Matthieu Baerts (NGI0) [this message]
2025-01-06 8:41 ` [PATCH mptcp-next v6 3/7] mptcp: pm: improve " Geliang Tang
2025-01-06 8:45 ` Matthieu Baerts
2025-01-06 8:55 ` Geliang Tang
2025-01-06 9:03 ` Matthieu Baerts
2024-12-30 13:24 ` [PATCH mptcp-next v6 4/7] mptcp: pm: userspace: flags: clearer msg if no remote addr Matthieu Baerts (NGI0)
2025-01-06 8:46 ` Geliang Tang
2024-12-30 13:24 ` [PATCH mptcp-next v6 5/7] mptcp: pm: userspace: use GENL_REQ_ATTR_CHECK Matthieu Baerts (NGI0)
2024-12-30 13:24 ` [PATCH mptcp-next v6 6/7] mptcp: pm: remove duplicated error messages Matthieu Baerts (NGI0)
2024-12-30 13:24 ` [PATCH mptcp-next v6 7/7] mptcp: pm: mark missing address attributes Matthieu Baerts (NGI0)
2024-12-30 14:21 ` [PATCH mptcp-next v6 0/7] mptcp: use GENL_REQ_ATTR_CHECK in userspace pm MPTCP CI
2025-01-06 8:24 ` Geliang Tang
2025-01-06 9:08 ` Matthieu Baerts
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=20241230-genl_req_attr_check-v6-3-3ec9103559e7@kernel.org \
--to=matttbe@kernel.org \
--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.