From nobody Tue Feb 10 09:27:48 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1558623155; cv=none; d=zoho.com; s=zohoarc; b=Wi1jJhGVXl+SILKbQYBOifo7ZsXApc/GshA7UI1M9aeXFvSDQco1VG1sAttp/+YM9dCeTyORbnPzGb2Q725wQOtdjdYbNaou6sGS9NWQzaIYN+NVFmllFXxfeRtnF2+tXZv8oRUGmtOaG33K3+357+F47f2pFU6nAdVTPqzmCOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558623155; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rPDPS5bHhWO8oIfu7wfw7O8ZYyMMYrT/hCyFGBeAQks=; b=k9WYC0SsL6WuE6eFnKy1YTJMHQTWddieqPsa7euoYdJtL8Dyc+WKuh9hQ7PKDeT65LUTnISUBK9eHohnjzVy5Qtb+GdDhLN87W09vGnw/f5/Xc4ibv6XTGoaY/tqEKvMTwcHAk8QIQ1onVpjyqfy7xKXvKGx01pagCF7iAVoZk4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558623155797813.1906071941961; Thu, 23 May 2019 07:52:35 -0700 (PDT) Received: from localhost ([127.0.0.1]:38157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTp4t-0002KG-Hm for importer@patchew.org; Thu, 23 May 2019 10:52:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTowu-0004CX-3L for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTows-0006Be-Tv for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:04 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:34261) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTows-00069c-Kz for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:02 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mzydy-1gfh6S11Bm-00x4Cg; Thu, 23 May 2019 16:43:46 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 May 2019 16:43:33 +0200 Message-Id: <20190523144336.13960-8-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523144336.13960-1-laurent@vivier.eu> References: <20190523144336.13960-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:wqhZU6gk88fwROrf82j7nD5p1cGnks1SE+P6uFI2h9boVBYa1xx j9dCF/nuRHLxPrQ6ONJFor1Dz92nwXFH7sKA7QSWl+3xBN5eWC1WsPuS79PaV2qqP46woZo 2TNddznXiC0wUznWi1fNKR7KKGlnz6aOlgwH8cOKkkEUN1EJtsRCDUW1XrfssjU8N1T7foL QHeZeC24NLwd0P5NB7Pzw== X-UI-Out-Filterresults: notjunk:1;V03:K0:d+8fK3F9eAM=:UNZiI+IwYo77XXgZv6V4fp tGpGZe0jTg0AgVyug8vmoX5XMzcUMBEToFDfjrOqmGOub7Ui4ktNmtbggjdbpIkzTcb0Hc2n8 PC5PXuecoi5q+HR1jUKSYymmIxcvFa3D30nKPpjjrdX/wB+7hx+m7LPA/lMSwQtFwehFGPKmc rUdKTncqztVHifTTQN3Lm1vtCuaAR2/jtxJZon0zc3FV/ZGADRi6A2rKP4O0BXUM08SmRV2BB szEV6NA0+2/KmAHSCenVj5tItlPE+Sx9n7koapoBnBoy2dgLRYrAJoH63cjZ9tm8qFtFwarRQ V85eDITLImlqgZTGbRLl7xs7ivypI/dBRCST5tMmMut6lPFdoWWOeJTLy9EYsmpCQ6vf6jdmN kLCJWk4ACiDk/XrSlAjOUl5hSGVmsW1I/VCeblYhu5wY7ZwLawqzKGAJNr6aKP26MI7cw2udx orDBmC44oGGg604vT4jkq8aH+YFcHfDQfYOy3qTa34LhpcdvhOyyYHMJxtWz2Xl5b4RqCdWh8 UXgOY4WVQ754O64jraI/GUqrDzLkkcjRwroUMv/Py3ROfK6w5SAxcCE1A+C26/q7ltbrMxbQ3 s1eigAeXszK0GNHpNVlM5NoUm592OwSkj7lmDxld3CFVADuYrW292T43y5kTHubp6o+80Zx0g B8pFuwkHEwiJHZT5iJOh2LU8vYYQnKUM4n6NGvAlCqy860YeKuTZ5s4ichzG/mGAEUbcrETMH dakVKqKney1fGkYBtYTiRZ83Zz3dEHZp/hGQaw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PULL 07/10] linux-user: Add support for setsockopt() options IPV6__MEMBERSHIP 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: Aleksandar Rikalo , Riku Voipio , Laurent Vivier , Aleksandar Markovic , Neng Chen , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Neng Chen Add support for options IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMPEMBERSHIP of the syscall setsockopt(). These options control membership in multicast groups. Their argument is a pointer to a struct ipv6_mreq, which is in turn defined in IP v6 header netinet/in.h as: struct ipv6_mreq { /* IPv6 multicast address of group */ struct in6_addr ipv6mr_multiaddr; /* local IPv6 address of interface */ int ipv6mr_interface; }; ...whereas its definition in kernel's include/uapi/linux/in6.h is: #if __UAPI_DEF_IPV6_MREQ struct ipv6_mreq { /* IPv6 multicast address of group */ struct in6_addr ipv6mr_multiaddr; /* local IPv6 address of interface */ int ipv6mr_ifindex; }; #endif The first field of ipv6_mreq has the same name ("ipv6mr_multiaddr") and type ("in6_addr") in both cases. Moreover, the in6_addr structure consists of fields that are always big-endian (on host of any endian), therefore the ipv6_mreq's field ipv6mr_multiaddr doesn't need any endian conversion. The second field of ipv6_mreq may, however, depending on the build environment, have different names. This is the reason why the line "#if __UAPI_DEF_IPV6_MREQ" is used in this patch - to establish the right choice for the field name. Also, endian conversion is needed for this field, since it is of type "int". Signed-off-by: Neng Chen Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier Message-Id: <1558282527-22183-5-git-send-email-aleksandar.markovic@rt-rk.co= m> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e5545cbafac7..a0c2bf7db43c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1911,6 +1911,29 @@ static abi_long do_setsockopt(int sockfd, int level,= int optname, &pki, sizeof(pki))); break; } + case IPV6_ADD_MEMBERSHIP: + case IPV6_DROP_MEMBERSHIP: + { + struct ipv6_mreq ipv6mreq; + + if (optlen < sizeof(ipv6mreq)) { + return -TARGET_EINVAL; + } + + if (copy_from_user(&ipv6mreq, optval_addr, sizeof(ipv6mreq))) { + return -TARGET_EFAULT; + } + +#if __UAPI_DEF_IPV6_MREQ + ipv6mreq.ipv6mr_ifindex =3D tswap32(ipv6mreq.ipv6mr_ifindex); +#else + ipv6mreq.ipv6mr_interface =3D tswap32(ipv6mreq.ipv6mr_interfac= e); +#endif /* __UAPI_DEF_IVP6_MREQ */ + + ret =3D get_errno(setsockopt(sockfd, level, optname, + &ipv6mreq, sizeof(ipv6mreq))); + break; + } default: goto unimplemented; } --=20 2.20.1