Commit 8cf2ebdc authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

mptcp: mptcp: avoid additional indirection in mptcp_bind()

We are going to remove the first subflow socket soon, so avoid
the additional indirection via at bind() time. Instead call directly
the recently introduced helpers on the first subflow sock.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e6d360ff
...@@ -3689,22 +3689,29 @@ static struct proto mptcp_prot = { ...@@ -3689,22 +3689,29 @@ static struct proto mptcp_prot = {
static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{ {
struct mptcp_sock *msk = mptcp_sk(sock->sk); struct mptcp_sock *msk = mptcp_sk(sock->sk);
struct sock *ssk, *sk = sock->sk;
struct socket *ssock; struct socket *ssock;
int err; int err = -EINVAL;
lock_sock(sock->sk); lock_sock(sk);
ssock = __mptcp_nmpc_socket(msk); ssock = __mptcp_nmpc_socket(msk);
if (IS_ERR(ssock)) { if (IS_ERR(ssock)) {
err = PTR_ERR(ssock); err = PTR_ERR(ssock);
goto unlock; goto unlock;
} }
err = READ_ONCE(ssock->ops)->bind(ssock, uaddr, addr_len); ssk = msk->first;
if (sk->sk_family == AF_INET)
err = inet_bind_sk(ssk, uaddr, addr_len);
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
else if (sk->sk_family == AF_INET6)
err = inet6_bind_sk(ssk, uaddr, addr_len);
#endif
if (!err) if (!err)
mptcp_copy_inaddrs(sock->sk, ssock->sk); mptcp_copy_inaddrs(sk, ssk);
unlock: unlock:
release_sock(sock->sk); release_sock(sk);
return err; return err;
} }
......
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