]> Git Repo - linux.git/commitdiff
net: Split a __sys_listen helper for io_uring
authorGabriel Krisman Bertazi <[email protected]>
Fri, 14 Jun 2024 16:30:45 +0000 (12:30 -0400)
committerJens Axboe <[email protected]>
Wed, 19 Jun 2024 13:57:21 +0000 (07:57 -0600)
io_uring holds a reference to the file and maintains a sockaddr_storage
address.  Similarly to what was done to __sys_connect_file, split an
internal helper for __sys_listen in preparation to support an
io_uring listen command.

Reviewed-by: Jens Axboe <[email protected]>
Signed-off-by: Gabriel Krisman Bertazi <[email protected]>
Reviewed-by: Kuniyuki Iwashima <[email protected]>
Acked-by: Jakub Kicinski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
include/linux/socket.h
net/socket.c

index b3000f49e9f59f5c59d38fb788aef6d64da7c1d6..c1f16cdab67762e00271b223b266f49b21b85241 100644 (file)
@@ -449,6 +449,7 @@ extern int __sys_connect_file(struct file *file, struct sockaddr_storage *addr,
 extern int __sys_connect(int fd, struct sockaddr __user *uservaddr,
                         int addrlen);
 extern int __sys_listen(int fd, int backlog);
+extern int __sys_listen_socket(struct socket *sock, int backlog);
 extern int __sys_getsockname(int fd, struct sockaddr __user *usockaddr,
                             int __user *usockaddr_len);
 extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr,
index fd0714e10cedd117ea41df89fcea9758f4db742f..fcbdd5bc47ac2ff98bb243a2c9ec4f91fd64e778 100644 (file)
@@ -1870,23 +1870,28 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
  *     necessary for a listen, and if that works, we mark the socket as
  *     ready for listening.
  */
+int __sys_listen_socket(struct socket *sock, int backlog)
+{
+       int somaxconn, err;
+
+       somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn);
+       if ((unsigned int)backlog > somaxconn)
+               backlog = somaxconn;
+
+       err = security_socket_listen(sock, backlog);
+       if (!err)
+               err = READ_ONCE(sock->ops)->listen(sock, backlog);
+       return err;
+}
 
 int __sys_listen(int fd, int backlog)
 {
        struct socket *sock;
        int err, fput_needed;
-       int somaxconn;
 
        sock = sockfd_lookup_light(fd, &err, &fput_needed);
        if (sock) {
-               somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn);
-               if ((unsigned int)backlog > somaxconn)
-                       backlog = somaxconn;
-
-               err = security_socket_listen(sock, backlog);
-               if (!err)
-                       err = READ_ONCE(sock->ops)->listen(sock, backlog);
-
+               err = __sys_listen_socket(sock, backlog);
                fput_light(sock->file, fput_needed);
        }
        return err;
This page took 0.05048 seconds and 4 git commands to generate.