From 460736d180939e1ede17ae0f61c1a50ce7798280 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Sat, 18 Jun 2016 22:24:46 +0300 Subject: [PATCH 1/2] lkl: fix exported struct sockaddr definition __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 --- arch/lkl/include/uapi/asm/syscalls.h | 12 ++++++++---- tools/lkl/tests/net-test.c | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/lkl/include/uapi/asm/syscalls.h b/arch/lkl/include/uapi/asm/syscalls.h index 34925b28338a5c..813ff4257a4d38 100644 --- a/arch/lkl/include/uapi/asm/syscalls.h +++ b/arch/lkl/include/uapi/asm/syscalls.h @@ -37,8 +37,6 @@ typedef __s64 s64; #define __user -#define sockaddr __lkl__kernel_sockaddr_storage - #include /* Temporary undefine system calls that don't have data types defined in UAPI * headers */ @@ -92,6 +90,14 @@ typedef __s64 s64; #include #include #include + +/* 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 #define __UAPI_DEF_IN_IPPROTO 1 #define __UAPI_DEF_IN_ADDR 1 @@ -110,8 +116,6 @@ typedef __s64 s64; #include #include -/* 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 */ diff --git a/tools/lkl/tests/net-test.c b/tools/lkl/tests/net-test.c index 092d046c9560ef..c86e6428d54e29 100644 --- a/tools/lkl/tests/net-test.c +++ b/tools/lkl/tests/net-test.c @@ -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)); From 059a2dc3108589d0bc8903afc433f69288d4d7f3 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Sat, 18 Jun 2016 22:31:49 +0300 Subject: [PATCH 2/2] lkl tools: allow run_netperf.sh to run under dash Even if run_netperf.sh uses #!/bin/bash it is invoked via sh which under Ubuntu may be dash. Signed-off-by: Octavian Purdila --- tools/lkl/tests/run_netperf.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lkl/tests/run_netperf.sh b/tools/lkl/tests/run_netperf.sh index 0be8b8475fe687..fb7e1fbb98d091 100644 --- a/tools/lkl/tests/run_netperf.sh +++ b/tools/lkl/tests/run_netperf.sh @@ -56,11 +56,11 @@ then exit 1 fi -function clean { +clean() { sudo killall netserver &> /dev/null || true } -function clean_with_tap { +clean_with_tap() { sudo ip link set dev $LKL_HIJACK_NET_IFPARAMS down &> /dev/null || true sudo ip tuntap del dev $LKL_HIJACK_NET_IFPARAMS mode tap &> /dev/null || true clean