Netdev List
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	netdev <netdev@vger.kernel.org>,
	virtualization <virtualization@lists.linux-foundation.org>
Subject: Re: [Q] packet truncated after enabling ip_forward for virtio-net in guest
Date: Wed, 14 Sep 2022 15:44:34 +0000	[thread overview]
Message-ID: <20220914154434.fng4ifuk73b5m2gt@master> (raw)
In-Reply-To: <CACGkMEvNMDG=9tYAWDOqdYKMy-Sk3qShQX3PWGQZBcdvZ7y3Tw@mail.gmail.com>

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

      reply	other threads:[~2022-09-14 15:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220914154434.fng4ifuk73b5m2gt@master \
    --to=richard.weiyang@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox