net: Fix announce_self with vhost
cover net: Fix announce_self with vhost
announce_self that sends a RARP packet after migration or with announce_self QMP/HMP command doesn't work with vhost because of the vnet headers.
announce_self is the only user of QEMU_NET_PACKET_FLAG_RAW and this flag is not correctly managed.
This series fix a problem with this flag in filter-dump and in qemu_deliver_packet_iov().
Laurent Vivier (2):
net: Fix announce_self
net/dump: Correctly compute Ethernet packet offset
net/dump.c | 3 ++- net/net.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.47.1
PATCH 1/2 net: Fix announce_self
b9ad513e1876 ("net: Remove receive_raw()") adds an iovec entry in qemu_deliver_packet_iov() to add the virtio-net header in the data when QEMU_NET_PACKET_FLAG_RAW is set but forgets to increase the number of iovec entries in the array, so receive_iov() will only send the first entry (the virtio-net entry, full of 0) and no data. The packet will be discarded.
The only user of QEMU_NET_PACKET_FLAG_RAW is announce_self.
We can see the problem with tcpdump:
- QEMU parameters:
.. -monitor stdio \
-netdev bridge,id=netdev0,br=virbr0 \
-device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \- HMP command:
(qemu) announce_self
- TCP dump:
$ sudo tcpdump -nxi virbr0
without the fix:
<nothing>
with the fix:
ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46
0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000
0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000
0x0020: 0000 0000 0000 0000 0000 0000 0000--- net/net.c | 1 + 1 file changed, 1 insertion(+)
net/net.c +1 -0
@@ -822,6 +822,7 @@ static ssize_t qemu_deliver_packet_iov(NetClientState *sender, iov_copy[0 ].iov_len = nc->vnet_hdr_len;memcpy (&iov_copy[1 ], iov, iovcnt *sizeof (*iov)); iov = iov_copy; + iovcnt++; }if (nc->info->receive_iov) {
Signature · 1 line
2.47.1
Re: [PATCH 1/2] net: Fix announce_self
Quoted 36 lines · Laurent Vivier
b9ad513e1876("net: Removereceive_raw()") adds an iovec entry inqemu_deliver_packet_iov()to add the virtio-net header in the data whenQEMU_NET_PACKET_FLAG_RAWis set but forgets to increase the number of iovec entries in the array, soreceive_iov()will only send the first entry (the virtio-net entry, full of 0) and no data. The packet will be discarded.The only user of
QEMU_NET_PACKET_FLAG_RAWisannounce_self.We can see the problem with tcpdump:
- QEMU parameters:
.. -monitor stdio \ -netdev bridge,id=netdev0,br=virbr0 \ -device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \- HMP command:
(qemu)
announce_self- TCP dump:
$ sudo tcpdump -nxi virbr0without the fix: <nothing> with the fix: ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46 0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000 0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000 0x0020: 0000 0000 0000 0000 0000 0000 0000
Quoted 5 lines
Reported-by Xiaohui Li <[email protected]>Fixes b9ad513e1876 ("net: Remove receive_raw()")Signed-off-by Laurent Vivier <[email protected]>
Thanks for finding out this bug:
I believe this should have:
Quoted 16 lines
--- net/net.c | 1 + 1 file changed, 1 insertion(+)net/net.c +1
-0@@ -822,6 +822,7 @@ static ssize_t qemu_deliver_packet_iov(NetClientState *sender, iov_copy[0 ].iov_len = nc->vnet_hdr_len;memcpy (&iov_copy[1 ], iov, iovcnt *sizeof (*iov)); iov = iov_copy; + iovcnt++; }if (nc->info->receive_iov) {
Re: [PATCH 1/2] net: Fix announce_self
In reply to Laurent VivierQuoted 37 lines · Laurent Vivier
b9ad513e1876("net: Removereceive_raw()") adds an iovec entry inqemu_deliver_packet_iov()to add the virtio-net header in the data whenQEMU_NET_PACKET_FLAG_RAWis set but forgets to increase the number of iovec entries in the array, soreceive_iov()will only send the first entry (the virtio-net entry, full of 0) and no data. The packet will be discarded.The only user of
QEMU_NET_PACKET_FLAG_RAWisannounce_self.We can see the problem with tcpdump:
- QEMU parameters:
.. -monitor stdio \ -netdev bridge,id=netdev0,br=virbr0 \ -device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \- HMP command:
(qemu)
announce_self- TCP dump:
$ sudo tcpdump -nxi virbr0without the fix:
<nothing>
with the fix:
ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46 0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000 0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000 0x0020: 0000 0000 0000 0000 0000 0000 0000
Quoted 6 lines
Reported-by Xiaohui Li <[email protected]>Fixes b9ad513e1876 ("net: Remove receive_raw()")Signed-off-by Laurent Vivier <[email protected]>---
Thanks
PATCH 2/2 net/dump: Correctly compute Ethernet packet offset
In reply to Laurent VivierWhen a packet is sent with QEMU_NET_PACKET_FLAG_RAW by QEMU it never includes virtio-net header even if qemu_get_vnet_hdr_len() is not 0, and filter-dump is not managing this case.
The only user of QEMU_NET_PACKET_FLAG_RAW is announce_self, we can show the problem using it and tcpddump:
- QEMU parameters:
.. -monitor stdio \
-netdev bridge,id=netdev0,br=virbr0 \
-device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \
-object filter-dump,netdev=netdev0,file=log.pcap,id=pcap0- HMP command:
(qemu) announce_self
- TCP dump:
$ tcpdump -nxr log.pcap
without the fix:
08:00:06:04:00:03 > 2e:2f:80:35:00:01, ethertype Unknown (0x9a2b), length 50:
0x0000: 2c2d 2e2f 0000 0000 9a2b 2c2d 2e2f 0000
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000
0x0020: 0000 0000with the fix:
ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46
0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000
0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000
0x0020: 0000 0000 0000 0000 0000 0000 0000--- net/dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/dump.c +2 -1
@@ -155,7 +155,8 @@ static ssize_t filter_dump_receive_iov(NetFilterState *nf, NetClientState *sndr, {NetFilterDumpState *nfds =FILTER_DUMP (nf); -dump_receive_iov (&nfds->ds, iov, iovcnt,qemu_get_vnet_hdr_len (nf->netdev)); +dump_receive_iov (&nfds->ds, iov, iovcnt, flags &QEMU_NET_PACKET_FLAG_RAW ? +0 :qemu_get_vnet_hdr_len (nf->netdev));return 0 ; }
Signature · 1 line
2.47.1
Re: [PATCH 2/2] net/dump: Correctly compute Ethernet packet offset
Quoted 36 lines · Laurent Vivier
When a packet is sent with
QEMU_NET_PACKET_FLAG_RAWby QEMU it never includes virtio-net header even ifqemu_get_vnet_hdr_len()is not 0, and filter-dump is not managing this case.The only user of
QEMU_NET_PACKET_FLAG_RAWisannounce_self, we can show the problem using it and tcpddump:- QEMU parameters:
.. -monitor stdio \ -netdev bridge,id=netdev0,br=virbr0 \ -device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \ -object filter-dump,netdev=netdev0,file=log.pcap,id=pcap0- HMP command:
(qemu)
announce_self- TCP dump:
$ tcpdump -nxr log.pcapwithout the fix: 08:00:06:04:00:03 > 2e:2f:80:35:00:01, ethertype Unknown (0x9a2b), length 50: 0x0000: 2c2d 2e2f 0000 0000 9a2b 2c2d 2e2f 0000 0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 0x0020: 0000 0000 with the fix: ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46 0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000 0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000 0x0020: 0000 0000 0000 0000 0000 0000 0000
Quoted 3 lines
Fixes 481c52320a26 ("net: Strip virtio-net header when dumping")Signed-off-by Laurent Vivier <[email protected]>
Re: [PATCH 2/2] net/dump: Correctly compute Ethernet packet offset
In reply to Laurent VivierQuoted 37 lines · Laurent Vivier
When a packet is sent with
QEMU_NET_PACKET_FLAG_RAWby QEMU it never includes virtio-net header even ifqemu_get_vnet_hdr_len()is not 0, and filter-dump is not managing this case.The only user of
QEMU_NET_PACKET_FLAG_RAWisannounce_self, we can show the problem using it and tcpddump:- QEMU parameters:
.. -monitor stdio \ -netdev bridge,id=netdev0,br=virbr0 \ -device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \ -object filter-dump,netdev=netdev0,file=log.pcap,id=pcap0- HMP command:
(qemu)
announce_self- TCP dump:
$ tcpdump -nxr log.pcapwithout the fix:
08:00:06:04:00:03 > 2e:2f:80:35:00:01, ethertype Unknown (0x9a2b), length 50: 0x0000: 2c2d 2e2f 0000 0000 9a2b 2c2d 2e2f 0000 0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 0x0020: 0000 0000with the fix:
ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46 0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000 0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000 0x0020: 0000 0000 0000 0000 0000 0000 0000
Quoted 4 lines
Fixes 481c52320a26 ("net: Strip virtio-net header when dumping")Signed-off-by Laurent Vivier <[email protected]>---
Thanks
Quoted 18 lines · Laurent Vivier
announce_selfthat sends a RARP packet after migration or withannounce_selfQMP/HMP command doesn't work with vhost because of the vnet headers.
announce_selfis the only user ofQEMU_NET_PACKET_FLAG_RAWand this flag is not correctly managed.This series fix a problem with this flag in filter-dump and in
qemu_deliver_packet_iov().Laurent Vivier (2):
net: Fixannounce_self
net/dump: Correctly compute Ethernet packet offsetnet/dump.c | 3 ++- net/net.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
Quoted 16 lines · Laurent Vivier
CC qemu-stable and qemu-trivial.Quoted 13 lines · Laurent Vivier
announce_selfthat sends a RARP packet after migration or withannounce_selfQMP/HMP command doesn't work with vhost because of the vnet headers.
announce_selfis the only user ofQEMU_NET_PACKET_FLAG_RAWand this flag is not correctly managed.This series fix a problem with this flag in filter-dump and in
qemu_deliver_packet_iov().Laurent Vivier (2):
net: Fixannounce_self
net/dump: Correctly compute Ethernet packet offset
Is this one - "Correctly compute Ethernet packet offset" - needed for older stable series too, like 8.2 and 7.2 (currently active ones)?
Since it doesn't apply without 4b52d63249 (tap: Remove qemu_using_vnet_hdr()).
Thanks,
/mjt
Le 01/02/2025 à 20:36, Michael Tokarev a écrit :
Quoted 14 lines
Quoted 13 lines · Laurent Vivier
CC qemu-stable and qemu-trivial.Quoted 10 lines · Laurent Vivier
announce_selfthat sends a RARP packet after migration or withannounce_selfQMP/HMP command doesn't work with vhost because of the vnet headers.
announce_selfis the only user ofQEMU_NET_PACKET_FLAG_RAWand this flag is not correctly managed.This series fix a problem with this flag in filter-dump and in
qemu_deliver_packet_iov().
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Laurent Vivier (2):
net: Fixannounce_self
net/dump: Correctly compute Ethernet packet offsetIs this one - "Correctly compute Ethernet packet offset" - needed for older stable series too, like 8.2 and 7.2 (currently active ones)?
Since it doesn't apply without
4b52d63249(tap: Removeqemu_using_vnet_hdr()).
It fixes 481c52320a26 ("net: Strip virtio-net header when dumping") that is only in 8.0.
But I'm not sure the bug exists without 4b52d63249 (tap: Remove qemu_using_vnet_hdr()), so it should be tested first.
Thanks,
Laurent
Quoted 10 lines · Laurent Vivier
announce_selfthat sends a RARP packet after migration or withannounce_selfQMP/HMP command doesn't work with vhost because of the vnet headers.
announce_selfis the only user ofQEMU_NET_PACKET_FLAG_RAWand this flag is not correctly managed.This series fix a problem with this flag in filter-dump and in
qemu_deliver_packet_iov().
Quoted 7 lines
Laurent Vivier (2):
net: Fixannounce_self
net/dump: Correctly compute Ethernet packet offsetnet/dump.c | 3 ++- net/net.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
Applied to trivial-patches and queued for qemu-stable.
Thanks,
/mjt
Quoted 15 lines · Michael Tokarev
Quoted 14 lines · Laurent Vivier
announce_selfthat sends a RARP packet after migration or withannounce_selfQMP/HMP command doesn't work with vhost because of the vnet headers.
announce_selfis the only user ofQEMU_NET_PACKET_FLAG_RAWand this flag is not correctly managed.This series fix a problem with this flag in filter-dump and in
qemu_deliver_packet_iov().Laurent Vivier (2):
net: Fixannounce_self
net/dump: Correctly compute Ethernet packet offset
Quoted 8 lines
Quoted 3 lines
net/dump.c| 3 ++-
net/net.c | 1 +2 files changed, 3 insertions(+), 1 deletion(-)Reviewed-by Michael Tokarev <[email protected]>Applied to trivial-patches and queued for qemu-stable.
When do you plan to send the PR for them?
Thanks,
Laurent
Quoted 1 line · Laurent Vivier
When do you plan to send the PR for them?
Um, sorry for the delay. Will do ASAP.
Thank you for the reminder!
/mjt