vsock/uapi: fix linux/vm_sockets.h userspace compilation errors
Subsystems (4)
Stefano Garzarella
maintainerPATCH 1/1 vsock/uapi: fix linux/vm_sockets.h userspace compilation errors
From: Stefano Garzarella <[email protected]>
If a userspace application just include <linux/vm_sockets.h> will fail to build with the following errors:
/usr/include/linux/vm_sockets.h:182:39: error: invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr’
182 | unsigned char svm_zero[sizeof(struct sockaddr) -
| ^~~~~~
/usr/include/linux/vm_sockets.h:183:39: error: ‘sa_family_t’ undeclared here (not in a function)
183 | sizeof(sa_family_t) -
|
Include <sys/socket.h> for userspace (guarded by ifndef __KERNEL__) where struct sockaddr and sa_family_t are defined.
We already do something similar in <linux/mptcp.h> and <linux/if.h>.
--- include/uapi/linux/vm_sockets.h | 4 ++++ 1 file changed, 4 insertions(+)
include/uapi/linux/vm_sockets.h +4 -0
@@ -17,6 +17,10 @@#ifndef _UAPI_VM_SOCKETS_H#define _UAPI_VM_SOCKETS_H +#ifndef __KERNEL__ +#include <sys/socket.h> /* for struct sockaddr and sa_family_t */ +#endif +#include <linux/socket.h> #include <linux/types.h>
Signature · 1 line
2.49.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Mon, 23 Jun 2025 12:00:53 +0200 you wrote:
From: Stefano Garzarella <[email protected]>
If a userspace application just include <
linux/vm_sockets.h> will fail to build with the following errors:
Quoted 8 lines
/usr/include/linux/vm_sockets.h:182:39: error: invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr’
182 | unsigned char svm_zero[sizeof(struct sockaddr) -
| ^~~~~~
/usr/include/linux/vm_sockets.h:183:39: error: ‘sa_family_t’ undeclared here (not in a function)
183 |sizeof(sa_family_t)-
|[...]
Here is the summary with links:
- [net] vsock/uapi: fix linux/vm_sockets.h userspace compilation errors
https://git.kernel.org/netdev/net/c/22bbc1dcd0d6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html