Skip to contentSkip to conversation

introduce IPsec Operation in virtio-net

RFC PATCH Superseded Srujana Challa 2 participants 9 messages Apr 29, 2025 – May 20, 2025

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 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 value differs between Virtio-crypto and Virtio-net.

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

v2:
- Addressed the review comments from Parav Pandit.
v3:
- Introduced VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN flag in the virtio_net_hdr:flags.
- Addressed the review comments from Parav Pandit.
v4:
- Rebased this series on VIRTIO_NET_F_OUT_NET_HEADER patch. v6:
- Replaced struct virtio_net_hdr:padding_reserved_2 with ipsec_resource_hdr.

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        | 213 +++++++++++++++++++++++-
 device-types/net/device-conformance.tex |   1 +
 device-types/net/driver-conformance.tex |   1 +
 3 files changed, 208 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH v6 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 | 53 ++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
device-types/net/description.tex +53 -0
index 0bb1cef..9def4d2 100644
@@ -140,6 +140,12 @@ \subsection{Feature bits}\label{sec:Device Types / Network Device / Feature bits
 \item[VIRTIO_NET_F_OUT_NET_HEADER(69)] Driver can provide the start of
  \field{outer_nh_offset} value. Device gains advantage by not reading packet
   to calculate outer network header offset.
+
+\item[VIRTIO_NET_F_IPSEC(70)] Device supports inline IPsec processing.
+ \field{struct virtio_net_hdr} size expands upto field \field{sturct ipsec_resource_hdr}
+ when VIRTIO_NET_F_IPSEC is negotiated. When a device offers IPsec feature, it SHOULD
+ also offer the VIRTIO_NET_F_OUT_NET_HEADER feature.
+
 \end{description}
 
 \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device / Feature bits / Feature bit requirements}
@@ -462,6 +468,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}
@@ -478,6 +488,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 parts}\label{sec:Device Types / Network Device / Device parts}
@@ -3480,6 +3494,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 performs 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 performs 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

RFC PATCH v6 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 | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
device-types/net/description.tex +22 -4
index 9def4d2..105a002 100644
@@ -3098,7 +3098,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}
@@ -3158,7 +3160,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}
@@ -3211,8 +3217,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.
+or VIRTIO_NET_FF_MASK_TYPE_IPV6. If the third selector exists, it can be set to
+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
@@ -3510,6 +3516,18 @@ \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, IPsec processing is applied on the packet.
+In the case of VIRTIO_NET_FF_ACTION_IPSEC_RECIRCULATE, the packet goes through IPsec processing and
+is then recirculated only once to avoid the infinite loops in the device. When a packet is
+recirculated, it undergoes flow filters processing again with the updated packet content.
+
+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
#3 lore raw

PATCH v6 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 | 51 ++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)
device-types/net/description.tex +48 -3
index 105a002..2540f2b 100644
@@ -597,6 +597,9 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O
 #define VIRTIO_NET_HDR_F_DATA_VALID    2
 #define VIRTIO_NET_HDR_F_RSC_INFO      4
 #define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8
+#define VIRTIO_NET_HDR_F_SECURITY      16
+#define VIRTIO_NET_HDR_F_SECURITY_ERR  32
+#define VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN 64
         u8 flags;
 #define VIRTIO_NET_HDR_GSO_NONE        0
 #define VIRTIO_NET_HDR_GSO_TCPV4       1
