Skip to contentSkip to conversation

introduce IPsec Operation in virtio-net

RFC PATCH Superseded Srujana Challa 2 participants 10 messages Jan 22, 2025 – Mar 28, 2025

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover introduce IPsec Operation in virtio-net

This series enhances virtio-net by adding support for IPsec Operation. These patches aim to extend the capabilities of virtio-net, enabling it to handle IPsec operations efficiently. This enables the offloading of IPsec processing, both before transmission and after reception, thereby providing inline offload capabilities.

It is using new virtio basic facilities of capability and resource objects. Below is a summary of the changes introduced:

Patch1:
This patch introduces the foundational support for IPsec within the virtio-net framework, outlining the necessary capabilities and resource objects for IPsec operations.

Patch2:
This patch introduces a new selector and action necessary for IPsec processing, leveraging flow filter actions.

Patch3:
This patch introduces new fields in "struct virtio_net_hdr" to to support IPsec functionality.

Patch4:
This patch specifies the requirements for both the device and the driver to support IPsec operations.

These enhancements are for providing support for IPsec within the virtio-net device/driver, improving security and performance for virtualized environments. We believe these additions will significantly benefit users who rely on virtio-net for secure data transmission.

This series references the Virtio-crypto IPsec service operation capabilities and resource objects data structures, and cryptographic algorithm definitions to avoid duplication, however the admin command type vaule differs between Virtio-crypto and Virtio-net.

depends-on: https://lore.kernel.org/virtio-comment/[email protected]/

v2:
- Addressed the review comments from Parav Pandit.

Srujana Challa (4):
virtio-net: Add IPsec operation, capabilities and resource objects
virtio-net: Add new flow filter selector and action for IPsec
virtio-net: extend virtio_net_hdr for IPsec support
virtio-net: Add IPsec operation device and driver requirements

 device-types/net/description.tex        | 195 +++++++++++++++++++++++-
 device-types/net/device-conformance.tex |   1 +
 device-types/net/driver-conformance.tex |   1 +
 3 files changed, 192 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH v2 1/4 virtio-net: Add IPsec operation, capabilities and resource objects

This commit introduces the IPsec Operation to the Net device along with the capabilities and resource objects. This enables the offloading of IPsec processing, both before transmission and after reception, thereby providing inline offload capabilities.

Capbilities:

1. IPsec Resource Capability (VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP):
Indicates the device's IPsec resource limits, such as the number of encryption and decryption Security Associations (SAs).
2. IPsec SA Capability (VIRTIO_CRYPTO_IPSEC_SA_CAP): Specifies the supported IPsec modes, along with the supported cryptographic algorithms, authentication algorithms, IPsec options and anti-replay window size.

Resource objects:
1. VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA
2. VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA

These IPsec SA resource objects encompass parameters necessary for packet encryption and decryption. These include the SPI, tunnel headers, IPsec mode, IPsec options, and metadata specific to cipher and authentication.

This patch refers the Virtio-crypto IPsec service operation capabilities and resource objects data structures and crypto algorithm definitions to avoid duplication, however the admin command type vaule differs between Virtio-crypto and Virtio-net.

---
 device-types/net/description.tex | 49 ++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
device-types/net/description.tex +49 -0
index b2a0d39..020d090 100644
@@ -124,6 +124,8 @@ \subsection{Feature bits}\label{sec:Device Types / Network Device / Feature bits
 \item[VIRTIO_NET_F_SPEED_DUPLEX(63)] Device reports speed and duplex.
 
 \item[VIRTIO_NET_F_RSS_CONTEXT(64)] Device supports multiple RSS contexts.
+
+\item[VIRTIO_NET_F_IPSEC(69)] Device supports inline IPsec processing.
 \end{description}
 
 \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device / Feature bits / Feature bit requirements}
@@ -415,6 +417,10 @@ \subsection{Device and driver capabilities}\label{sec:Device Types / Network Dev
 \hline
 0x0802 & \hyperref[par:Device Types / Network Device / Device Operation / Flow filter / Device and driver capabilities / VIRTIO-NET-FF-ACTION-CAP]{VIRTIO_NET_FF_ACTION_CAP} & Flow filter action capability \\
 \hline
+0x0803 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP]{VIRTIO_NET_IPSEC_RESOURCE_CAP} & IPsec resource capability \\
+\hline
+0x0804 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_NET_IPSEC_SA_CAP} & IPsec Security Association(SA) capability \\
+\hline
 \end{tabularx}
 
 \subsection{Device resource objects}\label{sec:Device Types / Network Device / Device resource objects}
@@ -431,6 +437,10 @@ \subsection{Device resource objects}\label{sec:Device Types / Network Device / D
 \hline
 0x0202 & \hyperref[par:Device Types / Network Device / Device Operation / Flow filter / Resource objects / VIRTIO-NET-RESOURCE-OBJ-FF-RULE]{VIRTIO_NET_RESOURCE_OBJ_FF_RULE} & Flow filter rule object \\
 \hline
+0x0203 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA} & IPsec outbound SA resource object \\
+\hline
+0x0204 & \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA} & IPsec inbound SA resource object \\
+\hline
 \end{tabularx}
 
 \subsection{Device Operation}\label{sec:Device Types / Network Device / Device Operation}
@@ -3020,6 +3030,45 @@ \subsubsection{Flow filter}\label{sec:Device Types / Network Device / Device Ope
 capability and the classifier object, unless the VIRTIO_NET_FF_MASK_F_PARTIAL_MASK
 is enabled.
 
+\subsubsection{IPsec Operation}\label{sec:Device Types / Network Device / Device Operation / IPsec Operation}
+
+A network device can support the processing of IPsec operations when
+VIRTIO_NET_F_IPSEC feature is negotiated. In addition to standard packet
+processing, the IPsec protocol processing is also handled by the network device.
+This occurs both pre-transmit and post-receive, providing inline IPsec capabilities.
+
+IPsec Inbound processing: In receive path the device will perform decryption,
+authentication, integrity checking and remove additional headers, including
+tunnel header if in tunnel mode, as well as the ESP/AH header from the packet
+(See \hyperref[intro:IPSEC]{[IPSEC]}). The resulting packet contains only the plain data.
+
+IPsec Outbound processing: In transmit path the device will perform encryption,
+attach ICV, update/add IP header and add ESP/AH header/trailer to the packet
+and transmit.
+
+\paragraph{Device and driver capabilities}
+\label{par:Device Types / Network Device / Device Operation / IPsec Operation / Device and driver capabilities}
+
+The device and the driver indicate IPsec SA resource limits using the capability
+\hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP]{VIRTIO_NET_IPSEC_RESOURCE_CAP}
+The \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Device and driver capabilities / VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_NET_IPSEC_SA_CAP}
+capability specifies which IPsec protocol capabilities the device supports. The driver indicates
+the IPsec parameters by setting the IPsec SA capability prior to adding any resource objects.
+
+\paragraph{Resource objects}
+\label{par:Device Types / Network Device / Device Operation / IPsec Operation / Resource objects}
+
+The driver controls the IPsec SA resource object using administration commands described in
+\ref{sec:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device resource objects}.
+
+The IPsec SA resource object contains necessary parameters for packet
+encryption and decryption. These include the SPI, tunnel headers, IPsec mode,
+IPsec options, and data specific to cipher and authentication.
+
+See \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA}.
+
+See \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA}.
+
 \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device
 Types / Network Device / Legacy Interface: Framing Requirements}
 
