Skip to contentSkip to conversation

virtio-vsock: add max payload size config field

PATCH Superseded Laura Loghin 4 participants 10 messages Apr 4, 2022 – Jun 24, 2022

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-vsock: add max payload size config field

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
 virtio-vsock.tex | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
virtio-vsock.tex +34 -0
index d79984d..a6950cc 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device Types / Socket Device / Feature bits}
 \begin{description}
 \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
 \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
+\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in
+	\field{data_max_size}. If offered by the device, device advises driver
+	about the value of its maximum payload size. If negotiated, the driver uses
+	\field{data_max_size} as the maximum packet payload size value.
 \end{description}
 
 \subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}
@@ -32,6 +36,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
 \begin{lstlisting}
 struct virtio_vsock_config {
 	le64 guest_cid;
+	le32 data_max_size;
 };
 \end{lstlisting}
 
@@ -57,6 +62,35 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
 \hline
 \end{tabular}
 
+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.
+
+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+The device MUST set \field{data_max_size} to between 0 and 65536 inclusive, if
+it offers VIRTIO_VSOCK_F_SIZE_MAX.
+
+The device MUST NOT modify \field{data_max_size} once it has been set.
+
+The device MUST NOT pass received packets that exceed \field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully
+negotiated.
+
+The device MUST forward transmitted packets of up to \field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully
+negotiated.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device offers it.
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST supply receive
+buffers that don't exceed the size \field{data_max_size} (plus header length).
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT transmit packets
+of size exceeding the value of \field{data_max_size} (plus header length).
+
 \subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}
 
 \begin{enumerate}
Signature · 23 lines
2.17.1




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/
#1 lore raw
Quoted 11 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
 virtio-vsock.tex | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

(...)

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device · line 74

Quoted 6 lines

+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +5 -0
+
+The device MUST set \field{data_max_size} to between 0 and 65536 inclusive, if
+it offers VIRTIO_VSOCK_F_SIZE_MAX.
+
+The device MUST NOT modify \field{data_max_size} once it has been set.

I'm not sure this is the best way to frame this. Maybe

"The device MUST NOT change the value exposed through \field{data_max_size}."

?

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#3 lore raw
In reply to Laura Loghin
Quoted 39 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
virtio-vsock.tex | 34 ++++++++++++++++++++++++++++++++++

1 file changed, 34 insertions(+)
virtio-vsock.tex +0 -0
index d79984d..a6950cc 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device Types / Socket Device / Feature bits}
 \begin{description}

\item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported. \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported. +\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in

virtio-vsock.tex +3 -0
+	\field{data_max_size}. If offered by the device, device advises driver
+	about the value of its maximum payload size. If negotiated, the driver uses
+	\field{data_max_size} as the maximum packet payload size value.

\end{description}

\subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +1 -0
@@ -32,6 +36,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
 \begin{lstlisting}
 struct virtio_vsock_config {
 	le64 guest_cid;
+	le32 data_max_size;
 };
 \end{lstlisting}
 
@@ -57,6 +62,35 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device

\hline
\end{tabular}

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device · line 67

Quoted 3 lines
virtio-vsock.tex +3 -0
+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.

Should we also define the maximum payload size when the feature is not negotiated? We never defined it, but the current implementation does not use payloads larger than 64k.

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device

Quoted 4 lines
virtio-vsock.tex +4 -0
+
+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+The device MUST set \field{data_max_size} to between 0 and 65536 

IIUC, this value is the maximum the device can manage, but then the driver can always allocate smaller buffers both for TX and RX, so maybe we could not put a limit, at the end the device can say what it wants, the driver must only avoid to exceed that value.

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device · line 78

Quoted 8 lines

inclusive, if

virtio-vsock.tex +7 -0
+it offers VIRTIO_VSOCK_F_SIZE_MAX.
+
+The device MUST NOT modify \field{data_max_size} once it has been set.
+
+The device MUST NOT pass received packets that exceed \field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully
+negotiated.

