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

net: factor out inet{,6}_bind_sk helpers

The mptcp protocol maintains an additional socket just to easily
invoke a few stream operations on the first subflow. One of
them is bind().

Factor out the helpers operating directly on the struct sock, to
allow get rid of the above dependency in the next patch without
duplicating the existing code.

No functional changes intended.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Acked-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 cfb63e50
...@@ -42,6 +42,7 @@ int inet_shutdown(struct socket *sock, int how); ...@@ -42,6 +42,7 @@ int inet_shutdown(struct socket *sock, int how);
int inet_listen(struct socket *sock, int backlog); int inet_listen(struct socket *sock, int backlog);
void inet_sock_destruct(struct sock *sk); void inet_sock_destruct(struct sock *sk);
int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len); int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
int inet_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len);
/* Don't allocate port at this moment, defer to connect. */ /* Don't allocate port at this moment, defer to connect. */
#define BIND_FORCE_ADDRESS_NO_PORT (1 << 0) #define BIND_FORCE_ADDRESS_NO_PORT (1 << 0)
/* Grab and release socket lock. */ /* Grab and release socket lock. */
......
...@@ -1216,6 +1216,7 @@ void inet6_cleanup_sock(struct sock *sk); ...@@ -1216,6 +1216,7 @@ void inet6_cleanup_sock(struct sock *sk);
void inet6_sock_destruct(struct sock *sk); void inet6_sock_destruct(struct sock *sk);
int inet6_release(struct socket *sock); int inet6_release(struct socket *sock);
int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len); int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
int inet6_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len);
int inet6_getname(struct socket *sock, struct sockaddr *uaddr, int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
int peer); int peer);
int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
......
...@@ -431,9 +431,8 @@ int inet_release(struct socket *sock) ...@@ -431,9 +431,8 @@ int inet_release(struct socket *sock)
} }
EXPORT_SYMBOL(inet_release); EXPORT_SYMBOL(inet_release);
int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) int inet_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{ {
struct sock *sk = sock->sk;
u32 flags = BIND_WITH_LOCK; u32 flags = BIND_WITH_LOCK;
int err; int err;
...@@ -454,6 +453,11 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -454,6 +453,11 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
return __inet_bind(sk, uaddr, addr_len, flags); return __inet_bind(sk, uaddr, addr_len, flags);
} }
int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
return inet_bind_sk(sock->sk, uaddr, addr_len);
}
EXPORT_SYMBOL(inet_bind); EXPORT_SYMBOL(inet_bind);
int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
......
...@@ -435,10 +435,8 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, ...@@ -435,10 +435,8 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
goto out; goto out;
} }
/* bind for INET6 API */ int inet6_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len)
int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{ {
struct sock *sk = sock->sk;
u32 flags = BIND_WITH_LOCK; u32 flags = BIND_WITH_LOCK;
const struct proto *prot; const struct proto *prot;
int err = 0; int err = 0;
...@@ -462,6 +460,12 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -462,6 +460,12 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
return __inet6_bind(sk, uaddr, addr_len, flags); return __inet6_bind(sk, uaddr, addr_len, flags);
} }
/* bind for INET6 API */
int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
return inet6_bind_sk(sock->sk, uaddr, addr_len);
}
EXPORT_SYMBOL(inet6_bind); EXPORT_SYMBOL(inet6_bind);
int inet6_release(struct socket *sock) int inet6_release(struct socket *sock)
......
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