mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Feng Liu <feliu@nvidia.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	Simon Horman <horms@kernel.org>
Cc: virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jason Wang <jasowang@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	Bodong Wang <bodong@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net v1] virtio_net: Introduce skb_vnet_common_hdr to avoid typecasting
Date: Wed, 16 Aug 2023 14:31:15 -0400	[thread overview]
Message-ID: <e8a414f0-ac55-9ac1-b115-94daa5914a9c@nvidia.com> (raw)
In-Reply-To: <64dce2f2b99f5_23f1f82949f@willemb.c.googlers.com.notmuch>



On 2023-08-16 a.m.10:53, Willem de Bruijn wrote:
> External email: Use caution opening links or attachments
> 
> 
>>
>> Thanks for the detailed explanation.
>>
>> I kept virtio_net_hdr_mrg_rxbuf and virtio_net_hdr_v1_hash structures in
>> virtio_net.h, which can be forward compatible with existing user
>> applications which use these structures.
> 
> They're UAPI, so we cannot modify or remove them anyway.
> 
> Which is exactly why we want to be careful with adding anything new.
> 
ok

>> virtio_net_hdr_v1_hash cannot use virtio_net_hdr as the first member,
>> because in virtio_net_hdr_v1, csum_start and csum_offset are stored in
>> union as a structure, and virtio_net_hdr cannot be used instead.
> 
> Oh right. That wasn't always the case, or the reason for this.
> Not super relevant but, commit ed9ecb0415b9 has the history
> 
>      virtio: Don't expose legacy net features when VIRTIO_NET_NO_LEGACY defined.
> 
>      In particular, the virtio header always has the u16 num_buffers field.
>      We define a new 'struct virtio_net_hdr_v1' for this (rather than
>      simply calling it 'struct virtio_net_hdr', to avoid nasty type errors
>      if some parts of a project define VIRTIO_NET_NO_LEGACY and some don't.
> 
>      Transitional devices (which can't define VIRTIO_NET_NO_LEGACY) will
>      have to keep using struct virtio_net_hdr_mrg_rxbuf, which has the same
>      byte layout as struct virtio_net_hdr_v1.
> 
> The union was added to overload csum use on tx with RSC use on rx, in
> commit 22b436c9b568. I don't quite follow why there now are three
> structs, rather than two. The first two seem to both implement csum
> partial. Anyway, not super important here.
>ok

>> In addition, I put this new structure virtio_net_common_hdr in uapi,
>> hoping it could be used in future user space application to avoid
>> potential risks caused by type coercion (such as the problems mentioned
>> in the patch description ). So I think it should be in this header file.
>> What do you think?
> 
> Adding anything to UAPI has a high bar. Do you have a concrete use
> case for this?

In the scene of with and without VIRTIO_NET_F_HASH_REPORT feature, this 
patch has been tested on my setup, and the function is ok.

> 
> This does seem mostly a helper to simplify kernel logic to me, which
> is better kept in non-UAPI headers.
OK, will change it.


      reply	other threads:[~2023-08-16 18:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14 17:18 Feng Liu
2023-08-15 10:51 ` Simon Horman
2023-08-15 15:09   ` Feng Liu
2023-08-15 16:29     ` Simon Horman
2023-08-15 18:13       ` Willem de Bruijn
2023-08-16  3:00         ` Feng Liu
2023-08-16 14:53           ` Willem de Bruijn
2023-08-16 18:31             ` Feng Liu [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=e8a414f0-ac55-9ac1-b115-94daa5914a9c@nvidia.com \
    --to=feliu@nvidia.com \
    --cc=bodong@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jasowang@redhat.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /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

all inboxes | Powered by JetHome®