@@ -618,7 +621,11 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O
         le16 outer_th_offset    (Only if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
         le16 inner_nh_offset;   (Only if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
         le16 outer_nh_offset;   /* Only if VIRTIO_NET_F_OUT_NET_HEADER negotiated */
-        u8 padding_reserved_2[6]; /* Only if VIRTIO_NET_F_OUT_NET_HEADER negotiated */
+        /* Only if VIRTIO_NET_F_IPSEC negotiated */
+        struct ipsec_resource_hdr {
+                le32 resource_id;
+                le16 resource_type;
+        };
 };
 \end{lstlisting}
 
@@ -972,6 +979,15 @@ \subsubsection{Packet Transmission}\label{sec:Device Types / Network Device / De
 together with the VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV4 bit or the
 VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV6 bit in \field{gso_type}.
 
+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.
 
@@ -1032,6 +1048,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
@@ -1084,8 +1104,8 @@ \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_2},
-i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER is negotiated or up to \field{inner_nh_offset}
+MUST consider all the fields inclusive up to \field{struct ipsec_resource_hdr},
+i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER or VIRTIO_NET_F_IPSEC is negotiated or up to \field{inner_nh_offset}
 i.e. 24 bytes if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO is negotiated or up to \field{padding_reserved}
 i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.
 
@@ -1341,6 +1361,21 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
 \field{flags}, the device MUST either provide a zero outer UDP header
 checksum or a fully checksummed outer UDP header.
 
+The device MUST set the VIRTIO_NET_HDR_F_SECURITY bit in the \field{flags}
+if the packet goes through the IPsec processing. Otherwise, this bit MUST
+be cleared. The device MUST set or clear this bit regardless of setting
+VIRTIO_NET_HDR_F_SECURITY_ERR or VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.
+
+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.
+The device MUST set or clear this bit regardless of setting
+VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.
+
+The device MUST set the VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit in the \field{flags}
+if the SA associated with \field{resource_id} reaches the SA lifetime soft limits configured in
+the \field{struct virtio_crypto_ipsec_lifetime}.
+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}.
+
 \drivernormative{\paragraph}{Processing of Incoming
 Packets}{Device Types / Network Device / Device Operation /
 Processing of Incoming Packets}
@@ -1392,6 +1427,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
 VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 in \field{gso_type} are not set,
 the driver MOST NOT accept the packet.
 
+When VIRTIO_NET_HDR_F_SECURITY and VIRTIO_NET_HDR_F_SECURITY_ERR bits are set in the \field{flags},
+it indicates that the device experienced a processing error on the IPsec packet.
+It need not be an 'error packet'. For example, a particular SA was not offloaded or
+SA has reached the SA lifetime hard limits configured in the \field{struct virtio_crypto_ipsec_lifetime}.
+So vnet_hdr will have both bits set.
+
 \paragraph{Hash calculation for incoming packets}
 \label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}
 
@@ -3528,6 +3569,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
Reviewed-by on v6 3/4
#4 lore raw

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

Quoted 39 lines

From: Srujana Challa <[email protected]>
Sent: Tuesday, April 29, 2025 6:10 PM

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 | 51
++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex
index 105a002..2540f2b 100644

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

Types / Network Device / Device O
#define VIRTIO_NET_HDR_F_DATA_VALID 2
#define VIRTIO_NET_HDR_F_RSC_INFO 4
#define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8

device-types/net/description.tex +3 -0
+#define VIRTIO_NET_HDR_F_SECURITY      16
+#define VIRTIO_NET_HDR_F_SECURITY_ERR  32 #define
+VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN 64
         u8 flags;
 #define VIRTIO_NET_HDR_GSO_NONE        0
 #define VIRTIO_NET_HDR_GSO_TCPV4       1
