net: provide __sys_shutdown_sock() that takes a socket
[ Upstream commit b713c195d59332277a31a59c91f755e53b5b302b ] No functional changes in this patch, needed to provide io_uring support for shutdown(2). Cc: netdev@vger.kernel.org Cc: David S. Miller <davem@davemloft.net> Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
0b8cd5d814
commit
069ac28d92
@@ -436,5 +436,6 @@ extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr,
|
|||||||
int __user *usockaddr_len);
|
int __user *usockaddr_len);
|
||||||
extern int __sys_socketpair(int family, int type, int protocol,
|
extern int __sys_socketpair(int family, int type, int protocol,
|
||||||
int __user *usockvec);
|
int __user *usockvec);
|
||||||
|
extern int __sys_shutdown_sock(struct socket *sock, int how);
|
||||||
extern int __sys_shutdown(int fd, int how);
|
extern int __sys_shutdown(int fd, int how);
|
||||||
#endif /* _LINUX_SOCKET_H */
|
#endif /* _LINUX_SOCKET_H */
|
||||||
|
15
net/socket.c
15
net/socket.c
@@ -2181,6 +2181,17 @@ SYSCALL_DEFINE5(getsockopt, int, fd, int, level, int, optname,
|
|||||||
* Shutdown a socket.
|
* Shutdown a socket.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int __sys_shutdown_sock(struct socket *sock, int how)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = security_socket_shutdown(sock, how);
|
||||||
|
if (!err)
|
||||||
|
err = sock->ops->shutdown(sock, how);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
int __sys_shutdown(int fd, int how)
|
int __sys_shutdown(int fd, int how)
|
||||||
{
|
{
|
||||||
int err, fput_needed;
|
int err, fput_needed;
|
||||||
@@ -2188,9 +2199,7 @@ int __sys_shutdown(int fd, int how)
|
|||||||
|
|
||||||
sock = sockfd_lookup_light(fd, &err, &fput_needed);
|
sock = sockfd_lookup_light(fd, &err, &fput_needed);
|
||||||
if (sock != NULL) {
|
if (sock != NULL) {
|
||||||
err = security_socket_shutdown(sock, how);
|
err = __sys_shutdown_sock(sock, how);
|
||||||
if (!err)
|
|
||||||
err = sock->ops->shutdown(sock, how);
|
|
||||||
fput_light(sock->file, fput_needed);
|
fput_light(sock->file, fput_needed);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
|
Reference in New Issue
Block a user