Skip to content

Commit

Permalink
lkl: fix exported struct sockaddr definition
Browse files Browse the repository at this point in the history
__kernel_sockaddr_storage is just the kernel internal storage space for
sockaddr. The userspace visible sockaddr needs to be 16 bytes, as that
is what used in several other structures visible to userpace APIs (e.g.
struct arpreq).

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
  • Loading branch information
Octavian Purdila committed Jun 18, 2016
1 parent 0609875 commit 460736d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions arch/lkl/include/uapi/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ typedef __s64 s64;

#define __user

#define sockaddr __lkl__kernel_sockaddr_storage

#include <asm/unistd.h>
/* Temporary undefine system calls that don't have data types defined in UAPI
* headers */
Expand Down Expand Up @@ -92,6 +90,14 @@ typedef __s64 s64;
#include <asm/siginfo.h>
#include <linux/utime.h>
#include <asm/socket.h>

/* Define data structures used in system calls that are not defined in UAPI
* headers */
struct sockaddr {
unsigned short int sa_family;
char sa_data[14];
};

#include <linux/if.h>
#define __UAPI_DEF_IN_IPPROTO 1
#define __UAPI_DEF_IN_ADDR 1
Expand All @@ -110,8 +116,6 @@ typedef __s64 s64;
#include <linux/virtio_net.h>
#include <linux/virtio_ring.h>

/* Define data structures used in system calls that are not defined in UAPI
* headers */
struct user_msghdr {
void __user *msg_name; /* ptr to socket address structure */
int msg_namelen; /* size of socket address structure */
Expand Down
2 changes: 1 addition & 1 deletion tools/lkl/tests/net-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int test_icmp(char *str, int len)
inet_aton(dst, &saddr.sin_addr);

ret = lkl_sys_sendto(sock, icmp, sizeof(*icmp), 0,
(struct __lkl__kernel_sockaddr_storage *)&saddr,
(struct lkl_sockaddr*)&saddr,
sizeof(saddr));
if (ret < 0) {
snprintf(str, len, "sendto error (%s)", strerror(errno));
Expand Down

0 comments on commit 460736d

Please sign in to comment.