From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWZ2o-0005YC-3t for qemu-devel@nongnu.org; Thu, 18 Feb 2016 19:35:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWZ2j-0006KX-5M for qemu-devel@nongnu.org; Thu, 18 Feb 2016 19:35:38 -0500 Received: from domu-toccata.ens-lyon.fr ([140.77.166.138]:38713 helo=sonata.ens-lyon.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWZ2i-0006KR-UN for qemu-devel@nongnu.org; Thu, 18 Feb 2016 19:35:33 -0500 Date: Fri, 19 Feb 2016 01:35:30 +0100 From: Samuel Thibault Message-ID: <20160219003530.GU2679@var.home> References: <56C46088.4050105@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56C46088.4050105@redhat.com> Subject: Re: [Qemu-devel] [PATCHv7 9/9] qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: zhanghailiang , Li Zhijian , Stefan Hajnoczi , Jason Wang , qemu-devel@nongnu.org, Vasiliy Tolstov , Dave Gilbert , Yann Bordenave , Gonglei , Jan Kiszka , Huangpeng , Guillaume Subiron Thomas Huth, on Wed 17 Feb 2016 12:59:04 +0100, wrote: > The IPv4 code seems to have a sanity check that the vhost address is > within the same net as specified with the "net=" parameter... maybe the > IPv6 part should have that, too? Or use the prefix from "ip6-net=" here > if ip6-host has not been specified manually? I'd say the latter indeed. I have reworked this part of the code, and then the implementation matches the documentation :) @@ -235,6 +242,52 @@ static int net_slirp_init(NetClientState *peer, const char *model, } #endif + + if (!vprefix6) { + vprefix6 = "fec0::"; + } + if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) { + return -1; + } + + if (!vprefix6_len) { + vprefix6_len = 64; + } + if (vprefix6_len < 0 || vprefix6_len > 128) { + return -1; + } + + if (vhost6) { + if (!inet_pton(AF_INET6, vhost6, &ip6_host)) { + return -1; + } + if (!in6_equal_net(&ip6_prefix, &ip6_host, vprefix6_len)) { + return -1; + } + } else { + if (vprefix6_len > 126) { + return -1; + } + ip6_host = ip6_prefix; + ip6_host.s6_addr[15] |= 2; + } + + if (vnameserver6) { + if (!inet_pton(AF_INET6, vnameserver6, &ip6_dns)) { + return -1; + } + if (!in6_equal_net(&ip6_prefix, &ip6_dns, vprefix6_len)) { + return -1; + } + } else { + if (vprefix6_len > 126) { + return -1; + } + ip6_dns = ip6_prefix; + ip6_dns.s6_addr[15] |= 3; + } + + nc = qemu_new_net_client(&net_slirp_info, peer, model, name); snprintf(nc->info_str, sizeof(nc->info_str),