Skip to contentSkip to conversation

net: provide __sys_shutdown_sock() that takes a socket

PATCH In review Jens Axboe 3 participants 8 messages Sep 5, 2020 – Sep 7, 2020

Subsystems (3)
lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

PATCH 1/1 net: provide __sys_shutdown_sock() that takes a socket

No functional changes in this patch, needed to provide io_uring support for shutdown(2).

---

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.

include/linux/socket.h +1 -0
index e9cb30d8cbfb..385894b4a8bb 100644
@@ -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);
net/socket.c +12 -3
index dbbe8ea7d395..59307db6097e 100644
@@ -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;
Signature · 1 line
Jens Axboe
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · 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).

Quoted 5 lines

---

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.

author
#2 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · 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).

---

Quoted 7 lines
Quoted 3 lines

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.

Thanks! Added your Acked-by.

Signature · 1 line
Jens Axboe
#3 lore raw
In reply to Jens Axboe
Quoted 3 lines · Jens Axboe

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?

author
#4 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Jens Axboe

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 :-)

Signature · 1 line
Jens Axboe
maintainer
#5 lore raw
Quoted 6 lines · On Mon, 7 Sep 2020 10:45:00 -0600 Jens Axboe wrote:
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Jens Axboe

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.

Quoted 8 lines
Quoted 2 lines

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.

#6 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Mon, 7 Sep 2020 10:45:00 -0600 Jens Axboe wrote:
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Jens Axboe

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?

Quoted 7 lines
Quoted 5 lines

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.

author
#7 lore raw
Quoted 14 lines · Christoph Hellwig
Quoted 13 lines · Jakub Kicinski
Quoted 12 lines · On Mon, 7 Sep 2020 10:45:00 -0600 Jens Axboe wrote:
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Jens Axboe

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.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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.

Agree, saves me the hassle... FWIW, networking does have an even broader space of func to __func to ____func and in some cases not "following" the usual calling order of them.

Signature · 1 line
Jens Axboe