diff mbox series

[for-next] net: provide __sys_shutdown_sock() that takes a socket

Message ID d3973f5b-2d86-665d-a5f3-95d017f9c79f@kernel.dk
State New
Headers show
Series [for-next] net: provide __sys_shutdown_sock() that takes a socket | expand

Commit Message

Jens Axboe Sept. 5, 2020, 10:05 p.m. UTC
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>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

There's a trivial io_uring patch that depends on this one. If this one
is acceptable to you, I'd like to queue it up in the io_uring branch for
5.10.

Comments

Jakub Kicinski Sept. 5, 2020, 10:39 p.m. UTC | #1
On Sat, 5 Sep 2020 16:05:48 -0600 Jens Axboe wrote:
> 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>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> ---
> 
> There's a trivial io_uring patch that depends on this one. If this one
> is acceptable to you, I'd like to queue it up in the io_uring branch for
> 5.10.

Go for it.

Acked-by: Jakub Kicinski <kuba@kernel.org>
Jens Axboe Sept. 5, 2020, 10:51 p.m. UTC | #2
On 9/5/20 4:39 PM, Jakub Kicinski wrote:
> On Sat, 5 Sep 2020 16:05:48 -0600 Jens Axboe wrote:
>> 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>
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>>
>> ---
>>
>> There's a trivial io_uring patch that depends on this one. If this one
>> is acceptable to you, I'd like to queue it up in the io_uring branch for
>> 5.10.
> 
> Go for it.
> 
> Acked-by: Jakub Kicinski <kuba@kernel.org>

Thanks! Added your Acked-by.
Christoph Hellwig Sept. 7, 2020, 5:48 a.m. UTC | #3
On Sat, Sep 05, 2020 at 04:05:48PM -0600, Jens Axboe wrote:
> There's a trivial io_uring patch that depends on this one. If this one
> is acceptable to you, I'd like to queue it up in the io_uring branch for
> 5.10.

Can you give it a better name?  These __ names re just horrible.
sock_shutdown_sock?
Christoph Hellwig Sept. 7, 2020, 5 p.m. UTC | #4
On Mon, Sep 07, 2020 at 09:58:13AM -0700, Jakub Kicinski wrote:
> On Mon, 7 Sep 2020 10:45:00 -0600 Jens Axboe wrote:
> > On 9/6/20 11:48 PM, Christoph Hellwig wrote:
> > > On Sat, Sep 05, 2020 at 04:05:48PM -0600, Jens Axboe wrote:  
> > >> There's a trivial io_uring patch that depends on this one. If this one
> > >> is acceptable to you, I'd like to queue it up in the io_uring branch for
> > >> 5.10.  
> > > 
> > > Can you give it a better name?  These __ names re just horrible.
> > > sock_shutdown_sock?  
> > 
> > Sure, I don't really care, just following what is mostly done already. And
> > it is meant to be internal in the sense that it's not exported to modules.
> > 
> > I'll let the net guys pass the final judgement on that, I'm obviously fine
> > with anything in terms of naming :-)
> 
> So am I :) But if Christoph prefers sock_shutdown_sock() let's use that.

Let's go with the original naming.  I might eventually do a big
naming sweep in socket.c after cleaning up more of the compat mess.
diff mbox series

Patch

diff --git a/include/linux/socket.h b/include/linux/socket.h
index e9cb30d8cbfb..385894b4a8bb 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -436,6 +436,7 @@  extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr,
 			     int __user *usockaddr_len);
 extern int __sys_socketpair(int family, int type, int protocol,
 			    int __user *usockvec);
+extern int __sys_shutdown_sock(struct socket *sock, int how);
 extern int __sys_shutdown(int fd, int how);
 
 extern struct ns_common *get_net_ns(struct ns_common *ns);
diff --git a/net/socket.c b/net/socket.c
index dbbe8ea7d395..59307db6097e 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2192,6 +2192,17 @@  SYSCALL_DEFINE5(getsockopt, int, fd, int, level, int, optname,
  *	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 err, fput_needed;
@@ -2199,9 +2210,7 @@  int __sys_shutdown(int fd, int how)
 
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (sock != NULL) {
-		err = security_socket_shutdown(sock, how);
-		if (!err)
-			err = sock->ops->shutdown(sock, how);
+		err = __sys_shutdown_sock(sock, how);
 		fput_light(sock->file, fput_needed);
 	}
 	return err;