From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWlZM-0006BK-NJ for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:58:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWlZI-0007h2-Mh for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:58:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWlZI-0007gx-Em for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:58:00 -0500 References: <2a2657073950270465c094dbdc2facc511e04758.1455471945.git.samuel.thibault@ens-lyon.org> From: Thomas Huth Message-ID: <56C71F5A.8010608@redhat.com> Date: Fri, 19 Feb 2016 14:57:46 +0100 MIME-Version: 1.0 In-Reply-To: <2a2657073950270465c094dbdc2facc511e04758.1455471945.git.samuel.thibault@ens-lyon.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv7 1/9] slirp: Adding IPv6, ICMPv6 Echo and NDP autoconfiguration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Samuel Thibault , qemu-devel@nongnu.org Cc: zhanghailiang , Li Zhijian , Stefan Hajnoczi , Jason Wang , Dave Gilbert , Vasiliy Tolstov , Huangpeng , Gonglei , Jan Kiszka , Guillaume Subiron On 14.02.2016 18:47, Samuel Thibault wrote: > From: Guillaume Subiron > > This patch adds the functions needed to handle IPv6 packets. ICMPv6 and > NDP headers are implemented. > > Slirp is now able to send NDP Router or Neighbor Advertisement when it > receives Router or Neighbor Solicitation. Using a 64bit-sized IPv6 > prefix, the guest is now able to perform stateless autoconfiguration > (SLAAC) and to compute its IPv6 address. > > This patch adds an ndp_table, mainly inspired by arp_table, to keep an > NDP cache and manage network address resolution. > Slirp regularly sends NDP Neighbor Advertisement, as recommended by the > RFC, to make the guest refresh its route. > > This also adds ip6_cksum() to compute ICMPv6 checksums using IPv6 > pseudo-header. > > Some #define ETH_* are moved upper in slirp.h to make them accessible to > other slirp/*.h > > Signed-off-by: Guillaume Subiron > Signed-off-by: Samuel Thibault > --- ... > diff --git a/slirp/slirp.c b/slirp/slirp.c > index 0466d33..5f42ada 100644 > --- a/slirp/slirp.c > +++ b/slirp/slirp.c > @@ -210,10 +210,12 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, > > slirp_init_once(); > > + slirp->grand = g_rand_new(); > slirp->restricted = restricted; > > if_init(slirp); > ip_init(slirp); > + ip6_init(slirp); > > /* Initialise mbufs *after* setting the MTU */ > m_init(slirp); > @@ -221,6 +223,9 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, > slirp->vnetwork_addr = vnetwork; > slirp->vnetwork_mask = vnetmask; > slirp->vhost_addr = vhost; > + inet_pton(AF_INET6, "fec0::0", &slirp->vprefix_addr6); > + slirp->vprefix_len = 64; > + inet_pton(AF_INET6, "fec0::2", &slirp->vhost_addr6); > if (vhostname) { > pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostname), > vhostname); > @@ -251,6 +256,7 @@ void slirp_cleanup(Slirp *slirp) > unregister_savevm(NULL, "slirp", slirp); > > ip_cleanup(slirp); > + ip6_cleanup(slirp); > m_cleanup(slirp); > > g_free(slirp->vdnssearch); Could you please also do a g_rand_free(slirp->grand) during the slirp_cleanup() function? Otherwise, the memory allocated for the rng won't be freed and you get a big fat "2,500 bytes in 1 blocks are definitely lost" from valgrind... Thomas