net: fix qemu_announce_self not emitting packets
PATCH v2 1/1 net: fix qemu_announce_self not emitting packets
commit fefe2a78 accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with the VIRTIO_NET_F_GUEST_ANNOUNCE feature.
---v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]
net/net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/net.c +9 -1
@@ -714,6 +714,11 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,NetClientState *nc = opaque;int ret; +/* we currently only support sending raw packets via qemu_send_packet_raw. +* If we want generic raw iov support we need to implement something like +* .receive_raw_iov in NetClientInfo first. */ +assert (!(flags &QEMU_NET_PACKET_FLAG_RAW ) || iovcnt ==1 ); +if (nc->link_down) {return iov_size (iov, iovcnt); }
@@ -722,7 +727,10 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,return 0 ; } -if (nc->info->receive_iov) { +if (flags &QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { +/* this is required for qemu_announce_self() */ + ret = nc->info->receive_raw (nc, iov[0 ].iov_base, iov[0 ].iov_len); + }else if (nc->info->receive_iov) { ret = nc->info->receive_iov (nc, iov, iovcnt); }else { ret =nc_sendv_compat (nc, iov, iovcnt, flags);
Signature · 1 line
1.9.1
Quoted 30 lines · Peter Lieven
commit
fefe2a78accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with theVIRTIO_NET_F_GUEST_ANNOUNCEfeature.Fixes fefe2a78abde932e0f340b21bded2c86def1d242Signed-off-by Peter Lieven <[email protected]>---
v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]net/net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)net/net.c +1
-0@@ -714,6 +714,11 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, NetClientState *nc = opaque;int ret; +/* we currently only support sending raw packets via
qemu_send_packet_raw.
+ * If we want generic raw iov support we need to implement something
like
net/net.c ssize_t qemu_deliver_packet_iov(NetClientState *sender, · line 721
Quoted 3 lines
net/net.c +3
-0+* .receive_raw_iov in NetClientInfo first. */ +assert (!(flags &QEMU_NET_PACKET_FLAG_RAW ) || iovcnt ==1 ); +
This assert is hard to understand IMO...I think move assert(iovcnt==1) as well as the
comment to if condition below as Paolo said previously is better...
Quoted 21 lines
if (nc->link_down) { return iov_size(iov, iovcnt); }net/net.c +4
-1@@ -722,7 +727,10 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, return 0; } -if (nc->info->receive_iov) { +if (flags &QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { +/* this is required for qemu_announce_self() */ + ret = nc->info->receive_raw (nc, iov[0 ].iov_base, iov[0 ].iov_len); + }else if (nc->info->receive_iov) { ret = nc->info->receive_iov (nc, iov, iovcnt); }else {ret = nc_sendv_compat(nc, iov, iovcnt, flags);--
1.9.1
Signature · 2 lines
Thanks, Yang
Am 07.06.2016 um 17:28 schrieb Yang Hongyang:
Quoted 35 lines · On Tue, Jun 7, 2016 at 9:00 PM, Peter Lieven <[email protected] <mailto:[email protected]>>…
commit
fefe2a78accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with theVIRTIO_NET_F_GUEST_ANNOUNCEfeature.Fixes fefe2a78abde932e0f340b21bded2c86def1d242Cc [email protected] <mailto:[email protected]>Cc [email protected] <mailto:[email protected]>Signed-off-by Peter Lieven <[email protected] <mailto:[email protected]>>---
v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]
net/net.c| 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)diff --git
a/net/net.cb/net/net.c
index 5f3e5a9..5e1b5fa 100644
---a/net/net.c
+++b/net/net.c
@@ -714,6 +714,11 @@ssize_tqemu_deliver_packet_iov(NetClientState *sender,
NetClientState *nc = opaque;
int ret;+ /* we currently only support sending raw packets via
qemu_send_packet_raw.
+ * If we want generic raw iov support we need to implement something like
+ * .receive_raw_iov in NetClientInfo first. */
+assert(!(flags & QEMU_NET_PACKET_FLAG_RAW) || iovcnt == 1);
+
Quoted 2 lines
This assert is hard to understand IMO...I think move assert(iovcnt==1) as well as the comment to if condition below as Paolo said previously is better...
This assert would only trigger if the NetClient implements .receive_raw. This way it could happen that someone injects RAW packets via an other way than qemu_send_packet_raw. But he might not see that its not allowed if he uses a backend that does not implement sending raw packets. If then someone uses a tap backend things break again.
Peter
Quoted 34 lines · Peter Lieven
commit
fefe2a78accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with theVIRTIO_NET_F_GUEST_ANNOUNCEfeature.Fixes fefe2a78abde932e0f340b21bded2c86def1d242Signed-off-by Peter Lieven <[email protected]>---
v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]net/net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)net/net.c +5
-0@@ -714,6 +714,11 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,NetClientState *nc = opaque;int ret; +/* we currently only support sending raw packets via qemu_send_packet_raw. +* If we want generic raw iov support we need to implement something like +* .receive_raw_iov in NetClientInfo first. */ +assert (!(flags &QEMU_NET_PACKET_FLAG_RAW ) || iovcnt ==1 ); +if (nc->link_down) {return iov_size (iov, iovcnt); }@@ -722,7 +727,10 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,return 0 ;
net/net.c ssize_t qemu_deliver_packet_iov(NetClientState *sender, · line 736
Quoted 10 lines
net/net.c +4
-1} -if (nc->info->receive_iov) { +if (flags &QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { +/* this is required for qemu_announce_self() */ + ret = nc->info->receive_raw (nc, iov[0 ].iov_base, iov[0 ].iov_len); + }else if (nc->info->receive_iov) { ret = nc->info->receive_iov (nc, iov, iovcnt); }else { ret =nc_sendv_compat (nc, iov, iovcnt, flags);
We still have raw packet support in nv_sendv_compat, can we use it? (and then there's no need for the assert above).
Thanks
Am 08.06.2016 um 08:39 schrieb Jason Wang:
Quoted 39 lines · Peter Lieven
Quoted 36 lines
commit
fefe2a78accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with theVIRTIO_NET_F_GUEST_ANNOUNCEfeature.Fixes fefe2a78abde932e0f340b21bded2c86def1d242Signed-off-by Peter Lieven <[email protected]>---
v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]net/net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)net/net.c +5
-0@@ -714,6 +714,11 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,NetClientState *nc = opaque;int ret; +/* we currently only support sending raw packets via qemu_send_packet_raw. +* If we want generic raw iov support we need to implement something like +* .receive_raw_iov in NetClientInfo first. */ +assert (!(flags &QEMU_NET_PACKET_FLAG_RAW ) || iovcnt ==1 ); +if (nc->link_down) {return iov_size (iov, iovcnt); }@@ -722,7 +727,10 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,return 0 ; } - if (nc->info->receive_iov) { +if (flags &QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) {
Quoted 8 lines
net/net.c ssize_t qemu_deliver_packet_iov(NetClientState *sender, · line 736
Quoted 6 lines
net/net.c +3
-0+/* this is required for qemu_announce_self() */ + ret = nc->info->receive_raw (nc, iov[0 ].iov_base, iov[0 ].iov_len); + }else if (nc->info->receive_iov) { ret = nc->info->receive_iov (nc, iov, iovcnt); }else { ret =nc_sendv_compat (nc, iov, iovcnt, flags);We still have raw packet support in
nv_sendv_compat, can we use it? (and then there's no need for the assert above).
Okay, so Version 1 of the patch is more appropiate. I would either use V1 or revert fefe2a78. The issue is quite serious for live migration.
Peter
Quoted 46 lines · Peter Lieven
Am 08.06.2016 um 08:39 schrieb Jason Wang:
Quoted 37 lines · Peter Lieven
Quoted 35 lines
commit
fefe2a78accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with theVIRTIO_NET_F_GUEST_ANNOUNCEfeature.Fixes fefe2a78abde932e0f340b21bded2c86def1d242Signed-off-by Peter Lieven <[email protected]>---
v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]net/net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)net/net.c +4
-0@@ -714,6 +714,11 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,NetClientState *nc = opaque;int ret; +/* we currently only support sending raw packets via qemu_send_packet_raw. +* If we want generic raw iov support we need to implement something like +* .receive_raw_iov in NetClientInfo first. */ +assert (!(flags &QEMU_NET_PACKET_FLAG_RAW ) || iovcnt ==1 ); +if (nc->link_down) {return iov_size (iov, iovcnt); }@@ -722,7 +727,10 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,return 0 ; } - if (nc->info->receive_iov) {Quoted 8 lines
net/net.c ssize_t qemu_deliver_packet_iov(NetClientState *sender, · line 736
Quoted 7 lines
net/net.c +4
-0+if (flags &QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { +/* this is required for qemu_announce_self() */ + ret = nc->info->receive_raw (nc, iov[0 ].iov_base, iov[0 ].iov_len); + }else if (nc->info->receive_iov) { ret = nc->info->receive_iov (nc, iov, iovcnt); }else { ret =nc_sendv_compat (nc, iov, iovcnt, flags);We still have raw packet support in
nv_sendv_compat, can we use it? (and then there's no need for the assert above).
Quoted 6 lines
Okay, so Version 1 of the patch is more appropiate. I would either use V1 or revert
fefe2a78. The issue is quite serious for live migration.Peter
V1 checks iovcnt and call receive_raw with hard coded first iov. Since we have raw packet support in nc_sendv_compat(), I mean when we detect QEMU_NET_PACKET_FLAG_RAW, call nc_sendv_compat() here.
----- Original Message -----
Quoted 8 lines
From: "Jason Wang" <[email protected]>
To: "Peter Lieven" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "hongyang yang" <[email protected]>
Sent: Wednesday, June 8, 2016 9:54:53 AM
Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH V2] net: fixqemu_announce_selfnot emitting packets
Quoted 56 lines
Quoted 55 lines · Peter Lieven
Am 08.06.2016 um 08:39 schrieb Jason Wang:
Quoted 43 lines · Peter Lieven
Quoted 41 lines
commit
fefe2a78accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with theVIRTIO_NET_F_GUEST_ANNOUNCEfeature.Fixes fefe2a78abde932e0f340b21bded2c86def1d242Signed-off-by Peter Lieven <[email protected]>---
v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]net/net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)net/net.c +1
-0@@ -714,6 +714,11 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, NetClientState *nc = opaque;int ret; + /* we currently only support sending raw packets viaqemu_send_packet_raw. +* If we want generic raw iov support we need to implement something like
net/net.c +5
-0+* .receive_raw_iov in NetClientInfo first. */ +assert (!(flags &QEMU_NET_PACKET_FLAG_RAW ) || iovcnt ==1 ); +if (nc->link_down) {return iov_size (iov, iovcnt); }@@ -722,7 +727,10 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, return 0; } - if (nc->info->receive_iov) { +if (flags &QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { +/* this is required for qemu_announce_self() */ Quoted 8 lines
net/net.c ssize_t qemu_deliver_packet_iov(NetClientState *sender, · line 736
Quoted 6 lines
net/net.c +2
-0+ ret = nc->info->receive_raw (nc, iov[0 ].iov_base, iov[0 ].iov_len); + }else if (nc->info->receive_iov) { ret = nc->info->receive_iov (nc, iov, iovcnt); }else { ret =nc_sendv_compat (nc, iov, iovcnt, flags);We still have raw packet support in
nv_sendv_compat, can we use it? (and then there's no need for the assert above).Okay, so Version 1 of the patch is more appropiate. I would either use V1 or revert
fefe2a78. The issue is quite serious
for live migration.
Or you can do even simpler:
if (nc->info->receive_iov && !(flags & QEMU_NET_PACKET_FLAG_RAW)))
nc->info->receive_iov
else
nc_sendv_compatPaolo
Quoted 9 lines
Quoted 4 lines
Peter
V1 checks iovcnt and call
receive_rawwith hard coded first iov. Since we have raw packet support innc_sendv_compat(), I mean when we detectQEMU_NET_PACKET_FLAG_RAW, callnc_sendv_compat()here.
Am 08.06.2016 um 12:23 schrieb Paolo Bonzini:
Quoted 65 lines
----- Original Message -----
Quoted 8 lines
From: "Jason Wang" <[email protected]>
To: "Peter Lieven" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "hongyang yang" <[email protected]>
Sent: Wednesday, June 8, 2016 9:54:53 AM
Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH V2] net: fixqemu_announce_selfnot emitting packetsQuoted 55 lines
Quoted 54 lines · Peter Lieven
Am 08.06.2016 um 08:39 schrieb Jason Wang:
Quoted 42 lines · Peter Lieven
Quoted 41 lines
commit
fefe2a78accidently dropped the code path for injecting raw packets. This feature is needed for sending gratuitous ARPs after an incoming migration has completed. The result is increased network downtime for vservers where the network card is not virtio-net with theVIRTIO_NET_F_GUEST_ANNOUNCEfeature.Fixes fefe2a78abde932e0f340b21bded2c86def1d242Signed-off-by Peter Lieven <[email protected]>---
v1->v2: assert that only raw packets with a plain buffer come in. [Paolo]net/net.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)net/net.c +1
-0@@ -714,6 +714,11 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, NetClientState *nc = opaque;int ret; + /* we currently only support sending raw packets viaqemu_send_packet_raw. +* If we want generic raw iov support we need to implement something like
net/net.c +5
-0+* .receive_raw_iov in NetClientInfo first. */ +assert (!(flags &QEMU_NET_PACKET_FLAG_RAW ) || iovcnt ==1 ); +if (nc->link_down) {return iov_size (iov, iovcnt); }@@ -722,7 +727,10 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, return 0; } - if (nc->info->receive_iov) { +if (flags &QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { +/* this is required for qemu_announce_self() */ Quoted 8 lines
net/net.c ssize_t qemu_deliver_packet_iov(NetClientState *sender, · line 736
Quoted 6 lines
net/net.c +2
-0+ ret = nc->info->receive_raw (nc, iov[0 ].iov_base, iov[0 ].iov_len); + }else if (nc->info->receive_iov) { ret = nc->info->receive_iov (nc, iov, iovcnt); }else { ret =nc_sendv_compat (nc, iov, iovcnt, flags);We still have raw packet support in
nv_sendv_compat, can we use it? (and then there's no need for the assert above).Okay, so Version 1 of the patch is more appropiate. I would either use V1 or revert
fefe2a78. The issue is quite serious
for live migration.
Quoted 6 lines
Or you can do even simpler:
if (nc->info->receive_iov && !(flags & QEMU_NET_PACKET_FLAG_RAW))) nc->info->receive_iov else nc_sendv_compat
I should have looked into this nc_sendv_compat function before ;-) This indeed is the best solution I think.
Will send a v3 tomorrow.
Peter