Skip to content

Commit 79b752f

Browse files
stefano-garzarellaNipaLocal
authored andcommitted
vsock/uapi: fix linux/vm_sockets.h userspace compilation errors
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>. Fixes: d021c34 ("VSOCK: Introduce VM Sockets") Reported-by: Daan De Meyer <[email protected]> Signed-off-by: Stefano Garzarella <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 1529300 commit 79b752f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/uapi/linux/vm_sockets.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#ifndef _UAPI_VM_SOCKETS_H
1818
#define _UAPI_VM_SOCKETS_H
1919

20+
#ifndef __KERNEL__
21+
#include <sys/socket.h> /* for struct sockaddr and sa_family_t */
22+
#endif
23+
2024
#include <linux/socket.h>
2125
#include <linux/types.h>
2226

0 commit comments

Comments
 (0)