From: Thomas Huth <thuth@redhat.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>, qemu-devel@nongnu.org
Cc: jan.kiszka@siemens.com, jasowang@redhat.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH 5/5] slirp: Add RDNSS advertisement
Date: Wed, 30 Mar 2016 11:55:52 +0200 [thread overview]
Message-ID: <56FBA2A8.8020003@redhat.com> (raw)
In-Reply-To: <1459208679-27805-6-git-send-email-samuel.thibault@ens-lyon.org>
On 29.03.2016 01:44, Samuel Thibault wrote:
> This adds the RDNSS option to IPv6 router advertisements, so that the guest
> can autoconfigure the DNS server address.
>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> slirp/ip6_icmp.c | 19 ++++++++++++++++---
> slirp/ip6_icmp.h | 12 ++++++++++--
> 2 files changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c
> index 09571bc..74585d1 100644
> --- a/slirp/ip6_icmp.c
> +++ b/slirp/ip6_icmp.c
> @@ -149,7 +149,8 @@ void ndp_send_ra(Slirp *slirp)
> rip->ip_nh = IPPROTO_ICMPV6;
> rip->ip_pl = htons(ICMP6_NDP_RA_MINLEN
> + NDPOPT_LINKLAYER_LEN
> - + NDPOPT_PREFIXINFO_LEN);
> + + NDPOPT_PREFIXINFO_LEN
> + + NDPOPT_RDNSS_LEN);
> t->m_len = sizeof(struct ip6) + ntohs(rip->ip_pl);
>
> /* Build ICMPv6 packet */
> @@ -167,16 +168,16 @@ void ndp_send_ra(Slirp *slirp)
> ricmp->icmp6_nra.lifetime = htons(NDP_AdvDefaultLifetime);
> ricmp->icmp6_nra.reach_time = htonl(NDP_AdvReachableTime);
> ricmp->icmp6_nra.retrans_time = htonl(NDP_AdvRetransTime);
> + t->m_data += ICMP6_NDP_RA_MINLEN;
>
> /* Source link-layer address (NDP option) */
> - t->m_data += ICMP6_NDP_RA_MINLEN;
> struct ndpopt *opt = mtod(t, struct ndpopt *);
> opt->ndpopt_type = NDPOPT_LINKLAYER_SOURCE;
> opt->ndpopt_len = NDPOPT_LINKLAYER_LEN / 8;
> in6_compute_ethaddr(rip->ip_src, opt->ndpopt_linklayer);
> + t->m_data += NDPOPT_LINKLAYER_LEN;
>
> /* Prefix information (NDP option) */
> - t->m_data += NDPOPT_LINKLAYER_LEN;
> struct ndpopt *opt2 = mtod(t, struct ndpopt *);
> opt2->ndpopt_type = NDPOPT_PREFIX_INFO;
> opt2->ndpopt_len = NDPOPT_PREFIXINFO_LEN / 8;
> @@ -188,8 +189,20 @@ void ndp_send_ra(Slirp *slirp)
> opt2->ndpopt_prefixinfo.pref_lt = htonl(NDP_AdvPrefLifetime);
> opt2->ndpopt_prefixinfo.reserved2 = 0;
> opt2->ndpopt_prefixinfo.prefix = slirp->vprefix_addr6;
> + t->m_data += NDPOPT_PREFIXINFO_LEN;
> +
> + /* Prefix information (NDP option) */
> + struct ndpopt *opt3 = mtod(t, struct ndpopt *);
> + opt3->ndpopt_type = NDPOPT_RDNSS;
> + opt3->ndpopt_len = NDPOPT_RDNSS_LEN / 8;
> + opt3->ndpopt_rdnss.reserved = 0;
> + opt3->ndpopt_rdnss.lifetime = htonl(2 * NDP_MaxRtrAdvInterval);
> + opt3->ndpopt_rdnss.addr = slirp->vnameserver_addr6;
> + t->m_data += NDPOPT_RDNSS_LEN;
>
> /* ICMPv6 Checksum */
> + t->m_data -= NDPOPT_RDNSS_LEN;
> + t->m_data -= NDPOPT_PREFIXINFO_LEN;
> t->m_data -= NDPOPT_LINKLAYER_LEN;
> t->m_data -= ICMP6_NDP_RA_MINLEN;
> t->m_data -= sizeof(struct ip6);
> diff --git a/slirp/ip6_icmp.h b/slirp/ip6_icmp.h
> index 9460bf8..2282d29 100644
> --- a/slirp/ip6_icmp.h
> +++ b/slirp/ip6_icmp.h
> @@ -122,6 +122,7 @@ struct ndpopt {
> uint8_t ndpopt_len; /* /!\ In units of 8 octets */
> union {
> unsigned char linklayer_addr[6]; /* Source/Target Link-layer */
> +#define ndpopt_linklayer ndpopt_body.linklayer_addr
> struct prefixinfo { /* Prefix Information */
> uint8_t prefix_length;
> #ifdef HOST_WORDS_BIGENDIAN
> @@ -134,19 +135,26 @@ struct ndpopt {
> uint32_t reserved2;
> struct in6_addr prefix;
> } QEMU_PACKED prefixinfo;
> - } ndpopt_body;
> -#define ndpopt_linklayer ndpopt_body.linklayer_addr
> #define ndpopt_prefixinfo ndpopt_body.prefixinfo
> + struct rdnss {
> + uint16_t reserved;
> + uint32_t lifetime;
> + struct in6_addr addr;
> + } QEMU_PACKED rdnss;
> +#define ndpopt_rdnss ndpopt_body.rdnss
> + } ndpopt_body;
> } QEMU_PACKED;
>
> /* NDP options type */
> #define NDPOPT_LINKLAYER_SOURCE 1 /* Source Link-Layer Address */
> #define NDPOPT_LINKLAYER_TARGET 2 /* Target Link-Layer Address */
> #define NDPOPT_PREFIX_INFO 3 /* Prefix Information */
> +#define NDPOPT_RDNSS 25 /* Recursive DNS Server Address */
>
> /* NDP options size, in octets. */
> #define NDPOPT_LINKLAYER_LEN 8
> #define NDPOPT_PREFIXINFO_LEN 32
> +#define NDPOPT_RDNSS_LEN 24
>
> /*
> * Definition of type and code field values.
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
prev parent reply other threads:[~2016-03-30 9:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-28 23:44 [Qemu-devel] [PATCH 0/5] ipv4-only and ipv6-only support Samuel Thibault
2016-03-28 23:44 ` [Qemu-devel] [PATCH 1/5] slirp: Allow disabling IPv4 or IPv6 Samuel Thibault
2016-03-30 8:38 ` Thomas Huth
2016-03-30 15:04 ` Samuel Thibault
2016-03-30 15:06 ` Thomas Huth
2016-03-30 15:13 ` Samuel Thibault
2016-03-30 15:29 ` Thomas Huth
2016-03-30 15:36 ` Samuel Thibault
2016-03-30 15:54 ` Eric Blake
2016-03-28 23:44 ` [Qemu-devel] [PATCH 2/5] slirp: Split get_dns_addr Samuel Thibault
2016-03-30 8:57 ` Thomas Huth
2016-03-28 23:44 ` [Qemu-devel] [PATCH 3/5] slirp: Add dns6 resolution Samuel Thibault
2016-03-30 9:32 ` Thomas Huth
2016-03-28 23:44 ` [Qemu-devel] [PATCH 4/5] slirp: Support link-local DNS addresses Samuel Thibault
2016-03-30 9:49 ` Thomas Huth
2016-03-28 23:44 ` [Qemu-devel] [PATCH 5/5] slirp: Add RDNSS advertisement Samuel Thibault
2016-03-30 9:55 ` Thomas Huth [this message]
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=56FBA2A8.8020003@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=samuel.thibault@ens-lyon.org \
/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).