[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv9 09/10] qapi-schema, qemu-options & slirp: Addi
From: |
Thomas Huth |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 22.02.2016 20:28, Samuel Thibault wrote:
> From: Yann Bordenave <address@hidden>
>
> 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 <address@hidden>
> Signed-off-by: Samuel Thibault <address@hidden>
> ---
> 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
- [Qemu-devel] [PATCHv9 0/10] slirp: Adding IPv6 support to Qemu -net user mode, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 03/10] slirp: Adding IPv6 UDP support, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 10/10] slirp: Add IPv6 support to the TFTP code, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 08/10] slirp: Adding IPv6 address for DNS relay, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 06/10] slirp: Reindent after refactoring, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 09/10] qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses, Samuel Thibault, 2016/02/22
- Re: [Qemu-devel] [PATCHv9 09/10] qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses,
Thomas Huth <=
- [Qemu-devel] [PATCHv9 07/10] slirp: Handle IPv6 in TCP functions, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 04/10] slirp: Factorizing tcpiphdr structure with an union, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 02/10] slirp: Adding ICMPv6 error sending, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 05/10] slirp: Generalizing and neutralizing various TCP functions before adding IPv6 stuff, Samuel Thibault, 2016/02/22
- [Qemu-devel] [PATCHv9 01/10] slirp: Adding IPv6, ICMPv6 Echo and NDP autoconfiguration, Samuel Thibault, 2016/02/22