* [RFC PATCH 3/3] io_uring/cmd: Add support for set_sockopt
2023-07-19 10:27 [RFC PATCH 0/3] io_uring: Initial support for {s,g}etsockopt commands Breno Leitao
@ 2023-07-19 10:27 ` Breno Leitao
0 siblings, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2023-07-19 10:27 UTC (permalink / raw)
To: asml.silence, axboe
Cc: io-uring, netdev, davem, kuba, edumazet, pabeni, linux-kernel
Add initial support for setsockopt for SOL_SOCKET level, by leveraging
the sockptr infrastructure.
Function io_uring_cmd_setsockopt is inspired by the function
__sys_setsockopt(), which handles the system call case.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
include/uapi/linux/io_uring.h | 1 +
io_uring/uring_cmd.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 8152151080db..3fe82df06abf 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -736,6 +736,7 @@ enum {
SOCKET_URING_OP_SIOCINQ = 0,
SOCKET_URING_OP_SIOCOUTQ,
SOCKET_URING_OP_GETSOCKOPT,
+ SOCKET_URING_OP_SETSOCKOPT,
};
#ifdef __cplusplus
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index 28fd09351be7..7c06634e744a 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -191,6 +191,28 @@ static inline int io_uring_cmd_getsockopt(struct socket *sock,
return -EOPNOTSUPP;
}
+static inline int io_uring_cmd_setsockopt(struct socket *sock,
+ struct io_uring_cmd *cmd)
+{
+ void __user *optval = u64_to_user_ptr(READ_ONCE(cmd->sqe->optval));
+ int optlen = READ_ONCE(cmd->sqe->optlen);
+ int optname = READ_ONCE(cmd->sqe->optname);
+ int level = READ_ONCE(cmd->sqe->level);
+ int err;
+
+ err = security_socket_setsockopt(sock, level, optname);
+ if (err)
+ return err;
+
+ if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) {
+ err = sock_setsockopt(sock, level, optname,
+ USER_SOCKPTR(optval), optlen);
+ return err;
+ }
+
+ return -EOPNOTSUPP;
+}
+
int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)
{
struct socket *sock = cmd->file->private_data;
@@ -214,6 +236,8 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)
return arg;
case SOCKET_URING_OP_GETSOCKOPT:
return io_uring_cmd_getsockopt(sock, cmd);
+ case SOCKET_URING_OP_SETSOCKOPT:
+ return io_uring_cmd_setsockopt(sock, cmd);
default:
return -EOPNOTSUPP;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 3/3] io_uring/cmd: Add support for set_sockopt
@ 2023-07-19 21:09 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-07-19 21:09 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "git am base is a link in commit message"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20230719102737.2513246-4-leitao@debian.org>
References: <20230719102737.2513246-4-leitao@debian.org>
TO: Breno Leitao <leitao@debian.org>
Hi Breno,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
[also build test ERROR on net-next/main linus/master v6.5-rc2 next-20230719]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Breno-Leitao/net-expose-sock_use_custom_sol_socket/20230719-183153
base: net/main
patch link: https://lore.kernel.org/r/20230719102737.2513246-4-leitao%40debian.org
patch subject: [RFC PATCH 3/3] io_uring/cmd: Add support for set_sockopt
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20230720/202307200541.M2snHBYx-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230720/202307200541.M2snHBYx-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202307200541.M2snHBYx-lkp@intel.com/
All errors (new ones prefixed by >>):
loongarch64-linux-ld: io_uring/uring_cmd.o: in function `io_uring_cmd_sock':
>> uring_cmd.c:(.text+0x454): undefined reference to `sock_setsockopt'
>> loongarch64-linux-ld: uring_cmd.c:(.text+0x4cc): undefined reference to `sk_getsockopt'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 3/3] io_uring/cmd: Add support for set_sockopt
@ 2023-07-19 21:30 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-07-19 21:30 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "git am base is a link in commit message"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20230719102737.2513246-4-leitao@debian.org>
References: <20230719102737.2513246-4-leitao@debian.org>
TO: Breno Leitao <leitao@debian.org>
Hi Breno,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
[also build test ERROR on net-next/main linus/master v6.5-rc2 next-20230719]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Breno-Leitao/net-expose-sock_use_custom_sol_socket/20230719-183153
base: net/main
patch link: https://lore.kernel.org/r/20230719102737.2513246-4-leitao%40debian.org
patch subject: [RFC PATCH 3/3] io_uring/cmd: Add support for set_sockopt
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: x86_64-buildonly-randconfig-r002-20230718 (https://download.01.org/0day-ci/archive/20230720/202307200559.88er76l4-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230720/202307200559.88er76l4-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202307200559.88er76l4-lkp@intel.com/
All errors (new ones prefixed by >>):
ld: io_uring/uring_cmd.o: in function `io_uring_cmd_sock':
io_uring/uring_cmd.c:183: undefined reference to `sk_getsockopt'
>> ld: io_uring/uring_cmd.c:208: undefined reference to `sock_setsockopt'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-19 21:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-19 21:09 [RFC PATCH 3/3] io_uring/cmd: Add support for set_sockopt kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2023-07-19 21:30 kernel test robot
2023-07-19 10:27 [RFC PATCH 0/3] io_uring: Initial support for {s,g}etsockopt commands Breno Leitao
2023-07-19 10:27 ` [RFC PATCH 3/3] io_uring/cmd: Add support for set_sockopt Breno Leitao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.