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>.
Showing the changes to include/uapi/linux (1 of 1 file). Show all
Unified · Split
| @@ -17,6 +17,10 @@ · 16 unmodified lines | |||
| 17 | #ifndef _UAPI_VM_SOCKETS_H | 17 | #ifndef _UAPI_VM_SOCKETS_H |
| 18 | #define _UAPI_VM_SOCKETS_H | 18 | #define _UAPI_VM_SOCKETS_H |
| 19 | 19 | ||
| 20 | #ifndef __KERNEL__ | ||
| 21 | #include <sys/socket.h> /* for struct sockaddr and sa_family_t */ | ||
| 22 | #endif | ||
| 23 | |||
| 20 | #include <linux/socket.h> | 24 | #include <linux/socket.h> |
| 21 | #include <linux/types.h> | 25 | #include <linux/types.h> |
| 22 | 26 | ||