From patchwork Tue Sep 19 08:15:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= X-Patchwork-Id: 9958449 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 B8BA16038F for ; Tue, 19 Sep 2017 08:17:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99D66205F6 for ; Tue, 19 Sep 2017 08:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E4C622299; Tue, 19 Sep 2017 08:17: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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 2FA6E205F6 for ; Tue, 19 Sep 2017 08:17:18 +0000 (UTC) Received: from localhost ([::1]:40718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duDiX-0000z4-H3 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Sep 2017 04:17:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duDhx-0000yp-KP for qemu-devel@nongnu.org; Tue, 19 Sep 2017 04:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duDhu-00080S-T1 for qemu-devel@nongnu.org; Tue, 19 Sep 2017 04:16:41 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duDhu-0007zn-N7 for qemu-devel@nongnu.org; Tue, 19 Sep 2017 04:16:38 -0400 Received: by mail-pf0-x242.google.com with SMTP id i23so1221514pfi.2 for ; Tue, 19 Sep 2017 01:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rYSvUbCkr/C6Er7x8CIXuEodM9tUaucnEYjbakjmllQ=; b=GFBli1IvwshHA+IH0SoAn+6R5lozd5zD0McZ5KPZAVI6kOjxZs9MUmsIRlFjimBhQV cN+zntoIy53lTgiVLfYec+rciN6qIzPY/NvORMpsf27tGPyMshjBIV21r+M38ezjj0n2 MvHwE9kWDxeXf4eRrhsoeeurMtwHWFGv+Fhy3W0JKbbLCRFEqtB1Br9XcyfChqRtj8TW jFDNEQAP/+L0+GZ87MSa72wb92jaZqrxkl85RVv3Js67HcU3ytl+VVLs62sEkSbDiLbE ysIZj0knHVLaVSyMVbA8LjN7+MrV89fxtpaRnF0VHtTpygWmsVKFA1WimCGlL+DjbxCj tjRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rYSvUbCkr/C6Er7x8CIXuEodM9tUaucnEYjbakjmllQ=; b=b8QifGwzDOcIpUC3JLG/ICTMx4f13mMxKlFxSZ5PjUHrl8oXS6mnQ23HJyA9FKWNKq 5b5LoD9RHkQD+5qYcFdOXfYVrgY8P+/uoEl9Z9MDf9VKRHOhDHmJSBJN93DJG6Uvcr2G wanRsY9gLWtI2hDjrjH2ac03qKVN8yqRWRVnJuaT58o4XOMVUn5fYoN3XAp0e6Bw+e91 hiS2MY2/i3cxNHxsz1w36hrJzYAU9l6KQNTZtbGKL0bF4f0SoKcQnaOG5KX2hdidcRvV 8FVrp0aDJbLd0m3kVtkbZr36wpr3Zo8ignxWJ9cgJ6yZROvzPC1k6K+klZ3iMBNmzxvJ L3jg== X-Gm-Message-State: AHPjjUjNpMQE/fhVP+RP/B9Wxyw3Kz+gaSZcBoF7zQFMl7/Qfyi8eVec T3qRMynYKUUzTo+jFm7fbKoa4jEe X-Google-Smtp-Source: AOwi7QA0UHsUR6+VbpOW6EQGY9HOKgQk1BMt1oXADTiCoGnDuVhyyknEI4L0zEbLxzX+Dg9eYCsZDA== X-Received: by 10.101.70.76 with SMTP id k12mr571843pgr.19.1505808996004; Tue, 19 Sep 2017 01:16:36 -0700 (PDT) Received: from localhost.localdomain (c-73-189-82-67.hsd1.ca.comcast.net. [73.189.82.67]) by smtp.gmail.com with ESMTPSA id r22sm2369391pfe.78.2017.09.19.01.16.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Sep 2017 01:16:35 -0700 (PDT) From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= To: qemu-devel@nongnu.org Date: Tue, 19 Sep 2017 01:15:49 -0700 Message-Id: <20170919081549.82541-1-carenas@gmail.com> X-Mailer: git-send-email 2.11.0 (Apple Git-81) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3] linux-user: syscall: Add SO_LINGER for setsockopt 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: peter.maydell@linaro.org, gang.chen.5i5j@gmail.com, riku.voipio@iki.fi, laurent@vivier.eu, =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= , rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Original implementation from Chen Gang; code moved around as per v2 Signed-off-by: Chen Gang Signed-off-by: Carlo Marcelo Arenas Belón --- linux-user/syscall.c | 16 ++++++++++++++++ linux-user/syscall_defs.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..d3c500ca78 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2829,6 +2829,8 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, int val; struct ip_mreqn *ip_mreq; struct ip_mreq_source *ip_mreq_source; + struct linger lg; + struct target_linger *tlg; switch(level) { case SOL_TCP: @@ -3071,6 +3073,20 @@ set_timeout: unlock_user (dev_ifname, optval_addr, 0); return ret; } + case TARGET_SO_LINGER: + optname = SO_LINGER; + if (optlen != sizeof(struct target_linger)) { + return -TARGET_EINVAL; + } + if (!lock_user_struct(VERIFY_READ, tlg, optval_addr, 1)) { + return -TARGET_EFAULT; + } + __get_user(lg.l_onoff, &tlg->l_onoff); + __get_user(lg.l_linger, &tlg->l_linger); + ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname, + &lg, sizeof(lg))); + unlock_user_struct(tlg, optval_addr, 0); + 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 40c5027e93..a60d6bb163 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -202,6 +202,11 @@ struct target_ip_mreq_source { uint32_t imr_sourceaddr; }; +struct target_linger { + abi_int l_onoff; /* Linger active */ + abi_int l_linger; /* How long to linger for */ +}; + struct target_timeval { abi_long tv_sec; abi_long tv_usec;