For the device the limit is anyway the buffer (allocated by the driver) it finds in RX, so I don't know if this sentence is useful.

Quoted 17 lines
virtio-vsock.tex +15 -0
+
+The device MUST forward transmitted packets of up to \field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully
+negotiated.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device offers it.
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST supply receive
+buffers that don't exceed the size \field{data_max_size} (plus header length).
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT transmit packets
+of size exceeding the value of \field{data_max_size} (plus header length).
+

\subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}

Quoted 2 lines

\begin{enumerate}
-- 2.17.1

I don't know if it is useful to define also a minimum size for the RX buffers. It could be useful for example when we will support datagram, we could use it to make driver allocate buffers that can contain entire datagram.

For now since we only support socket stream maybe it's not useful, so we can postpone it. And maybe it's not useful even with datagram if we support mergable buffers.

Thanks,
Stefano

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#4 lore raw
Quoted 50 lines · Stefano Garzarella

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

Quoted 45 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
virtio-vsock.tex | 34 ++++++++++++++++++++++++++++++++++

1 file changed, 34 insertions(+)
virtio-vsock.tex +0 -0
index d79984d..a6950cc 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device Types / 
 Socket Device / Feature bits}
 \begin{description}

\item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported. \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported. +\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in
+      \field{data_max_size}. If offered by the device, device advises driver
+      about the value of its maximum payload size. If negotiated, the driver uses
+      \field{data_max_size} as the maximum packet payload size value. \end{description}

\subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +0 -0
@@ -32,6 +36,7 @@ \subsection{Device configuration 

layout}\label{sec:Device Types / Socket Device
\begin{lstlisting}
struct virtio_vsock_config {
      le64 guest_cid;
+      le32 data_max_size;
};
\end{lstlisting}

virtio-vsock.tex +0 -0
@@ -57,6 +62,35 @@ \subsection{Device configuration 

layout}\label{sec:Device Types / Socket Device
\hline
\end{tabular}

Quoted 10 lines
Quoted 5 lines

+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.

Should we also define the maximum payload size when the feature is not negotiated?
We never defined it, but the current implementation does not use payloads larger than 64k.

Hmm I don't know exactly how the spec applies to the vsock. So do we consider the linux implementation as the "standard" one? In case the driver/device implementation accepted payloads larger than 64k before, then they will be forced now to negotiate data_max_size because of the fixed default value? Or that implementation was considered as not being compliant to the spec? I'm not exactly sure how backwards compatibility works here.

Quoted 11 lines

virtio-vsock.tex

Quoted 6 lines

+
+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+The device MUST set \field{data_max_size} to between 0 and 65536

IIUC, this value is the maximum the device can manage, but then the driver can always allocate smaller buffers both for TX and RX, so maybe we could not put a limit, at the end the device can say what it wants, the driver must only avoid to exceed that value.

True, I was thinking that a hard limit might be useful here, but I don't have a strong preference. I can remove this.

Quoted 15 lines
Quoted 11 lines

inclusive, if

virtio-vsock.tex +5 -0
+it offers VIRTIO_VSOCK_F_SIZE_MAX.
+
+The device MUST NOT modify \field{data_max_size} once it has been set.
+
+The device MUST NOT pass received packets that exceed 

\field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully
+negotiated.

For the device the limit is anyway the buffer (allocated by the driver) it finds in RX, so I don't know if this sentence is useful.

Yes, I don't think this sentence is needed, I'll remove it.

Quoted 25 lines
Quoted 25 lines
virtio-vsock.tex +2 -0
+
+The device MUST forward transmitted packets of up to 

\field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully

virtio-vsock.tex +3 -0
+negotiated.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device 

Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device 

offers it.

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST supply 

receive
+buffers that don't exceed the size \field{data_max_size} (plus header length).

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT 

transmit packets
+of size exceeding the value of \field{data_max_size} (plus header
length).
+
\subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}

Quoted 5 lines
Quoted 2 lines

\begin{enumerate}
-- 2.17.1

I don't know if it is useful to define also a minimum size for the RX buffers.

The reason for that would be to not work with a large number of descriptor chains for a packet?

Quoted 11 lines

It could be useful for example when we will support datagram, we could use it to make driver allocate buffers that can contain entire datagram.

For now since we only support socket stream maybe it's not useful, so we can postpone it. And maybe it's not useful even with datagram if we support mergable buffers.

Thanks,
Stefano

Thanks,
Laura

Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.

#5 lore raw
Quoted 62 lines · Laura Loghin
Quoted 50 lines · Stefano Garzarella

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

Quoted 45 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
virtio-vsock.tex | 34 ++++++++++++++++++++++++++++++++++

1 file changed, 34 insertions(+)
virtio-vsock.tex +0 -0
index d79984d..a6950cc 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device 
 Types / Socket Device / Feature bits}
 \begin{description}

