From: Christian Perle <chris@linuxinfotag.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Solution for qemu mcast / ipv6?
Date: Tue, 10 Mar 2009 16:50:33 +0100 [thread overview]
Message-ID: <20090310155033.GB8323@silmor.de> (raw)
Hello there,
We are using qemu's multicast networking feature (-net socket,mcast=...) to
connect some qemu instances (running linux guests) to each other. Qemu's
multicast networking code sets socket option IP_MULTICAST_LOOP to make
communication between local qemu instances possible. So each qemu gets
all the traffic, including its own.
This works fine as long as no ipv6 is used. Because ipv6 has a built-in
duplicate address detection (DAD) and each qemu instance sees its own
traffic, DAD will always detect a ipv6 address collision although there
is none.
Our solution is to patch the function qemu_send_packet() so it drops
packets from source mac address X if the network interface the packet
is being sent to has the same mac address X.
The patch adds a new member "macaddress" to the VLANClientState struct
which is filled by qemu_format_nic_info_str() during interface
initialization. An additional check in qemu_send_packet() decides if
the packet must be dropped.
----------------------------------------------------------------------
diff -ru qemu-0.10.0.orig/net.c qemu-0.10.0/net.c
--- qemu-0.10.0.orig/net.c 2009-03-04 23:54:45.000000000 +0100
+++ qemu-0.10.0/net.c 2009-03-06 16:38:09.000000000 +0100
@@ -303,6 +303,13 @@
vc->model,
macaddr[0], macaddr[1], macaddr[2],
macaddr[3], macaddr[4], macaddr[5]);
+ /* copy mac address into struct for quick matching */
+ vc->macaddress[0] = macaddr[0];
+ vc->macaddress[1] = macaddr[1];
+ vc->macaddress[2] = macaddr[2];
+ vc->macaddress[3] = macaddr[3];
+ vc->macaddress[4] = macaddr[4];
+ vc->macaddress[5] = macaddr[5];
}
static char *assign_name(VLANClientState *vc1, const char *model)
@@ -407,6 +414,19 @@
#endif
for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
if (vc != vc1 && !vc->link_down) {
+ /*
+ * Workaround for IPv6 DAD problem
+ * note: this assumes offset 6 for src mac
+ */
+ if (size >= 12) {
+ if (0 == memcmp(buf+6, &(vc->macaddress),
+ sizeof(vc->macaddress))) {
+#ifdef DEBUG_NET
+ printf("ignore own packet for %s\n", vc->info_str);
+#endif
+ continue;
+ }
+ }
vc->fd_read(vc->opaque, buf, size);
}
}
diff -ru qemu-0.10.0.orig/net.h qemu-0.10.0/net.h
--- qemu-0.10.0.orig/net.h 2009-03-04 23:54:45.000000000 +0100
+++ qemu-0.10.0/net.h 2009-03-06 16:06:04.000000000 +0100
@@ -24,6 +24,8 @@
struct VLANState *vlan;
char *model;
char *name;
+ /* mac address in binary format for quick matching */
+ uint8_t macaddress[6];
char info_str[256];
};
----------------------------------------------------------------------
Now the question: Is this a proper solution? Does it break anything?
So far we haven't seen any regression. It would be nice to have
this in standard qemu, maybe as a configurable option.
Greetings,
Chris
--
Christian Perle chris AT linuxinfotag.de
010111 http://chris.silmor.de/
101010 LinuxGuitarKitesBicyclesBeerPizzaRaytracing
next reply other threads:[~2009-03-10 15:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-10 15:50 Christian Perle [this message]
2009-03-10 16:11 ` [Qemu-devel] Solution for qemu mcast / ipv6? Paul Brook
2009-03-10 20:30 ` Christian Perle
2009-03-10 23:16 ` Paul Brook
2009-03-10 23:55 ` Jamie Lokier
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=20090310155033.GB8323@silmor.de \
--to=chris@linuxinfotag.de \
--cc=qemu-devel@nongnu.org \
/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).