The bulk of the configuration follows the existing code for the very similar Header Digest. The most notable difference is that Data Digest will default to None (rather than None,CRC32C as is the case for Header Digest). This preserves exiting behavior and avoids the potentially costly Data Digest from being selected accidentally.
Since CRC32C calculations on the data may not be all computed in a single operation, components of the existing crc32c function (used for Header Digest) has also been decomposed into three further functions:
crc32c_init
crc32c_chain
crc32c_chain_done
Furthermore, for the same reason we will need to "carry around" an interim digest so calculated_data_digest is added to both struct iscsi_pdu and struct iscsi_in_pdu. (The latter also includes a small buffer used to receiving a data digest, which again may not all come in at once.)
The digests, if present, are located, respectively, after the header and PDU-specific data and cover, respectively, the header and the PDU data, each including the padding bytes, if any.
Digests are not included in data or header length fields.
A zero-length Data Segment also implies a zero-length Data-Digest.
This PR adds Data Digest support to
libiscsi
.The bulk of the configuration follows the existing code for the very similar Header Digest. The most notable difference is that Data Digest will default to
None
(rather thanNone,CRC32C
as is the case for Header Digest). This preserves exiting behavior and avoids the potentially costly Data Digest from being selected accidentally.Since CRC32C calculations on the data may not be all computed in a single operation, components of the existing
crc32c
function (used for Header Digest) has also been decomposed into three further functions:crc32c_init
crc32c_chain
crc32c_chain_done
Furthermore, for the same reason we will need to "carry around" an interim digest so
calculated_data_digest
is added to bothstruct iscsi_pdu
andstruct iscsi_in_pdu
. (The latter also includes a small buffer used to receiving a data digest, which again may not all come in at once.)Also, some pertinent notes from RFC7143 Section 11.2.3 (emphasis mine)