qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: riku.voipio@linaro.org
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>
Subject: [Qemu-devel] [PULL 04/16] linux-user: convert sockaddr_ll from host to target
Date: Tue, 19 Jul 2016 15:54:02 +0300	[thread overview]
Message-ID: <a82ea9393df18276f36e3202d2cc3ad73b980e92.1468932683.git.riku.voipio@linaro.org> (raw)
In-Reply-To: <cover.1468932683.git.riku.voipio@linaro.org>

From: Laurent Vivier <laurent@vivier.eu>

As we convert sockaddr for AF_PACKET family for sendto() (target to
host) we need also to convert this for getsockname() (host to target).

arping uses getsockname() to get the the interface address and uses
this address with sendto().

Tested with:

    /sbin/arping -D -q -c2 -I eno1 192.168.122.88

...
getsockname(3, {sa_family=AF_PACKET, proto=0x806, if2,
pkttype=PACKET_HOST, addr(6)={1, 10c37b6b9a76}, [18]) = 0
...
sendto(3, "..." 28, 0,
       {sa_family=AF_PACKET, proto=0x806, if2, pkttype=PACKET_HOST,
       addr(6)={1, ffffffffffff}, 20) = 28
...

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f9ce9d8..919b589 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -100,6 +100,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <linux/route.h>
 #include <linux/filter.h>
 #include <linux/blkpg.h>
+#include <netpacket/packet.h>
 #include <linux/netlink.h>
 #ifdef CONFIG_RTNETLINK
 #include <linux/rtnetlink.h>
@@ -1383,6 +1384,10 @@ static inline abi_long host_to_target_sockaddr(abi_ulong target_addr,
         struct sockaddr_nl *target_nl = (struct sockaddr_nl *)target_saddr;
         target_nl->nl_pid = tswap32(target_nl->nl_pid);
         target_nl->nl_groups = tswap32(target_nl->nl_groups);
+    } else if (addr->sa_family == AF_PACKET) {
+        struct sockaddr_ll *target_ll = (struct sockaddr_ll *)target_saddr;
+        target_ll->sll_ifindex = tswap32(target_ll->sll_ifindex);
+        target_ll->sll_hatype = tswap16(target_ll->sll_hatype);
     }
     unlock_user(target_saddr, target_addr, len);
 
-- 
2.1.4

  parent reply	other threads:[~2016-07-19 12:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-19 12:53 [Qemu-devel] [PULL 00/16] linux-user before 2.7 hardfreeze riku.voipio
2016-07-19 12:53 ` [Qemu-devel] [PULL 01/16] linux-user: fd_trans_*_data() returns the length riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 02/16] linux-user: fix netlink memory corruption riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 03/16] linux-user: add fd_trans helper in do_recvfrom() riku.voipio
2016-07-19 12:54 ` riku.voipio [this message]
2016-07-19 12:54 ` [Qemu-devel] [PULL 05/16] linux-user: add nested netlink types riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 06/16] linux-user: Check sigsetsize argument to syscalls riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 07/16] linux-user: Add loop control ioctls riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 08/16] linux-user: Correct type for BLKSSZGET riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 09/16] linux-user: Correct type for LOOP_GET_STATUS{, 64} ioctls riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 10/16] linux-user: Forget about synchronous signal once it is delivered riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 11/16] linux-user: Handle short lengths in host_to_target_sockaddr() riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 12/16] linux-user: Add some new blk ioctls riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 13/16] TIOCGPTN and related terminal control ioctls were not converted to the guest ioctl format on x86_64 targets. Convert these ioctls to enable terminal functionality on x86_64 guests riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 14/16] linux-user: define missing sparc syscalls riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 15/16] linux-user: Fix type for SIOCATMARK ioctl riku.voipio
2016-07-19 12:54 ` [Qemu-devel] [PULL 16/16] linux-user: AArch64 has sync_file_range, not sync_file_range2 riku.voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a82ea9393df18276f36e3202d2cc3ad73b980e92.1468932683.git.riku.voipio@linaro.org \
    --to=riku.voipio@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).