All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] [PATCH v3 10/10] mptcp: Implement path manager interface commands
@ 2019-08-07 22:44 Peter Krystad
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Krystad @ 2019-08-07 22:44 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 3352 bytes --]

Use the addr_signal flag to indicate to the subflow layer
that a local address may be announced, and call subflow_connect()
to initiate a secondary subflow.

Signed-off-by: Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/pm.c       | 62 +++++++++++++++++++++++++++++++++++++++++---
 net/mptcp/protocol.h |  1 +
 net/mptcp/token.c    | 13 ++++++++++
 3 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index e81475a337b7..c98b92512adf 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -13,17 +13,73 @@
 int pm_announce_addr(u32 token, sa_family_t family, u8 local_id,
 		     struct in_addr *addr)
 {
-	return -ENOTSUPP;
+	struct mptcp_sock *msk = mptcp_sk(token_lookup_get(token));
+	int err = 0;
+
+	if (!msk)
+		return -EINVAL;
+
+	if (msk->pm.local_valid) {
+		err = -EBADR;
+		goto announce_put;
+	}
+
+	pr_debug("msk=%p, local_id=%d, addr=%x", msk, local_id, addr->s_addr);
+	msk->pm.local_valid = 1;
+	msk->pm.local_id = local_id;
+	msk->pm.local_family = family;
+	msk->pm.local_addr.s_addr = addr->s_addr;
+	msk->addr_signal = 1;
+
+announce_put:
+	sock_put((struct sock *)msk);
+	return err;
 }
 
 int pm_remove_addr(u32 token, u8 local_id)
 {
-	return -ENOTSUPP;
+	struct mptcp_sock *msk = mptcp_sk(token_lookup_get(token));
+
+	if (!msk)
+		return -EINVAL;
+
+	pr_debug("msk=%p", msk);
+	msk->pm.local_valid = 0;
+
+	sock_put((struct sock *)msk);
+	return 0;
 }
 
 int pm_create_subflow(u32 token, u8 remote_id)
 {
-	return -ENOTSUPP;
+	struct mptcp_sock *msk = mptcp_sk(token_lookup_get(token));
+	struct sockaddr_in remote;
+	struct sockaddr_in local;
+	int err;
+
+	if (!msk)
+		return -EINVAL;
+
+	pr_debug("msk=%p", msk);
+
+	if (!msk->pm.remote_valid || remote_id != msk->pm.remote_id) {
+		err = -EBADR;
+		goto create_put;
+	}
+
+	local.sin_family = AF_INET;
+	local.sin_port = 0;
+	local.sin_addr.s_addr = INADDR_ANY;
+
+	remote.sin_family = msk->pm.remote_family;
+	remote.sin_port = htons(msk->dport);
+	remote.sin_addr.s_addr = htonl(msk->pm.remote_addr.s_addr);
+
+	err = subflow_connect((struct sock *)msk, &local, &remote, remote_id);
+
+create_put:
+	sock_put((struct sock *)msk);
+	return err;
 }
 
 int pm_remove_subflow(u32 token, u8 remote_id)
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 243d896d9e42..bc1fbd3827a6 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -233,6 +233,7 @@ void token_new_subflow(struct sock *sk);
 void token_new_accept(struct sock *sk);
 int token_new_join(struct sock *sk);
 void token_update_accept(struct sock *sk, struct sock *conn);
+struct sock *token_lookup_get(u32 token);
 void token_release(u32 token);
 void token_destroy(u32 token);
 
diff --git a/net/mptcp/token.c b/net/mptcp/token.c
index 80acb6c6657f..b54f617d4c26 100644
--- a/net/mptcp/token.c
+++ b/net/mptcp/token.c
@@ -348,6 +348,19 @@ int token_new_join(struct sock *sk)
 	return -1;
 }
 
+struct sock *token_lookup_get(u32 token)
+{
+	struct sock *conn;
+
+	spin_lock_bh(&token_tree_lock);
+	conn = lookup_token(token);
+	if (conn)
+		sock_hold(conn);
+
+	spin_unlock_bh(&token_tree_lock);
+	return conn;
+}
+
 void token_destroy_request(u32 token)
 {
 	pr_debug("token=%u", token);
-- 
2.17.2


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

* Re: [MPTCP] [PATCH v3 10/10] mptcp: Implement path manager interface commands
@ 2019-08-12 19:36 Matthieu Baerts
  0 siblings, 0 replies; 2+ messages in thread
From: Matthieu Baerts @ 2019-08-12 19:36 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

Hi Peter, Paolo, Mat,

On 08/08/2019 00:44, Peter Krystad wrote:
> Use the addr_signal flag to indicate to the subflow layer
> that a local address may be announced, and call subflow_connect()
> to initiate a secondary subflow.

Thank you for the patch and the reviews!

Added at the end of the series:
- 9ad3c22dcab0: "new commit" in
t/mptcp-Implement-path-manager-interface-commands
- f7d9e8ce4717..2038a22e9690: result

Cheers,
Matt
-- 
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium

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

end of thread, other threads:[~2019-08-12 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-07 22:44 [MPTCP] [PATCH v3 10/10] mptcp: Implement path manager interface commands Peter Krystad
  -- strict thread matches above, loose matches on Subject: below --
2019-08-12 19:36 Matthieu Baerts

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.