qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCHv7 1/9] slirp: Adding IPv6, ICMPv6 Echo and NDP a


From: Thomas Huth
Subject: Re: [Qemu-devel] [PATCHv7 1/9] slirp: Adding IPv6, ICMPv6 Echo and NDP autoconfiguration
Date: Fri, 19 Feb 2016 14:57:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 14.02.2016 18:47, Samuel Thibault wrote:
> From: Guillaume Subiron <address@hidden>
> 
> 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 <address@hidden>
> Signed-off-by: Samuel Thibault <address@hidden>
> ---
...
> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]