[PATCH mptcp-next v3] mptcp: get sk from msk directly

Geliang Tang posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20221025032610.17496-1-geliang.tang@suse.com
Maintainers: Mat Martineau <mathew.j.martineau@linux.intel.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
net/mptcp/pm_userspace.c | 4 ++--
net/mptcp/protocol.c     | 4 ++--
net/mptcp/sockopt.c      | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
[PATCH mptcp-next v3] mptcp: get sk from msk directly
Posted by Geliang Tang 1 month, 1 week ago
Use '(struct sock *)msk' to get 'sk' from 'msk' in a more direct way
instead of using '&msk->sk.icsk_inet.sk'.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
v3:
- change protocol.c and sockopt.c too.

v2:
- fix the "uninitialized use occurs" error reported by kernel test robot
<lkp@intel.com>
---
 net/mptcp/pm_userspace.c | 4 ++--
 net/mptcp/protocol.c     | 4 ++--
 net/mptcp/sockopt.c      | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 9e82250cbb70..5cb65f0928f4 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -291,7 +291,7 @@ int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info)
 		goto create_err;
 	}
 
-	sk = &msk->sk.icsk_inet.sk;
+	sk = (struct sock *)msk;
 	lock_sock(sk);
 
 	err = __mptcp_subflow_connect(sk, &addr_l, &addr_r);
@@ -403,7 +403,7 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 		goto destroy_err;
 	}
 
