2015-04-08 16:42:13 +02:00
|
|
|
From 1a709119c593c74fb7db745030a0dda33e7dd18c Mon Sep 17 00:00:00 2001
|
2012-12-13 11:49:19 +01:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
|
|
|
Date: Wed, 12 Dec 2012 19:11:31 +0100
|
2015-03-21 12:46:36 +01:00
|
|
|
Subject: [PATCH] net: Warn about default MAC address
|
2012-12-13 11:49:19 +01:00
|
|
|
|
2015-03-21 12:46:36 +01:00
|
|
|
[AF: Suppress for QTest]
|
2012-12-13 11:49:19 +01:00
|
|
|
---
|
2015-03-21 12:46:36 +01:00
|
|
|
net/net.c | 24 ++++++++++++++++++++++++
|
|
|
|
1 file changed, 24 insertions(+)
|
2012-12-13 11:49:19 +01:00
|
|
|
|
2013-02-10 19:32:29 +01:00
|
|
|
diff --git a/net/net.c b/net/net.c
|
2015-03-21 12:46:36 +01:00
|
|
|
index 0be084d..552e233 100644
|
2013-02-10 19:32:29 +01:00
|
|
|
--- a/net/net.c
|
|
|
|
+++ b/net/net.c
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -42,6 +42,7 @@
|
|
|
|
#include "qapi/opts-visitor.h"
|
|
|
|
#include "qapi/dealloc-visitor.h"
|
|
|
|
#include "sysemu/sysemu.h"
|
|
|
|
+#include "sysemu/qtest.h"
|
|
|
|
|
|
|
|
/* Net bridge is currently not supported for W32. */
|
|
|
|
#if !defined(_WIN32)
|
|
|
|
@@ -160,6 +161,28 @@ void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6])
|
2012-12-13 11:49:19 +01:00
|
|
|
macaddr[3], macaddr[4], macaddr[5]);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void default_mac_check(void)
|
|
|
|
+{
|
|
|
|
+ static const MACAddr def_mac = { .a = { 0x52,0x54,0x00,0x12,0x34,0x56 } };
|
|
|
|
+ static int warned = 0;
|
|
|
|
+ int i;
|
|
|
|
+
|
2015-03-21 12:46:36 +01:00
|
|
|
+ for (i = 0; i < MAX_NICS; i++) {
|
|
|
|
+ if (!nd_table[i].used) {
|
2012-12-13 11:49:19 +01:00
|
|
|
+ continue;
|
2015-03-21 12:46:36 +01:00
|
|
|
+ }
|
|
|
|
+ if (memcmp(nd_table[i].macaddr.a, def_mac.a, 5)) {
|
2012-12-13 11:49:19 +01:00
|
|
|
+ continue;
|
2015-03-21 12:46:36 +01:00
|
|
|
+ }
|
2012-12-13 11:49:19 +01:00
|
|
|
+ if (nd_table[i].macaddr.a[5] >= 0x56 &&
|
2015-03-21 12:46:36 +01:00
|
|
|
+ nd_table[i].macaddr.a[5] < 0x56 + MAX_NICS && !warned && !qtest_enabled()) {
|
2012-12-13 11:49:19 +01:00
|
|
|
+ warned = 1;
|
|
|
|
+ fprintf(stderr, "Warning: default mac address being used, creating "
|
|
|
|
+ "potential for address conflict\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void qemu_macaddr_default_if_unset(MACAddr *macaddr)
|
|
|
|
{
|
|
|
|
static int index = 0;
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1313,6 +1336,7 @@ int net_init_clients(void)
|
2012-12-13 11:49:19 +01:00
|
|
|
if (qemu_opts_foreach(net, net_init_client, NULL, 1) == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
+ default_mac_check();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|