mptcp: implement support for user-space disconnect
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> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
71ba088ce0
Коммит
3d1d6d66e1
|
@ -3404,9 +3404,20 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
|
||||||
struct mptcp_sock *msk = mptcp_sk(sock->sk);
|
struct mptcp_sock *msk = mptcp_sk(sock->sk);
|
||||||
struct mptcp_subflow_context *subflow;
|
struct mptcp_subflow_context *subflow;
|
||||||
struct socket *ssock;
|
struct socket *ssock;
|
||||||
int err;
|
int err = -EINVAL;
|
||||||
|
|
||||||
lock_sock(sock->sk);
|
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) {
|
if (sock->state != SS_UNCONNECTED && msk->subflow) {
|
||||||
/* pending connection or invalid state, let existing subflow
|
/* pending connection or invalid state, let existing subflow
|
||||||
* cope with that
|
* cope with that
|
||||||
|
@ -3416,10 +3427,8 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
|
||||||
}
|
}
|
||||||
|
|
||||||
ssock = __mptcp_nmpc_socket(msk);
|
ssock = __mptcp_nmpc_socket(msk);
|
||||||
if (!ssock) {
|
if (!ssock)
|
||||||
err = -EINVAL;
|
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
|
||||||
|
|
||||||
mptcp_token_destroy(msk);
|
mptcp_token_destroy(msk);
|
||||||
inet_sk_state_store(sock->sk, TCP_SYN_SENT);
|
inet_sk_state_store(sock->sk, TCP_SYN_SENT);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче