diff mbox series

[mptcp-next,3/3] Squash-to: mptcp: netlink: allow userspace-driven subflow establishment

Message ID 20220419230340.2263545-4-kishen.maloor@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Matthieu Baerts
Headers show
Series mptcp: fix bug in userspace PM APIs | expand

Checks

Context Check Description
matttbe/build success Build and static analysis OK
matttbe/checkpatch warning total: 0 errors, 1 warnings, 0 checks, 139 lines checked
matttbe/KVM_Validation__normal success Success! ✅

Commit Message

Kishen Maloor April 19, 2022, 11:03 p.m. UTC
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
---
 net/mptcp/pm_userspace.c | 59 ++++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 27 deletions(-)

Comments

MPTCP CI April 20, 2022, 1:02 a.m. UTC | #1
Hi Kishen,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/5545811772702720
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5545811772702720/summary/summary.txt

- {"code":404,"message":
  - "HTTP 404 Not Found"}:
  - Task: https://cirrus-ci.com/task/6671711679545344
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6671711679545344/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/b0d39b257105


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-debug

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)
diff mbox series

Patch

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 3d8f6126b952..9f6b5eda5524 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -251,13 +251,13 @@  int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info)
 	struct mptcp_addr_info addr_r;
 	struct mptcp_addr_info addr_l;
 	struct mptcp_sock *msk;
+	int err = -EINVAL;
 	struct sock *sk;
 	u32 token_val;
-	int ret;
 
 	if (!laddr || !raddr || !token) {
 		GENL_SET_ERR_MSG(info, "missing required inputs");
-		return -EINVAL;
+		return err;
 	}
 
 	token_val = nla_get_u32(token);
@@ -265,39 +265,41 @@  int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info)
 	msk = mptcp_token_get_sock(genl_info_net(info), token_val);
 	if (!msk) {
 		NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token");
-		return -EINVAL;
+		return err;
 	}
 
 	if (!mptcp_pm_is_userspace(msk)) {
 		GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
-		return -EINVAL;
+		goto create_err;
 	}
 
-	ret = mptcp_pm_parse_addr(laddr, info, &addr_l);
-	if (ret < 0) {
+	err = mptcp_pm_parse_addr(laddr, info, &addr_l);
+	if (err < 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr");
-		return -EINVAL;
+		goto create_err;
 	}
 
 	if (addr_l.id == 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, laddr, "missing local addr id");
-		return -EINVAL;
+		goto create_err;
 	}
 
-	ret = mptcp_pm_parse_addr(raddr, info, &addr_r);
-	if (ret < 0) {
+	err = mptcp_pm_parse_addr(raddr, info, &addr_r);
+	if (err < 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr");
-		return -EINVAL;
+		goto create_err;
 	}
 
 	sk = &msk->sk.icsk_inet.sk;
 	lock_sock(sk);
 
-	ret = __mptcp_subflow_connect(sk, &addr_l, &addr_r);
+	err = __mptcp_subflow_connect(sk, &addr_l, &addr_r);
 
 	release_sock(sk);
 
-	return ret;
+ create_err:
+	sock_put((struct sock *)msk);
+	return err;
 }
 
 static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
@@ -366,12 +368,12 @@  int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 	struct mptcp_addr_info addr_r;
 	struct mptcp_sock *msk;
 	struct sock *sk, *ssk;
+	int err = -EINVAL;
 	u32 token_val;
-	int ret;
 
 	if (!laddr || !raddr || !token) {
 		GENL_SET_ERR_MSG(info, "missing required inputs");
-		return -EINVAL;
+		return err;
 	}
 
 	token_val = nla_get_u32(token);
@@ -379,34 +381,34 @@  int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 	msk = mptcp_token_get_sock(genl_info_net(info), token_val);
 	if (!msk) {
 		NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token");
-		return -EINVAL;
+		return err;
 	}
 
 	if (!mptcp_pm_is_userspace(msk)) {
 		GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
-		return -EINVAL;
+		goto destroy_err;
 	}
 
-	ret = mptcp_pm_parse_addr(laddr, info, &addr_l);
-	if (ret < 0) {
+	err = mptcp_pm_parse_addr(laddr, info, &addr_l);
+	if (err < 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr");
-		return ret;
+		goto destroy_err;
 	}
 
-	ret = mptcp_pm_parse_addr(raddr, info, &addr_r);
-	if (ret < 0) {
+	err = mptcp_pm_parse_addr(raddr, info, &addr_r);
+	if (err < 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr");
-		return ret;
+		goto destroy_err;
 	}
 
 	if (addr_l.family != addr_r.family) {
 		GENL_SET_ERR_MSG(info, "address families do not match");
-		return -EINVAL;
+		goto destroy_err;
 	}
 
 	if (!addr_l.port || !addr_r.port) {
 		GENL_SET_ERR_MSG(info, "missing local or remote port");
-		return -EINVAL;
+		goto destroy_err;
 	}
 
 	sk = &msk->sk.icsk_inet.sk;
@@ -416,9 +418,12 @@  int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 
 		mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN | SEND_SHUTDOWN);
 		mptcp_close_ssk(sk, ssk, subflow);
+		err = 0;
 	} else {
-		ret = -ESRCH;
+		err = -ESRCH;
 	}
 
-	return ret;
+ destroy_err:
+	sock_put((struct sock *)msk);
+	return err;
 }