From patchwork Sun Jun 26 22:18:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9199755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B75066075F for ; Sun, 26 Jun 2016 22:19:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E39B28557 for ; Sun, 26 Jun 2016 22:19:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F0332855B; Sun, 26 Jun 2016 22:19:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D7E3D28557 for ; Sun, 26 Jun 2016 22:19:03 +0000 (UTC) Received: from localhost ([::1]:55447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHIOL-00048v-8m for patchwork-qemu-devel@patchwork.kernel.org; Sun, 26 Jun 2016 18:19:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHIO4-00048n-60 for qemu-devel@nongnu.org; Sun, 26 Jun 2016 18:18:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHINz-0005NU-SF for qemu-devel@nongnu.org; Sun, 26 Jun 2016 18:18:43 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:52142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHINz-0005NE-I3 for qemu-devel@nongnu.org; Sun, 26 Jun 2016 18:18:39 -0400 Received: from Quad.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0MHrNV-1bKsLx2Cez-003hQi; Mon, 27 Jun 2016 00:18:28 +0200 From: Laurent Vivier To: Riku Voipio Date: Mon, 27 Jun 2016 00:18:22 +0200 Message-Id: <1466979502-7589-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.5 X-Provags-ID: V03:K0:LrsmiT1rp+sN58csns0QK9UrW5v00fjfvXVU91vpGmFPmtD+vz0 aqZyh0VB9/imLiALRgVCTCSl17AzrsbahlLw2enw3ZPE9cxGCkerPpa9REhN/auseQ4HmF6 SLQaBPayPf8OBXW2hPToEfdaJe6fYfM8YX6JBgzrZkYn+N+6iOSCcRTaejbJ1RfeQyinHyS lS9BFZMUWJpotjULiE/Yw== X-UI-Out-Filterresults: notjunk:1; V01:K0:m1Cu/Dz9N3E=:q8n1slEDX2VqRi8F/ZVxQL vg8m1EbGp9Z8pii5PDF40PnJLY9j48WQ3iHZRZb552ngd+ltoF0TfImJv9yd5ovCVRyO6ERg9 1avrZ3lZBllkhpe9x/dsE4Oe6t4Mbp+rhVdJG0Z7q6oY9mvgnL5P4vKTEi5KGyvch9OiQ2STD gou9oZC/9aSfs+Qgd7CXnm31Xzk3B9qVEP8eMNv2ICEaze463olxNWIf31bWQ9WqOpc9rqDZb chyB6kGIbVaaNWbLhTmSmEDkK05+3IHj+6Lx5L2MXp33uAzfTN0aajCKsdeRcf/xKSbWhaaxy wDYnFn3YiJphcd/oP62XF97JB3M4BkkyLfihdcZx7tdLVk46DxKSppbbin6OvO99Vg8eZ53YO lcR9WPSeQyiYxSxWg/ryR9odKgpWB8WPHe+v1PWrlAWw8LHr/VD8Ae4LftibtLipmU5Z4QbEA SBzTkTkMRvR6cLMo32zbQjOl82LRVA6wz8YjYa8B70n3GpiLHiX8MhUzAZ237EEPQJFplvhi3 bSPsa4cRAokEvnrNWcsFGMmV3PooGvCJIHef1sJNnnNvo1mIk7R4mpj+ScrDT40a/XfIliTCL oQLpaAZQbtX3MWz2/kH3r4512cgQQMlX5ZygYe+uyoyjY4Cv7rd9a6YdbOCsBUNWX0EO71ncT RTS2Xich83nwkxrcXEd4q/xK1VpOEND4DReFN20Mpv2QWwnFS3890JYS1AWyY7M7Nq1o= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.75 Subject: [Qemu-devel] [PATCH] linux-user: convert sockaddr_ll from host to target X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Peter Maydell --- linux-user/syscall.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 731926d..599b946 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 #include #include +#include #include #ifdef CONFIG_RTNETLINK #include @@ -1379,6 +1380,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);