All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Krystad <peter.krystad at linux.intel.com>
To: mptcp at lists.01.org
Subject: [MPTCP] [PATCH] mptcp: Re-factor mptcp_create_subflow()
Date: Mon, 24 Jun 2019 16:06:36 -0700	[thread overview]
Message-ID: <20190624230636.3513-1-peter.krystad@linux.intel.com> (raw)

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

Move to subflow.c (because it belongs there) and rename.
Outgoing MP_JOIN requests will use this routine to create
subflow sockets.

squashto: Associate MPTCP context with TCP socket

Signed-off-by: Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/protocol.c | 33 +++------------------------------
 net/mptcp/protocol.h |  1 +
 net/mptcp/subflow.c  | 25 +++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 775510bdbd4c..f2909457ef31 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -817,33 +817,6 @@ static struct proto mptcp_prot = {
 	.no_autobind	= 1,
 };
 
-static int mptcp_subflow_create(struct sock *sk)
-{
-	struct mptcp_sock *msk = mptcp_sk(sk);
-	struct net *net = sock_net(sk);
-	struct socket *sf;
-	int err;
-
-	pr_debug("msk=%p", msk);
-	err = sock_create_kern(net, PF_INET, SOCK_STREAM, IPPROTO_TCP, &sf);
-	if (!err) {
-		lock_sock(sf->sk);
-		err = tcp_set_ulp(sf->sk, "mptcp");
-		release_sock(sf->sk);
-		if (!err) {
-			struct subflow_context *subflow = subflow_ctx(sf->sk);
-
-			pr_debug("subflow=%p", subflow);
-			msk->subflow = sf;
-			subflow->conn = sk;
-			subflow->request_mptcp = 1; // @@ if MPTCP enabled
-			subflow->request_cksum = 1; // @@ if checksum enabled
-			subflow->version = 0;
-		}
-	}
-	return err;
-}
-
 static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 {
 	struct mptcp_sock *msk = mptcp_sk(sock->sk);
@@ -855,7 +828,7 @@ static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		return err;
 
 	if (!msk->subflow) {
-		err = mptcp_subflow_create(sock->sk);
+		err = subflow_create_socket(sock->sk, &msk->subflow);
 		if (err)
 			return err;
 	}
@@ -874,7 +847,7 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
 		return err;
 
 	if (!msk->subflow) {
-		err = mptcp_subflow_create(sock->sk);
+		err = subflow_create_socket(sock->sk, &msk->subflow);
 		if (err)
 			return err;
 	}
@@ -933,7 +906,7 @@ static int mptcp_listen(struct socket *sock, int backlog)
 	pr_debug("msk=%p", msk);
 
 	if (!msk->subflow) {
-		err = mptcp_subflow_create(sock->sk);
+		err = subflow_create_socket(sock->sk, &msk->subflow);
 		if (err)
 			return err;
 	}
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index ffc2452b4e77..e081b48d3f0d 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -201,6 +201,7 @@ mptcp_subflow_tcp_socket(const struct subflow_context *subflow)
 }
 
 void subflow_init(void);
+int subflow_create_socket(struct sock *sk, struct socket **new_sock);
 
 extern const struct inet_connection_sock_af_ops ipv4_specific;
 
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index a858cc966724..1236739425bc 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -201,6 +201,31 @@ static void subflow_data_ready(struct sock *sk)
 	}
 }
 
+int subflow_create_socket(struct sock *sk, struct socket **new_sock)
+{
+	struct net *net = sock_net(sk);
+	struct socket *sf;
+	int err;
+
+	err = sock_create_kern(net, PF_INET, SOCK_STREAM, IPPROTO_TCP, &sf);
+	if (!err) {
+		lock_sock(sf->sk);
+		err = tcp_set_ulp(sf->sk, "mptcp");
+		release_sock(sf->sk);
+		if (!err) {
+			struct subflow_context *subflow = subflow_ctx(sf->sk);
+
+			pr_debug("subflow=%p", subflow);
+			*new_sock = sf;
+			subflow->conn = sk;
+			subflow->request_mptcp = 1; // @@ if MPTCP enabled
+			subflow->request_cksum = 1; // @@ if checksum enabled
+			subflow->version = 0;
+		}
+	}
+	return err;
+}
+
 static struct subflow_context *subflow_create_ctx(struct sock *sk,
 						  struct socket *sock,
 						  gfp_t priority)
-- 
2.17.2


             reply	other threads:[~2019-06-24 23:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 23:06 Peter Krystad [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-06-25 12:32 [MPTCP] [PATCH] mptcp: Re-factor mptcp_create_subflow() Matthieu Baerts
2019-06-25 12:54 Matthieu Baerts
2019-06-25 14:27 Matthieu Baerts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190624230636.3513-1-peter.krystad@linux.intel.com \
    --to=unknown@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.