\item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported. \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported. +\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in
+      \field{data_max_size}. If offered by the device, device advises driver
+      about the value of its maximum payload size. If negotiated, the driver uses
+      \field{data_max_size} as the maximum packet payload size value. \end{description}

\subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +0 -0
@@ -32,6 +36,7 @@ \subsection{Device configuration 

layout}\label{sec:Device Types / Socket Device
\begin{lstlisting}
struct virtio_vsock_config {
      le64 guest_cid;
+      le32 data_max_size;
};
\end{lstlisting}

virtio-vsock.tex +0 -0
@@ -57,6 +62,35 @@ \subsection{Device configuration 

layout}\label{sec:Device Types / Socket Device
\hline
\end{tabular}

Quoted 10 lines
Quoted 5 lines

+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.

Should we also define the maximum payload size when the feature is not negotiated?
We never defined it, but the current implementation does not use payloads larger than 64k.

Quoted 2 lines

Hmm I don't know exactly how the spec applies to the vsock. So do we consider the linux implementation as the "standard" one? In case the

For the driver, I suppose the linux could be the "standard".

Quoted 2 lines

driver/device
implementation accepted payloads larger than 64k before, then they will be

I'm not sure, IIRC we were limited to 4K, then we increased to 64K for the TX:
0038ff357f05 vsock/virtio: change the maximum packet size allowed
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0038ff357f05fee242aa4e5ec5e75f83fa1ed28c

Quoted 3 lines

forced now to negotiate data_max_size because of the fixed default value? Or that implementation was considered as not being compliant to the spec? I'm not exactly sure how backwards compatibility works here.

Yes, I think we can avoid that. When the flag is not negotiated, the driver sets the buffer it wants.

Quoted 54 lines
Quoted 11 lines

virtio-vsock.tex

Quoted 6 lines

+
+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+The device MUST set \field{data_max_size} to between 0 and 65536

IIUC, this value is the maximum the device can manage, but then the driver can always allocate smaller buffers both for TX and RX, so maybe we could not put a limit, at the end the device can say what it wants, the driver must only avoid to exceed that value.

True, I was thinking that a hard limit might be useful here, but I don't have a strong preference. I can remove this.

Quoted 15 lines
Quoted 11 lines

inclusive, if

virtio-vsock.tex +5 -0
+it offers VIRTIO_VSOCK_F_SIZE_MAX.
+
+The device MUST NOT modify \field{data_max_size} once it has been set.
+
+The device MUST NOT pass received packets that exceed 

\field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully
+negotiated.

For the device the limit is anyway the buffer (allocated by the driver) it finds in RX, so I don't know if this sentence is useful.

Yes, I don't think this sentence is needed, I'll remove it.

Quoted 25 lines
Quoted 25 lines
virtio-vsock.tex +2 -0
+
+The device MUST forward transmitted packets of up to 

\field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully

virtio-vsock.tex +3 -0
+negotiated.
+
+\drivernormative{\subsubsection}{Device configuration 

layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device 

offers it.

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST supply 

receive
+buffers that don't exceed the size \field{data_max_size} (plus header length).

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT 

transmit packets
+of size exceeding the value of \field{data_max_size} (plus header
length).
+
\subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

\begin{enumerate}
-- 2.17.1

I don't know if it is useful to define also a minimum size for the RX buffers.

The reason for that would be to not work with a large number of descriptor chains for a packet?

Yes, exactly. I don't know if it makes sense to have it in the configuration, though.

Thanks,
Stefano

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#6 lore raw
Quoted 156 lines · Stefano Garzarella

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

Quoted 65 lines · Laura Loghin
Quoted 53 lines · Stefano Garzarella

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

Quoted 46 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
virtio-vsock.tex | 34 ++++++++++++++++++++++++++++++++++

1 file changed, 34 insertions(+)
virtio-vsock.tex +0 -0
index d79984d..a6950cc 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device
 Types / Socket Device / Feature bits}
 \begin{description}

\item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported. \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported. +\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in
+      \field{data_max_size}. If offered by the device, device advises driver
+      about the value of its maximum payload size. If negotiated, the driver uses
+      \field{data_max_size} as the maximum packet payload size value. \end{description}

\subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +0 -0
@@ -32,6 +36,7 @@ \subsection{Device configuration

layout}\label{sec:Device Types / Socket Device
\begin{lstlisting}
struct virtio_vsock_config {
      le64 guest_cid;
+      le32 data_max_size;
};
\end{lstlisting}

virtio-vsock.tex +0 -0
@@ -57,6 +62,35 @@ \subsection{Device configuration

layout}\label{sec:Device Types / Socket Device
\hline
\end{tabular}

Quoted 10 lines
Quoted 5 lines

+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.

Should we also define the maximum payload size when the feature is not negotiated?
We never defined it, but the current implementation does not use payloads larger than 64k.

Quoted 2 lines

Hmm I don't know exactly how the spec applies to the vsock. So do we consider the linux implementation as the "standard" one? In case the

For the driver, I suppose the linux could be the "standard".

Quoted 2 lines

driver/device
implementation accepted payloads larger than 64k before, then they will be

I'm not sure, IIRC we were limited to 4K, then we increased to 64K for the TX:
0038ff357f05 vsock/virtio: change the maximum packet size allowed
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0038ff357f05fee242aa4e5ec5e75f83fa1ed28c

Quoted 3 lines

forced now to negotiate data_max_size because of the fixed default value? Or that implementation was considered as not being compliant to the spec? I'm not exactly sure how backwards compatibility works here.

Yes, I think we can avoid that. When the flag is not negotiated, the driver sets the buffer it wants.

Quoted 65 lines
Quoted 12 lines

virtio-vsock.tex

Quoted 7 lines

+
+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+The device MUST set \field{data_max_size} to between 0 and 65536

IIUC, this value is the maximum the device can manage, but then the driver can always allocate smaller buffers both for TX and RX, so maybe we could not put a limit, at the end the device can say what it wants, the driver must only avoid to exceed that value.

True, I was thinking that a hard limit might be useful here, but I don't have
a strong preference. I can remove this.

Quoted 16 lines
Quoted 8 lines

inclusive, if

virtio-vsock.tex +3 -0
+it offers VIRTIO_VSOCK_F_SIZE_MAX.
+
+The device MUST NOT modify \field{data_max_size} once it has been 

set.

virtio-vsock.tex +2 -0
+
+The device MUST NOT pass received packets that exceed
Quoted 4 lines

\field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully
+negotiated.

For the device the limit is anyway the buffer (allocated by the driver) it finds in RX, so I don't know if this sentence is useful.

Yes, I don't think this sentence is needed, I'll remove it.

Quoted 32 lines
Quoted 27 lines
virtio-vsock.tex +2 -0
+
+The device MUST forward transmitted packets of up to

\field{data_max_size}
+(plus header length) size after VIRTIO_VSOCK_F_SIZE_MAX has been successfully

virtio-vsock.tex +3 -0
+negotiated.
+
+\drivernormative{\subsubsection}{Device configuration

layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device

offers it.

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST supply

receive
+buffers that don't exceed the size \field{data_max_size} (plus header length).

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST NOT

transmit packets
+of size exceeding the value of \field{data_max_size} (plus header length).
+
\subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}

Quoted 2 lines

\begin{enumerate}
-- 2.17.1

I don't know if it is useful to define also a minimum size for the RX buffers.

Quoted 6 lines
Quoted 2 lines

The reason for that would be to not work with a large number of descriptor chains for a packet?

Yes, exactly. I don't know if it makes sense to have it in the configuration, though.

Right now I don't see it there as well.

Quoted 2 lines

Thanks,
Stefano

I addressed your comments in v2:
https://lists.oasis-open.org/archives/virtio-comment/202204/msg00062.html.
Please have a look!

Quoted 9 lines

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Quoted 9 lines

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.

#7 lore raw
In reply to Laura Loghin

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device · line 67

Quoted 7 lines · Laura Loghin
virtio-vsock.tex +3 -0
@@ -57,6 +62,35 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
 \hline
 \end{tabular}
 
+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.

This wording can be misinterpreted but can be kept for now. This wording should be updated when the next field is added in the future, indicating that the field is only *used* when VIRTIO_VSOCK_F_SIZE_MAX has been negotiated. Further fields will be located after data_max_size so the field certainly *exists* even when VIRTIO_VSOCK_F_SIZE_MAX is not set.

If someone misinterprets this they might think the config struct layout depends on the combination of negotiated feature bits. That's not the case, the layout is always the same. The size of the struct depends on the features offered by the device.

Similar wording is used elsewhere in the spec, so we may want to clarify it for the entire spec.

Stefan

#8 lore raw
Quoted 19 lines · Stefan Hajnoczi

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device · line 67

Quoted 7 lines · Laura Loghin
virtio-vsock.tex +3 -0
@@ -57,6 +62,35 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
  \hline
  \end{tabular}
 
+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.

This wording can be misinterpreted but can be kept for now. This wording should be updated when the next field is added in the future, indicating that the field is only *used* when VIRTIO_VSOCK_F_SIZE_MAX has been negotiated. Further fields will be located after data_max_size so the field certainly *exists* even when VIRTIO_VSOCK_F_SIZE_MAX is not set.

If someone misinterprets this they might think the config struct layout depends on the combination of negotiated feature bits. That's not the case, the layout is always the same. The size of the struct depends on the features offered by the device.

Quoted 4 lines

Similar wording is used elsewhere in the spec, so we may want to clarify it for the entire spec.

Stefan

Yes, I agree with you. In fact when I added this section I had a look at the corresponding ones from other devices, and got confused by the wording. My understanding actually was that the field won't exist, but indeed I found it pretty weird, so it would be great if we can update all the spec sections that are propagating this misinterpretation. For now, I will update the section in this patch.

Thanks,
Laura

Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.

#9 lore raw
Quoted 22 lines · Laura Loghin
Quoted 21 lines · Stefan Hajnoczi

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device · line 66

Quoted 6 lines · Laura Loghin
virtio-vsock.tex +3 -0
@@ -57,6 +62,35 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
  \hline
  \end{tabular}
+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.

This wording can be misinterpreted but can be kept for now. This wording should be updated when the next field is added in the future, indicating that the field is only *used* when VIRTIO_VSOCK_F_SIZE_MAX has been negotiated. Further fields will be located after data_max_size so the field certainly *exists* even when VIRTIO_VSOCK_F_SIZE_MAX is not set.

If someone misinterprets this they might think the config struct layout depends on the combination of negotiated feature bits. That's not the case, the layout is always the same. The size of the struct depends on the features offered by the device.

Similar wording is used elsewhere in the spec, so we may want to clarify it for the entire spec.

Quoted 8 lines
Quoted 1 line

Stefan

Yes, I agree with you. In fact when I added this section I had a look at the corresponding ones from other devices, and got confused by the wording. My understanding actually was that the field won't exist, but indeed I found it pretty weird, so it would be great if we can update all the spec sections that are propagating this misinterpretation. For now, I will update the section in this patch.

Thanks!

Stefan