Signature · 1 line
2.25.1
#2 lore raw

RE: [PATCH RFC v2 1/4] virtio-net: Add IPsec operation, capabilities and resource objects

Quoted 111 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:52 AM

This commit introduces the IPsec Operation to the Net device along with the capabilities and resource objects. This enables the offloading of IPsec processing, both before transmission and after reception, thereby providing inline offload capabilities.

Capbilities:

1. IPsec Resource Capability (VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP):
Indicates the device's IPsec resource limits, such as the number of encryption and decryption Security Associations (SAs).
2. IPsec SA Capability (VIRTIO_CRYPTO_IPSEC_SA_CAP): Specifies the supported IPsec modes, along with the supported cryptographic algorithms, authentication algorithms, IPsec options and anti-replay window size.

Resource objects:
1. VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA
2. VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA

These IPsec SA resource objects encompass parameters necessary for packet encryption and decryption. These include the SPI, tunnel headers, IPsec mode, IPsec options, and metadata specific to cipher and authentication.

This patch refers the Virtio-crypto IPsec service operation capabilities and resource objects data structures and crypto algorithm definitions to avoid duplication, however the admin command type vaule differs between Virtio- crypto and Virtio-net.

---
 device-types/net/description.tex | 49
++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex
index b2a0d39..020d090 100644

device-types/net/description.tex +0 -0
@@ -124,6 +124,8 @@ \subsection{Feature bits}\label{sec:Device Types /

Network Device / Feature bits \item[VIRTIO_NET_F_SPEED_DUPLEX(63)] Device reports speed and duplex.

\item[VIRTIO_NET_F_RSS_CONTEXT(64)] Device supports multiple RSS
contexts.
+
+\item[VIRTIO_NET_F_IPSEC(69)] Device supports inline IPsec processing.
\end{description}

\subsubsection{Feature bit requirements}\label{sec:Device Types / Network
Device / Feature bits / Feature bit requirements} @@ -415,6 +417,10 @@ \subsection{Device and driver capabilities}\label{sec:Device Types / Network Dev \hline
0x0802 & \hyperref[par:Device Types / Network Device / Device Operation /
Flow filter / Device and driver capabilities / VIRTIO-NET-FF-ACTION- CAP]{VIRTIO_NET_FF_ACTION_CAP} & Flow filter action capability \\ \hline +0x0803 & \hyperref[par:Device Types / Crypto Device / Device Operation

device-types/net/description.tex +2 -0
+/ IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP]{VIRTIO_NET_IPSEC_RESOURCE_CAP}

&

device-types/net/description.tex +5 -0
+IPsec resource capability \\ \hline
+0x0804 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_NET_IPSEC_SA_CAP} & IPsec Security
+Association(SA) capability \\ \hline
 \end{tabularx}
 
 \subsection{Device resource objects}\label{sec:Device Types / Network

Device / Device resource objects} @@ -431,6 +437,10 @@ \subsection{Device resource objects}\label{sec:Device Types / Network Device / D \hline
0x0202 & \hyperref[par:Device Types / Network Device / Device Operation /
Flow filter / Resource objects / VIRTIO-NET-RESOURCE-OBJ-FF- RULE]{VIRTIO_NET_RESOURCE_OBJ_FF_RULE} & Flow filter rule object \\
\hline
+0x0203 & \hyperref[par:Device Types / Crypto Device / Device Operation

device-types/net/description.tex +2 -0
+/ IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-OUTBOUND-

SA]{VIRTIO_NET_RESOURCE_OBJ_I

device-types/net/description.tex +4 -0
+PSEC_OUTB_SA} & IPsec outbound SA resource object \\ \hline
+0x0204 & \hyperref[par:Device Types / Crypto Device / Device Operation
+/ IPsec Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-

SA]{VIRTIO_NET_RESOURCE_OBJ_IP
+SEC_INB_SA} & IPsec inbound SA resource object \\ \hline
\end{tabularx}

\subsection{Device Operation}\label{sec:Device Types / Network Device /
Device Operation} @@ -3020,6 +3030,45 @@ \subsubsection{Flow filter}\label{sec:Device Types / Network Device / Device Ope capability and the classifier object, unless the VIRTIO_NET_FF_MASK_F_PARTIAL_MASK is enabled.

+\subsubsection{IPsec Operation}\label{sec:Device Types / Network Device

device-types/net/description.tex +5 -0
+/ Device Operation / IPsec Operation}
+
+A network device can support the processing of IPsec operations when
+VIRTIO_NET_F_IPSEC feature is negotiated. In addition to standard
+packet processing, the IPsec protocol processing is also handled by the

network device.
+This occurs both pre-transmit and post-receive, providing inline IPsec capabilities.

device-types/net/description.tex +5 -0
+
+IPsec Inbound processing: In receive path the device will perform
+decryption, authentication, integrity checking and remove additional
+headers, including tunnel header if in tunnel mode, as well as the
+ESP/AH header from the packet (See \hyperref[intro:IPSEC]{[IPSEC]}). The
Quoted 2 lines

resulting packet contains only the plain data.
+

The device performs..
Please use the present tense, check the crypto series as well.

device-types/net/description.tex

Quoted 4 lines
device-types/net/description.tex +4 -0
+IPsec Outbound processing: In transmit path the device will perform
+encryption, attach ICV, update/add IP header and add ESP/AH
+header/trailer to the packet and transmit.
+

Use present tense.
Like how you wrote below for example, 'the driver controls'.

Quoted 40 lines

+\paragraph{Device and driver capabilities} \label{par:Device Types /

device-types/net/description.tex +12 -0
+Network Device / Device Operation / IPsec Operation / Device and driver
+capabilities}
+
+The device and the driver indicate IPsec SA resource limits using the
+capability \hyperref[par:Device Types / Crypto Device / Device
+Operation / IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-RESOURCE-CAP]{VIRTIO_NET_IPSEC_RESOURCE_CAP}
+The \hyperref[par:Device Types / Crypto Device / Device Operation /
+IPsec Service Operation / Device and driver capabilities /
+VIRTIO-CRYPTO-IPSEC-SA-CAP]{VIRTIO_NET_IPSEC_SA_CAP}
+capability specifies which IPsec protocol capabilities the device
+supports. The driver indicates the IPsec parameters by setting the IPsec SA

capability prior to adding any resource objects.

device-types/net/description.tex +7 -0
+
+\paragraph{Resource objects}
+\label{par:Device Types / Network Device / Device Operation / IPsec
+Operation / Resource objects}
+
+The driver controls the IPsec SA resource object using administration
+commands described in \ref{sec:Basic Facilities of a Virtio Device / Device

groups / Group administration commands / Device resource objects}.

device-types/net/description.tex +6 -0
+
+The IPsec SA resource object contains necessary parameters for packet
+encryption and decryption. These include the SPI, tunnel headers, IPsec
+mode, IPsec options, and data specific to cipher and authentication.
+
+See \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec

Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC- OUTBOUND-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA}.

device-types/net/description.tex +2 -0
+
+See \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec

Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC- INBOUND-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA}.
+
\subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device
Types / Network Device / Legacy Interface: Framing Requirements}

