summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>2025-02-07 14:59:21 +0100
committerPaolo Abeni <pabeni@redhat.com>2025-02-11 12:46:37 +0100
commit891a87f7a76c77f8afde876e08b55a2af9819709 (patch)
tree4ff7b5db440868443773b46a9baf27a643de7d73
parent58b21309f97b08b6b9814d1ee1419249eba9ef08 (diff)
mptcp: pm: more precise error messages
Some errors reported by the userspace PM were vague: "this or that is invalid". It is easier for the userspace to know which part is wrong, instead of having to guess that. While at it, in mptcp_userspace_pm_set_flags() move the parsing after the check linked to the local attribute. Reviewed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--net/mptcp/pm_userspace.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index b6cf8ea1161d..cdc83fabb7c2 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -223,8 +223,14 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
goto announce_err;
}
- if (addr_val.addr.id == 0 || !(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) {
- GENL_SET_ERR_MSG(info, "invalid addr id or flags");
+ if (addr_val.addr.id == 0) {
+ GENL_SET_ERR_MSG(info, "invalid addr id");
+ err = -EINVAL;
+ goto announce_err;
+ }
+
+ if (!(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) {
+ GENL_SET_ERR_MSG(info, "invalid addr flags");
err = -EINVAL;
goto announce_err;
}
@@ -531,8 +537,14 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
goto destroy_err;
}
- if (!addr_l.addr.port || !addr_r.port) {
- GENL_SET_ERR_MSG(info, "missing local or remote port");
+ if (!addr_l.addr.port) {
+ GENL_SET_ERR_MSG(info, "missing local port");
+ err = -EINVAL;
+ goto destroy_err;
+ }
+
+ if (!addr_r.port) {
+ GENL_SET_ERR_MSG(info, "missing remote port");
err = -EINVAL;
goto destroy_err;
}
@@ -580,13 +592,18 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
if (ret < 0)
goto set_flags_err;
+ if (loc.addr.family == AF_UNSPEC) {
+ GENL_SET_ERR_MSG(info, "invalid local address family");
+ ret = -EINVAL;
+ goto set_flags_err;
+ }
+
ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem);
if (ret < 0)
goto set_flags_err;
- if (loc.addr.family == AF_UNSPEC ||
- rem.addr.family == AF_UNSPEC) {
- GENL_SET_ERR_MSG(info, "invalid address families");
+ if (rem.addr.family == AF_UNSPEC) {
+ GENL_SET_ERR_MSG(info, "invalid remote address family");
ret = -EINVAL;
goto set_flags_err;
}