From patchwork Mon Jan 8 17:28:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 856951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="L+QYo2mJ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zFj6p69Rxz9s74 for ; Tue, 9 Jan 2018 04:33:38 +1100 (AEDT) Received: from localhost ([::1]:46992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYbIm-0002M6-PK for incoming@patchwork.ozlabs.org; Mon, 08 Jan 2018 12:33:36 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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_ADDR_MULTICAST' #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) ^ Reported-by: John Arbuckle Signed-off-by: Philippe Mathieu-Daudé --- 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)) +static inline bool in6_multicast(const struct in6_addr *a) +{ + return a->s6_addr[0] == 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 = %d, code = %d\n", type, code)); - 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, struct icmp6 *icmp) /* NDP */ ricmp->icmp6_nna.R = NDP_IsRouter; - ricmp->icmp6_nna.S = !IN6_IS_ADDR_MULTICAST(&rip->ip_dst); + ricmp->icmp6_nna.S = !in6_multicast(&rip->ip_dst); ricmp->icmp6_nna.O = 1; ricmp->icmp6_nna.reserved_hi = 0; ricmp->icmp6_nna.reserved_lo = 0; @@ -348,7 +348,7 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct ip6 *ip, DEBUG_CALL(" type = Neighbor Solicitation"); if (ip->ip_hl == 255 && icmp->icmp6_code == 0 - && !IN6_IS_ADDR_MULTICAST(&icmp->icmp6_nns.target) + && !in6_multicast(&icmp->icmp6_nns.target) && ntohs(ip->ip_pl) >= 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, struct ip6 *ip, if (ip->ip_hl == 255 && icmp->icmp6_code == 0 && ntohs(ip->ip_pl) >= 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 == 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])); - 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 address"); return; @@ -63,7 +63,7 @@ bool ndp_table_search(Slirp *slirp, struct in6_addr ip_addr, assert(!in6_zero(&ip_addr)); /* 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] = 0x33; out_ethaddr[1] = 0x33; out_ethaddr[2] = ip_addr.s6_addr[12]; out_ethaddr[3] = ip_addr.s6_addr[13];