--
2.25.1

#3 lore raw

RFC PATCH v2 2/4 virtio-net: Add new flow filter selector and action for IPsec

In reply to Srujana Challa

This update introduces a new flow filter selector to match the ESP header and adds a new flow filter action for IPsec processing.

---
 device-types/net/description.tex | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
device-types/net/description.tex +20 -3
index 020d090..cef109d 100644
@@ -2634,7 +2634,9 @@ \subsubsection{Flow filter}\label{sec:Device Types / Network Device / Device Ope
 \hline
 0x5 & VIRTIO_NET_FF_MASK_TYPE_UDP & 8 bytes of UDP header described in \hyperref[intro:UDP]{UDP} \\
 \hline
-0x6 - 0xFF & & Reserved for future \\
+0x6 & VIRTIO_NET_FF_MASK_TYPE_ESP & 8 bytes of ESP header \\
+\hline
+0x7 - 0xFF & & Reserved for future \\
 \hline
 \end{tabularx}
 \end{table}
@@ -2694,7 +2696,11 @@ \subsubsection{Flow filter}\label{sec:Device Types / Network Device / Device Ope
 \hline
 0x2 & VIRTIO_NET_FF_ACTION_DIRECT_RX_VQ & Matching packet will be directed to a receive queue \\
 \hline
-0x3 - 0xFF & & Reserved for future \\
+0x3 & VIRTIO_NET_FF_ACTION_IPSEC & Matching packet will undergo IPsec processing \\
+\hline
+0x4 & VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE & Matching packet will first undergo IPsec processing, followed by the flow filter rules again \\
+\hline
+0x5 - 0xFF & & Reserved for future \\
 \hline
 \end{tabularx}
 \end{table}
@@ -2748,7 +2754,8 @@ \subsubsection{Flow filter}\label{sec:Device Types / Network Device / Device Ope
 The first selector is always VIRTIO_NET_FF_MASK_TYPE_ETH. When there are multiple
 selectors, a second selector can be either VIRTIO_NET_FF_MASK_TYPE_IPV4
 or VIRTIO_NET_FF_MASK_TYPE_IPV6. If the third selector exists, the third
-selector can be either VIRTIO_NET_FF_MASK_TYPE_UDP or VIRTIO_NET_FF_MASK_TYPE_TCP.
+selector can be one of VIRTIO_NET_FF_MASK_TYPE_UDP, VIRTIO_NET_FF_MASK_TYPE_TCP
+and VIRTIO_NET_FF_MASK_TYPE_ESP.
 For example, to match a Ethernet IPv6 UDP packet,
 \field{selectors[0].type} is set to VIRTIO_NET_FF_MASK_TYPE_ETH, \field{selectors[1].type}
 is set to VIRTIO_NET_FF_MASK_TYPE_IPV6 and \field{selectors[2].type} is
@@ -3046,6 +3053,16 @@ \subsubsection{IPsec Operation}\label{sec:Device Types / Network Device / Device
 attach ICV, update/add IP header and add ESP/AH header/trailer to the packet
 and transmit.
 
+\paragraph{Packet processing order}
+\label{par:Device Types / Network Device / Device Operation / IPsec Operation / Packet processing order}
+
+If an IPsec action rule, either VIRTIO_NET_FF_ACTION_IPSEC or VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE,
+is matched during flow filter processing, then IPsec processing is applied on the packet.
+In the case of VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE, the packet is also recirculated.
+
+See \ref{sec:Device Types / Network Device / Device Operation / Flow filter}
+for details about flow filter.
+
 \paragraph{Device and driver capabilities}
 \label{par:Device Types / Network Device / Device Operation / IPsec Operation / Device and driver capabilities}
 
Signature · 1 line
2.25.1
#4 lore raw

RE: [PATCH RFC v2 2/4] virtio-net: Add new flow filter selector and action for IPsec

Quoted 49 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:52 AM

This update introduces a new flow filter selector to match the ESP header and adds a new flow filter action for IPsec processing.

---
 device-types/net/description.tex | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex
index 020d090..cef109d 100644

device-types/net/description.tex +0 -0
@@ -2634,7 +2634,9 @@ \subsubsection{Flow filter}\label{sec:Device Types

/ Network Device / Device Ope \hline
0x5 & VIRTIO_NET_FF_MASK_TYPE_UDP & 8 bytes of UDP header described
in \hyperref[intro:UDP]{UDP} \\ \hline
-0x6 - 0xFF & & Reserved for future \\
+0x6 & VIRTIO_NET_FF_MASK_TYPE_ESP & 8 bytes of ESP header \\ \hline +0x7 - 0xFF & & Reserved for future \\
\hline
\end{tabularx}
\end{table}

device-types/net/description.tex +0 -0
@@ -2694,7 +2696,11 @@ \subsubsection{Flow filter}\label{sec:Device

Types / Network Device / Device Ope \hline
0x2 & VIRTIO_NET_FF_ACTION_DIRECT_RX_VQ & Matching packet will be
directed to a receive queue \\ \hline
-0x3 - 0xFF & & Reserved for future \\
+0x3 & VIRTIO_NET_FF_ACTION_IPSEC & Matching packet will undergo IPsec

device-types/net/description.tex +5 -0
+processing \\ \hline
+0x4 & VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE & Matching packet will
+first undergo IPsec processing, followed by the flow filter rules again
+\\ \hline
+0x5 - 0xFF & & Reserved for future \\
 \hline
 \end{tabularx}
 \end{table}
@@ -2748,7 +2754,8 @@ \subsubsection{Flow filter}\label{sec:Device Types

/ Network Device / Device Ope The first selector is always VIRTIO_NET_FF_MASK_TYPE_ETH. When there are multiple selectors, a second selector can be either VIRTIO_NET_FF_MASK_TYPE_IPV4 or VIRTIO_NET_FF_MASK_TYPE_IPV6. If the third selector exists, the third - selector can be either VIRTIO_NET_FF_MASK_TYPE_UDP or VIRTIO_NET_FF_MASK_TYPE_TCP.

device-types/net/description.tex

Quoted 2 lines
device-types/net/description.tex +2 -0
+selector can be one of VIRTIO_NET_FF_MASK_TYPE_UDP,
+VIRTIO_NET_FF_MASK_TYPE_TCP and VIRTIO_NET_FF_MASK_TYPE_ESP.

If the third selector exists, it can be set to VIRTIO_NET_FF_MASK_TYPE_UDP, VIRTIO_NET_FF_MASK_TYPE_TCP, or VIRTIO_NET_FF_MASK_TYPE_ESP.

This reads better to indicating it is one of the choices.

Quoted 14 lines

For example, to match a Ethernet IPv6 UDP packet, \field{selectors[0].type}
is set to VIRTIO_NET_FF_MASK_TYPE_ETH, \field{selectors[1].type} is set to VIRTIO_NET_FF_MASK_TYPE_IPV6 and \field{selectors[2].type} is @@ - 3046,6 +3053,16 @@ \subsubsection{IPsec Operation}\label{sec:Device Types / Network Device / Device attach ICV, update/add IP header and add ESP/AH header/trailer to the packet and transmit.

+\paragraph{Packet processing order}
+\label{par:Device Types / Network Device / Device Operation / IPsec

device-types/net/description.tex +5 -0
+Operation / Packet processing order}
+
+If an IPsec action rule, either VIRTIO_NET_FF_ACTION_IPSEC or
+VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE,
+is matched during flow filter processing, then IPsec processing is applied on
Quoted 1 line

the packet.

I believe IPSEC processing should be limited to only type ACTION_IPSEC.
Can we keep the _ACTION_IPSEC_RECIRCULATE to just _ACTION_RECIRCULATE?
May be one will be able to use the generic recirculate action for macsec or some other decap operation too.

Quoted 3 lines

+In the case of VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE, the packet is also recirculated.
+

I think, better to say recirculate only once to avoid some infinite loop in the device. Otherwise, one may match on a field and just recirculate it without any real operation.

Quoted 8 lines
device-types/net/description.tex +3 -0
+See \ref{sec:Device Types / Network Device / Device Operation / Flow
+filter} for details about flow filter.
+
 \paragraph{Device and driver capabilities}  \label{par:Device Types / Network

Device / Device Operation / IPsec Operation / Device and driver capabilities}

--
2.25.1

#5 lore raw

RE: [PATCH RFC v2 2/4] virtio-net: Add new flow filter selector and action for IPsec

Quoted 64 lines
Quoted 16 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:52 AM

This update introduces a new flow filter selector to match the ESP header and adds a new flow filter action for IPsec processing.

---
 device-types/net/description.tex | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex index 020d090..cef109d 100644

device-types/net/description.tex +0 -0
@@ -2634,7 +2634,9 @@ \subsubsection{Flow filter}\label{sec:Device
Quoted 2 lines

Types / Network Device / Device Ope \hline
0x5 & VIRTIO_NET_FF_MASK_TYPE_UDP & 8 bytes of UDP header

described

Quoted 8 lines

in \hyperref[intro:UDP]{UDP} \\ \hline
-0x6 - 0xFF & & Reserved for future \\
+0x6 & VIRTIO_NET_FF_MASK_TYPE_ESP & 8 bytes of ESP header \\ \hline +0x7 - 0xFF & & Reserved for future \\
\hline
\end{tabularx}
\end{table}

device-types/net/description.tex +0 -0
@@ -2694,7 +2696,11 @@ \subsubsection{Flow filter}\label{sec:Device
Quoted 5 lines

Types / Network Device / Device Ope \hline
0x2 & VIRTIO_NET_FF_ACTION_DIRECT_RX_VQ & Matching packet will be
directed to a receive queue \\ \hline
-0x3 - 0xFF & & Reserved for future \\
+0x3 & VIRTIO_NET_FF_ACTION_IPSEC & Matching packet will undergo

IPsec

Quoted 2 lines

+processing \\ \hline
+0x4 & VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE & Matching packet

will

Quoted 13 lines
device-types/net/description.tex +3 -0
+first undergo IPsec processing, followed by the flow filter rules
+again \\ \hline
+0x5 - 0xFF & & Reserved for future \\
 \hline
 \end{tabularx}
 \end{table}
@@ -2748,7 +2754,8 @@ \subsubsection{Flow filter}\label{sec:Device

Types / Network Device / Device Ope The first selector is always VIRTIO_NET_FF_MASK_TYPE_ETH. When there are multiple selectors, a second selector can be either VIRTIO_NET_FF_MASK_TYPE_IPV4 or VIRTIO_NET_FF_MASK_TYPE_IPV6. If the third selector exists, the third
- selector can be either VIRTIO_NET_FF_MASK_TYPE_UDP or VIRTIO_NET_FF_MASK_TYPE_TCP.

device-types/net/description.tex

Quoted 2 lines
device-types/net/description.tex +2 -0
+selector can be one of VIRTIO_NET_FF_MASK_TYPE_UDP,
+VIRTIO_NET_FF_MASK_TYPE_TCP and VIRTIO_NET_FF_MASK_TYPE_ESP.

If the third selector exists, it can be set to VIRTIO_NET_FF_MASK_TYPE_UDP, VIRTIO_NET_FF_MASK_TYPE_TCP, or VIRTIO_NET_FF_MASK_TYPE_ESP.

This reads better to indicating it is one of the choices.

Quoted 8 lines

For example, to match a Ethernet IPv6 UDP packet,
\field{selectors[0].type} is set to VIRTIO_NET_FF_MASK_TYPE_ETH, \field{selectors[1].type} is set to VIRTIO_NET_FF_MASK_TYPE_IPV6 and \field{selectors[2].type} is @@ - 3046,6 +3053,16 @@ \subsubsection{IPsec Operation}\label{sec:Device Types / Network Device / Device attach ICV, update/add IP header and add ESP/AH header/trailer to the packet and transmit.

Quoted 14 lines
Quoted 9 lines

+\paragraph{Packet processing order}
+\label{par:Device Types / Network Device / Device Operation / IPsec

device-types/net/description.tex +6 -0
+Operation / Packet processing order}
+
+If an IPsec action rule, either VIRTIO_NET_FF_ACTION_IPSEC or
+VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE,
+is matched during flow filter processing, then IPsec processing is
+applied on

the packet.

I believe IPSEC processing should be limited to only type ACTION_IPSEC. Can we keep the _ACTION_IPSEC_RECIRCULATE to just _ACTION_RECIRCULATE?
May be one will be able to use the generic recirculate action for macsec or some other decap operation too.

I think chaining of the actions is required if we make IPSEC and RECIRCULATE
as separate actions and current spec doesn't support the chaining.
The current virtio spec states "Note that at most one action is ever taken for a given packet. If a rule is applied and an action is taken, the action of other rules is not taken." Thanks.

Quoted 18 lines
Quoted 4 lines

+In the case of VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE, the packet is also recirculated.
+

I think, better to say recirculate only once to avoid some infinite loop in the device.
Otherwise, one may match on a field and just recirculate it without any real operation.

Quoted 9 lines
device-types/net/description.tex +3 -0
+See \ref{sec:Device Types / Network Device / Device Operation / Flow
+filter} for details about flow filter.
+
 \paragraph{Device and driver capabilities}  \label{par:Device Types /

Network Device / Device Operation / IPsec Operation / Device and driver capabilities}

--
2.25.1

#6 lore raw

RE: [PATCH RFC v2 2/4] virtio-net: Add new flow filter selector and action for IPsec

Quoted 81 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, March 26, 2025 3:24 PM

Quoted 46 lines
Quoted 16 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:52 AM

This update introduces a new flow filter selector to match the ESP header and adds a new flow filter action for IPsec processing.

---
 device-types/net/description.tex | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex index 020d090..cef109d 100644

device-types/net/description.tex +0 -0
@@ -2634,7 +2634,9 @@ \subsubsection{Flow filter}\label{sec:Device
Quoted 2 lines

Types / Network Device / Device Ope \hline
0x5 & VIRTIO_NET_FF_MASK_TYPE_UDP & 8 bytes of UDP header

described

Quoted 8 lines

in \hyperref[intro:UDP]{UDP} \\ \hline
-0x6 - 0xFF & & Reserved for future \\
+0x6 & VIRTIO_NET_FF_MASK_TYPE_ESP & 8 bytes of ESP header \\ \hline +0x7 - 0xFF & & Reserved for future \\
\hline
\end{tabularx}
\end{table}

device-types/net/description.tex +0 -0
@@ -2694,7 +2696,11 @@ \subsubsection{Flow filter}\label{sec:Device
Quoted 5 lines

Types / Network Device / Device Ope \hline
0x2 & VIRTIO_NET_FF_ACTION_DIRECT_RX_VQ & Matching packet will be
directed to a receive queue \\ \hline
-0x3 - 0xFF & & Reserved for future \\
+0x3 & VIRTIO_NET_FF_ACTION_IPSEC & Matching packet will undergo

IPsec

Quoted 2 lines

+processing \\ \hline
+0x4 & VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE & Matching packet

will

Quoted 10 lines
device-types/net/description.tex +3 -0
+first undergo IPsec processing, followed by the flow filter rules
+again \\ \hline
+0x5 - 0xFF & & Reserved for future \\
 \hline
 \end{tabularx}
 \end{table}
@@ -2748,7 +2754,8 @@ \subsubsection{Flow filter}\label{sec:Device

Types / Network Device / Device Ope The first selector is always VIRTIO_NET_FF_MASK_TYPE_ETH. When there are multiple selectors, a second selector can be either VIRTIO_NET_FF_MASK_TYPE_IPV4 or

Quoted 8 lines

device-types/net/description.tex

Quoted 6 lines

VIRTIO_NET_FF_MASK_TYPE_IPV6. If the third selector exists, the third
- selector can be either VIRTIO_NET_FF_MASK_TYPE_UDP or VIRTIO_NET_FF_MASK_TYPE_TCP.

device-types/net/description.tex +2 -0
+selector can be one of VIRTIO_NET_FF_MASK_TYPE_UDP,
+VIRTIO_NET_FF_MASK_TYPE_TCP and VIRTIO_NET_FF_MASK_TYPE_ESP.

If the third selector exists, it can be set to VIRTIO_NET_FF_MASK_TYPE_UDP, VIRTIO_NET_FF_MASK_TYPE_TCP, or

VIRTIO_NET_FF_MASK_TYPE_ESP.

Quoted 11 lines

This reads better to indicating it is one of the choices.

Quoted 8 lines

For example, to match a Ethernet IPv6 UDP packet,
\field{selectors[0].type} is set to VIRTIO_NET_FF_MASK_TYPE_ETH, \field{selectors[1].type} is set to VIRTIO_NET_FF_MASK_TYPE_IPV6 and \field{selectors[2].type} is @@ - 3046,6 +3053,16 @@ \subsubsection{IPsec Operation}\label{sec:Device Types / Network Device / Device attach ICV, update/add IP header and add ESP/AH header/trailer to the packet and transmit.

Quoted 11 lines
Quoted 9 lines

+\paragraph{Packet processing order} \label{par:Device Types /

device-types/net/description.tex +7 -0
+Network Device / Device Operation / IPsec Operation / Packet
+processing order}
+
+If an IPsec action rule, either VIRTIO_NET_FF_ACTION_IPSEC or
+VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE,
+is matched during flow filter processing, then IPsec processing is
+applied on

the packet.

I believe IPSEC processing should be limited to only type ACTION_IPSEC. Can we keep the _ACTION_IPSEC_RECIRCULATE to just

Quoted 5 lines

_ACTION_RECIRCULATE?

Quoted 2 lines

May be one will be able to use the generic recirculate action for macsec or some other decap operation too.

I think chaining of the actions is required if we make IPSEC and RECIRCULATE as separate actions and current spec doesn't support the chaining.

The recirculate operation is doing more than one action anyway one after the other. So its fine to just have ACTION_RECIRCULATE.

Quoted 2 lines

The current virtio spec states "Note that at most one action is ever taken for a given packet.

This statement we need to extend anyway as,

Note that at most one action is every taken for a given packet, unless the action is RECIRCULATE.

I think _at_a_time there is still one action taken.
Its just that multiple rules are applied one after another due to the action _recirculate.

Quoted 2 lines

If a rule is applied and an action is taken, the action of other rules is not taken."

This still holds true. In your case the action=recirculate.

Quoted 20 lines

Thanks.

Quoted 19 lines
Quoted 5 lines
device-types/net/description.tex +2 -0
+In the case of VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE, the packet
+is

also recirculated.
+

I think, better to say recirculate only once to avoid some infinite loop in the device.
Otherwise, one may match on a field and just recirculate it without any real operation.

Quoted 9 lines
device-types/net/description.tex +3 -0
+See \ref{sec:Device Types / Network Device / Device Operation /
+Flow filter} for details about flow filter.
+
 \paragraph{Device and driver capabilities}  \label{par:Device Types

/ Network Device / Device Operation / IPsec Operation / Device and driver capabilities}

--
2.25.1

#7 lore raw

RFC PATCH v2 3/4 virtio-net: extend virtio_net_hdr for IPsec support

In reply to Srujana Challa

Add IPsec resource object identifiers to the virtio_net_hdr for identifying encryption/decryption operations on tx and rx side respectively, along with flags.

---
 device-types/net/description.tex | 44 ++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)
device-types/net/description.tex +42 -2
index cef109d..3616917 100644
@@ -455,6 +455,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O
 #define VIRTIO_NET_HDR_F_NEEDS_CSUM    1
 #define VIRTIO_NET_HDR_F_DATA_VALID    2
 #define VIRTIO_NET_HDR_F_RSC_INFO      4
+#define VIRTIO_NET_HDR_F_SECURITY      8
+#define VIRTIO_NET_HDR_F_SECURITY_ERR  16
         u8 flags;
 #define VIRTIO_NET_HDR_GSO_NONE        0
 #define VIRTIO_NET_HDR_GSO_TCPV4       1
@@ -471,6 +473,11 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O
         le32 hash_value;        (Only if VIRTIO_NET_F_HASH_REPORT negotiated)
         le16 hash_report;       (Only if VIRTIO_NET_F_HASH_REPORT negotiated)
         le16 padding_reserved;  (Only if VIRTIO_NET_F_HASH_REPORT negotiated)
+        /* Present only if VIRTIO_NET_F_IPSEC negotiated */
+        struct ipsec_resource_hdr {
+                le32 resource_id;
+                le16 resource_type;
+        };
 };
 \end{lstlisting}
 
@@ -655,6 +662,15 @@ \subsubsection{Packet Transmission}\label{sec:Device Types / Network Device / De
 The driver MUST NOT set the VIRTIO_NET_HDR_F_DATA_VALID and
 VIRTIO_NET_HDR_F_RSC_INFO bits in \field{flags}.
 
+If the device supports \hyperref[par:Device Types / Network Device / Device Operation / IPsec Operation]{IPsec Operation},
+the driver may set VIRTIO_NET_HDR_F_SECURITY bit in \field{flags}, if so:
+\begin{enumerate}
+\item the driver MUST create IPsec Outbound resource object
+\hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-ENC-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA}
+\item the driver MUST set \field{resource_id} to a valid IPsec outbound
+      resource object ID.
+\end{enumerate}
+
 \devicenormative{\paragraph}{Packet Transmission}{Device Types / Network Device / Device Operation / Packet Transmission}
 The device MUST ignore \field{flag} bits that it does not recognize.
 
@@ -686,6 +702,10 @@ \subsubsection{Packet Transmission}\label{sec:Device Types / Network Device / De
 
 If VIRTIO_NET_HDR_F_NEEDS_CSUM is not set, the device MUST NOT
 rely on the packet checksum being correct.
+
+If VIRTIO_NET_HDR_F_SECURITY bit in \field{flags} is not set, the
+device MUST NOT use the \field{resource_id} and \field{resource_type}.
+
 \paragraph{Packet Transmission Interrupt}\label{sec:Device Types / Network Device / Device Operation / Packet Transmission / Packet Transmission Interrupt}
 
 Often a driver will suppress transmission virtqueue interrupts
@@ -738,8 +758,13 @@ \subsubsection{Setting Up Receive Buffers}\label{sec:Device Types / Network Devi
 \end{note}
 
 When calculating the size of \field{struct virtio_net_hdr}, the driver
-MUST consider all the fields inclusive up to \field{padding_reserved},
-i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.
+MUST consider all the fields inclusive up to \field{ipsec_resource_hdr},
+\begin{itemize}
+\item 28 bytes if VIRTIO_NET_F_HASH_REPORT and VIRTIO_NET_F_IPSEC both are negotiated.
+\item 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated and VIRTIO_NET_F_IPSEC is not negotiated.
+\item 20 bytes if VIRTIO_NET_F_IPSEC is negotiated and VIRTIO_NET_F_HASH_REPORT is not negotiated.
+\item 12 bytes if VIRTIO_NET_F_IPSEC and VIRTIO_NET_F_HASH_REPORT both are not negotiated.
+\end{itemize}
 
 If VIRTIO_NET_F_MQ is negotiated, each of receiveq1\ldots receiveqN
 that will be used SHOULD be populated with receive buffers.
@@ -908,6 +933,13 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
 checksum (in case of multiple encapsulated protocols, one level
 of checksums is validated).
 
+The device MUST set the VIRTIO_NET_HDR_F_SECURITY bit in the \field{flags}
+if the packet is gone through the IPsec processing. Otherwise, it must
+be cleared.
+
+The device MUST set the VIRTIO_NET_HDR_F_SECURITY_ERR bit in the \field{flags}
+if any error is encountered during IPsec processing. Otherwise, this bit must be cleared.
+
 \drivernormative{\paragraph}{Processing of Incoming
 Packets}{Device Types / Network Device / Device Operation /
 Processing of Incoming Packets}
@@ -930,6 +962,10 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
 VIRTIO_NET_HDR_F_DATA_VALID is set, the driver MUST NOT
 rely on the packet checksum being correct.
 
+If VIRTIO_NET_HDR_F_SECURITY bit is set in the \field{flags},
+the driver MUST treat the packet as an error packet if the
+VIRTIO_NET_HDR_F_SECURITY_ERR bit is also set in the \field{flags}.
+
 \paragraph{Hash calculation for incoming packets}
 \label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}
 
@@ -3063,6 +3099,10 @@ \subsubsection{IPsec Operation}\label{sec:Device Types / Network Device / Device
 See \ref{sec:Device Types / Network Device / Device Operation / Flow filter}
 for details about flow filter.
 
+Note that there is a small race condition where a SA object might be destroyed
+while a recieve packet is still inflight. The driver should handle this situation
+appropriately.
+
 \paragraph{Device and driver capabilities}
 \label{par:Device Types / Network Device / Device Operation / IPsec Operation / Device and driver capabilities}
 
Signature · 1 line
2.25.1
#8 lore raw

RE: [PATCH RFC v2 3/4] virtio-net: extend virtio_net_hdr for IPsec support

Quoted 103 lines

From: Srujana Challa <[email protected]>
Sent: Wednesday, January 22, 2025 11:52 AM

Add IPsec resource object identifiers to the virtio_net_hdr for identifying encryption/decryption operations on tx and rx side respectively, along with flags.

---
 device-types/net/description.tex | 44 ++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex
index cef109d..3616917 100644

device-types/net/description.tex +0 -0
@@ -455,6 +455,8 @@ \subsection{Device Operation}\label{sec:Device Types

/ Network Device / Device O

 #define VIRTIO_NET_HDR_F_NEEDS_CSUM    1
 #define VIRTIO_NET_HDR_F_DATA_VALID    2
 #define VIRTIO_NET_HDR_F_RSC_INFO      4
device-types/net/description.tex +2 -0
+#define VIRTIO_NET_HDR_F_SECURITY      8
+#define VIRTIO_NET_HDR_F_SECURITY_ERR  16
         u8 flags;
 #define VIRTIO_NET_HDR_GSO_NONE        0
 #define VIRTIO_NET_HDR_GSO_TCPV4       1
@@ -471,6 +473,11 @@ \subsection{Device Operation}\label{sec:Device

Types / Network Device / Device O

         le32 hash_value;        (Only if VIRTIO_NET_F_HASH_REPORT negotiated)
         le16 hash_report;       (Only if VIRTIO_NET_F_HASH_REPORT negotiated)
         le16 padding_reserved;  (Only if VIRTIO_NET_F_HASH_REPORT

negotiated)

device-types/net/description.tex +5 -0
+        /* Present only if VIRTIO_NET_F_IPSEC negotiated */
+        struct ipsec_resource_hdr {
+                le32 resource_id;
+                le16 resource_type;
+        };
 };
 \end{lstlisting}
@@ -655,6 +662,15 @@ \subsubsection{Packet

Transmission}\label{sec:Device Types / Network Device / De The driver MUST NOT set the VIRTIO_NET_HDR_F_DATA_VALID and VIRTIO_NET_HDR_F_RSC_INFO bits in \field{flags}.

device-types/net/description.tex +2 -0
+If the device supports \hyperref[par:Device Types / Network Device /
+Device Operation / IPsec Operation]{IPsec Operation}, the driver may set

VIRTIO_NET_HDR_F_SECURITY bit in \field{flags}, if so:
+\begin{enumerate}
+\item the driver MUST create IPsec Outbound resource object +\hyperref[par:Device Types / Crypto Device / Device Operation / IPsec

device-types/net/description.tex +2 -0
+Service Operation / Resource objects /
+VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-ENC-

SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_

device-types/net/description.tex +5 -0
+OUTB_SA} \item the driver MUST set \field{resource_id} to a valid IPsec
+outbound
+      resource object ID.
+\end{enumerate}
+
 \devicenormative{\paragraph}{Packet Transmission}{Device Types / Network

Device / Device Operation / Packet Transmission} The device MUST ignore \field{flag} bits that it does not recognize.

device-types/net/description.tex +0 -0
@@ -686,6 +702,10 @@ \subsubsection{Packet

Transmission}\label{sec:Device Types / Network Device / De

If VIRTIO_NET_HDR_F_NEEDS_CSUM is not set, the device MUST NOT rely
on the packet checksum being correct.

device-types/net/description.tex +4 -0
+
+If VIRTIO_NET_HDR_F_SECURITY bit in \field{flags} is not set, the
+device MUST NOT use the \field{resource_id} and \field{resource_type}.
+
 \paragraph{Packet Transmission Interrupt}\label{sec:Device Types / Network

Device / Device Operation / Packet Transmission / Packet Transmission Interrupt}

Often a driver will suppress transmission virtqueue interrupts @@ -738,8
+758,13 @@ \subsubsection{Setting Up Receive Buffers}\label{sec:Device Types / Network Devi \end{note}

When calculating the size of \field{struct virtio_net_hdr}, the driver -MUST
consider all the fields inclusive up to \field{padding_reserved}, -i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.

device-types/net/description.tex +3 -0
+MUST consider all the fields inclusive up to
+\field{ipsec_resource_hdr}, \begin{itemize} \item 28 bytes if
+VIRTIO_NET_F_HASH_REPORT and VIRTIO_NET_F_IPSEC both are

negotiated.
+\item 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated and VIRTIO_NET_F_IPSEC is not negotiated.
+\item 20 bytes if VIRTIO_NET_F_IPSEC is negotiated and VIRTIO_NET_F_HASH_REPORT is not negotiated.
+\item 12 bytes if VIRTIO_NET_F_IPSEC and VIRTIO_NET_F_HASH_REPORT both are not negotiated.
+\end{itemize}

If VIRTIO_NET_F_MQ is negotiated, each of receiveq1\ldots receiveqN that
will be used SHOULD be populated with receive buffers.

device-types/net/description.tex +0 -0
@@ -908,6 +933,13 @@ \subsubsection{Processing of Incoming

Packets}\label{sec:Device Types / Network checksum (in case of multiple encapsulated protocols, one level of checksums is validated).

device-types/net/description.tex

Quoted 4 lines
device-types/net/description.tex +4 -0
+The device MUST set the VIRTIO_NET_HDR_F_SECURITY bit in the
+\field{flags} if the packet is gone through the IPsec processing.
+Otherwise, it must be cleared.
+

It MUST be cleared.
I think you want to add, that the bit is regardless of setting SECURITY_ERR bit.

Quoted 10 lines

+The device MUST set the VIRTIO_NET_HDR_F_SECURITY_ERR bit in the +\field{flags} if any error is encountered during IPsec processing. Otherwise, this bit must be cleared.
+
\drivernormative{\paragraph}{Processing of Incoming Packets}{Device Types
/ Network Device / Device Operation / Processing of Incoming Packets} @@ - 930,6 +962,10 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network VIRTIO_NET_HDR_F_DATA_VALID is set, the driver MUST NOT rely on the packet checksum being correct.

device-types/net/description.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network · line 968

Quoted 4 lines
device-types/net/description.tex +4 -0
+If VIRTIO_NET_HDR_F_SECURITY bit is set in the \field{flags}, the
+driver MUST treat the packet as an error packet if the
+VIRTIO_NET_HDR_F_SECURITY_ERR bit is also set in the \field{flags}.
+

'error packet' is vague.

I think you want to say that when SECURIRTY_ERR bit is set, it indicates that the device experienced a processing error on the ipsec packet. It need not be 'error packet'. For example, a particular SA was not offloaded. So vnet_hdr will have both bits set.

device-types/net/description.tex

Quoted 12 lines

\paragraph{Hash calculation for incoming packets} \label{sec:Device Types /
Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}

device-types/net/description.tex +0 -0
@@ -3063,6 +3099,10 @@ \subsubsection{IPsec Operation}\label{sec:Device

Types / Network Device / Device See \ref{sec:Device Types / Network Device / Device Operation / Flow filter} for details about flow filter.

device-types/net/description.tex +4 -0
+Note that there is a small race condition where a SA object might be
+destroyed while a recieve packet is still inflight. The driver should
+handle this situation appropriately.
+

s/should/SHOULD

Quoted 5 lines

\paragraph{Device and driver capabilities} \label{par:Device Types / Network
Device / Device Operation / IPsec Operation / Device and driver capabilities}

--
2.25.1

#9 lore raw

RFC PATCH v2 4/4 virtio-net: Add IPsec operation device and driver requirements

In reply to Srujana Challa

Add device and driver requirements for IPsec Operation.

---
 device-types/net/description.tex        | 79 +++++++++++++++++++++++++
 device-types/net/device-conformance.tex |  1 +
 device-types/net/driver-conformance.tex |  1 +
 3 files changed, 81 insertions(+)
device-types/net/description.tex +79 -0
index 3616917..52e5c4c 100644
@@ -3126,6 +3126,85 @@ \subsubsection{IPsec Operation}\label{sec:Device Types / Network Device / Device
 
 See \hyperref[par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects / VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC-INBOUND-SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA}.
 
+\devicenormative{\paragraph}{IPsec Operation}{Device Types / Net Device / Device Operation / IPsec Operation}
+
+When the device supports IPsec operations,
+\begin{itemize}
+\item the device MUST set VIRTIO_NET_IPSEC_RESOURCE_CAP, VIRTIO_NET_IPSEC_SA_CAP
+capability in the \field{supported_caps} in the command VIRTIO_ADMIN_CMD_CAP_SUPPORT_QUERY.
+\item the device MUST support the administration commands
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_MODIFY, VIRTIO_ADMIN_CMD_RESOURCE_OBJ_QUERY,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY for the resource types
+VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA and VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA.
+\end{itemize}
+
+When any of the VIRTIO_NET_IPSEC_RESOURCE_CAP or VIRTIO_NET_IPSEC_SA_CAP
+capability is disabled, the device MUST set \field{status} to
+VIRTIO_ADMIN_STATUS_Q_INVALID_OPCODE for the commands
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE,
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_MODIFY, VIRTIO_ADMIN_CMD_RESOURCE_OBJ_QUERY,
+and VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY for the resource types
+VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA and VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA.
+
+The device MUST set \field{status} to VIRTIO_ADMIN_STATUS_EEXIT for the
+command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE when the resource \field{type}
+is VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA or VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA,
+if the object already exists with the supplied \field{id}.
+
+The device MUST fail the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE for the
+VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA object if,
+\begin{itemize}
+\item \field{id} is greater than or equal to \field{outb_sa_limit}.
+\item the supplied SA parameters, such as mode, options, cipher and authentication
+      algorithms are not supported in the capabitlity VIRTIO_NET_IPSEC_SA_CAP.
+\end{itemize}
+
+The device MUST fail the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE for the
+VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA object if,
+\begin{itemize}
+\item \field{id} is greater than or equal to \field{inb_sa_limit}.
+\item the supplied SA parameters, such as mode, options, cipher and authentication
+      algorithms are not supported in the capabitlity VIRTIO_NET_IPSEC_SA_CAP.
+\end{itemize}
+
+The device SHOULD maintain a table for subsequent lookups to inbound/outbound data
+with the corresponding SA based on the supplied \field{id}.
+
+The device MUST allow recreating the resource objects using the command
+VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE which was previously destroyed using
+the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY respectively without
+undergoing a device reset.
+
+The device MAY fail the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE with
+the \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL for the
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTB_SA or VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INB_SA
+commands if the resource object with the same \field{spi} already exists.
+
+On device reset, the device MUST destroy all the resource objects which have been created.
+
+\drivernormative{\paragraph}{IPsec Operation}{Device Types / Net Device / Device Operation / IPsec Operation}
+
+The driver MUST query the capabilities using VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY
+to discover the capability types the device offers.
+
+The driver MUST get VIRTIO_NET_IPSEC_RESOURCE_CAP and VIRTIO_NET_IPSEC_SA_CAP
+if listed in VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY command result, using
+VIRTION_ADMIN_CMD_DEVICE_CAP_GET to discover the capabilities the device is
+able to offer.
+The driver MUST set VIRTIO_NET_IPSEC_RESOURCE_CAP and VIRTIO_NET_IPSEC_SA_CAP
+using VIRTIO_ADMIN_CMD_DEVICE_CAP_SET to indicate the device which capability
+the driver uses.
+
+For the command VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE, when creating a resource
+VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA, the driver MUST set all the parameters
+in \field{struct virtio_crypto_resource_obj_ipsec_sa} with relevant values.
+And when create a resource object VIRTIO_NET_RESOURCE_OBJ_IPSEC_INB_SA,
+the driver MUST set all the parameters except
+\field{struct virtio_crypto_ipsec_tunnel_param}.
+
+The driver SHOULD NOT add multiple inbound SA objects with the same \field{spi}.
+
 \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device
 Types / Network Device / Legacy Interface: Framing Requirements}
 
device-types/net/device-conformance.tex +1 -0
index d88484c..7fe8505 100644
@@ -18,4 +18,5 @@
 \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistics}
 \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / RSS Context}
 \item \ref{devicenormative:Device Types / Network Device / Device Operation / Flow filter}
+\item \ref{devicenormative:Device Types / Network Device / Device Operation / IPsec Operation}
 \end{itemize}
device-types/net/driver-conformance.tex +1 -0
index d346b88..0d20190 100644
@@ -18,4 +18,5 @@
 \item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistics}
 \item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / RSS Context}
 \item \ref{drivernormative:Device Types / Network Device / Device Operation / Flow filter}
+\item \ref{drivernormative:Device Types / Network Device / Device Operation / IPsec Operation}
 \end{itemize}
Signature · 1 line
2.25.1