qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>, qemu-devel@nongnu.org
Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>,
	Li Zhijian <lizhijian@cn.fujitsu.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Jason Wang <jasowang@redhat.com>,
	Dave Gilbert <dgilbert@redhat.com>,
	Vasiliy Tolstov <v.tolstov@selfip.ru>,
	Huangpeng <peter.huangpeng@huawei.com>,
	Yann Bordenave <meow@meowstars.org>,
	Gonglei <arei.gonglei@huawei.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Guillaume Subiron <maethor@subiron.org>
Subject: Re: [Qemu-devel] [PATCHv9 09/10] qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses
Date: Tue, 23 Feb 2016 09:27:24 +0100	[thread overview]
Message-ID: <56CC17EC.7010204@redhat.com> (raw)
In-Reply-To: <b4a9c7d435d4cd750f6e4486d3f3d7014cfc85ab.1456168872.git.samuel.thibault@ens-lyon.org>

On 22.02.2016 20:28, Samuel Thibault wrote:
> From: Yann Bordenave <meow@meowstars.org>
> 
> This patch adds parameters to manage some new options in the qemu -net
> command.
> Slirp IPv6 address, network prefix, and DNS IPv6 address can be given in
> argument to the qemu command.
> Defaults parameters are respectively fec0::2, fec0::, /64 and fec0::3.
> 
> Signed-off-by: Yann Bordenave <meow@meowstars.org>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
>  net/net.c        | 31 +++++++++++++++++++++++++
>  net/slirp.c      | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
>  qapi-schema.json | 40 ++++++++++++++++++++------------
>  qemu-options.hx  | 18 +++++++++++++--
>  slirp/libslirp.h |  8 ++++---
>  slirp/slirp.c    | 16 +++++++------
>  6 files changed, 150 insertions(+), 32 deletions(-)
...
> diff --git a/net/slirp.c b/net/slirp.c
> index 6b51fbc..bd712bc 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -36,6 +36,7 @@
>  #include "qemu/error-report.h"
>  #include "qemu/sockets.h"
>  #include "slirp/libslirp.h"
> +#include "slirp/ip6.h"
>  #include "sysemu/char.h"
>  
>  static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
> @@ -135,10 +136,13 @@ static NetClientInfo net_slirp_info = {
>  static int net_slirp_init(NetClientState *peer, const char *model,
>                            const char *name, int restricted,
>                            const char *vnetwork, const char *vhost,
> +                          const char *vprefix6, int vprefix6_len,
> +                          const char *vhost6,
>                            const char *vhostname, const char *tftp_export,
>                            const char *bootfile, const char *vdhcp_start,
> -                          const char *vnameserver, const char *smb_export,
> -                          const char *vsmbserver, const char **dnssearch)
> +                          const char *vnameserver, const char *vnameserver6,
> +                          const char *smb_export, const char *vsmbserver,
> +                          const char **dnssearch)
>  {
>      /* default settings according to historic slirp */
>      struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
> @@ -146,6 +150,9 @@ static int net_slirp_init(NetClientState *peer, const char *model,
>      struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
>      struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
>      struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
> +    struct in6_addr ip6_prefix;
> +    struct in6_addr ip6_host;
> +    struct in6_addr ip6_dns;
>  #ifndef _WIN32
>      struct in_addr smbsrv = { .s_addr = 0 };
>  #endif
> @@ -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;
> +    }

I think you could also immediately check for vprefix6_len > 126 here
already, then you could drop the two checks for 126 below. A prefix that
is bigger than 126 does not make much sense anyway, so I think it should
be ok to always disallow this (especially since there will be at least
three hosts in this network - the host, the guest, and the DNS server).

> +    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;
> +    }

The other parts of the patch looks fine to me now.

 Thomas

  reply	other threads:[~2016-02-23  8:27 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 19:28 [Qemu-devel] [PATCHv9 0/10] slirp: Adding IPv6 support to Qemu -net user mode Samuel Thibault
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 01/10] slirp: Adding IPv6, ICMPv6 Echo and NDP autoconfiguration Samuel Thibault
2016-03-07  6:53   ` Jason Wang
2016-03-07 11:24     ` Samuel Thibault
2016-03-08  1:39       ` Jason Wang
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 02/10] slirp: Adding ICMPv6 error sending Samuel Thibault
2016-03-07  6:55   ` Jason Wang
2016-03-07 13:34     ` Samuel Thibault
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 03/10] slirp: Adding IPv6 UDP support Samuel Thibault
2016-03-07  6:57   ` Jason Wang
2016-03-07 11:36     ` Samuel Thibault
2016-03-08  1:40       ` Jason Wang
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 04/10] slirp: Factorizing tcpiphdr structure with an union Samuel Thibault
2016-02-23  8:07   ` Thomas Huth
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 05/10] slirp: Generalizing and neutralizing various TCP functions before adding IPv6 stuff Samuel Thibault
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 06/10] slirp: Reindent after refactoring Samuel Thibault
2016-03-07  7:02   ` Jason Wang
2016-03-07 11:38     ` Samuel Thibault
2016-03-08  1:43       ` Jason Wang
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 07/10] slirp: Handle IPv6 in TCP functions Samuel Thibault
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 08/10] slirp: Adding IPv6 address for DNS relay Samuel Thibault
2016-02-23  8:12   ` Thomas Huth
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 09/10] qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses Samuel Thibault
2016-02-23  8:27   ` Thomas Huth [this message]
2016-03-07  7:05   ` Jason Wang
2016-03-07 11:39     ` Samuel Thibault
2016-03-07 11:41     ` Samuel Thibault
2016-03-07 16:05       ` Eric Blake
2016-02-22 19:28 ` [Qemu-devel] [PATCHv9 10/10] slirp: Add IPv6 support to the TFTP code Samuel Thibault
2016-03-04  8:41 ` [Qemu-devel] [PATCHv9 0/10] slirp: Adding IPv6 support to Qemu -net user mode Thomas Huth
2016-03-04 15:50   ` Jan Kiszka
2016-03-06 16:59     ` Samuel Thibault
2016-03-07  5:03       ` Jason Wang
2016-03-07 11:09         ` Samuel Thibault
2016-03-07 12:06           ` Jan Kiszka
2016-03-07 12:11             ` Samuel Thibault
2016-03-07 12:14             ` Thomas Huth
2016-03-07 12:16               ` Jan Kiszka
2016-03-08  2:50                 ` Jason Wang
2016-03-08  1:37           ` Jason Wang
2016-03-07  6:48 ` Jason Wang
2016-03-07 11:19   ` Samuel Thibault
2016-03-07 12:00     ` Thomas Huth
2016-03-07 13:37       ` Samuel Thibault
2016-03-08  2:48     ` Jason Wang
2016-03-08  8:53       ` Samuel Thibault
2016-03-07 11:55   ` Samuel Thibault
2016-03-07 15:37     ` Thomas Huth
2016-03-07 16:49       ` Samuel Thibault
2016-03-08  2:15     ` Jason Wang
2016-03-08  9:12       ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56CC17EC.7010204@redhat.com \
    --to=thuth@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jasowang@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=maethor@subiron.org \
    --cc=meow@meowstars.org \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=stefanha@gmail.com \
    --cc=v.tolstov@selfip.ru \
    --cc=zhang.zhanghailiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).