Commit 76660afb authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

mptcp: __mptcp_tcp_fallback() returns a struct sock

Currently __mptcp_tcp_fallback() always return NULL
on incoming connections, because MPTCP does not create
the additional socket for the first subflow.
Since the previous commit no __mptcp_tcp_fallback()
caller needs a struct socket, so let __mptcp_tcp_fallback()
return the first subflow sock and cope correctly even with
incoming connections.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fa68018d
...@@ -76,14 +76,14 @@ static bool mptcp_is_tcpsk(struct sock *sk) ...@@ -76,14 +76,14 @@ static bool mptcp_is_tcpsk(struct sock *sk)
return false; return false;
} }
static struct socket *__mptcp_tcp_fallback(struct mptcp_sock *msk) static struct sock *__mptcp_tcp_fallback(struct mptcp_sock *msk)
{ {
sock_owned_by_me((const struct sock *)msk); sock_owned_by_me((const struct sock *)msk);
if (likely(!__mptcp_check_fallback(msk))) if (likely(!__mptcp_check_fallback(msk)))
return NULL; return NULL;
return msk->subflow; return msk->first;
} }
static int __mptcp_socket_create(struct mptcp_sock *msk) static int __mptcp_socket_create(struct mptcp_sock *msk)
...@@ -1498,7 +1498,7 @@ static int mptcp_setsockopt(struct sock *sk, int level, int optname, ...@@ -1498,7 +1498,7 @@ static int mptcp_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, unsigned int optlen) char __user *optval, unsigned int optlen)
{ {
struct mptcp_sock *msk = mptcp_sk(sk); struct mptcp_sock *msk = mptcp_sk(sk);
struct socket *ssock; struct sock *ssk;
pr_debug("msk=%p", msk); pr_debug("msk=%p", msk);
...@@ -1509,11 +1509,10 @@ static int mptcp_setsockopt(struct sock *sk, int level, int optname, ...@@ -1509,11 +1509,10 @@ static int mptcp_setsockopt(struct sock *sk, int level, int optname,
* to the one remaining subflow. * to the one remaining subflow.
*/ */
lock_sock(sk); lock_sock(sk);
ssock = __mptcp_tcp_fallback(msk); ssk = __mptcp_tcp_fallback(msk);
release_sock(sk); release_sock(sk);
if (ssock) if (ssk)
return tcp_setsockopt(ssock->sk, level, optname, optval, return tcp_setsockopt(ssk, level, optname, optval, optlen);
optlen);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1522,7 +1521,7 @@ static int mptcp_getsockopt(struct sock *sk, int level, int optname, ...@@ -1522,7 +1521,7 @@ static int mptcp_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *option) char __user *optval, int __user *option)
{ {
struct mptcp_sock *msk = mptcp_sk(sk); struct mptcp_sock *msk = mptcp_sk(sk);
struct socket *ssock; struct sock *ssk;
pr_debug("msk=%p", msk); pr_debug("msk=%p", msk);
...@@ -1533,11 +1532,10 @@ static int mptcp_getsockopt(struct sock *sk, int level, int optname, ...@@ -1533,11 +1532,10 @@ static int mptcp_getsockopt(struct sock *sk, int level, int optname,
* to the one remaining subflow. * to the one remaining subflow.
*/ */
lock_sock(sk); lock_sock(sk);
ssock = __mptcp_tcp_fallback(msk); ssk = __mptcp_tcp_fallback(msk);
release_sock(sk); release_sock(sk);
if (ssock) if (ssk)
return tcp_getsockopt(ssock->sk, level, optname, optval, return tcp_getsockopt(ssk, level, optname, optval, option);
option);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment