netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues
@ 2020-09-07 10:29 Geliang Tang
  2020-09-07 10:29 ` [MPTCP][PATCH net 2/2] mptcp: fix subflow's remote_id issues Geliang Tang
  2020-09-07 15:07 ` [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues Matthieu Baerts
  0 siblings, 2 replies; 4+ messages in thread
From: Geliang Tang @ 2020-09-07 10:29 UTC (permalink / raw)
  To: Mat Martineau, Matthieu Baerts, David S. Miller, Jakub Kicinski
  Cc: Geliang Tang, netdev, mptcp, linux-kernel

In mptcp_pm_nl_get_local_id, skc_local is the same as msk_local, so it
always return 0. Thus every subflow's local_id is 0. It's incorrect.

This patch fixed this issue.

Also, we need to ignore the zero address here, like 0.0.0.0 in IPv4. When
we use the zero address as a local address, it means that we can use any
one of the local addresses. The zero address is not a new address, we don't
need to add it to PM, so this patch added a new function address_zero to
check whether an address is the zero address, if it is, we ignore this
address.

Reviewed-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 net/mptcp/pm_netlink.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 2c208d2e65cd..dc2c57860d2d 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -66,6 +66,19 @@ static bool addresses_equal(const struct mptcp_addr_info *a,
 	return a->port == b->port;
 }
 
+static bool address_zero(const struct mptcp_addr_info *addr)
+{
+	struct mptcp_addr_info zero;
+
+	memset(&zero, 0, sizeof(zero));
+	zero.family = addr->family;
+
+	if (addresses_equal(addr, &zero, false))
+		return true;
+
+	return false;
+}
+
 static void local_address(const struct sock_common *skc,
 			  struct mptcp_addr_info *addr)
 {
@@ -323,10 +336,13 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 	 * addr
 	 */
 	local_address((struct sock_common *)msk, &msk_local);
-	local_address((struct sock_common *)msk, &skc_local);
+	local_address((struct sock_common *)skc, &skc_local);
 	if (addresses_equal(&msk_local, &skc_local, false))
 		return 0;
 
+	if (address_zero(&skc_local))
+		return 0;
+
 	pernet = net_generic(sock_net((struct sock *)msk), pm_nl_pernet_id);
 
 	rcu_read_lock();
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [MPTCP][PATCH net 2/2] mptcp: fix subflow's remote_id issues
  2020-09-07 10:29 [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues Geliang Tang
@ 2020-09-07 10:29 ` Geliang Tang
  2020-09-07 15:07   ` Matthieu Baerts
  2020-09-07 15:07 ` [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues Matthieu Baerts
  1 sibling, 1 reply; 4+ messages in thread
From: Geliang Tang @ 2020-09-07 10:29 UTC (permalink / raw)
  To: Mat Martineau, Matthieu Baerts, David S. Miller, Jakub Kicinski
  Cc: Geliang Tang, netdev, mptcp, linux-kernel

This patch set the init remote_id to zero, otherwise it will be a random
number.

Then it added the missing subflow's remote_id setting code both in
__mptcp_subflow_connect and in subflow_ulp_clone.

Reviewed-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 net/mptcp/pm_netlink.c | 2 +-
 net/mptcp/subflow.c    | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index dc2c57860d2d..255695221309 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -186,7 +186,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 {
 	struct sock *sk = (struct sock *)msk;
 	struct mptcp_pm_addr_entry *local;
-	struct mptcp_addr_info remote;
+	struct mptcp_addr_info remote = { 0 };
 	struct pm_nl_pernet *pernet;
 
 	pernet = net_generic(sock_net((struct sock *)msk), pm_nl_pernet_id);
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index e8cac2655c82..9ead43f79023 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1063,6 +1063,7 @@ int __mptcp_subflow_connect(struct sock *sk, int ifindex,
 	struct mptcp_sock *msk = mptcp_sk(sk);
 	struct mptcp_subflow_context *subflow;
 	struct sockaddr_storage addr;
+	int remote_id = remote->id;
 	int local_id = loc->id;
 	struct socket *sf;
 	struct sock *ssk;
@@ -1107,10 +1108,11 @@ int __mptcp_subflow_connect(struct sock *sk, int ifindex,
 		goto failed;
 
 	mptcp_crypto_key_sha(subflow->remote_key, &remote_token, NULL);
-	pr_debug("msk=%p remote_token=%u local_id=%d", msk, remote_token,
-		 local_id);
+	pr_debug("msk=%p remote_token=%u local_id=%d remote_id=%d", msk,
+		 remote_token, local_id, remote_id);
 	subflow->remote_token = remote_token;
 	subflow->local_id = local_id;
+	subflow->remote_id = remote_id;
 	subflow->request_join = 1;
 	subflow->request_bkup = 1;
 	mptcp_info2sockaddr(remote, &addr);
@@ -1347,6 +1349,7 @@ static void subflow_ulp_clone(const struct request_sock *req,
 		new_ctx->fully_established = 1;
 		new_ctx->backup = subflow_req->backup;
 		new_ctx->local_id = subflow_req->local_id;
+		new_ctx->remote_id = subflow_req->remote_id;
 		new_ctx->token = subflow_req->token;
 		new_ctx->thmac = subflow_req->thmac;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues
  2020-09-07 10:29 [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues Geliang Tang
  2020-09-07 10:29 ` [MPTCP][PATCH net 2/2] mptcp: fix subflow's remote_id issues Geliang Tang
@ 2020-09-07 15:07 ` Matthieu Baerts
  1 sibling, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2020-09-07 15:07 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Mat Martineau, David S. Miller, Jakub Kicinski, netdev, mptcp,
	linux-kernel

Hi Geliang,

On 07/09/2020 12:29, Geliang Tang wrote:
> In mptcp_pm_nl_get_local_id, skc_local is the same as msk_local, so it
> always return 0. Thus every subflow's local_id is 0. It's incorrect.
> 
> This patch fixed this issue.
> 
> Also, we need to ignore the zero address here, like 0.0.0.0 in IPv4. When
> we use the zero address as a local address, it means that we can use any
> one of the local addresses. The zero address is not a new address, we don't
> need to add it to PM, so this patch added a new function address_zero to
> check whether an address is the zero address, if it is, we ignore this
> address.

Thank you for this patch!

As any patch for -net, may you add a "Fixes:" tag please?

(Also, I don't know if it is normal but I didn't receive the cover-letter)

(...)

> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 2c208d2e65cd..dc2c57860d2d 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -66,6 +66,19 @@ static bool addresses_equal(const struct mptcp_addr_info *a,
>   	return a->port == b->port;
>   }
>   
> +static bool address_zero(const struct mptcp_addr_info *addr)
> +{
> +	struct mptcp_addr_info zero;
> +
> +	memset(&zero, 0, sizeof(zero));
> +	zero.family = addr->family;
> +
> +	if (addresses_equal(addr, &zero, false))

Small detail: here you can simply have:

   return addresses_equal(addr, &zero, false);

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [MPTCP][PATCH net 2/2] mptcp: fix subflow's remote_id issues
  2020-09-07 10:29 ` [MPTCP][PATCH net 2/2] mptcp: fix subflow's remote_id issues Geliang Tang
@ 2020-09-07 15:07   ` Matthieu Baerts
  0 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2020-09-07 15:07 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Mat Martineau, David S. Miller, Jakub Kicinski, netdev, mptcp,
	linux-kernel

Hi Geliang,

On 07/09/2020 12:29, Geliang Tang wrote:
> This patch set the init remote_id to zero, otherwise it will be a random
> number.
> 
> Then it added the missing subflow's remote_id setting code both in
> __mptcp_subflow_connect and in subflow_ulp_clone.

Thank you for this other patch!

Here as well, may you add a "Fixes:" tag please?

(...)

> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index dc2c57860d2d..255695221309 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -186,7 +186,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
>   {
>   	struct sock *sk = (struct sock *)msk;
>   	struct mptcp_pm_addr_entry *local;
> -	struct mptcp_addr_info remote;
> +	struct mptcp_addr_info remote = { 0 };

To respect the "reversed Xmas tree" way to declare variables, may you 
move this line up to be the first one in the list please?

The rest looks good to me, thank you!

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-07 15:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 10:29 [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues Geliang Tang
2020-09-07 10:29 ` [MPTCP][PATCH net 2/2] mptcp: fix subflow's remote_id issues Geliang Tang
2020-09-07 15:07   ` Matthieu Baerts
2020-09-07 15:07 ` [MPTCP][PATCH net 1/2] mptcp: fix subflow's local_id issues Matthieu Baerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).