Netdev List
 help / color / mirror / Atom feed
* [Q] packet truncated after enabling ip_forward for virtio-net in guest
@ 2022-09-13 15:42 Wei Yang
  2022-09-14  3:46 ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Yang @ 2022-09-13 15:42 UTC (permalink / raw)
  To: Michael S. Tsirkin, jasowang; +Cc: netdev, virtualization

Hi, I am running a guest with vhost-net as backend. After I enable
ip_forward, the packet received is truncated.

Host runs a 5.10 kernel, while guest kernel is v5.11 which doesn't
include this commit:

  virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO

After applying this commit, the issue is gone. I guess the reason is
this device doesn't have NETIF_F_GRO_HW set, so
virtnet_set_guest_offloads is not called.

I am wondering why packet is truncated without this fix. I follow
virtnet_set_guest_offloads and just see virtio_net_handle_ctrl in qemu
handles VIRTIO_NET_CTRL_GUEST_OFFLOADS. Since we use a tap dev, then I
follow tap_fd_set_offload to ioctl(fd, TUNSETOFFLOAD, offload).

But I am lost here. tap_ioctl -> set_offload(). Since we use a normal
tap device instead of ipvtap/macvtap, update_features is empty. So I
don't get how the device's behavior is changed after set LRO.

Do I follow the wrong path? Any suggestions on investigation?

I'd appreciate it if someone could give a hint :-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Q] packet truncated after enabling ip_forward for virtio-net in guest
  2022-09-13 15:42 [Q] packet truncated after enabling ip_forward for virtio-net in guest Wei Yang
@ 2022-09-14  3:46 ` Jason Wang
  2022-09-14 15:44   ` Wei Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2022-09-14  3:46 UTC (permalink / raw)
  To: Wei Yang; +Cc: Michael S. Tsirkin, netdev, virtualization

On Tue, Sep 13, 2022 at 11:43 PM Wei Yang <richard.weiyang@gmail.com> wrote:
>
> Hi, I am running a guest with vhost-net as backend. After I enable
> ip_forward, the packet received is truncated.
>
> Host runs a 5.10 kernel, while guest kernel is v5.11 which doesn't
> include this commit:
>
>   virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
>
> After applying this commit, the issue is gone. I guess the reason is
> this device doesn't have NETIF_F_GRO_HW set,

Note that form device POV, it should be VIRTIO_NET_F_GUEST_TSOX.

> so
> virtnet_set_guest_offloads is not called.
>
> I am wondering why packet is truncated without this fix. I follow
> virtnet_set_guest_offloads and just see virtio_net_handle_ctrl in qemu
> handles VIRTIO_NET_CTRL_GUEST_OFFLOADS. Since we use a tap dev, then I
> follow tap_fd_set_offload to ioctl(fd, TUNSETOFFLOAD, offload).
>
> But I am lost here. tap_ioctl -> set_offload(). Since we use a normal
> tap device instead of ipvtap/macvtap, update_features is empty. So I
> don't get how the device's behavior is changed after set LRO.
>
> Do I follow the wrong path? Any suggestions on investigation?

Note that if you are using tuntap, you should refert driver/net/tun.c
instead of tap.c. Where it calls netdev_update_features() that will
change the TX offloading.

Thanks

>
> I'd appreciate it if someone could give a hint :-)
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Q] packet truncated after enabling ip_forward for virtio-net in guest
  2022-09-14  3:46 ` Jason Wang
@ 2022-09-14 15:44   ` Wei Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Yang @ 2022-09-14 15:44 UTC (permalink / raw)
  To: Jason Wang; +Cc: Wei Yang, Michael S. Tsirkin, netdev, virtualization

On Wed, Sep 14, 2022 at 11:46:56AM +0800, Jason Wang wrote:
>On Tue, Sep 13, 2022 at 11:43 PM Wei Yang <richard.weiyang@gmail.com> wrote:
>>
>> Hi, I am running a guest with vhost-net as backend. After I enable
>> ip_forward, the packet received is truncated.
>>
>> Host runs a 5.10 kernel, while guest kernel is v5.11 which doesn't
>> include this commit:
>>
>>   virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
>>
>> After applying this commit, the issue is gone. I guess the reason is
>> this device doesn't have NETIF_F_GRO_HW set,
>
>Note that form device POV, it should be VIRTIO_NET_F_GUEST_TSOX.
>
>> so
>> virtnet_set_guest_offloads is not called.
>>
>> I am wondering why packet is truncated without this fix. I follow
>> virtnet_set_guest_offloads and just see virtio_net_handle_ctrl in qemu
>> handles VIRTIO_NET_CTRL_GUEST_OFFLOADS. Since we use a tap dev, then I
>> follow tap_fd_set_offload to ioctl(fd, TUNSETOFFLOAD, offload).
>>

Thanks Jason

So virtnet_set_guest_offloads() in guest would be handled by
virtio_net_handle_ctrl in qemu. This understanding is correct.

>> But I am lost here. tap_ioctl -> set_offload(). Since we use a normal
>> tap device instead of ipvtap/macvtap, update_features is empty. So I
>> don't get how the device's behavior is changed after set LRO.
>>
>> Do I follow the wrong path? Any suggestions on investigation?
>
>Note that if you are using tuntap, you should refert driver/net/tun.c
>instead of tap.c. Where it calls netdev_update_features() that will
>change the TX offloading.

netdev_update_features(struct net_device *dev)
	__netdev_update_features(dev);
		dev->netdev_ops->ndo_fix_features();
		dev->netdev_ops->ndo_set_features();
	netdev_features_change(dev);

If my understanding is correct, this netdev_ops is tun_netdev_ops. While this
one doesn't have ndo_set_features.

I see the log "Features changed: xxx" in dmesg, but I still don't get how the
behavior changes.

>
>Thanks
>
>>
>> I'd appreciate it if someone could give a hint :-)
>>

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-14 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-13 15:42 [Q] packet truncated after enabling ip_forward for virtio-net in guest Wei Yang
2022-09-14  3:46 ` Jason Wang
2022-09-14 15:44   ` Wei Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox