All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] [RFC PATCH v3] mptcp: Implement interim path manager
@ 2019-08-28 19:21 Peter Krystad
  0 siblings, 0 replies; only message in thread
From: Peter Krystad @ 2019-08-28 19:21 UTC (permalink / raw)
  To: mptcp

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

Two features: 1) When an incoming connection is received
announce a local address and 2) When an outgoing connection
is fully established and a remote address has been received
initiate a secondary subflow.

The second local address must be hard-coded for now.

v3 - only take reference if queue_work succeeds

Signed-off-by: Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/pm.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 60 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index bc07376a823b..770938471f66 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -8,6 +8,10 @@
 #include <net/mptcp.h>
 #include "protocol.h"
 
+struct workqueue_struct *mptcp_wq;
+static void announce_addr_worker(struct work_struct *work);
+static void create_subflow_worker(struct work_struct *work);
+
 /* path manager command handlers */
 
 int pm_announce_addr(u32 token, sa_family_t family, u8 local_id,
@@ -91,16 +95,34 @@ int pm_remove_subflow(u32 token, u8 remote_id)
 
 void pm_new_connection(struct mptcp_sock *msk, int server_side)
 {
-	pr_debug("msk=%p", msk);
+	struct mptcp_pm_data *pm = &msk->pm;
+
+	pr_debug("msk=%p, token=%u", msk, msk->token);
 
-	msk->pm.server_side = server_side;
+	pm->server_side = server_side;
+	pm->token = msk->token;
+
+	/* trigger announce address in interim local path manager */
+	if (pm->server_side) {
+		INIT_WORK(&pm->addr_work, announce_addr_worker);
+		if (queue_work(mptcp_wq, &pm->addr_work))
+			sock_hold((struct sock *)msk);
+	}
 }
 
 void pm_fully_established(struct mptcp_sock *msk)
 {
+	struct mptcp_pm_data *pm = &msk->pm;
+
 	pr_debug("msk=%p", msk);
 
-	msk->pm.fully_established = 1;
+	/* trigger create subflow in interim local path manager */
+	if (!pm->server_side && !pm->fully_established && pm->remote_valid) {
+		INIT_WORK(&pm->subflow_work, create_subflow_worker);
+		if (queue_work(mptcp_wq, &pm->subflow_work))
+			sock_hold((struct sock *)msk);
+	}
+	pm->fully_established = 1;
 }
 
 void pm_connection_closed(struct mptcp_sock *msk)
@@ -120,12 +142,21 @@ void pm_subflow_closed(struct mptcp_sock *msk, u8 id)
 
 void pm_add_addr(struct mptcp_sock *msk, const struct in_addr *addr, u8 id)
 {
+	struct mptcp_pm_data *pm = &msk->pm;
+
 	pr_debug("msk=%p, addr=%x, remote_id=%d", msk, addr->s_addr, id);
 
 	msk->pm.remote_addr.s_addr = addr->s_addr;
 	msk->pm.remote_id = id;
 	msk->pm.remote_family = AF_INET;
-	msk->pm.remote_valid = 1;
+
+	/* trigger create subflow in interim local path manager */
+	if (!pm->server_side && !pm->remote_valid && pm->fully_established) {
+		INIT_WORK(&pm->subflow_work, create_subflow_worker);
+		if (queue_work(mptcp_wq, &pm->subflow_work))
+			sock_hold((struct sock *)msk);
+	}
+	pm->remote_valid = 1;
 }
 
 void pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr, u8 id)
@@ -177,4 +208,29 @@ int pm_get_local_id(struct request_sock *req, struct sock *sk,
 
 void pm_init(void)
 {
+	mptcp_wq = alloc_workqueue("mptcp_wq", WQ_UNBOUND | WQ_MEM_RECLAIM, 8);
+	if (!mptcp_wq)
+		panic("Failed to allocate workqueue");
+}
+
+static void announce_addr_worker(struct work_struct *work)
+{
+	struct mptcp_pm_data *pm = container_of(work, struct mptcp_pm_data,
+						addr_work);
+	struct mptcp_sock *msk = container_of(pm, struct mptcp_sock, pm);
+	struct in_addr addr;
+
+	/* @@ hard-code address to announce here... */
+	pm_announce_addr(pm->token, AF_INET, 1, &addr);
+	sock_put((struct sock *)msk);
+}
+
+static void create_subflow_worker(struct work_struct *work)
+{
+	struct mptcp_pm_data *pm = container_of(work, struct mptcp_pm_data,
+						subflow_work);
+	struct mptcp_sock *msk = container_of(pm, struct mptcp_sock, pm);
+
+	pm_create_subflow(pm->token, pm->remote_id);
+	sock_put((struct sock *)msk);
 }
-- 
2.17.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-28 19:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28 19:21 [MPTCP] [RFC PATCH v3] mptcp: Implement interim path manager Peter Krystad

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.