Received: from eggs.gnu.org ([2001:4830:134:3::10]:52052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXD0W-0003af-FL for qemu-devel@nongnu.org; Fri, 18 Oct 2013 12:34:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXD0Q-000452-GB for qemu-devel@nongnu.org; Fri, 18 Oct 2013 12:34:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXD0Q-00044n-6h for qemu-devel@nongnu.org; Fri, 18 Oct 2013 12:34:30 -0400 Date: Fri, 18 Oct 2013 18:34:25 +0200 From: Stefan Hajnoczi Message-ID: <20131018163425.GA29516@stefanha-thinkpad.redhat.com> References: <1382103314-21608-1-git-send-email-stefanha@redhat.com> <1382103314-21608-5-git-send-email-stefanha@redhat.com> <20131018145655.GA22563@amosk.info> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131018145655.GA22563@amosk.info> Subject: Re: [Qemu-devel] [PULL 4/4] net: disallow to specify multicast MAC address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: qemu-devel@nongnu.org, Dmitry Krivenok , Anthony Liguori On Fri, Oct 18, 2013 at 10:56:55PM +0800, Amos Kong wrote: > On Fri, Oct 18, 2013 at 03:35:14PM +0200, Stefan Hajnoczi wrote: > > From: Dmitry Krivenok > > > > Added explicit check of MAC address specified via macaddr option. > > Multicast MAC addresses are no longer allowed. > > This fixes bug lp#495566. > > > > Signed-off-by: Dmitry V. Krivenok > > Signed-off-by: Stefan Hajnoczi > > --- > > net/net.c | 5 +++++ > > net/util.c | 5 +++++ > > net/util.h | 2 ++ > > 3 files changed, 12 insertions(+) > > > > diff --git a/net/net.c b/net/net.c > > index c330c9a..009dece 100644 > > --- a/net/net.c > > +++ b/net/net.c > > @@ -689,6 +689,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 && > > + net_macaddr_is_multicast(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) { > > diff --git a/net/util.c b/net/util.c > > index 7e95076..0177bb3 100644 > > --- a/net/util.c > > +++ b/net/util.c > > @@ -58,3 +58,8 @@ int net_parse_macaddr(uint8_t *macaddr, const char *p) > > > > return 0; > > } > > + > > +bool net_macaddr_is_multicast(uint8_t *macaddr) > > +{ > > + return macaddr[0] % 2; > > +} > > Duplicate, we already have is_multicast_ether_addr() in include/net/eth.h And net_macaddr_is_multicast() is wrong: bit 0 is the unicast/multicast bit, not bit 1. I will drop the patch and send a new pull request.