net/socket: remove unused do_sock_{set,get}sockopt() exports
Subsystems (3)
PATCH v2 1/1 net/socket: remove unused do_sock_{set,get}sockopt() exports
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.
Drop the symbol exports.
---
Changes in v2:
- s/export/exports/ in the commit message (hch)
- Link to v1: https://patch.msgid.link/[email protected]
--- net/socket.c | 2 -- 1 file changed, 2 deletions(-)
net/socket.c +0 -2
@@ -2371,7 +2371,6 @@ int do_sock_setsockopt(struct socket *sock, bool compat, int level, out_put:return err; } -EXPORT_SYMBOL (do_sock_setsockopt);/* Set a socket option. Because we don't know the option lengths we have * to pass the user mode parameter for the protocols to sort out.
@@ -2484,7 +2483,6 @@ int do_sock_getsockopt(struct socket *sock, bool compat, int level,return err; } -EXPORT_SYMBOL (do_sock_getsockopt);/* * Get a socket option. Because we don't know the option lengths we have
---
base-commit: 564973a259ec76f2dad0853420e7034cc43994c4
change-id: 20260819-hch_not_export-908dcceab01f
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
Quoted 9 lines · Breno Leitao
do_sock_setsockopt()anddo_sock_getsockopt()have been exported since they were split out of the syscall handlers forio_uringto reuse.
io_uringis the only caller outsidenet/socket.c, and it is never
modular: cmd_net.o is built under obj-$(CONFIG_NET), and bothCONFIG_NETandCONFIG_IO_URINGare bool. The declarations in <net/sock.h> are all it needs, so no module has ever been able to use these exports.
Quoted 7 lines
Drop the symbol exports.
Fixes 1406245c2945 ("net/socket: Break down __sys_setsockopt")Fixes 0b05b0cd78c9 ("net/socket: Break down __sys_getsockopt")Suggested-by Christoph Hellwig <[email protected]>Signed-off-by Breno Leitao <[email protected]>
Jakub Kicinski
maintainerQuoted 7 lines · On Fri, 21 Aug 2026 01:28:32 -0700 Breno Leitao wrote:
do_sock_setsockopt()anddo_sock_getsockopt()have been exported since they were split out of the syscall handlers forio_uringto reuse.
io_uringis the only caller outsidenet/socket.c, and it is never
modular: cmd_net.o is built under obj-$(CONFIG_NET), and bothCONFIG_NETandCONFIG_IO_URINGare 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.
Quoted 4 lines · On Sat, 22 Aug 2026 12:39:57 -0700 Jakub Kicinski <[email protected]> wrote:
Quoted 3 lines · On Fri, 21 Aug 2026 01:28:32 -0700 Breno Leitao wrote:
do_sock_setsockopt()anddo_sock_getsockopt()have been exported since they were split out of the syscall handlers forio_uringto reuse.
Quoted 9 lines
Quoted 4 lines
io_uringis the only caller outsidenet/socket.c, and it is never
modular: cmd_net.o is built under obj-$(CONFIG_NET), and bothCONFIG_NETandCONFIG_IO_URINGare 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
Quoted 4 lines · Jakub Kicinski
Quoted 3 lines · On Fri, 21 Aug 2026 01:28:32 -0700 Breno Leitao wrote:
do_sock_setsockopt()anddo_sock_getsockopt()have been exported since they were split out of the syscall handlers forio_uringto reuse.
Quoted 8 lines
Quoted 4 lines
io_uringis the only caller outsidenet/socket.c, and it is never
modular: cmd_net.o is built under obj-$(CONFIG_NET), and bothCONFIG_NETandCONFIG_IO_URINGare 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.
Fair — you and Christoph disagree here, and the nvme-tcp series needs it modular.
I'll park this until that settles. If we decide to keep it, I would suggest we change it to EXPORT_SYMBOL_GPL, at least.
--
pw-bot: rejected