Bug 1387477

Summary: virtual interface offload for virtio - disable host ufo only will not work
Product: Red Hat Enterprise Linux 7 Reporter: yalzhang <yalzhang>
Component: qemu-kvm-rhevAssignee: Wei <wexu>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: ailan, chayang, jasowang, juzhang, knoel, virt-maint, weliao, wexu, yalzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-08 12:07:17 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:
Embargoed:

Description yalzhang@redhat.com 2016-10-21 02:12:38 UTC
Description of problem:
when set offloads for virtual interface, if only disable UDP related offloads, after set ufo='off' both for host and guest, the "udp-fragmentation-offload" is still on in the guest.

Version-Release number of selected component (if applicable):
libvirt-2.0.0-10.el7.x86_64
qemu-kvm-rhev-2.6.0-28.el7.x86_64
kernel-3.10.0-510.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1. set ufo=off both on guest and host, the <host ufo='off'/> will not work(check on guest).

# virsh dumpxml r7 | grep /interface -B6
      <driver>
        <host ufo='off'/>
        <guest ufo='off'/>
      </driver>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

# ps -aux | grep qemu-kvm
...
-netdev tap,fd=27,id=hostnet0,vhost=on,vhostfd=29 -device virtio-net-pci,host_ufo=off,guest_ufo=off,netdev=hostnet0,id=net0,mac=52:54:00:36:c6:d0,bus=pci.0,addr=0x3 
...

2. On the guest:
# ethtool -k eth0 | head -18
Features for eth0:
rx-checksumming: on [fixed]
tx-checksumming: on
	tx-checksum-ipv4: off [fixed]
	tx-checksum-ip-generic: on
	tx-checksum-ipv6: off [fixed]
	tx-checksum-fcoe-crc: off [fixed]
	tx-checksum-sctp: off [fixed]
scatter-gather: on
	tx-scatter-gather: on
	tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
	tx-tcp-segmentation: on
	tx-tcp-ecn-segmentation: on
	tx-tcp6-segmentation: on
**** udp-fragmentation-offload: on  ****
generic-segmentation-offload: on
generic-receive-offload: on

# ethtool -K eth0 ufo off
# ethtool -k eth0 | grep udp-fragmentation
udp-fragmentation-offload: off

3. set gso=on and ufo=off, it works.
# virsh dumpxml r7.3 | grep /interface -B11
    <interface type='network'>
      <mac address='52:54:00:12:fc:9e'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <driver>
        <host gso='off' ufo='off'/>
        <guest ufo='off'/>
      </driver>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

on guest:
# ethtool -k eth0
Features for eth0:
rx-checksumming: on [fixed]
tx-checksumming: on
	tx-checksum-ipv4: off [fixed]
	tx-checksum-ip-generic: on
	tx-checksum-ipv6: off [fixed]
	tx-checksum-fcoe-crc: off [fixed]
	tx-checksum-sctp: off [fixed]
scatter-gather: on
	tx-scatter-gather: on
	tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
	tx-tcp-segmentation: on
	tx-tcp-ecn-segmentation: on
	tx-tcp6-segmentation: on
** udp-fragmentation-offload: off [fixed] **
......


Actual results:
In step 2, the udp-fragmentation-offload if on,but in the xml we set <host ufo='off'/>

Expected results:
In step 2, the udp-fragmentation-offload should be off

Additional info:
Have asked this question on this bug, and mst have provided some valuable information https://bugzilla.redhat.com/show_bug.cgi?id=1139364#c18

Comment 2 Wei 2016-11-01 16:17:00 UTC
Yal,
I have tried it with upstream, it doesn't work even with your step 3, can you share your test machine with me?

My cases:
-device virtio-net-pci,host_ufo=off,gso=off,guest_ufo=off,netdev=hn1,mac=52:54:00:11:22:10 

-device virtio-net-pci,host_ufo=off,guest_ufo=off,netdev=hn1,mac=52:54:00:11:22:10 

-device virtio-net-pci,guest_ufo=off,netdev=hn1,mac=52:54:00:11:22:10 \

BTW, can you add me to the cc list of bug 1139364 as well? Seems I don't have permission to access the bz.

Comment 3 Wei 2016-11-01 16:21:04 UTC
Just noticed you were using 'gso=on', also tried that, not working for upstream.

-device virtio-net-pci,host_ufo=off,gso=on,guest_ufo=off,netdev=hn1,mac=52:54:00:11:22:10 \
-device virtio-net-pci,host_ufo=off,gso=off,guest_ufo=off,netdev=hn1,mac=52:54:00:11:22:10 \
-device virtio-net-pci,host_ufo=off,guest_ufo=off,netdev=hn1,mac=52:54:00:11:22:10 \
-device virtio-net-pci,guest_ufo=on,netdev=hn1,mac=52:54:00:11:22:10 \
-device virtio-net-pci,guest_ufo=off,netdev=hn1,mac=52:54:00:11:22:10 \

Comment 4 Wei 2016-11-02 06:44:09 UTC
A bit correction, ufo can only be turned  off via  'host_ufo=off,gso=off,guest_ufo=off'.

From guest's point of view, 'ufo' depends on gso, ufo will turned on if gso has been enabled.

For host side, ufo depends on host ufo as well.

Looks this is by design when probing virtio net device in guest, thus it is not a bug.


if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
    dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
        | NETIF_F_TSO_ECN | NETIF_F_TSO6;
}
/* Individual feature bits: what can host handle? */
if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO4))
    dev->hw_features |= NETIF_F_TSO;
if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO6))
    dev->hw_features |= NETIF_F_TSO6;
if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
    dev->hw_features |= NETIF_F_TSO_ECN;
if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
    dev->hw_features |= NETIF_F_UFO;

Comment 5 jason wang 2016-11-02 07:23:47 UTC
Yes, this looks not like a bug. If you're checking guest ufo (TX) through ethtool, it has nothing to do with guest_ufo (RX).

Comment 6 yalzhang@redhat.com 2016-12-02 07:57:19 UTC
Many thanks to jason and Wei, I think I got the meaning. It is not a bug but a wrong usage, it is something about the principle of GSO/TSO/UFO. 
If I want to disable ufo for the guest(both transmit and receive), I should set gso=off together, the xml should like this:

  <driver>
        <host gso='off' ufo='off'/>  ===> for receive
        <guest ufo='off'/>   ====> for transmit
      </driver>

If I want to disable tcp related segments for guest, the xml should be like:

  <driver>
        <host gso='off' tso4='off' tso6='off' ecn='off'/>  ===> for receive
        <guest tso4='off' tso6='off' ecn='off'/> ====> for transmit
      </driver>

Both of them should include the "gso='off'" because tso and gso all depends on gso. Please help to check if I get the point, thank you very much!

Comment 7 Wei 2016-12-08 03:33:30 UTC
that is it.