qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL 4/4] net: disallow to specify multicast MAC addre


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PULL 4/4] net: disallow to specify multicast MAC address
Date: Fri, 18 Oct 2013 18:41:41 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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 <address@hidden>
> > 
> > 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 <address@hidden>
> > Signed-off-by: Stefan Hajnoczi <address@hidden>
> > ---
> >  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;
> > +}

Scratch what I said about bit 0 and bit 1, this function is using '%' not
'&'.

But we should still respin to use the existing function in eth.h.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]