From patchwork Tue Jul 15 14:24:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 33671 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3872320CAD for ; Tue, 15 Jul 2014 14:28:38 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf22996544oag.8 for ; Tue, 15 Jul 2014 07:28:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=TG+xMf7iLqJ775op6FrYdymfvi1uGkHBIw17JYTK9QM=; b=YfhlboUY5CmowIb7pvDMtctfabb2oVgjuzPqAj+qFIVPGEQOP4oHpKzl8iC0sUR5Lu MNOwAqO18kEHaeTXdVfpCEEUzdB0QZWCwKe29ivvpHvM8UB6JUjcy9Ujh1t3zACfPdHe BbLXVqR06dEf1BnTYnOQaNY4YwvOM3jn2HhPfgVatllnGN8+DXOjGTMA9/B3cx5HXrp6 hhGcEOrVMJAPOoeQxsjGZ3pcAquOEsCVUL+t8vI6kmC8oHYwFo3F5NBUE8fdh4x8vv60 uVqfmV40/cKwVT2dIlpeSiRpL0nmUMsOJRso7LYRI81/YJWdySdmScx3S9Emp3LYHaCZ hqxw== X-Gm-Message-State: ALoCoQk1Q8WOLiRQwQql724mnoAmNyxPRFh0WTV6RpYLQaQMPhw824oYfsBv9mUozPKZBAbDq6FC X-Received: by 10.43.114.138 with SMTP id fa10mr12635409icc.17.1405434517546; Tue, 15 Jul 2014 07:28:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.37 with SMTP id q34ls109862qgd.5.gmail; Tue, 15 Jul 2014 07:28:37 -0700 (PDT) X-Received: by 10.220.44.141 with SMTP id a13mr804665vcf.71.1405434517455; Tue, 15 Jul 2014 07:28:37 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id sj4si6798590vec.18.2014.07.15.07.28.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 07:28:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id id10so10215219vcb.24 for ; Tue, 15 Jul 2014 07:28:37 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr666919vdb.86.1405434517371; Tue, 15 Jul 2014 07:28:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp219019vcb; Tue, 15 Jul 2014 07:28:36 -0700 (PDT) X-Received: by 10.140.42.181 with SMTP id c50mr18151774qga.17.1405434516450; Tue, 15 Jul 2014 07:28:36 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id eb3si20714307qcb.17.2014.07.15.07.28.36 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Jul 2014 07:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:34997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73ie-0002Kf-0p for patch@linaro.org; Tue, 15 Jul 2014 10:28:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73fI-0005hD-CJ for qemu-devel@nongnu.org; Tue, 15 Jul 2014 10:25:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X73fA-0007Ws-Dv for qemu-devel@nongnu.org; Tue, 15 Jul 2014 10:25:08 -0400 Received: from afflict.kos.to ([92.243.29.197]:37248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73fA-0007W5-7T for qemu-devel@nongnu.org; Tue, 15 Jul 2014 10:25:00 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 0ACD826547; Tue, 15 Jul 2014 16:24:59 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 15 Jul 2014 17:24:54 +0300 Message-Id: <451aaf688c709c91a0d511c24624104677cc754e.1405434118.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Peter Maydell , Joakim Tjernlund Subject: [Qemu-devel] [PULL for-2.1 2/5] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Joakim Tjernlund Signed-off-by: Joakim Tjernlund Reviewed-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5a272d3..dcf1323 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1497,6 +1497,25 @@ set_timeout: unlock_user_struct(tfprog, optval_addr, 1); return ret; } + case TARGET_SO_BINDTODEVICE: + { + char *dev_ifname, *addr_ifname; + + if (optlen > IFNAMSIZ - 1) { + optlen = IFNAMSIZ - 1; + } + dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1); + if (!dev_ifname) { + return -TARGET_EFAULT; + } + optname = SO_BINDTODEVICE; + addr_ifname = alloca(IFNAMSIZ); + memcpy(addr_ifname, dev_ifname, optlen); + addr_ifname[optlen] = 0; + ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen)); + unlock_user (dev_ifname, optval_addr, 0); + return ret; + } /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG;