netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dominik Brodowski <linux@dominikbrodowski.net>
To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
	davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH -next 11/22] net: socket: add __sys_shutdown() helper; remove in-kernel call to syscall
Date: Fri, 16 Mar 2018 18:06:03 +0100	[thread overview]
Message-ID: <20180316170614.5392-12-linux@dominikbrodowski.net> (raw)
In-Reply-To: <20180316170614.5392-1-linux@dominikbrodowski.net>

Using the net-internal helper __sys_shutdown() allows us to avoid the
internal calls to the sys_shutdown() syscall.

Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 include/linux/socket.h | 1 +
 net/compat.c           | 2 +-
 net/socket.c           | 9 +++++++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index dbdddf0d079e..b205138b69f1 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -374,5 +374,6 @@ 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(int fd, int how);
 
 #endif /* _LINUX_SOCKET_H */
diff --git a/net/compat.c b/net/compat.c
index 04db26316438..f1ec23e9dfce 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -849,7 +849,7 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
 					  compat_ptr(a[4]), compat_ptr(a[5]));
 		break;
 	case SYS_SHUTDOWN:
-		ret = sys_shutdown(a0, a1);
+		ret = __sys_shutdown(a0, a1);
 		break;
 	case SYS_SETSOCKOPT:
 		ret = compat_sys_setsockopt(a0, a1, a[2],
diff --git a/net/socket.c b/net/socket.c
index 5861821f46f5..ad5dfd6a1d59 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1942,7 +1942,7 @@ SYSCALL_DEFINE5(getsockopt, int, fd, int, level, int, optname,
  *	Shutdown a socket.
  */
 
-SYSCALL_DEFINE2(shutdown, int, fd, int, how)
+int __sys_shutdown(int fd, int how)
 {
 	int err, fput_needed;
 	struct socket *sock;
@@ -1957,6 +1957,11 @@ SYSCALL_DEFINE2(shutdown, int, fd, int, how)
 	return err;
 }
 
+SYSCALL_DEFINE2(shutdown, int, fd, int, how)
+{
+	return __sys_shutdown(fd, how);
+}
+
 /* A couple of helpful macros for getting the address of the 32/64 bit
  * fields which are the same type (int / unsigned) on our platforms.
  */
@@ -2544,7 +2549,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
 				     (int __user *)a[5]);
 		break;
 	case SYS_SHUTDOWN:
-		err = sys_shutdown(a0, a1);
+		err = __sys_shutdown(a0, a1);
 		break;
 	case SYS_SETSOCKOPT:
 		err = sys_setsockopt(a0, a1, a[2], (char __user *)a[3], a[4]);
-- 
2.16.2

  parent reply	other threads:[~2018-03-16 17:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 17:05 [PATCH -next 00/22] remove in-kernel syscall invocations (part 2 == netdev) Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 01/22] net: socket: add __sys_recvfrom() helper; remove in-kernel call to syscall Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 02/22] net: socket: add __sys_sendto() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 03/22] net: socket: add __sys_accept4() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 04/22] net: socket: add __sys_socket() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 05/22] net: socket: add __sys_bind() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 06/22] net: socket: add __sys_connect() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 07/22] net: socket: add __sys_listen() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 08/22] net: socket: add __sys_getsockname() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 09/22] net: socket: add __sys_getpeername() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 10/22] net: socket: add __sys_socketpair() " Dominik Brodowski
2018-03-16 17:06 ` Dominik Brodowski [this message]
2018-03-16 17:06 ` [PATCH -next 12/22] net: socket: add __sys_setsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 13/22] net: socket: add __sys_getsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 14/22] net: socket: add do_sys_recvmmsg() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 15/22] net: socket: move check for forbid_cmsg_compat to __sys_...msg() Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 16/22] net: socket: replace calls to sys_send() with __sys_sendto() Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 17/22] net: socket: replace call to sys_recv() with __sys_recvfrom() Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 18/22] net: socket: add __compat_sys_recvfrom() helper; remove in-kernel call to compat syscall Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 19/22] net: socket: add __compat_sys_setsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 20/22] net: socket: add __compat_sys_getsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 21/22] net: socket: add __compat_sys_recvmmsg() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 22/22] net: socket: add __compat_sys_...msg() helpers; remove in-kernel calls to compat syscalls Dominik Brodowski
2018-03-16 18:30 ` [PATCH -next 00/22] remove in-kernel syscall invocations (part 2 == netdev) David Miller
2018-03-16 19:39   ` Dominik Brodowski
2018-03-16 19:42   ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180316170614.5392-12-linux@dominikbrodowski.net \
    --to=linux@dominikbrodowski.net \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).