-	sk = &msk->sk.icsk_inet.sk;
+	sk = (struct sock *)msk;
 	lock_sock(sk);
 	ssk = mptcp_nl_find_ssk(msk, &addr_l, &addr_r);
 	if (ssk) {
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index ddeb8b36a677..dceeaaf3bab4 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2440,7 +2440,7 @@ static bool mptcp_check_close_timeout(const struct sock *sk)
 static void mptcp_check_fastclose(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
-	struct sock *sk = &msk->sk.icsk_inet.sk;
+	struct sock *sk = (struct sock *)msk;
 
 	if (likely(!READ_ONCE(msk->rcv_fastclose)))
 		return;
@@ -2602,7 +2602,7 @@ static void mptcp_do_fastclose(struct sock *sk)
 static void mptcp_worker(struct work_struct *work)
 {
 	struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);
-	struct sock *sk = &msk->sk.icsk_inet.sk;
+	struct sock *sk = (struct sock *)msk;
 	unsigned long fail_tout;
 	int state;
 
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index f85e9bbfe86f..f62f6483ef77 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -987,7 +987,7 @@ static int mptcp_getsockopt_tcpinfo(struct mptcp_sock *msk, char __user *optval,
 				    int __user *optlen)
 {
 	struct mptcp_subflow_context *subflow;
-	struct sock *sk = &msk->sk.icsk_inet.sk;
+	struct sock *sk = (struct sock *)msk;
 	unsigned int sfcount = 0, copied = 0;
 	struct mptcp_subflow_data sfd;
 	char __user *infoptr;
@@ -1078,8 +1078,8 @@ static void mptcp_get_sub_addrs(const struct sock *sk, struct mptcp_subflow_addr
 static int mptcp_getsockopt_subflow_addrs(struct mptcp_sock *msk, char __user *optval,
 					  int __user *optlen)
 {
-	struct sock *sk = &msk->sk.icsk_inet.sk;
 	struct mptcp_subflow_context *subflow;
+	struct sock *sk = (struct sock *)msk;
 	unsigned int sfcount = 0, copied = 0;
 	struct mptcp_subflow_data sfd;
 	char __user *addrptr;
-- 
2.35.3
Re: [PATCH mptcp-next v3] mptcp: get sk from msk directly
Posted by Matthieu Baerts 1 month ago
Hi Geliang, Mat,

On 25/10/2022 05:26, Geliang Tang wrote:
> Use '(struct sock *)msk' to get 'sk' from 'msk' in a more direct way
> instead of using '&msk->sk.icsk_inet.sk'.

Thank you for the patch and the review!

Now in our tree (feat. for net-next) with Mat's RvB tag:

New patches for t/upstream:
- 4e306bab073d: mptcp: get sk from msk directly
- Results: d708694301f4..c760a79c8d57 (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20221031T155336

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
Re: mptcp: get sk from msk directly: Tests Results
Posted by MPTCP CI 1 month, 1 week ago
Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Unstable: 1 failed test(s): packetdrill_add_addr 🔴:
  - Task: https://cirrus-ci.com/task/5515831614898176
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5515831614898176/summary/summary.txt

- KVM Validation: debug:
  - Unstable: 2 failed test(s): packetdrill_add_addr selftest_mptcp_join 🔴:
  - Task: https://cirrus-ci.com/task/6641731521740800
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6641731521740800/summary/summary.txt

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


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)
Re: [PATCH mptcp-next v3] mptcp: get sk from msk directly
Posted by Mat Martineau 1 month, 1 week ago
On Tue, 25 Oct 2022, Geliang Tang wrote:

> Use '(struct sock *)msk' to get 'sk' from 'msk' in a more direct way
> instead of using '&msk->sk.icsk_inet.sk'.
>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> v3:
> - change protocol.c and sockopt.c too.
>
> v2:
> - fix the "uninitialized use occurs" error reported by kernel test robot
> <lkp@intel.com>

v3 looks good to me, thanks Geliang:

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>


> ---
> net/mptcp/pm_userspace.c | 4 ++--
> net/mptcp/protocol.c     | 4 ++--
> net/mptcp/sockopt.c      | 4 ++--
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 9e82250cbb70..5cb65f0928f4 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -291,7 +291,7 @@ int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info)
> 		goto create_err;
> 	}
>
> -	sk = &msk->sk.icsk_inet.sk;
> +	sk = (struct sock *)msk;
> 	lock_sock(sk);
>
> 	err = __mptcp_subflow_connect(sk, &addr_l, &addr_r);
> @@ -403,7 +403,7 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
> 		goto destroy_err;
> 	}
>
> -	sk = &msk->sk.icsk_inet.sk;
> +	sk = (struct sock *)msk;
> 	lock_sock(sk);
> 	ssk = mptcp_nl_find_ssk(msk, &addr_l, &addr_r);
> 	if (ssk) {
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index ddeb8b36a677..dceeaaf3bab4 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2440,7 +2440,7 @@ static bool mptcp_check_close_timeout(const struct sock *sk)
> static void mptcp_check_fastclose(struct mptcp_sock *msk)
> {
> 	struct mptcp_subflow_context *subflow, *tmp;
> -	struct sock *sk = &msk->sk.icsk_inet.sk;
> +	struct sock *sk = (struct sock *)msk;
>
> 	if (likely(!READ_ONCE(msk->rcv_fastclose)))
> 		return;
> @@ -2602,7 +2602,7 @@ static void mptcp_do_fastclose(struct sock *sk)
> static void mptcp_worker(struct work_struct *work)
> {
> 	struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);
> -	struct sock *sk = &msk->sk.icsk_inet.sk;
> +	struct sock *sk = (struct sock *)msk;
> 	unsigned long fail_tout;
> 	int state;
>
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index f85e9bbfe86f..f62f6483ef77 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
> @@ -987,7 +987,7 @@ static int mptcp_getsockopt_tcpinfo(struct mptcp_sock *msk, char __user *optval,
> 				    int __user *optlen)
> {
> 	struct mptcp_subflow_context *subflow;
> -	struct sock *sk = &msk->sk.icsk_inet.sk;
> +	struct sock *sk = (struct sock *)msk;
> 	unsigned int sfcount = 0, copied = 0;
> 	struct mptcp_subflow_data sfd;
> 	char __user *infoptr;
> @@ -1078,8 +1078,8 @@ static void mptcp_get_sub_addrs(const struct sock *sk, struct mptcp_subflow_addr
> static int mptcp_getsockopt_subflow_addrs(struct mptcp_sock *msk, char __user *optval,
> 					  int __user *optlen)
> {
> -	struct sock *sk = &msk->sk.icsk_inet.sk;
> 	struct mptcp_subflow_context *subflow;
> +	struct sock *sk = (struct sock *)msk;
> 	unsigned int sfcount = 0, copied = 0;
> 	struct mptcp_subflow_data sfd;
> 	char __user *addrptr;
> -- 
> 2.35.3
>
>
>

--
Mat Martineau
Intel
Re: mptcp: get sk from msk directly: Tests Results
Posted by MPTCP CI 1 month, 1 week ago
Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- {"code":404,"message":
  - "Can't find artifacts containing file conclusion.txt"}:
  - Task: https://cirrus-ci.com/task/5498513902534656
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5498513902534656/summary/summary.txt

- {"code":404,"message":
  - "Can't find artifacts containing file conclusion.txt"}:
  - Task: https://cirrus-ci.com/task/6624413809377280
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6624413809377280/summary/summary.txt

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


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)