mirror of
https://github.com/torvalds/linux
synced 2026-07-21 17:50:43 +09:00
rxrpc: convert to getsockopt_iter
Convert RxRPC socket's getsockopt implementation to use the new getsockopt_iter callback with sockopt_t. Key changes: - Replace (char __user *optval, int __user *optlen) with sockopt_t *opt - Use opt->optlen for buffer length (input) and returned size (output) - Use copy_to_iter() instead of put_user()/copy_to_user() Acked-by: Stanislav Fomichev <sdf@fomichev.me> Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20260520-getsock_four-v3-5-b8c0b16b7780@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
f83e9cd645
commit
4b94edae0b
@@ -16,6 +16,7 @@
|
||||
#include <linux/poll.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/key-type.h>
|
||||
#include <linux/uio.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/sock.h>
|
||||
#include <net/af_rxrpc.h>
|
||||
@@ -743,23 +744,24 @@ error:
|
||||
* Get socket options.
|
||||
*/
|
||||
static int rxrpc_getsockopt(struct socket *sock, int level, int optname,
|
||||
char __user *optval, int __user *_optlen)
|
||||
sockopt_t *opt)
|
||||
{
|
||||
int optlen;
|
||||
int optlen, val;
|
||||
|
||||
if (level != SOL_RXRPC)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (get_user(optlen, _optlen))
|
||||
return -EFAULT;
|
||||
optlen = opt->optlen;
|
||||
|
||||
switch (optname) {
|
||||
case RXRPC_SUPPORTED_CMSG:
|
||||
if (optlen < sizeof(int))
|
||||
return -ETOOSMALL;
|
||||
if (put_user(RXRPC__SUPPORTED - 1, (int __user *)optval) ||
|
||||
put_user(sizeof(int), _optlen))
|
||||
val = RXRPC__SUPPORTED - 1;
|
||||
if (copy_to_iter(&val, sizeof(val), &opt->iter_out) !=
|
||||
sizeof(val))
|
||||
return -EFAULT;
|
||||
opt->optlen = sizeof(val);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
@@ -1009,7 +1011,7 @@ static const struct proto_ops rxrpc_rpc_ops = {
|
||||
.listen = rxrpc_listen,
|
||||
.shutdown = rxrpc_shutdown,
|
||||
.setsockopt = rxrpc_setsockopt,
|
||||
.getsockopt = rxrpc_getsockopt,
|
||||
.getsockopt_iter = rxrpc_getsockopt,
|
||||
.sendmsg = rxrpc_sendmsg,
|
||||
.recvmsg = rxrpc_recvmsg,
|
||||
.mmap = sock_no_mmap,
|
||||
|
||||
Reference in New Issue
Block a user