All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/1] virtio-vsock: introduce SEQPACKET description
@ 2021-02-18  5:52 Arseny Krasnov
  2021-02-18  5:53 ` [RFC PATCH v1 1/1] virtio-vsock: add SOCK_SEQPACKET description Arseny Krasnov
  0 siblings, 1 reply; 2+ messages in thread
From: Arseny Krasnov @ 2021-02-18  5:52 UTC (permalink / raw)
  To: cohuck, virtio-comment, Stefan Hajnoczi, Stefano Garzarella,
	Michael S. Tsirkin, Jason Wang, David S. Miller, Jakub Kicinski,
	Arseny Krasnov, Jorgen Hansen, Norbert Slusarek, Colin Ian King,
	Andra Paraschiv
  Cc: virtualization, oxffffaa

This patchset adds description of SOCK_SEQPACKET socket's type
of virtio vsock.

Here is implementation:
https://lkml.org/lkml/2021/2/18/24

 Arseny Krasnov(1):
  virtio-vsock: add SOCK_SEQPACKET description

 virtio-vsock.tex | 40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)

TODO:
- for messages identification I use header's field called 'msg_cnt'.
  May be it is better to call it 'msg_id' or 'msg_num', because it
  is used as ID, but implemented as counter.

- in current version of specification, some values of headers' fields
  still unnamed, for example type of socket (stream or seqpacket), then
  shutdown flags. Spec says that for stream socket value of 'type'
  must be 1. For receive shutdown bit 0 is set in 'flags', for send
  shutdown bit 1 is set in 'flags'. But in Linux these unnamed ones and
  zeroes are implemented as enums, so may be it will be ok to add such
  enums in specification (as 'enum virtio_vsock_event_id').

Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>

-- 
2.25.1


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

* [RFC PATCH v1 1/1] virtio-vsock: add SOCK_SEQPACKET description
  2021-02-18  5:52 [RFC PATCH v1 0/1] virtio-vsock: introduce SEQPACKET description Arseny Krasnov
@ 2021-02-18  5:53 ` Arseny Krasnov
  0 siblings, 0 replies; 2+ messages in thread
From: Arseny Krasnov @ 2021-02-18  5:53 UTC (permalink / raw)
  To: cohuck, virtio-comment, Stefan Hajnoczi, Stefano Garzarella,
	Michael S. Tsirkin, Jason Wang, David S. Miller, Jakub Kicinski,
	Arseny Krasnov, Jorgen Hansen, Colin Ian King, Norbert Slusarek,
	Andra Paraschiv
  Cc: virtualization, oxffffaa

Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
---
 virtio-vsock.tex | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/virtio-vsock.tex b/virtio-vsock.tex
index da7e641..1ee8f99 100644
--- a/virtio-vsock.tex
+++ b/virtio-vsock.tex
@@ -102,6 +102,11 @@ \subsection{Device Operation}\label{sec:Device Types / Socket Device / Device Op
 	VIRTIO_VSOCK_OP_CREDIT_UPDATE = 6,
 	/* Request the peer to send the credit info to us */
 	VIRTIO_VSOCK_OP_CREDIT_REQUEST = 7,
+
+	/* Message begin for SOCK_SEQPACKET */
+	VIRTIO_VSOCK_OP_SEQ_BEGIN = 8,
+	/* Message end for SOCK_SEQPACKET */
+	VIRTIO_VSOCK_OP_SEQ_END = 9,
 };
 \end{lstlisting}
 
@@ -140,11 +145,11 @@ \subsubsection{Addressing}\label{sec:Device Types / Socket Device / Device Opera
 consists of a (cid, port number) tuple. The header fields used for this are
 \field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.
 
-Currently only stream sockets are supported. \field{type} is 1 for stream
-socket types.
+Currently stream and seqpacket sockets are supported. \field{type} is 1 for
+stream socket types. \field{type} is 2 for seqpacket socket types.
 
 Stream sockets provide in-order, guaranteed, connection-oriented delivery
-without message boundaries.
+without message boundaries. Seqpacket sockets also provide message boundaries.
 
 \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket Device / Device Operation / Buffer Space Management}
 \field{buf_alloc} and \field{fwd_cnt} are used for buffer space management of
@@ -240,6 +245,35 @@ \subsubsection{Stream Sockets}\label{sec:Device Types / Socket Device / Device O
 destination) address tuple for a new connection while the other peer is still
 processing the old connection.
 
+\subsubsection{Seqpacket Sockets}\label{sec:Device Types / Socket Device / Device Operation / Seqpacket Sockets}
+
+Seqpacket sockets differ from stream sockets only in data transmission way: in
+stream sockets all data is sent using only VIRTIO_VSOCK_OP_RW packets. In
+seqpacket sockets, to provide message boundaries, every sequence of
+VIRTIO_VSOCK_OP_RW packets of each message is headed with
+VIRTIO_VSOCK_OP_SEQ_BEGIN and tailed with VIRTIO_VSOCK_OP_SEQ_END packets.
+Both VIRTIO_VSOCK_OP_SEQ_BEGIN and VIRTIO_VSOCK_OP_SEQ_END packets carry
+special header in payload:
+
+\begin{lstlisting}
+struct virtio_vsock_seq_hdr {
+	__le32  msg_cnt;
+	__le32  msg_len;
+};
+\end{lstlisting}
+
+\field{msg_cnt} is per socket and incremented by 1 on every send of
+VIRTIO_VSOCK_OP_SEQ_BEGIN or VIRTIO_VSOCK_OP_SEQ_END. \field{msg_len} contains
+message length. This header is used to check integrity of each message: message
+is valid if length of data in VIRTIO_VSOCK_OP_RW packets is equal to
+\field{msg_len} of prepending VIRTIO_VSOCK_OP_SEQ_BEGIN and \field{msg_cnt} of
+VIRTIO_VSOCK_OP_SEQ_END differs from \field{msg_cnt} of
+VIRTIO_VSOCK_OP_SEQ_BEGIN by 1.
+
+POSIX MSG_EOR flag is supported by special value of \field{flags} in packet's
+header. If this flag is set for message, then all VIRTIO_VSOCK_OP_RW packets
+of this message have bit 0 is set to 1 in \field{flags}.
+
 \subsubsection{Device Events}\label{sec:Device Types / Socket Device / Device Operation / Device Events}
 
 Certain events are communicated by the device to the driver using the event
-- 
2.25.1


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

end of thread, other threads:[~2021-02-18  5:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18  5:52 [RFC PATCH v1 0/1] virtio-vsock: introduce SEQPACKET description Arseny Krasnov
2021-02-18  5:53 ` [RFC PATCH v1 1/1] virtio-vsock: add SOCK_SEQPACKET description Arseny Krasnov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.