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 12/22] net: socket: add __sys_setsockopt() helper; remove in-kernel call to syscall
Date: Fri, 16 Mar 2018 18:06:04 +0100	[thread overview]
Message-ID: <20180316170614.5392-13-linux@dominikbrodowski.net> (raw)
In-Reply-To: <20180316170614.5392-1-linux@dominikbrodowski.net>

Using the net-internal helper __sys_setsockopt() allows us to avoid the
internal calls to the sys_setsockopt() 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/socket.c           | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index b205138b69f1..cad120e4ed4b 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -376,4 +376,5 @@ 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/socket.c b/net/socket.c
index ad5dfd6a1d59..5dd2e39a6cd4 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1878,8 +1878,8 @@ SYSCALL_DEFINE4(recv, int, fd, void __user *, ubuf, size_t, size,
  *	to pass the user mode parameter for the protocols to sort out.
  */
 
-SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,
-		char __user *, optval, int, optlen)
+static int __sys_setsockopt(int fd, int level, int optname,
+			    char __user *optval, int optlen)
 {
 	int err, fput_needed;
 	struct socket *sock;
@@ -1907,6 +1907,12 @@ SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,
 	return err;
 }
 
+SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,
+		char __user *, optval, int, optlen)
+{
+	return __sys_setsockopt(fd, level, optname, optval, optlen);
+}
+
 /*
  *	Get a socket option. Because we don't know the option lengths we have
  *	to pass a user mode parameter for the protocols to sort out.
@@ -2552,7 +2558,8 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
 		err = __sys_shutdown(a0, a1);
 		break;
 	case SYS_SETSOCKOPT:
-		err = sys_setsockopt(a0, a1, a[2], (char __user *)a[3], a[4]);
+		err = __sys_setsockopt(a0, a1, a[2], (char __user *)a[3],
+				       a[4]);
 		break;
 	case SYS_GETSOCKOPT:
 		err =
-- 
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 ` [PATCH -next 11/22] net: socket: add __sys_shutdown() " Dominik Brodowski
2018-03-16 17:06 ` Dominik Brodowski [this message]
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-13-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).