socket,mcast looping back frames -> IPv6 broken
Hello,
The reason why IPv6 does not work when using -net socket,mcast=foo is that since qemu explicitly sets IP_MULTICAST_LOOP to 1, it receives its own frames. When the IPv6 stack performs duplicate addresse detection (DAD) through a multicasted announce, it receives its own announcement, and thus believes another machine has the same address.
AIUI, on a real physical network network boards do not receive the multicasts they send, so the issue does not happen. Perhaps some boards even filter out any frame with its own MAC as source, eliminating the issue altogether.
As a result, we should probably perform this kind of dropping, I'm just wondering at which level that would be preferable.
- We could do that in qemu_send_packet_async_with_flags, thus fixing the issue for all kinds of frame transporters.
- Or we could do that for the only case that matters, mcast, in net_socket_send_dgram (which will thus do it for the unicast udp case too).
What do people think about it?
Samuel
Quoted 5 lines · Samuel Thibault
The reason why IPv6 does not work when using -net socket,mcast=foo is that since qemu explicitly sets
IP_MULTICAST_LOOPto 1, it receives its own frames. When the IPv6 stack performs duplicate addresse detection (DAD) through a multicasted announce, it receives its own announcement, and thus believes another machine has the same address.
The reason for IP_MULTICAST_LOOP is to allow QEMU processes running on the same host to communicate with each other.
Quoted 8 lines
AIUI, on a real physical network network boards do not receive the multicasts they send, so the issue does not happen. Perhaps some boards even filter out any frame with its own MAC as source, eliminating the issue altogether.
As a result, we should probably perform this kind of dropping, I'm just wondering at which level that would be preferable.
Quoted 8 lines
- We could do that in
qemu_send_packet_async_with_flags, thus fixing the issue for all kinds of frame transporters.- Or we could do that for the only case that matters, mcast, in
net_socket_send_dgram(which will thus do it for the unicast udp case too).What do people think about it?
We should fix the layer that introduces the problem. Therefore I think the fix needs to be net/socket.c.
Unfortunately net/socket.c does not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.
Are you aware of a way to filter out just the packets sent by *this* process?
Stefan
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 9 lines · Stefan Hajnoczi, le Wed 06 Mar 2013 13:29:37 +0100, a écrit :
Quoted 5 lines · Samuel Thibault
The reason why IPv6 does not work when using -net socket,mcast=foo is that since qemu explicitly sets
IP_MULTICAST_LOOPto 1, it receives its own frames. When the IPv6 stack performs duplicate addresse detection (DAD) through a multicasted announce, it receives its own announcement, and thus believes another machine has the same address.The reason for
IP_MULTICAST_LOOPis to allow QEMU processes running on the same host to communicate with each other.
Sure, I've seen the comment, I wasn't suggesting to drop that :)
Quoted 11 lines
Quoted 11 lines
AIUI, on a real physical network network boards do not receive the multicasts they send, so the issue does not happen. Perhaps some boards even filter out any frame with its own MAC as source, eliminating the issue altogether.
As a result, we should probably perform this kind of dropping, I'm just wondering at which level that would be preferable.
- We could do that in
qemu_send_packet_async_with_flags, thus fixing the issue for all kinds of frame transporters.
Quoted 8 lines
Quoted 5 lines
- Or we could do that for the only case that matters, mcast, in
net_socket_send_dgram(which will thus do it for the unicast udp case too).What do people think about it?
We should fix the layer that introduces the problem. Therefore I think the fix needs to be
net/socket.c.
Ok.
Quoted 6 lines
Unfortunately
net/socket.cdoes not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.Are you aware of a way to filter out just the packets sent by *this* process?
I haven't seen any in the Linux source code. One thing that should work, however, is to use recvfrom, and drop whatever comes from our sockname.
Samuel
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 6 lines · Samuel Thibault
Quoted 5 lines · Stefan Hajnoczi, le Wed 06 Mar 2013 13:29:37 +0100, a écrit :
On Tue, Mar 05, 2013 at 05:35:10PM +0100, Samuel Thibault wrote:
Unfortunatelynet/socket.cdoes not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.
Quoted 6 lines
Quoted 2 lines
Are you aware of a way to filter out just the packets sent by *this* process?
I haven't seen any in the Linux source code. One thing that should work, however, is to use recvfrom, and drop whatever comes from our sockname.
Sounds like a plan :).
Stefan
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 7 lines · Stefan Hajnoczi, le Thu 07 Mar 2013 10:38:26 +0100, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 5 lines · Stefan Hajnoczi, le Wed 06 Mar 2013 13:29:37 +0100, a écrit :
On Tue, Mar 05, 2013 at 05:35:10PM +0100, Samuel Thibault wrote:
Unfortunatelynet/socket.cdoes not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Are you aware of a way to filter out just the packets sent by *this* process?
I haven't seen any in the Linux source code. One thing that should work, however, is to use recvfrom, and drop whatever comes from our sockname.
Sounds like a plan :).
Except that the sockname is the multicast address itself... I'll have a closer look.
Samuel
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 11 lines · Samuel Thibault
Quoted 10 lines · Stefan Hajnoczi, le Thu 07 Mar 2013 10:38:26 +0100, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 7 lines · Stefan Hajnoczi, le Wed 06 Mar 2013 13:29:37 +0100, a écrit :
On Tue, Mar 05, 2013 at 05:35:10PM +0100, Samuel Thibault wrote:
Unfortunatelynet/socket.cdoes not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.Are you aware of a way to filter out just the packets sent by *this* process?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I haven't seen any in the Linux source code. One thing that should work, however, is to use recvfrom, and drop whatever comes from our sockname.
Sounds like a plan :).
Except that the sockname is the multicast address itself... I'll have a closer look.
What about the port number?
Stefan
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 16 lines · Stefan Hajnoczi, le Fri 08 Mar 2013 09:43:18 +0100, a écrit :
Quoted 15 lines · Samuel Thibault
Quoted 14 lines · Stefan Hajnoczi, le Thu 07 Mar 2013 10:38:26 +0100, a écrit :
Quoted 12 lines · Samuel Thibault
Quoted 7 lines · Stefan Hajnoczi, le Wed 06 Mar 2013 13:29:37 +0100, a écrit :
On Tue, Mar 05, 2013 at 05:35:10PM +0100, Samuel Thibault wrote:
Unfortunatelynet/socket.cdoes not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.Are you aware of a way to filter out just the packets sent by *this* process?
I haven't seen any in the Linux source code. One thing that should work, however, is to use recvfrom, and drop whatever comes from our sockname.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Sounds like a plan :).
Except that the sockname is the multicast address itself... I'll have a closer look.
What about the port number?
It needs to be the same.
There does exist some unique address, which is returned by recvfrom, I'll have a look at how to get access to it.
Samuel
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 2 lines · Samuel Thibault, le Fri 08 Mar 2013 10:08:55 +0100, a écrit :
There does exist some unique address, which is returned by recvfrom, I'll have a look at how to get access to it.
Ah, no, it's not unique... It's just the host IP address and the same port as the multicast address, so it'll be the same for all qemus on the same host. I've checked how Linux bounces the datagram, it's through the loopback interface, and thus dispatched over all listeners without distinction. I don't see any way to get the information that the packet comes from us, except using the ethernet content.
Samuel
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
In reply to Stefan HajnocziQuoted 11 lines · Stefan Hajnoczi, le Wed 06 Mar 2013 13:29:37 +0100, a écrit :
Quoted 1 line
What do people think about it?
We should fix the layer that introduces the problem. Therefore I think the fix needs to be
net/socket.c.Unfortunately
net/socket.cdoes not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.Are you aware of a way to filter out just the packets sent by *this* process?
So in the end I couldn't find any way (even Linuxish) to distinguish packets coming from self or from other qemus running on the same host, event with recvmsg etc.
So, it seems if we want to fix the issue we'll have to filter by source MAC address. Since the guest can actually change its own MACs, we'd have to learn them on the fly. We can also implement some aging on the entries in case the user migrates a MAC from a VM to another.
Otherwise we may just document that one has to disable Duplicate Address Detection to get IPv6 working :/
Samuel
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 13 lines · Samuel Thibault
Quoted 11 lines · Stefan Hajnoczi, le Wed 06 Mar 2013 13:29:37 +0100, a écrit :
Quoted 1 line
What do people think about it?
We should fix the layer that introduces the problem. Therefore I think the fix needs to be
net/socket.c.Unfortunately
net/socket.cdoes not have the concept of a link-layer address, so we cannot easily filter out multicast packets coming from our NIC's address.Are you aware of a way to filter out just the packets sent by *this* process?
Quoted 8 lines
So in the end I couldn't find any way (even Linuxish) to distinguish packets coming from self or from other qemus running on the same host, event with recvmsg etc.
So, it seems if we want to fix the issue we'll have to filter by source MAC address. Since the guest can actually change its own MACs, we'd have to learn them on the fly. We can also implement some aging on the entries in case the user migrates a MAC from a VM to another.
Yes, the guest may use multiple MACs at the same time (e.g. nested virtualization).
Quoted 2 lines
Otherwise we may just document that one has to disable Duplicate Address Detection to get IPv6 working :/
Seems like this might be the only way for now.
Stefan
PATCH 1/1 Document mcast+ipv6 (Was: Re: socket, mcast looping back frames -> IPv6 broken)
Quoted 4 lines · Stefan Hajnoczi, le Mon 11 Mar 2013 09:36:14 +0100, a écrit :
Quoted 2 lines
Otherwise we may just document that one has to disable Duplicate Address Detection to get IPv6 working :/
Seems like this might be the only way for now.
Here is a patch
Samuel
Document how to get IPv6 working with mcast socket
Document that IPv6 can not work in mcast mode unless disabling DAD in the guest.
qemu-options.hx +6 -0
@@ -1683,6 +1683,12 @@ mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mc @url{http://user-mode-linux.sf.net}. @item Use @option{fd=h} to specify an already opened UDP multicast socket. +@item +Since with multicast diffusion the guest will receive its own frames, its IPv6 +Duplicate Address Detection (DAD) will erroneously detect a duplicate, thus +preventing IPv6 from working. One has to disable DAD to get IPv6 working, for +instance on Linux by setting the sysctl @code{net.ipv6.conf.all.accept_dad} to +0. @end enumerate Example:
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
In reply to Samuel ThibaultQuoted 9 lines · Samuel Thibault
Quoted 2 lines · Samuel Thibault, le Fri 08 Mar 2013 10:08:55 +0100, a écrit :
There does exist some unique address, which is returned by recvfrom, I'll have a look at how to get access to it.
Ah, no, it's not unique... It's just the host IP address and the same port as the multicast address, so it'll be the same for all qemus on the same host. I've checked how Linux bounces the datagram, it's through the loopback interface, and thus dispatched over all listeners without distinction. I don't see any way to get the information that the packet comes from us, except using the ethernet content.
this is actually a problem that i dealt with when i was building the switched multicast backend i did last year. ( http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg04082.html )
one solution is to actually use two sockets. one that is bound to the multicast address, which receives the multicast packets, and another that is just bound to any ephemeral udp port, which is used for sending packets. when a packet is to be sent out to the multicast address, call sendto on the ephemeral socket with a destination of the multicast address. then, using recv_from on the multicast socket, packets being received can be compared to the local ephemeral address. if the address on the recv_from matches the address for the local ephemeral socket, the packet can just be dropped. no inspection of the packet being passed around is needed in this case.
if the group is interested is a solution like this, i can probably make some time over the next couple days to cook up a patch. thoughts?
mike
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 11 lines · Mike Lovell, le Mon 01 Apr 2013 00:35:03 -0600, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 2 lines · Samuel Thibault, le Fri 08 Mar 2013 10:08:55 +0100, a écrit :
There does exist some unique address, which is returned by recvfrom, I'll have a look at how to get access to it.
Ah, no, it's not unique... It's just the host IP address and the same port as the multicast address, so it'll be the same for all qemus on the same host. I've checked how Linux bounces the datagram, it's through the loopback interface, and thus dispatched over all listeners without distinction. I don't see any way to get the information that the packet comes from us, except using the ethernet content.
Quoted 3 lines
one solution is to actually use two sockets. one that is bound to the multicast address, which receives the multicast packets, and another that is just bound to any ephemeral udp port, which is used for sending packets.
Mmm, that should work indeed.
Quoted 2 lines
if the group is interested is a solution like this, i can probably make some time over the next couple days to cook up a patch. thoughts?
Yes, please.
Samuel
Re: [Qemu-devel] [PER] Re: socket, mcast looping back frames -> IPv6 broken
Quoted 16 lines · Samuel Thibault
Quoted 11 lines · Mike Lovell, le Mon 01 Apr 2013 00:35:03 -0600, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 2 lines · Samuel Thibault, le Fri 08 Mar 2013 10:08:55 +0100, a écrit :
There does exist some unique address, which is returned by recvfrom, I'll have a look at how to get access to it.
Ah, no, it's not unique... It's just the host IP address and the same port as the multicast address, so it'll be the same for all qemus on the same host. I've checked how Linux bounces the datagram, it's through the loopback interface, and thus dispatched over all listeners without distinction. I don't see any way to get the information that the packet comes from us, except using the ethernet content.
Quoted 3 lines
one solution is to actually use two sockets. one that is bound to the multicast address, which receives the multicast packets, and another that is just bound to any ephemeral udp port, which is used for sending packets.
Quoted 6 lines
Mmm, that should work indeed.
Quoted 2 lines
if the group is interested is a solution like this, i can probably make some time over the next couple days to cook up a patch. thoughts?
Yes, please.
Yeah, great. It's a real problem that people are hitting so it would be worth fixing.
Stefan
Re: [Qemu-devel] [PATCH] Document mcast+ipv6 (Was: Re: socket, mcast looping back frames -> IPv6 broken)
In reply to Samuel ThibaultQuoted 7 lines · Samuel Thibault
Quoted 4 lines · Stefan Hajnoczi, le Mon 11 Mar 2013 09:36:14 +0100, a écrit :
Quoted 2 lines
Otherwise we may just document that one has to disable Duplicate Address Detection to get IPv6 working :/
Seems like this might be the only way for now.
Here is a patch
Let's check out the 2 socket patch first. If that doesn't work out I'll merge the documentation warning.
Stefan
Re: [Qemu-devel] [PATCH] Document mcast+ipv6 (Was: Re: socket, mcast looping back frames -> IPv6 broken)
Quoted 11 lines · Stefan Hajnoczi, le Mon 08 Apr 2013 13:13:19 +0200, a écrit :
Quoted 7 lines · Samuel Thibault
Quoted 4 lines · Stefan Hajnoczi, le Mon 11 Mar 2013 09:36:14 +0100, a écrit :
Quoted 2 lines
Otherwise we may just document that one has to disable Duplicate Address Detection to get IPv6 working :/
Seems like this might be the only way for now.
Here is a patch
Let's check out the 2 socket patch first. If that doesn't work out I'll merge the documentation warning.
Sure.
Samuel