summaryrefslogtreecommitdiffstats
path: root/linux-user
diff options
context:
space:
mode:
authorLaurent Vivier <laurent@vivier.eu>2013-08-30 01:46:41 +0200
committerRiku Voipio <riku.voipio@linaro.org>2013-09-24 10:47:06 +0300
commitf57d419241e7c7cce5d11172081a5860e86aa8bc (patch)
tree89b55a02a73c2895c7f3634309aee67accfafb03 /linux-user
parentde6b9933772c743789808531b3092329faf42496 (diff)
downloadhqemu-f57d419241e7c7cce5d11172081a5860e86aa8bc.zip
hqemu-f57d419241e7c7cce5d11172081a5860e86aa8bc.tar.gz
linux-user: Add setsockopt(SO_ATTACH_FILTER)
This is needed to be able to run dhclient. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/syscall.c44
-rw-r--r--linux-user/syscall_defs.h12
2 files changed, 56 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 251c116..505031b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -106,6 +106,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
#include <linux/dm-ioctl.h>
#include <linux/reboot.h>
#include <linux/route.h>
+#include <linux/filter.h>
#include "linux_loop.h"
#include "cpu-uname.h"
@@ -1357,6 +1358,49 @@ set_timeout:
case TARGET_SO_SNDTIMEO:
optname = SO_SNDTIMEO;
goto set_timeout;
+ case TARGET_SO_ATTACH_FILTER:
+ {
+ struct target_sock_fprog *tfprog;
+ struct target_sock_filter *tfilter;
+ struct sock_fprog fprog;
+ struct sock_filter *filter;
+ int i;
+
+ if (optlen != sizeof(*tfprog)) {
+ return -TARGET_EINVAL;
+ }
+ if (!lock_user_struct(VERIFY_READ, tfprog, optval_addr, 0)) {
+ return -TARGET_EFAULT;
+ }
+ if (!lock_user_struct(VERIFY_READ, tfilter,
+ tswapal(tfprog->filter), 0)) {
+ unlock_user_struct(tfprog, optval_addr, 1);
+ return -TARGET_EFAULT;
+ }
+
+ fprog.len = tswap16(tfprog->len);
+ filter = malloc(fprog.len * sizeof(*filter));
+ if (filter == NULL) {
+ unlock_user_struct(tfilter, tfprog->filter, 1);
+ unlock_user_struct(tfprog, optval_addr, 1);
+ return -TARGET_ENOMEM;
+ }
+ for (i = 0; i < fprog.len; i++) {
+ filter[i].code = tswap16(tfilter[i].code);
+ filter[i].jt = tfilter[i].jt;
+ filter[i].jf = tfilter[i].jf;
+ filter[i].k = tswap32(tfilter[i].k);
+ }
+ fprog.filter = filter;
+
+ ret = get_errno(setsockopt(sockfd, SOL_SOCKET,
+ SO_ATTACH_FILTER, &fprog, sizeof(fprog)));
+ free(filter);
+
+ unlock_user_struct(tfilter, tfprog->filter, 1);
+ unlock_user_struct(tfprog, optval_addr, 1);
+ return ret;
+ }
/* Options with 'int' argument. */
case TARGET_SO_DEBUG:
optname = SO_DEBUG;
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 2ebe356..5f53a28 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -119,6 +119,18 @@ struct target_sockaddr {
uint8_t sa_data[14];
};
+struct target_sock_filter {
+ abi_ushort code;
+ uint8_t jt;
+ uint8_t jf;
+ abi_uint k;
+};
+
+struct target_sock_fprog {
+ abi_ushort len;
+ abi_ulong filter;
+};
+
struct target_in_addr {
uint32_t s_addr; /* big endian */
};
OpenPOWER on IntegriCloud