From patchwork Fri Nov 8 16:40:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 289890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E3C302C00AC for ; Sat, 9 Nov 2013 03:42:45 +1100 (EST) Received: from localhost ([::1]:46787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vep8u-0007HX-4e for incoming@patchwork.ozlabs.org; Fri, 08 Nov 2013 11:42:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vep8a-00077t-7T for qemu-devel@nongnu.org; Fri, 08 Nov 2013 11:42:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vep8U-0004Rx-99 for qemu-devel@nongnu.org; Fri, 08 Nov 2013 11:42:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vep8U-0004Rk-0v for qemu-devel@nongnu.org; Fri, 08 Nov 2013 11:42:18 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA8GeFjm024519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Nov 2013 11:40:15 -0500 Received: from localhost (ovpn-112-22.ams2.redhat.com [10.36.112.22]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rA8Ge8YW009853; Fri, 8 Nov 2013 11:40:08 -0500 From: Stefan Hajnoczi To: Date: Fri, 8 Nov 2013 17:40:02 +0100 Message-Id: <1383928804-28866-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1383928804-28866-1-git-send-email-stefanha@redhat.com> References: <1383928804-28866-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , Dmitry Krivenok , Anthony Liguori Subject: [Qemu-devel] [PULL 1/3] net: disallow to specify multicast MAC address 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Dmitry Krivenok [Assigning a multicast MAC address to a NIC leads to confusing behavior. Reject multicast MAC addresses so users are alerted to their error straight away. The "net/eth.h" in6_addr rename prevents a name collision with on Linux. -- Stefan] Signed-off-by: Dmitry V. Krivenok Reviewed-by: Amos Kong Signed-off-by: Stefan Hajnoczi --- include/net/eth.h | 6 +++--- net/net.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/net/eth.h b/include/net/eth.h index 1d48e06..b3273b8 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -84,7 +84,7 @@ typedef struct ip_pseudo_header { } ip_pseudo_header; /* IPv6 address */ -struct in6_addr { +struct in6_address { union { uint8_t __u6_addr8[16]; } __in6_u; @@ -105,8 +105,8 @@ struct ip6_header { uint8_t ip6_un3_ecn; /* 2 bits ECN, top 6 bits payload length */ } ip6_un3; } ip6_ctlun; - struct in6_addr ip6_src; /* source address */ - struct in6_addr ip6_dst; /* destination address */ + struct in6_address ip6_src; /* source address */ + struct in6_address ip6_dst; /* destination address */ }; struct ip6_ext_hdr { diff --git a/net/net.c b/net/net.c index c330c9a..870d3bb 100644 --- a/net/net.c +++ b/net/net.c @@ -27,6 +27,7 @@ #include "clients.h" #include "hub.h" #include "net/slirp.h" +#include "net/eth.h" #include "util.h" #include "monitor/monitor.h" @@ -689,6 +690,11 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, error_report("invalid syntax for ethernet address"); return -1; } + if (nic->has_macaddr && + is_multicast_ether_addr(nd->macaddr.a)) { + error_report("NIC cannot have multicast MAC address (odd 1st byte)"); + return -1; + } qemu_macaddr_default_if_unset(&nd->macaddr); if (nic->has_vectors) {