Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Paolo Abeni and committed by
David S. Miller
8cf2ebdc e6d360ff

+12 -5
+12 -5
net/mptcp/protocol.c
··· 3689 3689 static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) 3690 3690 { 3691 3691 struct mptcp_sock *msk = mptcp_sk(sock->sk); 3692 + struct sock *ssk, *sk = sock->sk; 3692 3693 struct socket *ssock; 3693 - int err; 3694 + int err = -EINVAL; 3694 3695 3695 - lock_sock(sock->sk); 3696 + lock_sock(sk); 3696 3697 ssock = __mptcp_nmpc_socket(msk); 3697 3698 if (IS_ERR(ssock)) { 3698 3699 err = PTR_ERR(ssock); 3699 3700 goto unlock; 3700 3701 } 3701 3702 3702 - err = READ_ONCE(ssock->ops)->bind(ssock, uaddr, addr_len); 3703 + ssk = msk->first; 3704 + if (sk->sk_family == AF_INET) 3705 + err = inet_bind_sk(ssk, uaddr, addr_len); 3706 + #if IS_ENABLED(CONFIG_MPTCP_IPV6) 3707 + else if (sk->sk_family == AF_INET6) 3708 + err = inet6_bind_sk(ssk, uaddr, addr_len); 3709 + #endif 3703 3710 if (!err) 3704 - mptcp_copy_inaddrs(sock->sk, ssock->sk); 3711 + mptcp_copy_inaddrs(sk, ssk); 3705 3712 3706 3713 unlock: 3707 - release_sock(sock->sk); 3714 + release_sock(sk); 3708 3715 return err; 3709 3716 } 3710 3717