Re: [PATCH net v2] net/socket: remove unused do_sock_{set,get}sockopt() exports
From: David Laight
Date: Sat Aug 22 2026 - 17:50:05 EST
On Sat, 22 Aug 2026 12:39:57 -0700
Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
> On Fri, 21 Aug 2026 01:28:32 -0700 Breno Leitao wrote:
> > do_sock_setsockopt() and do_sock_getsockopt() have been exported since
> > they were split out of the syscall handlers for io_uring to reuse.
> >
> > io_uring is the only caller outside net/socket.c, and it is never
> > modular: cmd_net.o is built under obj-$(CONFIG_NET), and both CONFIG_NET
> > and CONFIG_IO_URING are bool. The declarations in <net/sock.h> are all
> > it needs, so no module has ever been able to use these exports.
>
> FTR I'd prefer this export (or something along these lines) to having
> to add individual helpers for every sockopt for in-kernel networking
> socket users. Maybe other maintainers disagree.
>
As a 'user' I'd re-instate the kernel_setsockopt() that was removed in 5.7
before sockptr_t was added in 5.8.
Before I retired I supported some code that contains:
int xxx_setsockopt(struct socket *sock, int level, int optname,
void *optval, unsigned int optlen)
{
sockptr_t koptval = KERNEL_SOCKPTR(optval);
if (level == SOL_SOCKET)
return sock_setsockopt(sock, level, optname, koptval, optlen);
else
return sock->ops->setsockopt(sock, level, optname, koptval, optlen);
}
I suspect both bpf and io_uring have to do the same.
The code does need one getsockopt() - SCTP_STATUS to get the negotiated
number of output streams, any code using SCTP needs to do that.
However that returns the wrong value for kernels 5.1 to 5.8 so the driver
digs the value out of the sctp internal data structures.
(Not exporting functions doesn't make much difference!)
David