From nobody Fri May 3 06:22:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490741714480328.70155998520556; Tue, 28 Mar 2017 15:55:14 -0700 (PDT) Received: from localhost ([::1]:55576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ct01B-0001PR-4V for importer@patchew.org; Tue, 28 Mar 2017 18:55:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cszza-0000Pz-Hn for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cszzZ-0000IE-I4 for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:34 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:53294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cszzZ-0000Hr-BX for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:33 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id CDE2FA599; Wed, 29 Mar 2017 00:53:32 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GQmMuJcmlIpk; Wed, 29 Mar 2017 00:53:30 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 0927DAEE0; Wed, 29 Mar 2017 00:53:28 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.88) (envelope-from ) id 1cszzU-0004Mr-31; Wed, 29 Mar 2017 00:53:28 +0200 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Wed, 29 Mar 2017 00:53:25 +0200 Message-Id: <20170328225327.16707-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328225327.16707-1-samuel.thibault@ens-lyon.org> References: <20170328225327.16707-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PULL 1/3] slirp: fix compilation errors with DEBUG set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jan.kiszka@siemens.com, Laurent Vivier , stefanha@redhat.com, Samuel Thibault Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier slirp/slirp.c: In function 'get_dns_addr_resolv_conf': slirp/slirp.c:202:29: error: initialization discards 'const' qualifier from= pointer target type [-Werror=3Ddiscarded-qualifiers] char *res =3D inet_ntop(af, tmp_addr, s, sizeof(s)); ^~~~~~~~~ slirp/slirp.c:204:25: error: assignment discards 'const' qualifier from poi= nter target type [-Werror=3Ddiscarded-qualifiers] res =3D "(string conversion error)"; Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Samuel Thibault Reviewed-by: Stefan Hajnoczi --- slirp/slirp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 60539de7a3..5a94b06f5e 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -198,7 +198,7 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_= addr, void *cached_addr, #ifdef DEBUG else { char s[INET6_ADDRSTRLEN]; - char *res =3D inet_ntop(af, tmp_addr, s, sizeof(s)); + const char *res =3D inet_ntop(af, tmp_addr, s, sizeof(s)); if (!res) { res =3D "(string conversion error)"; } --=20 2.11.0 From nobody Fri May 3 06:22:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149074179648453.784847972350235; Tue, 28 Mar 2017 15:56:36 -0700 (PDT) Received: from localhost ([::1]:55583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ct02V-0002QU-6u for importer@patchew.org; Tue, 28 Mar 2017 18:56:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cszzb-0000Q4-2e for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cszzY-0000HN-3u for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:35 -0400 Received: from hera.aquilenet.fr ([141.255.128.1]:52522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cszzX-0000Gz-QI for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:32 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 8A3D27379; Wed, 29 Mar 2017 00:53:30 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E5LN7sO5rnPS; Wed, 29 Mar 2017 00:53:29 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id EC52FA599; Wed, 29 Mar 2017 00:53:28 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.88) (envelope-from ) id 1cszzU-0004Mt-4p; Wed, 29 Mar 2017 00:53:28 +0200 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Wed, 29 Mar 2017 00:53:26 +0200 Message-Id: <20170328225327.16707-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328225327.16707-1-samuel.thibault@ens-lyon.org> References: <20170328225327.16707-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 141.255.128.1 Subject: [Qemu-devel] [PULL 2/3] slirp: Make RA build more flexible X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Do not hardcode the RA size at all, use a pl_size variable which accounts the accumulated size, and fill rip->ip_pl at the end. This will allow to make some blocks optional. Signed-off-by: Samuel Thibault Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- slirp/ip6_icmp.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c index 298a48dd25..d0f5cc1456 100644 --- a/slirp/ip6_icmp.c +++ b/slirp/ip6_icmp.c @@ -143,17 +143,10 @@ void ndp_send_ra(Slirp *slirp) /* Build IPv6 packet */ struct mbuf *t =3D m_get(slirp); struct ip6 *rip =3D mtod(t, struct ip6 *); + size_t pl_size =3D 0; rip->ip_src =3D (struct in6_addr)LINKLOCAL_ADDR; rip->ip_dst =3D (struct in6_addr)ALLNODES_MULTICAST; rip->ip_nh =3D IPPROTO_ICMPV6; - rip->ip_pl =3D htons(ICMP6_NDP_RA_MINLEN - + NDPOPT_LINKLAYER_LEN - + NDPOPT_PREFIXINFO_LEN -#ifndef _WIN32 - + NDPOPT_RDNSS_LEN -#endif - ); - t->m_len =3D sizeof(struct ip6) + ntohs(rip->ip_pl); =20 /* Build ICMPv6 packet */ t->m_data +=3D sizeof(struct ip6); @@ -171,6 +164,7 @@ void ndp_send_ra(Slirp *slirp) ricmp->icmp6_nra.reach_time =3D htonl(NDP_AdvReachableTime); ricmp->icmp6_nra.retrans_time =3D htonl(NDP_AdvRetransTime); t->m_data +=3D ICMP6_NDP_RA_MINLEN; + pl_size +=3D ICMP6_NDP_RA_MINLEN; =20 /* Source link-layer address (NDP option) */ struct ndpopt *opt =3D mtod(t, struct ndpopt *); @@ -178,6 +172,7 @@ void ndp_send_ra(Slirp *slirp) opt->ndpopt_len =3D NDPOPT_LINKLAYER_LEN / 8; in6_compute_ethaddr(rip->ip_src, opt->ndpopt_linklayer); t->m_data +=3D NDPOPT_LINKLAYER_LEN; + pl_size +=3D NDPOPT_LINKLAYER_LEN; =20 /* Prefix information (NDP option) */ struct ndpopt *opt2 =3D mtod(t, struct ndpopt *); @@ -192,6 +187,7 @@ void ndp_send_ra(Slirp *slirp) opt2->ndpopt_prefixinfo.reserved2 =3D 0; opt2->ndpopt_prefixinfo.prefix =3D slirp->vprefix_addr6; t->m_data +=3D NDPOPT_PREFIXINFO_LEN; + pl_size +=3D NDPOPT_PREFIXINFO_LEN; =20 #ifndef _WIN32 /* Prefix information (NDP option) */ @@ -203,16 +199,14 @@ void ndp_send_ra(Slirp *slirp) opt3->ndpopt_rdnss.lifetime =3D htonl(2 * NDP_MaxRtrAdvInterval); opt3->ndpopt_rdnss.addr =3D slirp->vnameserver_addr6; t->m_data +=3D NDPOPT_RDNSS_LEN; + pl_size +=3D NDPOPT_RDNSS_LEN; #endif =20 + rip->ip_pl =3D htons(pl_size); + t->m_data -=3D sizeof(struct ip6) + pl_size; + t->m_len =3D sizeof(struct ip6) + pl_size; + /* ICMPv6 Checksum */ -#ifndef _WIN32 - t->m_data -=3D NDPOPT_RDNSS_LEN; -#endif - t->m_data -=3D NDPOPT_PREFIXINFO_LEN; - t->m_data -=3D NDPOPT_LINKLAYER_LEN; - t->m_data -=3D ICMP6_NDP_RA_MINLEN; - t->m_data -=3D sizeof(struct ip6); ricmp->icmp6_cksum =3D ip6_cksum(t); =20 ip6_output(NULL, t, 0); --=20 2.11.0 From nobody Fri May 3 06:22:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490741709147345.220999409256; Tue, 28 Mar 2017 15:55:09 -0700 (PDT) Received: from localhost ([::1]:55575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ct015-0001MK-9M for importer@patchew.org; Tue, 28 Mar 2017 18:55:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cszzZ-0000Pu-UO for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cszzY-0000Hj-SL for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:34 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:53288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cszzY-0000HU-MP for qemu-devel@nongnu.org; Tue, 28 Mar 2017 18:53:32 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id D1011BE83; Wed, 29 Mar 2017 00:53:31 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fo0ZadQZYbTS; Wed, 29 Mar 2017 00:53:29 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id ED5E5AC40; Wed, 29 Mar 2017 00:53:28 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.88) (envelope-from ) id 1cszzU-0004My-79; Wed, 29 Mar 2017 00:53:28 +0200 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Wed, 29 Mar 2017 00:53:27 +0200 Message-Id: <20170328225327.16707-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328225327.16707-1-samuel.thibault@ens-lyon.org> References: <20170328225327.16707-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PULL 3/3] slirp: Send RDNSS in RA only if host has an IPv6 DNS server X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Previously we would always send an RDNSS option in the RA, making the guest try to resolve DNS through IPv6, even if the host does not actually have and IPv6 DNS server available. This makes the RDNSS option enabled only when an IPv6 DNS server is available. Signed-off-by: Samuel Thibault Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- slirp/ip6_icmp.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c index d0f5cc1456..777eb574be 100644 --- a/slirp/ip6_icmp.c +++ b/slirp/ip6_icmp.c @@ -144,6 +144,9 @@ void ndp_send_ra(Slirp *slirp) struct mbuf *t =3D m_get(slirp); struct ip6 *rip =3D mtod(t, struct ip6 *); size_t pl_size =3D 0; + struct in6_addr addr; + uint32_t scope_id; + rip->ip_src =3D (struct in6_addr)LINKLOCAL_ADDR; rip->ip_dst =3D (struct in6_addr)ALLNODES_MULTICAST; rip->ip_nh =3D IPPROTO_ICMPV6; @@ -189,18 +192,18 @@ void ndp_send_ra(Slirp *slirp) t->m_data +=3D NDPOPT_PREFIXINFO_LEN; pl_size +=3D NDPOPT_PREFIXINFO_LEN; =20 -#ifndef _WIN32 /* Prefix information (NDP option) */ - /* disabled for windows for now, until get_dns6_addr is implemented */ - struct ndpopt *opt3 =3D mtod(t, struct ndpopt *); - opt3->ndpopt_type =3D NDPOPT_RDNSS; - opt3->ndpopt_len =3D NDPOPT_RDNSS_LEN / 8; - opt3->ndpopt_rdnss.reserved =3D 0; - opt3->ndpopt_rdnss.lifetime =3D htonl(2 * NDP_MaxRtrAdvInterval); - opt3->ndpopt_rdnss.addr =3D slirp->vnameserver_addr6; - t->m_data +=3D NDPOPT_RDNSS_LEN; - pl_size +=3D NDPOPT_RDNSS_LEN; -#endif + if (get_dns6_addr(&addr, &scope_id) >=3D 0) { + /* Host system does have an IPv6 DNS server, announce our proxy. = */ + struct ndpopt *opt3 =3D mtod(t, struct ndpopt *); + opt3->ndpopt_type =3D NDPOPT_RDNSS; + opt3->ndpopt_len =3D NDPOPT_RDNSS_LEN / 8; + opt3->ndpopt_rdnss.reserved =3D 0; + opt3->ndpopt_rdnss.lifetime =3D htonl(2 * NDP_MaxRtrAdvInterval); + opt3->ndpopt_rdnss.addr =3D slirp->vnameserver_addr6; + t->m_data +=3D NDPOPT_RDNSS_LEN; + pl_size +=3D NDPOPT_RDNSS_LEN; + } =20 rip->ip_pl =3D htons(pl_size); t->m_data -=3D sizeof(struct ip6) + pl_size; --=20 2.11.0