All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: mptcp@lists.linux.dev
Subject: [PATCH v2 mptcp-next 6/7] mptcp: implement support for user-space disconnect
Date: Thu, 11 Nov 2021 17:21:41 +0100	[thread overview]
Message-ID: <3ca2682745f315b4106c2041a85e58b325eed03b.1636647623.git.pabeni@redhat.com> (raw)
In-Reply-To: <cover.1636647623.git.pabeni@redhat.com>

Handle explicitly AF_UNSPEC in mptcp_stream_connnect() to
allow user-space to disconnect established MPTCP connections

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index ee2a5169c13a..8319db8ae3ed 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3428,9 +3428,20 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
 	struct mptcp_sock *msk = mptcp_sk(sock->sk);
 	struct mptcp_subflow_context *subflow;
 	struct socket *ssock;
-	int err;
+	int err = -EINVAL;
 
 	lock_sock(sock->sk);
+	if (uaddr) {
+		if (addr_len < sizeof(uaddr->sa_family))
+			goto unlock;
+
+		if (uaddr->sa_family == AF_UNSPEC) {
+			err = mptcp_disconnect(sock->sk, flags);
+			sock->state = err ? SS_DISCONNECTING : SS_UNCONNECTED;
+			goto unlock;
+		}
+	}
+
 	if (sock->state != SS_UNCONNECTED && msk->subflow) {
 		/* pending connection or invalid state, let existing subflow
 		 * cope with that
@@ -3440,10 +3451,8 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
 	}
 
 	ssock = __mptcp_nmpc_socket(msk);
-	if (!ssock) {
-		err = -EINVAL;
+	if (!ssock)
 		goto unlock;
-	}
 
 	mptcp_token_destroy(msk);
 	inet_sk_state_store(sock->sk, TCP_SYN_SENT);
-- 
2.33.1


  parent reply	other threads:[~2021-11-11 16:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 16:21 [PATCH v2 mptcp-next 0/7] mptcp: improve accept() and disconnect() Paolo Abeni
2021-11-11 16:21 ` [PATCH v2 mptcp-next 1/7] mptcp: keep snd_una updated for fallback socket Paolo Abeni
2021-11-11 16:21 ` [PATCH v2 mptcp-next 2/7] mptcp: never allow the PM to close a listener subflow Paolo Abeni
2021-11-11 16:21 ` [PATCH v2 mptcp-next 3/7] mptcp: implement fastclose xmit path Paolo Abeni
2021-11-11 16:21 ` [PATCH v2 mptcp-next 4/7] mptcp: full disconnect implementation Paolo Abeni
2021-11-11 16:21 ` [PATCH v2 mptcp-next 5/7] mptcp: cleanup accept and poll Paolo Abeni
2021-11-11 16:21 ` Paolo Abeni [this message]
2021-11-11 16:21 ` [PATCH v2 mptcp-next 7/7] mptcp: add disconnect selftests Paolo Abeni
2021-11-12  4:24 ` [PATCH v2 mptcp-next 0/7] mptcp: improve accept() and disconnect() Mat Martineau
2021-11-19 16:47 ` 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=3ca2682745f315b4106c2041a85e58b325eed03b.1636647623.git.pabeni@redhat.com \
    --to=pabeni@redhat.com \
    --cc=mptcp@lists.linux.dev \
    /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.