net: disallow to specify multicast MAC address
[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 <netinet/in.h> on Linux. -- Stefan] Signed-off-by: Dmitry V. Krivenok <krivenok.dmitry@gmail.com> Reviewed-by: Amos Kong <kongjianjun@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
964668b03d
commit
d60b20cf2a
@ -84,7 +84,7 @@ typedef struct ip_pseudo_header {
|
|||||||
} ip_pseudo_header;
|
} ip_pseudo_header;
|
||||||
|
|
||||||
/* IPv6 address */
|
/* IPv6 address */
|
||||||
struct in6_addr {
|
struct in6_address {
|
||||||
union {
|
union {
|
||||||
uint8_t __u6_addr8[16];
|
uint8_t __u6_addr8[16];
|
||||||
} __in6_u;
|
} __in6_u;
|
||||||
@ -105,8 +105,8 @@ struct ip6_header {
|
|||||||
uint8_t ip6_un3_ecn; /* 2 bits ECN, top 6 bits payload length */
|
uint8_t ip6_un3_ecn; /* 2 bits ECN, top 6 bits payload length */
|
||||||
} ip6_un3;
|
} ip6_un3;
|
||||||
} ip6_ctlun;
|
} ip6_ctlun;
|
||||||
struct in6_addr ip6_src; /* source address */
|
struct in6_address ip6_src; /* source address */
|
||||||
struct in6_addr ip6_dst; /* destination address */
|
struct in6_address ip6_dst; /* destination address */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ip6_ext_hdr {
|
struct ip6_ext_hdr {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "clients.h"
|
#include "clients.h"
|
||||||
#include "hub.h"
|
#include "hub.h"
|
||||||
#include "net/slirp.h"
|
#include "net/slirp.h"
|
||||||
|
#include "net/eth.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include "monitor/monitor.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");
|
error_report("invalid syntax for ethernet address");
|
||||||
return -1;
|
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);
|
qemu_macaddr_default_if_unset(&nd->macaddr);
|
||||||
|
|
||||||
if (nic->has_vectors) {
|
if (nic->has_vectors) {
|
||||||
|
Loading…
Reference in New Issue
Block a user