From: Dmitry Krivenok <krivenok.dmitry@gmail.com>
To: qemu-devel@nongnu.org, Anthony Liguori <aliguori@amazon.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH] net: disallow to specify multicast MAC address
Date: Thu, 17 Oct 2013 19:06:28 +0400 [thread overview]
Message-ID: <CAJN_NGZ_CosR42CkUiPMd56DW2x1P6gCUAroyib62Howy1OuFA@mail.gmail.com> (raw)
Added explicit check of MAC address specified via macaddr option.
Multicast MAC addresses are no longer allowed.
This fixes bug #495566.
Signed-off-by: Dmitry V. Krivenok <krivenok.dmitry@gmail.com>
---
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..b3a42e5 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..b86ac03 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) ? true : false;
+}
diff --git a/net/util.h b/net/util.h
index 10c7da9..4581cb7 100644
--- a/net/util.h
+++ b/net/util.h
@@ -26,7 +26,9 @@
#define QEMU_NET_UTIL_H
#include <stdint.h>
+#include <stdbool.h>
int net_parse_macaddr(uint8_t *macaddr, const char *p);
+bool net_macaddr_is_multicast(uint8_t *macaddr);
#endif /* QEMU_NET_UTIL_H */
--
1.8.3
next reply other threads:[~2013-10-17 15:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 15:06 Dmitry Krivenok [this message]
2013-10-17 15:19 ` [Qemu-devel] [PATCH] net: disallow to specify multicast MAC address Eric Blake
2013-10-17 18:44 ` Dmitry Krivenok
2013-10-18 11:25 ` Stefan Hajnoczi
2013-10-18 16:40 ` Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2013-10-17 11:07 Dmitry Krivenok
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJN_NGZ_CosR42CkUiPMd56DW2x1P6gCUAroyib62Howy1OuFA@mail.gmail.com \
--to=krivenok.dmitry@gmail.com \
--cc=aliguori@amazon.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).