Bug 2175449

Summary: Networking receive/transmit_bytes metrics values are swapped for pre-created macvtap device
Product: Red Hat Enterprise Linux 9 Reporter: yalzhang <yalzhang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
libvirt sub component: Networking QA Contact: yalzhang <yalzhang>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: dzheng, jdenemar, lmen, virt-maint
Version: 9.2Keywords: Triaged, Upstream
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-9.2.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:30:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version: 9.2.0
Embargoed:

Description yalzhang@redhat.com 2023-03-05 00:43:09 UTC
Description of problem:
The statistics from domifstat will be reversed for pre-created macvtap devices

Version-Release number of selected component (if applicable):
libvirt-9.0.0-7.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. create a macvtap device:
# ip link add link eno1 name mymacvtap0 address 52:54:00:11:11:11  type macvtap mode bridge
# ip link set mymacvtap0 up

2. start a vm with ethernet interface with managed=no and use this macvtap device:
# virsh dumpxml rhel --xpath //interface
<interface type="ethernet">
  <mac address="52:54:00:11:11:11"/>
  <target dev="mymacvtap0" managed="no"/>
  <model type="virtio"/>
  <alias name="net0"/>  
<address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

3. start the vm and download a file, then check the statistics both on guest and host:
[on guest]# ip -s l show enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:11:11:11 brd ff:ff:ff:ff:ff:ff
    RX:  bytes packets errors dropped  missed   mcast          
     517301139  347222      0     135       0       0
    TX:  bytes packets errors dropped carrier collsns          
      18240947  224857      0       0       0       0

[on host]# virsh domifstat rhel mymacvtap0   ---- > it's not guest view, which is reversed
mymacvtap0 rx_bytes 18241853    
mymacvtap0 rx_packets 224868
mymacvtap0 rx_errs 0
mymacvtap0 rx_drop 0
mymacvtap0 tx_bytes 517337187
mymacvtap0 tx_packets 347773
mymacvtap0 tx_errs 0
mymacvtap0 tx_drop 51

Actual results:
The statistics from domifstat will be reversed for pre-created macvtap devices

Expected results:
The statistics get from the domifstat should show the guest view

Additional info:

Comment 1 Michal Privoznik 2023-03-06 09:48:45 UTC
Patches posted on the list:

https://listman.redhat.com/archives/libvir-list/2023-March/238400.html

Comment 2 Michal Privoznik 2023-03-06 11:24:19 UTC
Merged upstream as:

928e741172 src: Document virDomainInterfaceStats() limitation
172dd3d9f7 conf: Make macvtap ethernet share host view

v9.1.0-57-g928e741172

Comment 3 yalzhang@redhat.com 2023-04-04 16:14:23 UTC
Test on libvirt-9.2.0-1.el9.x86_64 with the same steps in comment 0, the issue is fixed.
From the guest:
# ip -s l show enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:11:11:11 brd ff:ff:ff:ff:ff:ff
    RX:  bytes packets errors dropped  missed   mcast           
     625194377   95305      0       0       0       0 
    TX:  bytes packets errors dropped carrier collsns           
       5499660   83251      0       0       0       0

From the host:
# virsh domifstat avocado-vt-vm1 mymacvtap0
mymacvtap0 rx_bytes 625204985
mymacvtap0 rx_packets 95421
mymacvtap0 rx_errs 0
mymacvtap0 rx_drop 0
mymacvtap0 tx_bytes 5500954
mymacvtap0 tx_packets 83266
mymacvtap0 tx_errs 0
mymacvtap0 tx_drop 0

Comment 7 yalzhang@redhat.com 2023-05-19 02:22:21 UTC
Test on libvirt-9.3.0-2.el9.x86_64, the result is as expected.

Comment 9 errata-xmlrpc 2023-11-07 08:30:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: libvirt security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6409