Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1564329

Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on receiving

From Jason Wang <jasowang@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on receiving
Date 2017-01-22 09:20 +0100
Message-ID <t2lxw-6NP-13@gated-at.bofh.it> (permalink)
References <t1B1D-3Nl-7@gated-at.bofh.it> <t1KHE-1gZ-31@gated-at.bofh.it> <t2go9-3hA-1@gated-at.bofh.it> <t2hWV-4pB-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 2017年01月22日 12:22, Michael S. Tsirkin wrote:
> On Sun, Jan 22, 2017 at 10:41:22AM +0800, Jason Wang wrote:
>>
>> On 2017年01月21日 00:45, Michael S. Tsirkin wrote:
>>> On Fri, Jan 20, 2017 at 02:32:42PM +0800, Jason Wang wrote:
>>>> Commit 501db511397f ("virtio: don't set VIRTIO_NET_HDR_F_DATA_VALID on
>>>> xmit") in fact disables VIRTIO_HDR_F_DATA_VALID on receiving path too,
>>>> fixing this by adding a hint (has_data_valid) and set it only on the
>>>> receiving path.
>>>>
>>>> Cc: Rolf Neugebauer<rolf.neugebauer@docker.com>
>>>> Signed-off-by: Jason Wang<jasowang@redhat.com>
>>>> ---
>>>>    drivers/net/macvtap.c      | 2 +-
>>>>    drivers/net/tun.c          | 2 +-
>>>>    drivers/net/virtio_net.c   | 2 +-
>>>>    include/linux/virtio_net.h | 6 +++++-
>>>>    net/packet/af_packet.c     | 4 ++--
>>>>    5 files changed, 10 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
>>>> index 5c26653..4026185 100644
>>>> --- a/drivers/net/macvtap.c
>>>> +++ b/drivers/net/macvtap.c
>>>> @@ -825,7 +825,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
>>>>    			return -EINVAL;
>>>>    		if (virtio_net_hdr_from_skb(skb, &vnet_hdr,
>>>> -					    macvtap_is_little_endian(q)))
>>>> +					    macvtap_is_little_endian(q), true))
>>>>    			BUG();
>>>>    		if (copy_to_iter(&vnet_hdr, sizeof(vnet_hdr), iter) !=
>>>> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
>>>> index cd8e02c..2cd10b2 100644
>>>> --- a/drivers/net/tun.c
>>>> +++ b/drivers/net/tun.c
>>>> @@ -1360,7 +1360,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
>>>>    			return -EINVAL;
>>>>    		if (virtio_net_hdr_from_skb(skb, &gso,
>>>> -					    tun_is_little_endian(tun))) {
>>>> +					    tun_is_little_endian(tun), true)) {
>>>>    			struct skb_shared_info *sinfo = skb_shinfo(skb);
>>>>    			pr_err("unexpected GSO type: "
>>>>    			       "0x%x, gso_size %d, hdr_len %d\n",
>>>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>>>> index 4a10500..3474243 100644
>>>> --- a/drivers/net/virtio_net.c
>>>> +++ b/drivers/net/virtio_net.c
>>>> @@ -1104,7 +1104,7 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
>>>>    		hdr = skb_vnet_hdr(skb);
>>>>    	if (virtio_net_hdr_from_skb(skb, &hdr->hdr,
>>>> -				    virtio_is_little_endian(vi->vdev)))
>>>> +				    virtio_is_little_endian(vi->vdev), false))
>>>>    		BUG();
>>>>    	if (vi->mergeable_rx_bufs)
>>>> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
>>>> index 5643647..5209b5e 100644
>>>> --- a/include/linux/virtio_net.h
>>>> +++ b/include/linux/virtio_net.h
>>>> @@ -56,7 +56,8 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
>>>>    static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
>>>>    					  struct virtio_net_hdr *hdr,
>>>> -					  bool little_endian)
>>>> +					  bool little_endian,
>>>> +					  bool has_data_valid)
>>>>    {
>>>>    	memset(hdr, 0, sizeof(*hdr));   /* no info leak */
>>> I would prefer naming it is_rx. Callers should not know about
>>> internal details like data valid, the issue we are trying to fix
>>> here is that tx and tx headers are slightly different.
>>>
>> Actually, I've considered something like this, but the problem is:
>>
>> - tun use this on xmit, so is_rx = true may cause some confusion here
> tun is generally weird, yes. how about rx_format?

Ok.

>
>> - I believe we may want to support DATA_VALID (like xen-netback) on tx
>> (probably with a feature) in the future.
>>
>> Thanks
> We'll put that knowledge within virtio_net_hdr_from_skb not
> in the callers I think.
>

Maybe, will prepare a patch for net-next.

Thanks

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on receiving Jason Wang <jasowang@redhat.com> - 2017-01-20 07:40 +0100
  Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on receiving Rolf Neugebauer <rolf.neugebauer@docker.com> - 2017-01-20 12:00 +0100
  Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on  receiving David Miller <davem@davemloft.net> - 2017-01-20 17:10 +0100
  Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on  receiving "Michael S. Tsirkin" <mst@redhat.com> - 2017-01-20 18:00 +0100
    Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on  receiving Jason Wang <jasowang@redhat.com> - 2017-01-22 03:50 +0100
      Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on  receiving "Michael S. Tsirkin" <mst@redhat.com> - 2017-01-22 05:30 +0100
        Re: [PATCH net] virtio-net: restore VIRTIO_HDR_F_DATA_VALID on  receiving Jason Wang <jasowang@redhat.com> - 2017-01-22 09:20 +0100

csiph-web