From patchwork Tue Jul 19 12:54:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9237085 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 2C422607DA for ; Tue, 19 Jul 2016 12:59:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DAF426B41 for ; Tue, 19 Jul 2016 12:59:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 127C226C2F; Tue, 19 Jul 2016 12:59:18 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 B736726B4A for ; Tue, 19 Jul 2016 12:59:17 +0000 (UTC) Received: from localhost ([::1]:55699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPUcG-0003ht-R8 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Jul 2016 08:59:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPUXX-0006y7-W3 for qemu-devel@nongnu.org; Tue, 19 Jul 2016 08:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPUXX-0003LB-4F for qemu-devel@nongnu.org; Tue, 19 Jul 2016 08:54:23 -0400 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]:36377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPUXW-0003L4-SZ for qemu-devel@nongnu.org; Tue, 19 Jul 2016 08:54:23 -0400 Received: by mail-lf0-x230.google.com with SMTP id g62so13364749lfe.3 for ; Tue, 19 Jul 2016 05:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oHCEApwLG4q/wkdIvU1dX+tYQ1iZkkLkhMOg1DVLivQ=; b=AWV3mWgZH5IedfIyx1MGVLGyDLPfajaZ2Mld8SRsVf01YXcqaIQ0kkgL0YKtzC0KoQ Ujz9LGB8ySamDnLTbb/FaYdzDTKFgdMfxhxAT2BXAjFaQ7Eh3vizkh681cnzhYIml6FH 6WtFZzppyOeAu/qzxksM50zYknebJ8/m+3BEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oHCEApwLG4q/wkdIvU1dX+tYQ1iZkkLkhMOg1DVLivQ=; b=XOyFJ+4HgzgoJJbfDvEzFWYGbUp0ar4qelTT48mix47lFCc9h/n+Ro1DiXOfiilinT Zbl3P9H1OWSqyte7x9V7aKNFUqmf3z79hKraccWQFmi9xxPriNQ/CKkYcDKZzxOmPohC O5i6Ov912NIffaLp9Ji9fcNSnjQN9PbklF0baRgQ5DyxO+bVXkPzB7SyVfXnrD+iZCUq BUaar2kz5sb0sf0gGdVgiMz//vLkzZL3ob60PfseUUnGz4JNqSVevoTQUCACd9FfTgvY nm8ElPnzX6I6LhYZQDODpE3WsZ5btx3kaU60EfjjoLgU/xzKZ4MWg/9FSVtRnx5mELRl RkKQ== X-Gm-Message-State: ALyK8tLcjGYd0WFZZzUItc0lfvX9f5yRziZI28QCEYuuO5ocRAFGdODkGYaWStgAtioTfTu8 X-Received: by 10.25.20.87 with SMTP id k84mr18295850lfi.207.1468932861876; Tue, 19 Jul 2016 05:54:21 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id g3sm2248898lfe.14.2016.07.19.05.54.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 05:54:21 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 19 Jul 2016 15:54:02 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::230 Subject: [Qemu-devel] [PULL 04/16] 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: Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Vivier 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 Signed-off-by: Riku Voipio --- 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 #include #include +#include #include #ifdef CONFIG_RTNETLINK #include @@ -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);