From patchwork Sun Mar 20 15:26:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 8626611 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F16DD9F44D for ; Sun, 20 Mar 2016 15:26:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4645C20328 for ; Sun, 20 Mar 2016 15:26:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 628D820304 for ; Sun, 20 Mar 2016 15:26:51 +0000 (UTC) Received: from localhost ([::1]:53310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahfFi-0003Pd-NX for patchwork-qemu-devel@patchwork.kernel.org; Sun, 20 Mar 2016 11:26:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahfFT-0003OL-JT for qemu-devel@nongnu.org; Sun, 20 Mar 2016 11:26:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahfFR-0003c3-J0 for qemu-devel@nongnu.org; Sun, 20 Mar 2016 11:26:35 -0400 Received: from domu-toccata.ens-lyon.fr ([140.77.166.138]:44271 helo=sonata.ens-lyon.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahfFR-0003ay-Bc for qemu-devel@nongnu.org; Sun, 20 Mar 2016 11:26:33 -0400 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 5D677200E9; Sun, 20 Mar 2016 16:26:30 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8-yPhphx_pPD; Sun, 20 Mar 2016 16:26:30 +0100 (CET) Received: from var.youpi.perso.aquilenet.fr (LFbn-1-6757-94.w90-120.abo.wanadoo.fr [90.120.189.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 24EE8200CC; Sun, 20 Mar 2016 16:26:30 +0100 (CET) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.86_2) (envelope-from ) id 1ahfFN-0006zP-Gq; Sun, 20 Mar 2016 16:26:29 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org, thuth@redhat.com Date: Sun, 20 Mar 2016 16:26:28 +0100 Message-Id: <1458487588-26812-5-git-send-email-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458487588-26812-1-git-send-email-samuel.thibault@ens-lyon.org> References: <1458487588-26812-1-git-send-email-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 140.77.166.138 Cc: Samuel Thibault , jan.kiszka@siemens.com Subject: [Qemu-devel] [PATCH 4/4] slirp: Add RDNSS advertisement X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds the RDNSS option to IPv6 router advertisements, so that the guest can autoconfigure the DNS server address. Signed-off-by: Samuel Thibault --- 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 69c0a16..c25d423 100644 --- a/slirp/ip6_icmp.c +++ b/slirp/ip6_icmp.c @@ -151,7 +151,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 */ @@ -169,16 +170,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; @@ -190,8 +191,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.