@@ -618,7 +621,11 @@ \subsection{Device Operation}\label{sec:Device

Types / Network Device / Device O
le16 outer_th_offset (Only if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO
or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
le16 inner_nh_offset; (Only if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO
or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
le16 outer_nh_offset; /* Only if VIRTIO_NET_F_OUT_NET_HEADER
negotiated */
- u8 padding_reserved_2[6]; /* Only if VIRTIO_NET_F_OUT_NET_HEADER
negotiated */

device-types/net/description.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O

Quoted 3 lines
device-types/net/description.tex +2 -0
+        /* Only if VIRTIO_NET_F_IPSEC negotiated */
 
+        /* Only if VIRTIO_NET_F_OUT_NET_HEADER or VIRTIO_NET_F_IPSEC negotiated */

This should be,

union {
	u8 padding_reserved_2[6];
	struct ipsec_resource_hdr {
                 le32 resource_id;
                 le16 resource_type;
              } ipsec_resource_hdr;

};

Quoted 50 lines

\end{lstlisting}

device-types/net/description.tex +0 -0
@@ -972,6 +979,15 @@ \subsubsection{Packet

Transmission}\label{sec:Device Types / Network Device / De together with the VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV4 bit or the
VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV6 bit in \field{gso_type}.

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
@@ -1032,6 +1048,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 @@ -1084,8
+1104,8 @@ \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_2}, -i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER is negotiated or up to \field{inner_nh_offset}

device-types/net/description.tex +3 -0
+MUST consider all the fields inclusive up to \field{struct
+ipsec_resource_hdr}, i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER or
+VIRTIO_NET_F_IPSEC is negotiated or up to \field{inner_nh_offset}
 i.e. 24 bytes if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO is negotiated or up
Quoted 3 lines

to \field{padding_reserved} i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.

Please change the wording to refer to padding or ipsec_resource_hdr accordingly.

Quoted 58 lines
device-types/net/description.tex +0 -0
@@ -1341,6 +1361,21 @@ \subsubsection{Processing of Incoming

Packets}\label{sec:Device Types / Network \field{flags}, the device MUST either provide a zero outer UDP header checksum or a fully checksummed outer UDP header.

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 goes through the IPsec processing.
+Otherwise, this bit MUST be cleared. The device MUST set or clear this
+bit regardless of setting VIRTIO_NET_HDR_F_SECURITY_ERR or

VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.

device-types/net/description.tex +3 -0
+
+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.

device-types/net/description.tex +4 -0
+The device MUST set or clear this bit regardless of setting
+VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.
+
+The device MUST set the

VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN

device-types/net/description.tex +2 -0
+bit in the \field{flags} if the SA associated with \field{resource_id}
+reaches the SA lifetime soft limits configured in the \field{struct

virtio_crypto_ipsec_lifetime}.
+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}.
+
\drivernormative{\paragraph}{Processing of Incoming Packets}{Device Types
/ Network Device / Device Operation / Processing of Incoming Packets} @@ - 1392,6 +1427,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 in \field{gso_type} are not set,
the driver MOST NOT accept the packet.

+When VIRTIO_NET_HDR_F_SECURITY and VIRTIO_NET_HDR_F_SECURITY_ERR bits
+are set in the \field{flags}, it indicates that the device experienced a processing error on the IPsec packet.

device-types/net/description.tex +2 -0
+It need not be an 'error packet'. For example, a particular SA was not
+offloaded or SA has reached the SA lifetime hard limits configured in the

\field{struct virtio_crypto_ipsec_lifetime}.

device-types/net/description.tex +2 -0
+So vnet_hdr will have both bits set.
+
 \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
@@ -3528,6 +3569,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.
+
 \paragraph{Device and driver capabilities}  \label{par:Device Types / Network

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

Quoted 2 lines

--
2.25.1

For the rest of the content of this patch:

#5 lore raw

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

Quoted 107 lines

Subject: [EXTERNAL] RE: [PATCH v6 3/4] virtio-net: extend virtio_net_hdr for IPsec support

Quoted 34 lines

From: Srujana Challa <schalla@ marvell. com> > Sent: Tuesday, April 29, 2025 6: 10 PM > > Add IPsec resource object identifiers to the virtio_net_hdr for identifying > encryption/decryption operations on tx and rx side respectively,

From: Srujana Challa <[email protected]>
Sent: Tuesday, April 29, 2025 6:10 PM

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 | 51
++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex index 105a002..2540f2b 100644

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

Types / Network Device / Device O
#define VIRTIO_NET_HDR_F_DATA_VALID 2
#define VIRTIO_NET_HDR_F_RSC_INFO 4
#define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8

device-types/net/description.tex +3 -0
+#define VIRTIO_NET_HDR_F_SECURITY      16
+#define VIRTIO_NET_HDR_F_SECURITY_ERR  32 #define
+VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN 64
         u8 flags;
 #define VIRTIO_NET_HDR_GSO_NONE        0
 #define VIRTIO_NET_HDR_GSO_TCPV4       1
@@ -618,7 +621,11 @@ \subsection{Device Operation}\label{sec:Device
Quoted 2 lines

Types / Network Device / Device O
le16 outer_th_offset (Only if

VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO

Quoted 2 lines

or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
le16 inner_nh_offset; (Only if

VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO

Quoted 4 lines

or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
le16 outer_nh_offset; /* Only if VIRTIO_NET_F_OUT_NET_HEADER
negotiated */
- u8 padding_reserved_2[6]; /* Only if

VIRTIO_NET_F_OUT_NET_HEADER

device-types/net/description.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O

Quoted 5 lines

negotiated */

device-types/net/description.tex +3 -0
+        /* Only if VIRTIO_NET_F_IPSEC negotiated */
 
+        /* Only if VIRTIO_NET_F_OUT_NET_HEADER or VIRTIO_NET_F_IPSEC
+ negotiated */

This should be,

union {
	u8 padding_reserved_2[6];
	struct ipsec_resource_hdr {
                 le32 resource_id;
                 le16 resource_type;
              } ipsec_resource_hdr;

};

Quoted 45 lines

\end{lstlisting}

device-types/net/description.tex +0 -0
@@ -972,6 +979,15 @@ \subsubsection{Packet

Transmission}\label{sec:Device Types / Network Device / De together with the
VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV4 bit or the
VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV6 bit in \field{gso_type}.

device-types/net/description.tex +3 -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
@@ -1032,6 +1048,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 @@
-1084,8
+1104,8 @@ \subsubsection{Setting Up Receive Buffers}\label{sec:Device Types / Network Devi \end{note}

Quoted 14 lines
Quoted 9 lines

When calculating the size of \field{struct virtio_net_hdr}, the
driver -MUST consider all the fields inclusive up to \field{padding_reserved_2}, -i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER is negotiated or up to \field{inner_nh_offset}

device-types/net/description.tex +3 -0
+MUST consider all the fields inclusive up to \field{struct
+ipsec_resource_hdr}, i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER or
+VIRTIO_NET_F_IPSEC is negotiated or up to \field{inner_nh_offset}
 i.e. 24 bytes if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO is negotiated or up
Quoted 3 lines

to \field{padding_reserved} i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.

Please change the wording to refer to padding or ipsec_resource_hdr accordingly.

Could you confirm if changing as below would be fine,
i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER or VIRTIO_NET_F_IPSEC is negotiated or up to \field{inner_nh_offset}. If only VIRTIO_NET_F_OUT_NET_HEADER is negotiated and VIRTIO_NET_F_IPSEC is not negotiated, the driver SHOULD reference \field{padding_reserved_2}. Otherwise, it SHOULD reference \field{struct ipsec_resource_hdr} from the \field{union}.
i.e. 24 bytes if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO is negotiated or up to \field{padding_reserved}.

Thanks.

Quoted 72 lines
Quoted 27 lines
device-types/net/description.tex +0 -0
@@ -1341,6 +1361,21 @@ \subsubsection{Processing of Incoming

Packets}\label{sec:Device Types / Network \field{flags}, the device MUST either provide a zero outer UDP header checksum or a fully checksummed outer UDP header.

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 goes through the IPsec processing.
+Otherwise, this bit MUST be cleared. The device MUST set or clear
+this bit regardless of setting VIRTIO_NET_HDR_F_SECURITY_ERR or

VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.

device-types/net/description.tex +4 -0
+
+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.

device-types/net/description.tex +4 -0
+The device MUST set or clear this bit regardless of setting
+VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.
+
+The device MUST set the

VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN

device-types/net/description.tex +3 -0
+bit in the \field{flags} if the SA associated with
+\field{resource_id} reaches the SA lifetime soft limits configured in
+the \field{struct

virtio_crypto_ipsec_lifetime}.

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

Service Operation / Resource objects /
VIRTIO-CRYPTO-RESOURCE-OBJ-IPSEC- OUTBOUND-

SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA}.

Quoted 37 lines

+
\drivernormative{\paragraph}{Processing of Incoming Packets}{Device
Types / Network Device / Device Operation / Processing of Incoming Packets} @@ -
1392,6 +1427,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 in \field{gso_type} are not set,
the driver MOST NOT accept the packet.

+When VIRTIO_NET_HDR_F_SECURITY and
VIRTIO_NET_HDR_F_SECURITY_ERR bits

device-types/net/description.tex +2 -0
+are set in the \field{flags}, it indicates that the device
+experienced a

processing error on the IPsec packet.

device-types/net/description.tex +3 -0
+It need not be an 'error packet'. For example, a particular SA was
+not offloaded or SA has reached the SA lifetime hard limits
+configured in the

\field{struct virtio_crypto_ipsec_lifetime}.

device-types/net/description.tex +2 -0
+So vnet_hdr will have both bits set.
+
 \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
@@ -3528,6 +3569,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.
+
 \paragraph{Device and driver capabilities}  \label{par:Device Types /

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

Quoted 2 lines

--
2.25.1

For the rest of the content of this patch:

#6 lore raw

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

Quoted 127 lines

From: Srujana Challa <[email protected]>
Sent: Tuesday, May 20, 2025 2:39 PM

Quoted 108 lines

Subject: [EXTERNAL] RE: [PATCH v6 3/4] virtio-net: extend virtio_net_hdr for IPsec support

Quoted 34 lines

From: Srujana Challa <schalla@ marvell. com> > Sent: Tuesday, April 29, 2025 6: 10 PM > > Add IPsec resource object identifiers to the virtio_net_hdr for identifying > encryption/decryption operations on tx and rx side respectively,

From: Srujana Challa <[email protected]>
Sent: Tuesday, April 29, 2025 6:10 PM

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 | 51
++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)
device- renamed from device-types/net/description.tex +0 -0

types/net/description.tex index 105a002..2540f2b 100644

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

Types / Network Device / Device O
#define VIRTIO_NET_HDR_F_DATA_VALID 2
#define VIRTIO_NET_HDR_F_RSC_INFO 4
#define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8

device-types/net/description.tex +3 -0
+#define VIRTIO_NET_HDR_F_SECURITY      16
+#define VIRTIO_NET_HDR_F_SECURITY_ERR  32 #define
+VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN 64
         u8 flags;
 #define VIRTIO_NET_HDR_GSO_NONE        0
 #define VIRTIO_NET_HDR_GSO_TCPV4       1
@@ -618,7 +621,11 @@ \subsection{Device Operation}\label{sec:Device
Quoted 2 lines

Types / Network Device / Device O
le16 outer_th_offset (Only if

VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO

Quoted 2 lines

or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
le16 inner_nh_offset; (Only if

VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO

Quoted 4 lines

or VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO negotiated)
le16 outer_nh_offset; /* Only if VIRTIO_NET_F_OUT_NET_HEADER
negotiated */
- u8 padding_reserved_2[6]; /* Only if

VIRTIO_NET_F_OUT_NET_HEADER

device-types/net/description.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O

Quoted 5 lines

negotiated */

device-types/net/description.tex +3 -0
+        /* Only if VIRTIO_NET_F_IPSEC negotiated */
 
+        /* Only if VIRTIO_NET_F_OUT_NET_HEADER or
+ VIRTIO_NET_F_IPSEC negotiated */

This should be,

union {
	u8 padding_reserved_2[6];
	struct ipsec_resource_hdr {
                 le32 resource_id;
                 le16 resource_type;
              } ipsec_resource_hdr;

};

Quoted 46 lines

\end{lstlisting}

device-types/net/description.tex +0 -0
@@ -972,6 +979,15 @@ \subsubsection{Packet

Transmission}\label{sec:Device Types / Network Device / De together with the
VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV4 bit or the
VIRTIO_NET_HDR_F_GSO_UDP_TUNNEL_IPV6 bit in \field{gso_type}.

device-types/net/description.tex +3 -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 /

device-types/net/description.tex +2 -0
+IPsec 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
@@ -1032,6 +1048,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 @@
-1084,8
+1104,8 @@ \subsubsection{Setting Up Receive +Buffers}\label{sec:Device
Types / Network Devi \end{note}

Quoted 15 lines
Quoted 10 lines

When calculating the size of \field{struct virtio_net_hdr}, the
driver -MUST consider all the fields inclusive up to \field{padding_reserved_2}, -i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER is negotiated or up to \field{inner_nh_offset}

device-types/net/description.tex +4 -0
+MUST consider all the fields inclusive up to \field{struct
+ipsec_resource_hdr}, i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER
+or VIRTIO_NET_F_IPSEC is negotiated or up to
+\field{inner_nh_offset}
 i.e. 24 bytes if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO is negotiated or
Quoted 3 lines

up to \field{padding_reserved} i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.

Please change the wording to refer to padding or ipsec_resource_hdr accordingly.

Quoted 3 lines

Could you confirm if changing as below would be fine, i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER or VIRTIO_NET_F_IPSEC is negotiated or up to \field{inner_nh_offset}.

Small nit changes to adhere to existing wording,

When calculating the size of struct virtio_net_hdr, the driver MUST consider all the fields inclusive up to padding_reserved_2, i.e. 32 bytes if VIRTIO_NET_F_OUT_NET_HEADER or VIRTIO_NET_F_OUT_NET_HEADER is negotiated or up to inner_- nh_offset i.e. 24 bytes if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO is negotiated or up to padding_-
reserved i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.

Quoted 7 lines

If only VIRTIO_NET_F_OUT_NET_HEADER is negotiated and VIRTIO_NET_F_IPSEC is not negotiated, the driver SHOULD reference \field{padding_reserved_2}. Otherwise, it SHOULD reference \field{struct ipsec_resource_hdr} from the \field{union}.
i.e. 24 bytes if VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO is negotiated or up to \field{padding_reserved}.

When describing the vnet hdr size allocation, do not mix it on what to access or not. You can move this in ipsec description if its not already there.

Quoted 75 lines

Thanks.

Quoted 22 lines
Quoted 22 lines
device-types/net/description.tex +0 -0
@@ -1341,6 +1361,21 @@ \subsubsection{Processing of Incoming

Packets}\label{sec:Device Types / Network \field{flags}, the device MUST either provide a zero outer UDP header checksum or a fully checksummed outer UDP header.

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 goes through the IPsec processing.
+Otherwise, this bit MUST be cleared. The device MUST set or clear
+this bit regardless of setting VIRTIO_NET_HDR_F_SECURITY_ERR or

VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.

device-types/net/description.tex +4 -0
+
+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.

device-types/net/description.tex +4 -0
+The device MUST set or clear this bit regardless of setting
+VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN bit.
+
+The device MUST set the

VIRTIO_NET_HDR_F_SECURITY_SA_SOFT_EXPIRY_WARN +bit in the \field{flags} if the SA associated with

Quoted 15 lines
Quoted 7 lines

+\field{resource_id} reaches the SA lifetime soft limits configured +in the \field{struct
virtio_crypto_ipsec_lifetime}.

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- OUTBOUND-

SA]{VIRTIO_NET_RESOURCE_OBJ_IPSEC_OUTB_SA}.

Quoted 7 lines

+
\drivernormative{\paragraph}{Processing of Incoming
Packets}{Device Types / Network Device / Device Operation / Processing of Incoming Packets} @@ -
1392,6 +1427,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 in \field{gso_type} are not

set,

Quoted 36 lines
Quoted 31 lines

the driver MOST NOT accept the packet.

+When VIRTIO_NET_HDR_F_SECURITY and
VIRTIO_NET_HDR_F_SECURITY_ERR bits

device-types/net/description.tex +2 -0
+are set in the \field{flags}, it indicates that the device
+experienced a

processing error on the IPsec packet.

device-types/net/description.tex +3 -0
+It need not be an 'error packet'. For example, a particular SA was
+not offloaded or SA has reached the SA lifetime hard limits
+configured in the

\field{struct virtio_crypto_ipsec_lifetime}.

device-types/net/description.tex +2 -0
+So vnet_hdr will have both bits set.
+
 \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
@@ -3528,6 +3569,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.
+
 \paragraph{Device and driver capabilities}  \label{par:Device Types

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

Quoted 2 lines

--
2.25.1

For the rest of the content of this patch:

#7 lore raw

RFC PATCH v6 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        | 83 +++++++++++++++++++++++++
 device-types/net/device-conformance.tex |  1 +
 device-types/net/driver-conformance.tex |  1 +
 3 files changed, 85 insertions(+)
device-types/net/description.tex +83 -0
index 2540f2b..36b2a80 100644
@@ -3596,6 +3596,89 @@ \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}.
+
+In the outbound data path, the driver MUST ensure that packets do
+not exceed the PMTU prior to transmission to the device.
+(Refer to \hyperref[intro:IPSEC]{[IPSEC]} for a detailed description of PMTU)
+
 \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