[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [RFC PATCH v4 2/2] virtio-vsock: SOCK_SEQPACKET description
This adds description of SOCK_SEQPACKET socket type support for virtio-vsock. Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com> --- virtio-vsock.tex | 65 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/virtio-vsock.tex b/virtio-vsock.tex index ad57f9d..c366de7 100644 --- a/virtio-vsock.tex +++ b/virtio-vsock.tex @@ -17,6 +17,10 @@ \subsection{Virtqueues}\label{sec:Device Types / Socket Device / Virtqueues} \subsection{Feature bits}\label{sec:Device Types / Socket Device / Feature bits} There are currently no feature bits defined for this device. +\begin{description} +\item VIRTIO_VSOCK_F_SEQPACKET (0) SOCK_SEQPACKET socket type is + supported. +\end{description} \subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout} @@ -98,6 +102,10 @@ \subsection{Device Operation}\label{sec:Device Types / Socket Device / Device Op #define VIRTIO_VSOCK_OP_CREDIT_UPDATE 6 /* Request the peer to send the credit info to us */ #define VIRTIO_VSOCK_OP_CREDIT_REQUEST 7 +/* Message begin for SOCK_SEQPACKET */ +#define VIRTIO_VSOCK_OP_SEQ_BEGIN 8 +/* Message end for SOCK_SEQPACKET */ +#define VIRTIO_VSOCK_OP_SEQ_END 9 \end{lstlisting} \subsubsection{Virtqueue Flow Control}\label{sec:Device Types / Socket Device / Device Operation / Virtqueue Flow Control} @@ -135,15 +143,16 @@ \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 (VIRTIO_VSOCK_TYPE_STREAM) -for stream socket types. +Currently stream and seqpacket sockets are supported. \field{type} is 1 (VIRTIO_VSOCK_TYPE_STREAM) +for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for seqpacket socket types. \begin{lstlisting} -#define VIRTIO_VSOCK_TYPE_STREAM 1 +#define VIRTIO_VSOCK_TYPE_STREAM 1 +#define VIRTIO_VSOCK_TYPE_SEQPACKET 2 \end{lstlisting} 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 @@ -170,8 +179,10 @@ \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket Device / communicating updates any time a change in buffer space occurs. \drivernormative{\paragraph}{Device Operation: Buffer Space Management}{Device Types / Socket Device / Device Operation / Buffer Space Management} -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has -sufficient free buffer space for the payload. +VIRTIO_VSOCK_OP_RW data packets as well as VIRTIO_VSOCK_OP_SEQ_BEGIN and +VIRTIO_VSOCK_OP_SEQ_END message boundary packets MUST only be +transmitted when the peer has sufficient free buffer space for the +payload. All packets associated with a stream flow MUST contain valid information in \field{buf_alloc} and \field{fwd_cnt} fields. @@ -244,6 +255,48 @@ \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} + +\paragraph{Message boundaries}\label{sec:Device Types / Socket Device / Device Operation / Seqpacket Sockets / Message boundaries} + +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 MUST be 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 MUST carry +special structure in payload: + +\begin{lstlisting} +struct virtio_vsock_seq_hdr { + __le32 msg_id; + __le32 msg_len; +}; +\end{lstlisting} + +This data MUST be placed starting from the first byte of payload and no more +data is allowed to be beyond it. Also payload of such packet MUST be transmitted +without fragmentation. \field{len} of packet header MUST be set to the size of +the struct virtio_vsock_seq_hdr. + +\field{msg_id} is value to identify message. It MUST be same for pair of +VIRTIO_VSOCK_OP_SEQ_BEGIN and VIRTIO_VSOCK_OP_SEQ_END of one message, and MUST +differ in next messages. \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_id} of VIRTIO_VSOCK_OP_SEQ_END is equal +to \field{msg_id} of VIRTIO_VSOCK_OP_SEQ_BEGIN. + +\paragraph{POSIX MSG_EOR flag}\label{sec:Device Types / Socket Device / Device Operation / Seqpacket Sockets / MSG_EOR flag} + +When message is sent using one of POSIX functions: send(), sendto() or sendmsg() and +MSG_EOR flag is set in \field{flags} parameter of these functions, then all VIRTIO_VSOCK_OP_RW +packets of this message MUST have \field{flags} field in header set to special constanst: + +\begin{lstlisting} +#define VIRTIO_VSOCK_RW_EOR 1 +\end{lstlisting} + \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
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]