From nobody Tue Oct 28 12:14:06 2025 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.zohomail.com; dkim=fail; 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 1515432894435156.31677100186766; Mon, 8 Jan 2018 09:34:54 -0800 (PST) Received: from localhost ([::1]:46996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYbK1-0003ec-Ik for importer@patchew.org; Mon, 08 Jan 2018 12:34:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYbEj-00088L-Q4 for qemu-devel@nongnu.org; Mon, 08 Jan 2018 12:29:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYbEi-00006s-MR for qemu-devel@nongnu.org; Mon, 08 Jan 2018 12:29:25 -0500 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:45163) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eYbEi-00006O-HV for qemu-devel@nongnu.org; Mon, 08 Jan 2018 12:29:24 -0500 Received: by mail-qt0-x241.google.com with SMTP id g10so14518174qtj.12 for ; Mon, 08 Jan 2018 09:29:24 -0800 (PST) Received: from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id j127sm787922qkd.88.2018.01.08.09.29.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jan 2018 09:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6VekvQluN2/YEmicRBuoEFHj4BFLqNTFprISPH+UcQ4=; b=L+QYo2mJnwUb0GCjYTL7rAYxY6TpOBC1xsQUKA2dl8CHkXhbIEl67OkSNlojRXfTnF c2IRXGM1VobVVjEkCeZL+9qeqVUw1iSSHoFPpbDIXmXTr4d4CXkIEKJCQwd8aGcAr/hq jcBcFTrFstSJQzXnJ8KeoiqYzdNyzG1D0ax+4Yy/9Lu2yiWY8pKVaMpqLXSM3AyZMCfl 3qtjyYHv238hUyWNLHtr5zesIWBDA7HkVgzBFcLP1UGQSdjcQ9T4bNBFLNOpD8PC5KS8 Ehl40l7w0zt6n57pOXAAxfG4EL7wsL+AktgkOyPaab7WpHtMVpe6hzztFFTZcqlGAEM0 k6BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=6VekvQluN2/YEmicRBuoEFHj4BFLqNTFprISPH+UcQ4=; b=oAuvCa71a/s/ySMeBmURvYBKV74u5vWah7XY9kxzZwoWR8o0xYA8/mjeIXZ5GEG6x5 bY81qRZGUzYspHQo1xLJO8hOr288GkAg4LCygM355z/1qFjJG3g0YJIHoXMggqhkRx9/ d+OHczJWqMHV3IfajeCr+j2SEGEsCs2NFxUd2/Co3D15NPsBFBjCpNvpLklLQRlrkrIp qazW81h5tFw2i4tLBjkg6OFCe4Hp5nMKCZMkNXrHD1zp1caT77ZrWekwDCxakfhCfYeu rCKsTQPWRZnNl+Mu9BIF7iK1MchxGwQZjkkNIMkdcZOv3M7YzJsrDhfWB7aPQ2l6Whfl hU3Q== X-Gm-Message-State: AKwxytfcnuLgxunMpbMM+yPj+TU+Pq1vnaJBE9JCOzyKYi25Zl86X0kS byRlBTO5NBz9oVT08WH3rGA= X-Google-Smtp-Source: ACJfBoujvVShwJq2KXPCbdmzYYXJXeiNnLjkJv3eZkOVXewggnEUxG7TG8o1JBuW/DlcQmPznP8rmw== X-Received: by 10.200.44.111 with SMTP id e44mr17648434qta.183.1515432563929; Mon, 08 Jan 2018 09:29:23 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Samuel Thibault , Jan Kiszka , "Michael S . Tsirkin" , Paolo Bonzini , Eric Blake , Thomas Huth Date: Mon, 8 Jan 2018 14:28:56 -0300 Message-Id: <20180108172904.8772-5-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180108172904.8772-1-f4bug@amsat.org> References: <20180108172904.8772-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH 04/12] slirp: add in6_multicast() and use it instead of IN6_IS_ADDR_MULTICAST() 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Host: Mac OS 10.12.5 Compiler: Apple LLVM version 8.1.0 (clang-802.0.42) slirp/ip6_icmp.c:79:32: warning: taking address of packed member 'ip_src'= of class or structure 'ip6' may result in an unaligned pointer value [-Waddress-of-packed-member] if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) || ^~~~~~~~~~ /usr/include/netinet6/in6.h:299:36: note: expanded from macro 'IN6_IS_ADD= R_MULTICAST' #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] =3D=3D 0xff) ^ Reported-by: John Arbuckle Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- slirp/ip6.h | 5 +++++ slirp/ip6_icmp.c | 10 +++++----- slirp/ndp_table.c | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/slirp/ip6.h b/slirp/ip6.h index b1bea43b3c..6c5d4eeaa3 100644 --- a/slirp/ip6.h +++ b/slirp/ip6.h @@ -93,6 +93,11 @@ static inline bool in6_equal_mach(const struct in6_addr = *a, #define in6_zero(a)\ (in6_equal(a, &(struct in6_addr)ZERO_ADDR)) =20 +static inline bool in6_multicast(const struct in6_addr *a) +{ + return a->s6_addr[0] =3D=3D 0xff; +} + /* Compute emulated host MAC address from its ipv6 address */ static inline void in6_compute_ethaddr(struct in6_addr ip, uint8_t eth[ETH_ALEN]) diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c index ee333d05a2..9796624648 100644 --- a/slirp/ip6_icmp.c +++ b/slirp/ip6_icmp.c @@ -76,7 +76,7 @@ void icmp6_send_error(struct mbuf *m, uint8_t type, uint8= _t code) DEBUG_CALL("icmp6_send_error"); DEBUG_ARGS((dfd, " type =3D %d, code =3D %d\n", type, code)); =20 - if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) || + if (in6_multicast(&ip->ip_src) || in6_zero(&ip->ip_src)) { /* TODO icmp error? */ return; @@ -291,7 +291,7 @@ static void ndp_send_na(Slirp *slirp, struct ip6 *ip, s= truct icmp6 *icmp) =20 /* NDP */ ricmp->icmp6_nna.R =3D NDP_IsRouter; - ricmp->icmp6_nna.S =3D !IN6_IS_ADDR_MULTICAST(&rip->ip_dst); + ricmp->icmp6_nna.S =3D !in6_multicast(&rip->ip_dst); ricmp->icmp6_nna.O =3D 1; ricmp->icmp6_nna.reserved_hi =3D 0; ricmp->icmp6_nna.reserved_lo =3D 0; @@ -348,7 +348,7 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, str= uct ip6 *ip, DEBUG_CALL(" type =3D Neighbor Solicitation"); if (ip->ip_hl =3D=3D 255 && icmp->icmp6_code =3D=3D 0 - && !IN6_IS_ADDR_MULTICAST(&icmp->icmp6_nns.target) + && !in6_multicast(&icmp->icmp6_nns.target) && ntohs(ip->ip_pl) >=3D ICMP6_NDP_NS_MINLEN && (!in6_zero(&ip->ip_src) || in6_solicitednode_multicast(&ip->ip_dst))) { @@ -365,8 +365,8 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, str= uct ip6 *ip, if (ip->ip_hl =3D=3D 255 && icmp->icmp6_code =3D=3D 0 && ntohs(ip->ip_pl) >=3D ICMP6_NDP_NA_MINLEN - && !IN6_IS_ADDR_MULTICAST(&icmp->icmp6_nna.target) - && (!IN6_IS_ADDR_MULTICAST(&ip->ip_dst) + && !in6_multicast(&icmp->icmp6_nna.target) + && (!in6_multicast(&ip->ip_dst) || icmp->icmp6_nna.S =3D=3D 0)) { ndp_table_add(slirp, ip->ip_src, eth->h_source); } diff --git a/slirp/ndp_table.c b/slirp/ndp_table.c index e1676a0a7b..5ff4bf2f3d 100644 --- a/slirp/ndp_table.c +++ b/slirp/ndp_table.c @@ -23,7 +23,7 @@ void ndp_table_add(Slirp *slirp, struct in6_addr ip_addr, ethaddr[0], ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5])); =20 - if (IN6_IS_ADDR_MULTICAST(&ip_addr) || in6_zero(&ip_addr)) { + if (in6_multicast(&ip_addr) || in6_zero(&ip_addr)) { /* Do not register multicast or unspecified addresses */ DEBUG_CALL(" abort: do not register multicast or unspecified addre= ss"); return; @@ -63,7 +63,7 @@ bool ndp_table_search(Slirp *slirp, struct in6_addr ip_ad= dr, assert(!in6_zero(&ip_addr)); =20 /* Multicast address: fec0::abcd:efgh/8 -> 33:33:ab:cd:ef:gh */ - if (IN6_IS_ADDR_MULTICAST(&ip_addr)) { + if (in6_multicast(&ip_addr)) { out_ethaddr[0] =3D 0x33; out_ethaddr[1] =3D 0x33; out_ethaddr[2] =3D ip_addr.s6_addr[12]; out_ethaddr[3] =3D ip_addr.s6_addr[13]; --=20 2.15.1