netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] net/packet: support of specifying virtio net header size
@ 2023-02-09 12:43 沈安琪(凛玥)
  2023-02-09 12:43 ` [PATCH 1/2] net/packet: add socketopt to set/get vnet_hdr_sz 沈安琪(凛玥)
  2023-02-09 12:43 ` [PATCH 2/2] net/packet: send and receive pkt with given vnet_hdr_sz 沈安琪(凛玥)
  0 siblings, 2 replies; 19+ messages in thread
From: 沈安琪(凛玥) @ 2023-02-09 12:43 UTC (permalink / raw)
  To: netdev
  Cc: willemdebruijn.kernel, mst, davem, jasowang,
	沈安琪(凛玥)

Raw socket, like tap, can be used as the backend for kernel vhost.
In raw socket, virtio net header size is currently hardcoded to be
the size of struct virtio_net_hdr, which is 10 bytes; however, it is not
always the case: some virtio features, such as mrg_rxbuf and VERSION_1,
need virtio net header to be 12-byte long.

These virtio features are worthy to support: for example, packets
that larger than one-mbuf size will be dropped in vhost worker's
handle_rx if mrg_rxbuf feature is not used, but large packets cannot be
avoided and increasing mbuf's size is not economical.

With these virtio features enabled, raw socket with hardcoded 10-byte
virtio net header will parse mac head incorrectly in packet_snd by taking
the last two bytes of virtio net header as part of mac header as well.
This incorrect mac header parsing will cause packet be dropped due to
invalid ether head checking in later under-layer device packet receiving.

By adding extra field vnet_hdr_sz in packet_sock to record current using
virtio net header size and supporting extra sockopt PACKET_VNET_HDR_SZ to
set specified vnet_hdr_sz, packet_sock can know the exact length of virtio
net header that virtio user gives. In packet_snd, tpacket_snd and
packet_recvmsg, instead of using hardcode virtio net header size, it can
get the exact vnet_hdr_sz from corresponding packet_sock, and parse mac
header correctly based on this information.

Anqi Shen (2):
  net/packet: add socketopt to set/get vnet_hdr_sz
  net/packet: send and receive pkt with given vnet_hdr_sz

 include/uapi/linux/if_packet.h |  1 +
 net/packet/af_packet.c         | 82 ++++++++++++++++++++++++++++++++++--------
 net/packet/internal.h          |  3 +-
 3 files changed, 70 insertions(+), 16 deletions(-)

-- 
1.8.3.1


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

end of thread, other threads:[~2023-02-22 15:05 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).