From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: "沈安琪(凛玥)" <amy.saq@antgroup.com>,
"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, jasowang@redhat.com,
谈鉴锋 <henry.tjf@antgroup.com>
Subject: Re: [PATCH 2/2] net/packet: send and receive pkt with given vnet_hdr_sz
Date: Tue, 14 Feb 2023 09:28:15 -0500 [thread overview]
Message-ID: <63eb9a7fe973e_310218208b4@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <d759d787-4d76-c8e1-a5e2-233a097679b1@antgroup.com>
沈安琪(凛玥) wrote:
>
> 在 2023/2/10 下午11:39, Willem de Bruijn 写道:
> > Michael S. Tsirkin wrote:
> >> On Fri, Feb 10, 2023 at 12:01:03PM +0800, 沈安琪(凛玥) wrote:
> >>> 在 2023/2/9 下午9:07, Michael S. Tsirkin 写道:
> >>>> On Thu, Feb 09, 2023 at 08:43:15PM +0800, 沈安琪(凛玥) wrote:
> >>>>> From: "Jianfeng Tan" <henry.tjf@antgroup.com>
> >>>>>
> >>>>> When raw socket is used as the backend for kernel vhost, currently it
> >>>>> will regard the virtio net header as 10-byte, which is not always the
> >>>>> case since some virtio features need virtio net header other than
> >>>>> 10-byte, such as mrg_rxbuf and VERSION_1 that both need 12-byte virtio
> >>>>> net header.
> >>>>>
> >>>>> Instead of hardcoding virtio net header length to 10 bytes, tpacket_snd,
> >>>>> tpacket_rcv, packet_snd and packet_recvmsg now get the virtio net header
> >>>>> size that is recorded in packet_sock to indicate the exact virtio net
> >>>>> header size that virtio user actually prepares in the packets. By doing
> >>>>> so, it can fix the issue of incorrect mac header parsing when these
> >>>>> virtio features that need virtio net header other than 10-byte are
> >>>>> enable.
> >>>>>
> >>>>> Signed-off-by: Jianfeng Tan <henry.tjf@antgroup.com>
> >>>>> Co-developed-by: Anqi Shen <amy.saq@antgroup.com>
> >>>>> Signed-off-by: Anqi Shen <amy.saq@antgroup.com>
> >>>> Does it handle VERSION_1 though? That one is also LE.
> >>>> Would it be better to pass a features bitmap instead?
> >>>
> >>> Thanks for quick reply!
> >>>
> >>> I am a little confused abot what "LE" presents here?
> >> LE == little_endian.
> >> Little endian format.
> >>
> >>> For passing a features bitmap to af_packet here, our consideration is
> >>> whether it will be too complicated for af_packet to understand the virtio
> >>> features bitmap in order to get the vnet header size. For now, all the
> >>> virtio features stuff is handled by vhost worker and af_packet actually does
> >>> not need to know much about virtio features. Would it be better if we keep
> >>> the virtio feature stuff in user-level and let user-level tell af_packet how
> >>> much space it should reserve?
> >> Presumably, we'd add an API in include/linux/virtio_net.h ?
> > Better leave this opaque to packet sockets if they won't act on this
> > type info.
> >
> > This patch series probably should be a single patch btw. As else the
> > socket option introduced in the first is broken at that commit, since
> > the behavior is only introduced in patch 2.
>
>
> Good point, will merge this patch series into one patch.
>
>
> Thanks for Michael's enlightening advice, we plan to modify current UAPI
> change of adding an extra socketopt from only setting vnet header size
> only to setting a bit-map of virtio features, and implement another
> helper function in include/linux/virtio_net.h to parse the feature
> bit-map. In this case, packet sockets have no need to understand the
> feature bit-map but only pass this bit-map to virtio_net helper and get
> back the information, such as vnet header size, it needs.
>
> This change will make the new UAPI more general and avoid further
> modification if there are more virtio features to support in the future.
>
Please also comment how these UAPI extension are intended to be used.
As that use is not included in this initial patch series.
If the only intended user is vhost-net, we can consider not exposing
outside the kernel at all. That makes it easier to iterate if
necessary (no stable ABI) and avoids accidentally opening up new
avenues for bugs and exploits (syzkaller has a history with
virtio_net_header options).
next prev parent reply other threads:[~2023-02-14 14:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 12:43 [PATCH 0/2] net/packet: support of specifying virtio net header size 沈安琪(凛玥)
2023-02-09 12:43 ` [PATCH 1/2] net/packet: add socketopt to set/get vnet_hdr_sz 沈安琪(凛玥)
2023-02-09 14:45 ` Willem de Bruijn
2023-02-10 4:00 ` 沈安琪(凛玥)
2023-02-09 12:43 ` [PATCH 2/2] net/packet: send and receive pkt with given vnet_hdr_sz 沈安琪(凛玥)
2023-02-09 13:07 ` Michael S. Tsirkin
2023-02-10 4:01 ` 沈安琪(凛玥)
2023-02-10 8:10 ` Michael S. Tsirkin
2023-02-10 15:36 ` Willem de Bruijn
2023-02-12 9:54 ` Michael S. Tsirkin
2023-02-10 15:39 ` Willem de Bruijn
2023-02-13 11:06 ` 沈安琪(凛玥)
2023-02-14 14:28 ` Willem de Bruijn [this message]
2023-02-21 9:40 ` 沈安琪(凛玥)
2023-02-21 15:03 ` Willem de Bruijn
2023-02-22 8:04 ` 沈安琪(凛玥)
2023-02-22 11:37 ` Michael S. Tsirkin
2023-02-22 11:43 ` 沈安琪(凛玥)
2023-02-22 15:04 ` Willem de Bruijn
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=63eb9a7fe973e_310218208b4@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=amy.saq@antgroup.com \
--cc=davem@davemloft.net \
--cc=henry.tjf@antgroup.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).